Home | History | Annotate | Download | only in surfaceflinger
      1 /*
      2  * Copyright (C) 2006 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 #ifndef ANDROID_SF_ISURFACE_COMPOSER_H
     18 #define ANDROID_SF_ISURFACE_COMPOSER_H
     19 
     20 #include <stdint.h>
     21 #include <sys/types.h>
     22 
     23 #include <utils/RefBase.h>
     24 #include <utils/Errors.h>
     25 
     26 #include <binder/IInterface.h>
     27 
     28 #include <ui/PixelFormat.h>
     29 
     30 #include <surfaceflinger/ISurfaceComposerClient.h>
     31 #include <surfaceflinger/IGraphicBufferAlloc.h>
     32 
     33 namespace android {
     34 // ----------------------------------------------------------------------------
     35 
     36 class IMemoryHeap;
     37 class ComposerState;
     38 
     39 class ISurfaceComposer : public IInterface
     40 {
     41 public:
     42     DECLARE_META_INTERFACE(SurfaceComposer);
     43 
     44     enum { // (keep in sync with Surface.java)
     45         eHidden             = 0x00000004,
     46         eDestroyBackbuffer  = 0x00000020,
     47         eSecure             = 0x00000080,
     48         eNonPremultiplied   = 0x00000100,
     49         eOpaque             = 0x00000400,
     50         eProtectedByApp     = 0x00000800,
     51         eProtectedByDRM     = 0x00001000,
     52 
     53         eFXSurfaceNormal    = 0x00000000,
     54         eFXSurfaceBlur      = 0x00010000,
     55         eFXSurfaceDim       = 0x00020000,
     56         eFXSurfaceScreenshot= 0x00030000,
     57         eFXSurfaceMask      = 0x000F0000,
     58     };
     59 
     60     enum {
     61         ePositionChanged            = 0x00000001,
     62         eLayerChanged               = 0x00000002,
     63         eSizeChanged                = 0x00000004,
     64         eAlphaChanged               = 0x00000008,
     65         eMatrixChanged              = 0x00000010,
     66         eTransparentRegionChanged   = 0x00000020,
     67         eVisibilityChanged          = 0x00000040,
     68         eFreezeTintChanged          = 0x00000080,
     69     };
     70 
     71     enum {
     72         eLayerHidden        = 0x01,
     73         eLayerFrozen        = 0x02,
     74         eLayerDither        = 0x04,
     75         eLayerFilter        = 0x08,
     76         eLayerBlurFreeze    = 0x10
     77     };
     78 
     79     enum {
     80         eOrientationDefault     = 0,
     81         eOrientation90          = 1,
     82         eOrientation180         = 2,
     83         eOrientation270         = 3,
     84         eOrientationUnchanged   = 4,
     85         eOrientationSwapMask    = 0x01
     86     };
     87 
     88     enum {
     89         eElectronBeamAnimationOn  = 0x01,
     90         eElectronBeamAnimationOff = 0x10
     91     };
     92 
     93     /* create connection with surface flinger, requires
     94      * ACCESS_SURFACE_FLINGER permission
     95      */
     96     virtual sp<ISurfaceComposerClient> createConnection() = 0;
     97 
     98     /* create a graphic buffer allocator
     99      */
    100     virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
    101 
    102     /* retrieve the control block */
    103     virtual sp<IMemoryHeap> getCblk() const = 0;
    104 
    105     /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
    106     virtual void setTransactionState(const Vector<ComposerState>& state,
    107             int orientation) = 0;
    108 
    109     /* signal that we're done booting.
    110      * Requires ACCESS_SURFACE_FLINGER permission
    111      */
    112     virtual void bootFinished() = 0;
    113 
    114     /* Capture the specified screen. requires READ_FRAME_BUFFER permission
    115      * This function will fail if there is a secure window on screen.
    116      */
    117     virtual status_t captureScreen(DisplayID dpy,
    118             sp<IMemoryHeap>* heap,
    119             uint32_t* width, uint32_t* height, PixelFormat* format,
    120             uint32_t reqWidth, uint32_t reqHeight,
    121             uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
    122 
    123     virtual status_t turnElectronBeamOff(int32_t mode) = 0;
    124     virtual status_t turnElectronBeamOn(int32_t mode) = 0;
    125 
    126     /* verify that an ISurfaceTexture was created by SurfaceFlinger.
    127      */
    128     virtual bool authenticateSurfaceTexture(
    129             const sp<ISurfaceTexture>& surface) const = 0;
    130 };
    131 
    132 // ----------------------------------------------------------------------------
    133 
    134 class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
    135 {
    136 public:
    137     enum {
    138         // Note: BOOT_FINISHED must remain this value, it is called from
    139         // Java by ActivityManagerService.
    140         BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
    141         CREATE_CONNECTION,
    142         CREATE_GRAPHIC_BUFFER_ALLOC,
    143         GET_CBLK,
    144         SET_TRANSACTION_STATE,
    145         SET_ORIENTATION,
    146         FREEZE_DISPLAY,
    147         UNFREEZE_DISPLAY,
    148         CAPTURE_SCREEN,
    149         TURN_ELECTRON_BEAM_OFF,
    150         TURN_ELECTRON_BEAM_ON,
    151         AUTHENTICATE_SURFACE,
    152     };
    153 
    154     virtual status_t    onTransact( uint32_t code,
    155                                     const Parcel& data,
    156                                     Parcel* reply,
    157                                     uint32_t flags = 0);
    158 };
    159 
    160 // ----------------------------------------------------------------------------
    161 
    162 }; // namespace android
    163 
    164 #endif // ANDROID_SF_ISURFACE_COMPOSER_H
    165