ISurfaceComposer.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. #ifndef ANDROID_GUI_ISURFACE_COMPOSER_H
  17. #define ANDROID_GUI_ISURFACE_COMPOSER_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <utils/RefBase.h>
  21. #include <utils/Errors.h>
  22. #include <utils/Timers.h>
  23. #include <utils/Vector.h>
  24. #include <binder/IInterface.h>
  25. #include <ui/FrameStats.h>
  26. #include <gui/IGraphicBufferAlloc.h>
  27. #include <gui/ISurfaceComposerClient.h>
  28. namespace android {
  29. // ----------------------------------------------------------------------------
  30. class ComposerState;
  31. class DisplayState;
  32. struct DisplayInfo;
  33. struct DisplayStatInfo;
  34. class IDisplayEventConnection;
  35. class IMemoryHeap;
  36. class Rect;
  37. /*
  38. * This class defines the Binder IPC interface for accessing various
  39. * SurfaceFlinger features.
  40. */
  41. class ISurfaceComposer: public IInterface {
  42. public:
  43. DECLARE_META_INTERFACE(SurfaceComposer);
  44. // flags for setTransactionState()
  45. enum {
  46. eSynchronous = 0x01,
  47. eAnimation = 0x02,
  48. };
  49. enum {
  50. eDisplayIdMain = 0,
  51. eDisplayIdHdmi = 1,
  52. #ifdef QTI_BSP
  53. eDisplayIdTertiary = 2
  54. #endif
  55. };
  56. enum Rotation {
  57. eRotateNone = 0,
  58. eRotate90 = 1,
  59. eRotate180 = 2,
  60. eRotate270 = 3
  61. };
  62. /* create connection with surface flinger, requires
  63. * ACCESS_SURFACE_FLINGER permission
  64. */
  65. virtual sp<ISurfaceComposerClient> createConnection() = 0;
  66. /* create a graphic buffer allocator
  67. */
  68. virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
  69. /* return an IDisplayEventConnection */
  70. virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
  71. /* create a virtual display
  72. * requires ACCESS_SURFACE_FLINGER permission.
  73. */
  74. virtual sp<IBinder> createDisplay(const String8& displayName,
  75. bool secure) = 0;
  76. /* destroy a virtual display
  77. * requires ACCESS_SURFACE_FLINGER permission.
  78. */
  79. virtual void destroyDisplay(const sp<IBinder>& display) = 0;
  80. /* get the token for the existing default displays. possible values
  81. * for id are eDisplayIdMain and eDisplayIdHdmi.
  82. */
  83. virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
  84. /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
  85. virtual void setTransactionState(const Vector<ComposerState>& state,
  86. const Vector<DisplayState>& displays, uint32_t flags) = 0;
  87. /* signal that we're done booting.
  88. * Requires ACCESS_SURFACE_FLINGER permission
  89. */
  90. virtual void bootFinished() = 0;
  91. /* verify that an IGraphicBufferProducer was created by SurfaceFlinger.
  92. */
  93. virtual bool authenticateSurfaceTexture(
  94. const sp<IGraphicBufferProducer>& surface) const = 0;
  95. /* set display power mode. depending on the mode, it can either trigger
  96. * screen on, off or low power mode and wait for it to complete.
  97. * requires ACCESS_SURFACE_FLINGER permission.
  98. */
  99. virtual void setPowerMode(const sp<IBinder>& display, int mode) = 0;
  100. /* returns information for each configuration of the given display
  101. * intended to be used to get information about built-in displays */
  102. virtual status_t getDisplayConfigs(const sp<IBinder>& display,
  103. Vector<DisplayInfo>* configs) = 0;
  104. /* returns display statistics for a given display
  105. * intended to be used by the media framework to properly schedule
  106. * video frames */
  107. virtual status_t getDisplayStats(const sp<IBinder>& display,
  108. DisplayStatInfo* stats) = 0;
  109. /* indicates which of the configurations returned by getDisplayInfo is
  110. * currently active */
  111. virtual int getActiveConfig(const sp<IBinder>& display) = 0;
  112. /* specifies which configuration (of those returned by getDisplayInfo)
  113. * should be used */
  114. virtual status_t setActiveConfig(const sp<IBinder>& display, int id) = 0;
  115. /* Capture the specified screen. requires READ_FRAME_BUFFER permission
  116. * This function will fail if there is a secure window on screen.
  117. */
  118. virtual status_t captureScreen(const sp<IBinder>& display,
  119. const sp<IGraphicBufferProducer>& producer,
  120. Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
  121. uint32_t minLayerZ, uint32_t maxLayerZ,
  122. bool useIdentityTransform,
  123. Rotation rotation = eRotateNone,
  124. bool isCpuConsumer = false) = 0;
  125. /* Clears the frame statistics for animations.
  126. *
  127. * Requires the ACCESS_SURFACE_FLINGER permission.
  128. */
  129. virtual status_t clearAnimationFrameStats() = 0;
  130. /* Gets the frame statistics for animations.
  131. *
  132. * Requires the ACCESS_SURFACE_FLINGER permission.
  133. */
  134. virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0;
  135. };
  136. // ----------------------------------------------------------------------------
  137. class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
  138. public:
  139. enum {
  140. // Note: BOOT_FINISHED must remain this value, it is called from
  141. // Java by ActivityManagerService.
  142. BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
  143. CREATE_CONNECTION,
  144. CREATE_GRAPHIC_BUFFER_ALLOC,
  145. CREATE_DISPLAY_EVENT_CONNECTION,
  146. CREATE_DISPLAY,
  147. DESTROY_DISPLAY,
  148. GET_BUILT_IN_DISPLAY,
  149. SET_TRANSACTION_STATE,
  150. AUTHENTICATE_SURFACE,
  151. GET_DISPLAY_CONFIGS,
  152. GET_ACTIVE_CONFIG,
  153. SET_ACTIVE_CONFIG,
  154. CONNECT_DISPLAY,
  155. CAPTURE_SCREEN,
  156. CLEAR_ANIMATION_FRAME_STATS,
  157. GET_ANIMATION_FRAME_STATS,
  158. SET_POWER_MODE,
  159. GET_DISPLAY_STATS,
  160. };
  161. virtual status_t onTransact(uint32_t code, const Parcel& data,
  162. Parcel* reply, uint32_t flags = 0);
  163. };
  164. // ----------------------------------------------------------------------------
  165. }; // namespace android
  166. #endif // ANDROID_GUI_ISURFACE_COMPOSER_H