diff options
author | Mathias Agopian <mathias@google.com> | 2009-08-10 21:59:56 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-08-11 16:12:56 -0700 |
commit | df37b62c62f8efd3b5a433f9b4d40d30cec13a31 (patch) | |
tree | 43c783e665b9e1c47210d3c5a8f929b33acda72f /include | |
parent | d779f052b4180f347ed0bd725fdfedda504773e5 (diff) | |
download | frameworks_native-df37b62c62f8efd3b5a433f9b4d40d30cec13a31.zip frameworks_native-df37b62c62f8efd3b5a433f9b4d40d30cec13a31.tar.gz frameworks_native-df37b62c62f8efd3b5a433f9b4d40d30cec13a31.tar.bz2 |
SurfaceFlinger will now allocate buffers based on the usage specified by the clients. This allows to allocate the right kind of buffer automatically, without having the user to specify anything.
This change makes SurfaceHolder.setType(GPU) obsolete (it's now ignored).
Added an API to android_native_window_t to allow extending the functionality without ever breaking binary compatibility. This is used to implement the new set_usage() API. This API needs to be called by software renderers because the default is to use usage flags suitable for h/w.
Diffstat (limited to 'include')
-rw-r--r-- | include/ui/FramebufferNativeWindow.h | 1 | ||||
-rw-r--r-- | include/ui/ISurface.h | 2 | ||||
-rw-r--r-- | include/ui/Surface.h | 5 | ||||
-rw-r--r-- | include/ui/egl/android_natives.h | 43 |
4 files changed, 47 insertions, 4 deletions
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h index cb9bf94..68144b5 100644 --- a/include/ui/FramebufferNativeWindow.h +++ b/include/ui/FramebufferNativeWindow.h @@ -63,6 +63,7 @@ private: static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer); static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer); static int query(android_native_window_t* window, int what, int* value); + static int perform(android_native_window_t* window, int operation, ...); framebuffer_device_t* fbDev; alloc_device_t* grDev; diff --git a/include/ui/ISurface.h b/include/ui/ISurface.h index adba45a..7909c2f 100644 --- a/include/ui/ISurface.h +++ b/include/ui/ISurface.h @@ -50,7 +50,7 @@ protected: public: DECLARE_META_INTERFACE(Surface); - virtual sp<SurfaceBuffer> getBuffer() = 0; + virtual sp<SurfaceBuffer> getBuffer(int usage) = 0; class BufferHeap { public: diff --git a/include/ui/Surface.h b/include/ui/Surface.h index d5dad31..4ff0e4a 100644 --- a/include/ui/Surface.h +++ b/include/ui/Surface.h @@ -184,7 +184,7 @@ private: friend class IOMX; const sp<ISurface>& getISurface() const { return mSurface; } - status_t getBufferLocked(int index); + status_t getBufferLocked(int index, int usage); status_t validate(per_client_cblk_t const* cblk) const; static void _send_dirty_region(layer_cblk_t* lcblk, const Region& dirty); @@ -197,11 +197,13 @@ private: static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer); static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer); static int query(android_native_window_t* window, int what, int* value); + static int perform(android_native_window_t* window, int operation, ...); int dequeueBuffer(android_native_buffer_t** buffer); int lockBuffer(android_native_buffer_t* buffer); int queueBuffer(android_native_buffer_t* buffer); int query(int what, int* value); + int perform(int operation, va_list args); status_t dequeueBuffer(sp<SurfaceBuffer>* buffer); status_t lockBuffer(const sp<SurfaceBuffer>& buffer); @@ -217,6 +219,7 @@ private: uint32_t mIdentity; uint32_t mWidth; uint32_t mHeight; + uint32_t mUsage; PixelFormat mFormat; uint32_t mFlags; mutable Region mDirtyRegion; diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h index 7da69b1..4c58e47 100644 --- a/include/ui/egl/android_natives.h +++ b/include/ui/egl/android_natives.h @@ -67,6 +67,11 @@ enum { NATIVE_WINDOW_FORMAT = 2, }; +/* valid operations for the (*perform)() hook */ +enum { + NATIVE_WINDOW_SET_USAGE = 0 +}; + struct android_native_window_t { #ifdef __cplusplus @@ -142,11 +147,45 @@ struct android_native_window_t * Returns 0 on success or -errno on error. */ int (*query)(struct android_native_window_t* window, - int what, int* value); + int what, int* value); + + /* + * hook used to perform various operations on the surface. + * (*perform)() is a generic mechanism to add functionality to + * android_native_window_t while keeping backward binary compatibility. + * + * This hook should not be called directly, instead use the helper functions + * defined below. + * + * The valid operations are: + * NATIVE_WINDOW_SET_USAGE + * + */ + + int (*perform)(struct android_native_window_t* window, + int operation, ... ); - void* reserved_proc[4]; + void* reserved_proc[3]; }; + +/* + * native_window_set_usage() sets the intended usage flags for the next + * buffers acquired with (*lockBuffer)() and on. + * By default (if this function is never called), a usage of + * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE + * is assumed. + * Calling this function will usually cause following buffers to be + * reallocated. + */ + +inline int native_window_set_usage( + struct android_native_window_t* window, int usage) +{ + return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); +} + + // --------------------------------------------------------------------------- /* FIXME: this is legacy for pixmaps */ |