00001 #if !defined(HFILE_libgui) && ANDROID_VER>=400
00002 #define HFILE_libgui
00003
00004 #include "libbinder.h"
00005 #include "libui.h"
00006
00007 namespace android {
00008
00009 class ScreenshotClient {
00010 public:
00011 ScreenshotClient();
00012 #if (ANDROID_VER>=430)
00013 ~ScreenshotClient();
00014 #endif
00015 #if (ANDROID_VER>=500)
00016 status_t update(const sp<IBinder>& display, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform);
00017 #elif (ANDROID_VER>=420)
00018 status_t update(const sp<IBinder>& display);
00019 status_t update(const sp<IBinder>& display, uint32_t reqWidth, uint32_t reqHeight);
00020 #elif (ANDROID_VER>=400)
00021 status_t update();
00022 status_t update(uint32_t reqWidth, uint32_t reqHeight);
00023 #endif
00024 void release();
00025 void const* getPixels() const;
00026
00027 uint32_t getWidth() const;
00028 uint32_t getHeight() const;
00029 uint32_t getStride() const;
00030 int32_t getFormat() const;
00031 size_t getSize() const;
00032 private:
00033 char __data[sizeof(void*)*256];
00034
00035
00036
00037
00038
00039
00040 };
00041
00042 #if (ANDROID_VER>=420)
00043
00044 enum {
00045 NATIVE_WINDOW_WIDTH = 0,
00046 NATIVE_WINDOW_HEIGHT = 1,
00047 NATIVE_WINDOW_FORMAT = 2,
00048 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
00049 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
00050 NATIVE_WINDOW_CONCRETE_TYPE = 5,
00051 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
00052 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
00053 NATIVE_WINDOW_TRANSFORM_HINT = 8,
00054 NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
00055 NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10
00056 };
00057
00058
00059 enum {
00060 NATIVE_WINDOW_API_EGL = 1,
00061 NATIVE_WINDOW_API_CPU = 2,
00062 NATIVE_WINDOW_API_MEDIA = 3,
00063 NATIVE_WINDOW_API_CAMERA = 4,
00064 };
00065
00066
00067 enum {
00068 HAL_PIXEL_FORMAT_RGBA_8888 = 1,
00069 HAL_PIXEL_FORMAT_RGBX_8888 = 2,
00070 HAL_PIXEL_FORMAT_RGB_888 = 3,
00071 HAL_PIXEL_FORMAT_RGB_565 = 4,
00072 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
00073 HAL_PIXEL_FORMAT_RGBA_5551 = 6,
00074 HAL_PIXEL_FORMAT_RGBA_4444 = 7,
00075 HAL_PIXEL_FORMAT_YV12 = 0x32315659,
00076 };
00077
00078
00079 enum {
00080 GRALLOC_USAGE_SW_READ_NEVER = 0x00000000,
00081 GRALLOC_USAGE_SW_READ_RARELY = 0x00000002,
00082 GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003,
00083 GRALLOC_USAGE_SW_READ_MASK = 0x0000000F,
00084 GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000,
00085 GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020,
00086 GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030,
00087 GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0,
00088 GRALLOC_USAGE_HW_TEXTURE = 0x00000100,
00089 GRALLOC_USAGE_HW_RENDER = 0x00000200,
00090 GRALLOC_USAGE_HW_2D = 0x00000400,
00091 GRALLOC_USAGE_HW_COMPOSER = 0x00000800,
00092 GRALLOC_USAGE_HW_FB = 0x00001000,
00093 GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000,
00094 GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000,
00095 GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000,
00096 GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000,
00097 GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000,
00098 GRALLOC_USAGE_HW_MASK = 0x00071F00,
00099 GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000,
00100 GRALLOC_USAGE_PROTECTED = 0x00004000,
00101 };
00102
00103 #if (ANDROID_VER>=430)
00104 class IGraphicBufferProducer;
00105 #elif (ANDROID_VER>=420)
00106 class ISurfaceTexture;
00107 #define IGraphicBufferProducer ISurfaceTexture
00108 #define BnGraphicBufferProducer BnSurfaceTexture
00109 #endif
00110
00111 struct DisplayInfo;
00112
00113 class SurfaceComposerClient {
00114 public:
00115 static sp<IBinder> getBuiltInDisplay(int32_t id);
00116 static sp<IBinder> createDisplay(const String8& displayName, bool secure);
00117 static void destroyDisplay(const sp<IBinder>& display);
00118 static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
00119 static void openGlobalTransaction();
00120 static void closeGlobalTransaction(bool synchronous = false);
00121 static void setDisplaySurface(const sp<IBinder>& token, const sp<IGraphicBufferProducer>& bufferProducer);
00122 static void setDisplayLayerStack(const sp<IBinder>& token, uint32_t layerStack);
00123 static void setDisplayProjection(const sp<IBinder>& token, uint32_t orientation, const Rect& layerStackRect, const Rect& displayRect);
00124 static void blankDisplay(const sp<IBinder>& display);
00125 static void unblankDisplay(const sp<IBinder>& display);
00126 };
00127
00128 class GraphicBuffer;
00129 class Fence;
00130
00131 class IGraphicBufferAlloc : public IInterface {
00132 public:
00133 virtual const String16& getInterfaceDescriptor() const;
00134 virtual ~IGraphicBufferAlloc();
00135
00136 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage, status_t* error) = 0;
00137 };
00138
00139 struct ComposerState;
00140 struct DisplayState;
00141
00142 class ISurfaceComposer: public IInterface {
00143 public:
00144 static const android::String16 descriptor;
00145 virtual const String16& getInterfaceDescriptor() const;
00146 virtual ~ISurfaceComposer();
00147 static sp<ISurfaceComposer> asInterface(const sp<IBinder>& obj);
00148
00149 virtual void createConnection() = 0;
00150 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
00151 virtual void createDisplayEventConnection() = 0;
00152 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure) = 0;
00153 #if (ANDROID_VER>=440)
00154 virtual void destroyDisplay(const sp<IBinder>& display) = 0;
00155 #endif
00156 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
00157 virtual void setTransactionState(const Vector<ComposerState>& state, const Vector<DisplayState>& displays, uint32_t flags) = 0;
00158 virtual void bootFinished() = 0;
00159 virtual bool authenticateSurfaceTexture() const = 0;
00160 #if (ANDROID_VER<430)
00161 virtual status_t captureScreen() = 0;
00162 #endif
00163 virtual void blank(const sp<IBinder>& display) = 0;
00164 virtual void unblank(const sp<IBinder>& display) = 0;
00165 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
00166 #if (ANDROID_VER>=430)
00167 virtual status_t captureScreen() = 0;
00168 #endif
00169 };
00170
00171 struct ComposerState {
00172
00173
00174 };
00175
00176 struct DisplayState {
00177 enum {
00178 eSurfaceChanged = 0x01,
00179 eLayerStackChanged = 0x02,
00180 eDisplayProjectionChanged = 0x04
00181 };
00182 uint32_t what;
00183 sp<IBinder> token;
00184 sp<IGraphicBufferProducer> surface;
00185 uint32_t layerStack;
00186 uint32_t orientation;
00187 Rect viewport;
00188 Rect frame;
00189 status_t write(Parcel& output) const;
00190 };
00191
00192 struct DisplayInfo {
00193 uint32_t w;
00194 uint32_t h;
00195 float xdpi;
00196 float ydpi;
00197 float fps;
00198 float density;
00199 uint8_t orientation;
00200 bool secure;
00201 uint8_t reserved[2];
00202 #if (ANDROID_VER<440)
00203
00204 size_t PixelFormatInfo_version;
00205 size_t PixelFormatInfo_dummy[15];
00206
00207 DisplayInfo() {
00208 PixelFormatInfo_version = 0;
00209 }
00210 #endif
00211 };
00212
00213 class ComposerService {
00214 public:
00215 static sp<ISurfaceComposer> getComposerService();
00216 };
00217
00218 class
00219 #if (ANDROID_VER>=430)
00220 IGraphicBufferProducer
00221 #elif (ANDROID_VER>=420)
00222 ISurfaceTexture
00223 #endif
00224 : public IInterface {
00225 public:
00226 enum {
00227 BUFFER_NEEDS_REALLOCATION = 0x1,
00228 RELEASE_ALL_BUFFERS = 0x2,
00229 };
00230 struct QueueBufferInput {
00231 size_t getFlattenedSize() const;
00232 size_t getFdCount() const;
00233 #if (ANDROID_VER>=440)
00234 status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
00235 #elif (ANDROID_VER>=420)
00236 status_t flatten(void* buffer, size_t size, int fds[], size_t count) const;
00237 #endif
00238 };
00239
00240 struct
00241 #if (ANDROID_VER>=500)
00242 __attribute__ ((__packed__))
00243 #endif
00244 QueueBufferOutput {
00245 uint32_t width;
00246 uint32_t height;
00247 uint32_t transformHint;
00248 uint32_t numPendingBuffers;
00249 };
00250
00251 #if (ANDROID_VER>=430)
00252 virtual const String16& getInterfaceDescriptor() const;
00253 virtual ~IGraphicBufferProducer();
00254 #elif (ANDROID_VER>=420)
00255 virtual const String16& getInterfaceDescriptor() const;
00256 virtual ~ISurfaceTexture();
00257 #endif
00258
00259 virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) = 0;
00260 virtual status_t setBufferCount(int bufferCount) = 0;
00261 #if (ANDROID_VER>=440)
00262 virtual status_t dequeueBuffer(int *slot, sp<Fence>* fence, bool async, uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
00263 #elif (ANDROID_VER>=430)
00264 virtual status_t dequeueBuffer(int *slot, sp<Fence>* fence, uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
00265 #elif (ANDROID_VER>=420)
00266 virtual status_t dequeueBuffer(int *slot, sp<Fence>& fence, uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
00267 #endif
00268 #if (ANDROID_VER>=500)
00269 virtual status_t detachBuffer(int slot) = 0;
00270 virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence) = 0;
00271 virtual status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer) = 0;
00272 #endif
00273 virtual status_t queueBuffer(int slot, const QueueBufferInput& input, QueueBufferOutput* output) = 0;
00274 #if (ANDROID_VER>=440)
00275 virtual void cancelBuffer(int slot, const sp<Fence>& fence) = 0;
00276 #elif (ANDROID_VER>=420)
00277 virtual void cancelBuffer(int slot, sp<Fence> fence) = 0;
00278 #endif
00279 virtual int query(int what, int* value) = 0;
00280 #if (ANDROID_VER<440)
00281 virtual status_t setSynchronousMode(bool enabled) = 0;
00282 #endif
00283 #if (ANDROID_VER>=440)
00284 virtual status_t connect(const sp<IBinder>& token, int api, bool producerControlledByApp, QueueBufferOutput* output) = 0;
00285 #elif (ANDROID_VER>=420)
00286 virtual status_t connect(int api, QueueBufferOutput* output) = 0;
00287 #endif
00288 virtual status_t disconnect(int api) = 0;
00289 #if (ANDROID_VER>=500)
00290 virtual status_t setSidebandStream(void* stream) = 0;
00291 virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, uint32_t format, uint32_t usage) = 0;
00292 #endif
00293 };
00294
00295 #if (ANDROID_VER>=430)
00296 class BnGraphicBufferProducer : public BnInterface<IGraphicBufferProducer> {
00297 public:
00298 virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
00299 };
00300 #elif (ANDROID_VER>=420)
00301 class BnSurfaceTexture : public BnInterface<ISurfaceTexture> {
00302 public:
00303 virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
00304 };
00305 #endif
00306 #endif
00307
00308 }
00309
00310 #endif //end of lib