1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <binder/IInterface.h> 20 #include <binder/SafeInterface.h> 21 #include <gui/LayerMetadata.h> 22 #include <ui/PixelFormat.h> 23 24 #include <unordered_map> 25 26 namespace android { 27 28 class FrameStats; 29 class IGraphicBufferProducer; 30 31 class ISurfaceComposerClient : public IInterface { 32 public: 33 DECLARE_META_INTERFACE(SurfaceComposerClient) 34 35 // flags for createSurface() 36 enum { // (keep in sync with SurfaceControl.java) 37 eHidden = 0x00000004, 38 eDestroyBackbuffer = 0x00000020, 39 eSkipScreenshot = 0x00000040, 40 eSecure = 0x00000080, 41 eNonPremultiplied = 0x00000100, 42 eOpaque = 0x00000400, 43 eProtectedByApp = 0x00000800, 44 eProtectedByDRM = 0x00001000, 45 eCursorWindow = 0x00002000, 46 eNoColorFill = 0x00004000, 47 48 eFXSurfaceBufferQueue = 0x00000000, 49 eFXSurfaceEffect = 0x00020000, 50 eFXSurfaceBufferState = 0x00040000, 51 eFXSurfaceContainer = 0x00080000, 52 eFXSurfaceMask = 0x000F0000, 53 }; 54 55 // TODO(b/172002646): Clean up the Surface Creation Arguments 56 /* 57 * Requires ACCESS_SURFACE_FLINGER permission 58 */ 59 virtual status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format, 60 uint32_t flags, const sp<IBinder>& parent, 61 LayerMetadata metadata, sp<IBinder>* handle, 62 sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId, 63 uint32_t* outTransformHint) = 0; 64 65 /* 66 * Requires ACCESS_SURFACE_FLINGER permission 67 */ 68 virtual status_t createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h, 69 PixelFormat format, uint32_t flags, 70 const sp<IGraphicBufferProducer>& parent, 71 LayerMetadata metadata, sp<IBinder>* handle, 72 sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId, 73 uint32_t* outTransformHint) = 0; 74 75 /* 76 * Requires ACCESS_SURFACE_FLINGER permission 77 */ 78 virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const = 0; 79 80 /* 81 * Requires ACCESS_SURFACE_FLINGER permission 82 */ 83 virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const = 0; 84 85 virtual status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle, 86 int32_t* outLayerId) = 0; 87 }; 88 89 class BnSurfaceComposerClient : public SafeBnInterface<ISurfaceComposerClient> { 90 public: BnSurfaceComposerClient()91 BnSurfaceComposerClient() 92 : SafeBnInterface<ISurfaceComposerClient>("BnSurfaceComposerClient") {} 93 94 status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) override; 95 }; 96 97 } // namespace android 98