Merge "Fix bug 4355335 - android.app.cts.DialogTest.testContextMenu failing on IRJ28"
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h
index fe9b049..c77bc4c 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -45,20 +45,20 @@
SurfaceTextureClient(const SurfaceTextureClient& rhs);
// ANativeWindow hooks
- static int cancelBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
- static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer);
- static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
+ static int cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
+ static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer);
+ static int lockBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
static int perform(ANativeWindow* window, int operation, ...);
- static int query(ANativeWindow* window, int what, int* value);
- static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
+ static int query(const ANativeWindow* window, int what, int* value);
+ static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
static int setSwapInterval(ANativeWindow* window, int interval);
- int cancelBuffer(android_native_buffer_t* buffer);
- int dequeueBuffer(android_native_buffer_t** buffer);
- int lockBuffer(android_native_buffer_t* buffer);
+ int cancelBuffer(ANativeWindowBuffer* buffer);
+ int dequeueBuffer(ANativeWindowBuffer** buffer);
+ int lockBuffer(ANativeWindowBuffer* buffer);
int perform(int operation, va_list args);
- int query(int what, int* value);
- int queueBuffer(android_native_buffer_t* buffer);
+ int query(int what, int* value) const;
+ int queueBuffer(ANativeWindowBuffer* buffer);
int setSwapInterval(int interval);
int dispatchConnect(va_list args);
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h
index 3923e61..ab30f45 100644
--- a/include/surfaceflinger/Surface.h
+++ b/include/surfaceflinger/Surface.h
@@ -202,18 +202,18 @@
* ANativeWindow hooks
*/
static int setSwapInterval(ANativeWindow* window, int interval);
- static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer);
- static int cancelBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
- static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
- static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
- static int query(ANativeWindow* window, int what, int* value);
+ static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer);
+ static int cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
+ static int lockBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
+ static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
+ static int query(const ANativeWindow* window, int what, int* value);
static int perform(ANativeWindow* 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 cancelBuffer(android_native_buffer_t* buffer);
- int query(int what, int* value);
+ int dequeueBuffer(ANativeWindowBuffer** buffer);
+ int lockBuffer(ANativeWindowBuffer* buffer);
+ int queueBuffer(ANativeWindowBuffer* buffer);
+ int cancelBuffer(ANativeWindowBuffer* buffer);
+ int query(int what, int* value) const;
int perform(int operation, va_list args);
void dispatch_setUsage(va_list args);
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h
index 16117ad..302d012 100644
--- a/include/ui/FramebufferNativeWindow.h
+++ b/include/ui/FramebufferNativeWindow.h
@@ -67,10 +67,10 @@
friend class LightRefBase<FramebufferNativeWindow>;
~FramebufferNativeWindow(); // this class cannot be overloaded
static int setSwapInterval(ANativeWindow* window, int interval);
- static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer);
- static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
- static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
- static int query(ANativeWindow* window, int what, int* value);
+ static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer);
+ static int lockBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
+ static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
+ static int query(const ANativeWindow* window, int what, int* value);
static int perform(ANativeWindow* window, int operation, ...);
framebuffer_device_t* fbDev;
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 02d6f8f..370253a 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -26,7 +26,7 @@
#include <utils/Flattenable.h>
#include <pixelflinger/pixelflinger.h>
-struct android_native_buffer_t;
+struct ANativeWindowBuffer;
namespace android {
@@ -38,7 +38,7 @@
class GraphicBuffer
: public EGLNativeBase<
- android_native_buffer_t,
+ ANativeWindowBuffer,
GraphicBuffer,
LightRefBase<GraphicBuffer> >, public Flattenable
{
@@ -74,8 +74,8 @@
GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
uint32_t stride, native_handle_t* handle, bool keepOwnership);
- // create a buffer from an existing android_native_buffer_t
- GraphicBuffer(android_native_buffer_t* buffer, bool keepOwnership);
+ // create a buffer from an existing ANativeWindowBuffer
+ GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
// return status
status_t initCheck() const;
@@ -94,7 +94,7 @@
status_t lock(GGLSurface* surface, uint32_t usage);
status_t unlock();
- android_native_buffer_t* getNativeBuffer() const;
+ ANativeWindowBuffer* getNativeBuffer() const;
void setIndex(int index);
int getIndex() const;
@@ -149,7 +149,7 @@
// If we're wrapping another buffer then this reference will make sure it
// doesn't get freed.
- sp<android_native_buffer_t> mWrappedBuffer;
+ sp<ANativeWindowBuffer> mWrappedBuffer;
};
}; // namespace android
diff --git a/include/ui/android_native_buffer.h b/include/ui/android_native_buffer.h
index 402843e..b6e1db4 100644
--- a/include/ui/android_native_buffer.h
+++ b/include/ui/android_native_buffer.h
@@ -19,53 +19,4 @@
#include <ui/egl/android_natives.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*****************************************************************************/
-
-typedef struct android_native_buffer_t
-{
-#ifdef __cplusplus
- android_native_buffer_t() {
- common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
- common.version = sizeof(android_native_buffer_t);
- memset(common.reserved, 0, sizeof(common.reserved));
- }
-
- // Implement the methods that sp<android_native_buffer_t> expects so that it
- // can be used to automatically refcount android_native_buffer_t's.
- void incStrong(const void* id) const {
- common.incRef(const_cast<android_native_base_t*>(&common));
- }
- void decStrong(const void* id) const {
- common.decRef(const_cast<android_native_base_t*>(&common));
- }
-#endif
-
- struct android_native_base_t common;
-
- int width;
- int height;
- int stride;
- int format;
- int usage;
-
- void* reserved[2];
-
- buffer_handle_t handle;
-
- void* reserved_proc[8];
-} android_native_buffer_t;
-
-
-/*****************************************************************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-/*****************************************************************************/
-
#endif /* ANDROID_ANDROID_NATIVES_PRIV_H */
diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h
index 0a6e4fb..9ac50a5 100644
--- a/include/ui/egl/android_natives.h
+++ b/include/ui/egl/android_natives.h
@@ -21,400 +21,9 @@
#include <string.h>
#include <hardware/gralloc.h>
-
+#include <system/window.h>
+// FIXME: remove this header, it's for legacy use. native_window is pulled from frameworks/base/native/include/android/
#include <android/native_window.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*****************************************************************************/
-
-#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
- (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
-
-#define ANDROID_NATIVE_WINDOW_MAGIC \
- ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
-
-#define ANDROID_NATIVE_BUFFER_MAGIC \
- ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
-
-// ---------------------------------------------------------------------------
-
-struct android_native_buffer_t;
-
-typedef struct android_native_rect_t
-{
- int32_t left;
- int32_t top;
- int32_t right;
- int32_t bottom;
-} android_native_rect_t;
-
-// ---------------------------------------------------------------------------
-
-typedef struct android_native_base_t
-{
- /* a magic value defined by the actual EGL native type */
- int magic;
-
- /* the sizeof() of the actual EGL native type */
- int version;
-
- void* reserved[4];
-
- /* reference-counting interface */
- void (*incRef)(struct android_native_base_t* base);
- void (*decRef)(struct android_native_base_t* base);
-} android_native_base_t;
-
-// ---------------------------------------------------------------------------
-
-/* attributes queriable with query() */
-enum {
- NATIVE_WINDOW_WIDTH = 0,
- NATIVE_WINDOW_HEIGHT,
- NATIVE_WINDOW_FORMAT,
-
- /* The minimum number of buffers that must remain un-dequeued after a buffer
- * has been queued. This value applies only if set_buffer_count was used to
- * override the number of buffers and if a buffer has since been queued.
- * Users of the set_buffer_count ANativeWindow method should query this
- * value before calling set_buffer_count. If it is necessary to have N
- * buffers simultaneously dequeued as part of the steady-state operation,
- * and this query returns M then N+M buffers should be requested via
- * native_window_set_buffer_count.
- *
- * Note that this value does NOT apply until a single buffer has been
- * queued. In particular this means that it is possible to:
- *
- * 1. Query M = min undequeued buffers
- * 2. Set the buffer count to N + M
- * 3. Dequeue all N + M buffers
- * 4. Cancel M buffers
- * 5. Queue, dequeue, queue, dequeue, ad infinitum
- */
- NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
-
- /* Check whether queueBuffer operations on the ANativeWindow send the buffer
- * to the window compositor. The query sets the returned 'value' argument
- * to 1 if the ANativeWindow DOES send queued buffers directly to the window
- * compositor and 0 if the buffers do not go directly to the window
- * compositor.
- *
- * This can be used to determine whether protected buffer content should be
- * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
- * indicate that queued buffers will be protected from applications or users
- * capturing their contents. If that behavior is desired then some other
- * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
- * conjunction with this query.
- */
- NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
-
- /* Get the concrete type of a ANativeWindow. See below for the list of
- * possible return values.
- *
- * This query should not be used outside the Android framework and will
- * likely be removed in the near future.
- */
- NATIVE_WINDOW_CONCRETE_TYPE,
-};
-
-/* valid operations for the (*perform)() hook */
-enum {
- NATIVE_WINDOW_SET_USAGE = 0,
- NATIVE_WINDOW_CONNECT,
- NATIVE_WINDOW_DISCONNECT,
- NATIVE_WINDOW_SET_CROP,
- NATIVE_WINDOW_SET_BUFFER_COUNT,
- NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
- NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
- NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
-};
-
-/* parameter for NATIVE_WINDOW_[DIS]CONNECT */
-enum {
- NATIVE_WINDOW_API_EGL = 1
-};
-
-/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
-enum {
- /* flip source image horizontally */
- NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
- /* flip source image vertically */
- NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
- /* rotate source image 90 degrees clock-wise */
- NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
- /* rotate source image 180 degrees */
- NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
- /* rotate source image 270 degrees clock-wise */
- NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
-};
-
-/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
-enum {
- NATIVE_WINDOW_FRAMEBUFFER, // FramebufferNativeWindow
- NATIVE_WINDOW_SURFACE, // Surface
- NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, // SurfaceTextureClient
-};
-
-/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
- *
- * Special timestamp value to indicate that timestamps should be auto-generated
- * by the native window when queueBuffer is called. This is equal to INT64_MIN,
- * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
- */
-const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
-
-struct ANativeWindow
-{
-#ifdef __cplusplus
- ANativeWindow()
- : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
- {
- common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
- common.version = sizeof(ANativeWindow);
- memset(common.reserved, 0, sizeof(common.reserved));
- }
-
- // Implement the methods that sp<ANativeWindow> expects so that it
- // can be used to automatically refcount ANativeWindow's.
- void incStrong(const void* id) const {
- common.incRef(const_cast<android_native_base_t*>(&common));
- }
- void decStrong(const void* id) const {
- common.decRef(const_cast<android_native_base_t*>(&common));
- }
-#endif
-
- struct android_native_base_t common;
-
- /* flags describing some attributes of this surface or its updater */
- const uint32_t flags;
-
- /* min swap interval supported by this updated */
- const int minSwapInterval;
-
- /* max swap interval supported by this updated */
- const int maxSwapInterval;
-
- /* horizontal and vertical resolution in DPI */
- const float xdpi;
- const float ydpi;
-
- /* Some storage reserved for the OEM's driver. */
- intptr_t oem[4];
-
-
- /*
- * Set the swap interval for this surface.
- *
- * Returns 0 on success or -errno on error.
- */
- int (*setSwapInterval)(struct ANativeWindow* window,
- int interval);
-
- /*
- * hook called by EGL to acquire a buffer. After this call, the buffer
- * is not locked, so its content cannot be modified.
- * this call may block if no buffers are available.
- *
- * Returns 0 on success or -errno on error.
- */
- int (*dequeueBuffer)(struct ANativeWindow* window,
- struct android_native_buffer_t** buffer);
-
- /*
- * hook called by EGL to lock a buffer. This MUST be called before modifying
- * the content of a buffer. The buffer must have been acquired with
- * dequeueBuffer first.
- *
- * Returns 0 on success or -errno on error.
- */
- int (*lockBuffer)(struct ANativeWindow* window,
- struct android_native_buffer_t* buffer);
- /*
- * hook called by EGL when modifications to the render buffer are done.
- * This unlocks and post the buffer.
- *
- * Buffers MUST be queued in the same order than they were dequeued.
- *
- * Returns 0 on success or -errno on error.
- */
- int (*queueBuffer)(struct ANativeWindow* window,
- struct android_native_buffer_t* buffer);
-
- /*
- * hook used to retrieve information about the native window.
- *
- * Returns 0 on success or -errno on error.
- */
- int (*query)(struct ANativeWindow* window,
- int what, int* value);
-
- /*
- * hook used to perform various operations on the surface.
- * (*perform)() is a generic mechanism to add functionality to
- * ANativeWindow while keeping backward binary compatibility.
- *
- * This hook should not be called directly, instead use the helper functions
- * defined below.
- *
- * (*perform)() returns -ENOENT if the 'what' parameter is not supported
- * by the surface's implementation.
- *
- * The valid operations are:
- * NATIVE_WINDOW_SET_USAGE
- * NATIVE_WINDOW_CONNECT
- * NATIVE_WINDOW_DISCONNECT
- * NATIVE_WINDOW_SET_CROP
- * NATIVE_WINDOW_SET_BUFFER_COUNT
- * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY
- * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
- * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
- *
- */
-
- int (*perform)(struct ANativeWindow* window,
- int operation, ... );
-
- /*
- * hook used to cancel a buffer that has been dequeued.
- * No synchronization is performed between dequeue() and cancel(), so
- * either external synchronization is needed, or these functions must be
- * called from the same thread.
- */
- int (*cancelBuffer)(struct ANativeWindow* window,
- struct android_native_buffer_t* buffer);
-
-
- void* reserved_proc[2];
-};
-
-// Backwards compatibility... please switch to ANativeWindow.
-typedef struct ANativeWindow android_native_window_t;
-
-/*
- * native_window_set_usage(..., 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.
- */
-
-static inline int native_window_set_usage(
- ANativeWindow* window, int usage)
-{
- return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
-}
-
-/*
- * native_window_connect(..., NATIVE_WINDOW_API_EGL)
- * Must be called by EGL when the window is made current.
- * Returns -EINVAL if for some reason the window cannot be connected, which
- * can happen if it's connected to some other API.
- */
-static inline int native_window_connect(
- ANativeWindow* window, int api)
-{
- return window->perform(window, NATIVE_WINDOW_CONNECT, api);
-}
-
-/*
- * native_window_disconnect(..., NATIVE_WINDOW_API_EGL)
- * Must be called by EGL when the window is made not current.
- * An error is returned if for instance the window wasn't connected in the
- * first place.
- */
-static inline int native_window_disconnect(
- ANativeWindow* window, int api)
-{
- return window->perform(window, NATIVE_WINDOW_DISCONNECT, api);
-}
-
-/*
- * native_window_set_crop(..., crop)
- * Sets which region of the next queued buffers needs to be considered.
- * A buffer's crop region is scaled to match the surface's size.
- *
- * The specified crop region applies to all buffers queued after it is called.
- *
- * if 'crop' is NULL, subsequently queued buffers won't be cropped.
- *
- * An error is returned if for instance the crop region is invalid,
- * out of the buffer's bound or if the window is invalid.
- */
-static inline int native_window_set_crop(
- ANativeWindow* window,
- android_native_rect_t const * crop)
-{
- return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
-}
-
-/*
- * native_window_set_buffer_count(..., count)
- * Sets the number of buffers associated with this native window.
- */
-static inline int native_window_set_buffer_count(
- ANativeWindow* window,
- size_t bufferCount)
-{
- return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
-}
-
-/*
- * native_window_set_buffers_geometry(..., int w, int h, int format)
- * All buffers dequeued after this call will have the geometry specified.
- * In particular, all buffers will have a fixed-size, independent form the
- * native-window size. They will be appropriately scaled to the window-size
- * upon composition.
- *
- * If all parameters are 0, the normal behavior is restored. That is,
- * dequeued buffers following this call will be sized to the window's size.
- *
- * Calling this function will reset the window crop to a NULL value, which
- * disables cropping of the buffers.
- */
-static inline int native_window_set_buffers_geometry(
- ANativeWindow* window,
- int w, int h, int format)
-{
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
- w, h, format);
-}
-
-/*
- * native_window_set_buffers_transform(..., int transform)
- * All buffers queued after this call will be displayed transformed according
- * to the transform parameter specified.
- */
-static inline int native_window_set_buffers_transform(
- ANativeWindow* window,
- int transform)
-{
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
- transform);
-}
-
-/*
- * native_window_set_buffers_timestamp(..., int64_t timestamp)
- * All buffers queued after this call will be associated with the timestamp
- * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
- * (the default), timestamps will be generated automatically when queueBuffer is
- * called. The timestamp is measured in nanoseconds, and must be monotonically
- * increasing.
- */
-static inline int native_window_set_buffers_timestamp(
- ANativeWindow* window,
- int64_t timestamp)
-{
- return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
- timestamp);
-}
-
// ---------------------------------------------------------------------------
/* FIXME: this is legacy for pixmaps */
@@ -437,13 +46,6 @@
/*****************************************************************************/
#ifdef __cplusplus
-}
-#endif
-
-
-/*****************************************************************************/
-
-#ifdef __cplusplus
#include <utils/RefBase.h>
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 44d9b4b..0c5767b 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -513,32 +513,32 @@
}
int Surface::dequeueBuffer(ANativeWindow* window,
- android_native_buffer_t** buffer) {
+ ANativeWindowBuffer** buffer) {
Surface* self = getSelf(window);
return self->dequeueBuffer(buffer);
}
int Surface::cancelBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer) {
+ ANativeWindowBuffer* buffer) {
Surface* self = getSelf(window);
return self->cancelBuffer(buffer);
}
int Surface::lockBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer) {
+ ANativeWindowBuffer* buffer) {
Surface* self = getSelf(window);
return self->lockBuffer(buffer);
}
int Surface::queueBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer) {
+ ANativeWindowBuffer* buffer) {
Surface* self = getSelf(window);
return self->queueBuffer(buffer);
}
-int Surface::query(ANativeWindow* window,
+int Surface::query(const ANativeWindow* window,
int what, int* value) {
- Surface* self = getSelf(window);
+ const Surface* self = getSelf(window);
return self->query(what, value);
}
@@ -570,7 +570,7 @@
return newNeewBuffer;
}
-int Surface::dequeueBuffer(android_native_buffer_t** buffer)
+int Surface::dequeueBuffer(ANativeWindowBuffer** buffer)
{
status_t err = validate();
if (err != NO_ERROR)
@@ -624,7 +624,7 @@
return err;
}
-int Surface::cancelBuffer(android_native_buffer_t* buffer)
+int Surface::cancelBuffer(ANativeWindowBuffer* buffer)
{
status_t err = validate(true);
switch (err) {
@@ -651,7 +651,7 @@
}
-int Surface::lockBuffer(android_native_buffer_t* buffer)
+int Surface::lockBuffer(ANativeWindowBuffer* buffer)
{
status_t err = validate();
if (err != NO_ERROR)
@@ -670,7 +670,7 @@
return err;
}
-int Surface::queueBuffer(android_native_buffer_t* buffer)
+int Surface::queueBuffer(ANativeWindowBuffer* buffer)
{
status_t err = validate();
if (err != NO_ERROR)
@@ -697,7 +697,7 @@
return err;
}
-int Surface::query(int what, int* value)
+int Surface::query(int what, int* value) const
{
switch (what) {
case NATIVE_WINDOW_WIDTH:
@@ -969,7 +969,7 @@
// we're intending to do software rendering from this point
setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
- android_native_buffer_t* out;
+ ANativeWindowBuffer* out;
status_t err = dequeueBuffer(&out);
LOGE_IF(err, "dequeueBuffer failed (%s)", strerror(-err));
if (err == NO_ERROR) {
@@ -1063,7 +1063,7 @@
if (idx < 0) {
// The buffer doesn't have an index set. See if the handle the same as
// one of the buffers for which we do know the index. This can happen
- // e.g. if GraphicBuffer is used to wrap an android_native_buffer_t that
+ // e.g. if GraphicBuffer is used to wrap an ANativeWindowBuffer that
// was dequeued from an ANativeWindow.
for (size_t i = 0; i < mBuffers.size(); i++) {
if (mBuffers[i] != 0 && buffer->handle == mBuffers[i]->handle) {
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index f4b2416..ec6da43 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -53,31 +53,32 @@
}
int SurfaceTextureClient::dequeueBuffer(ANativeWindow* window,
- android_native_buffer_t** buffer) {
+ ANativeWindowBuffer** buffer) {
SurfaceTextureClient* c = getSelf(window);
return c->dequeueBuffer(buffer);
}
int SurfaceTextureClient::cancelBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer) {
+ ANativeWindowBuffer* buffer) {
SurfaceTextureClient* c = getSelf(window);
return c->cancelBuffer(buffer);
}
int SurfaceTextureClient::lockBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer) {
+ ANativeWindowBuffer* buffer) {
SurfaceTextureClient* c = getSelf(window);
return c->lockBuffer(buffer);
}
int SurfaceTextureClient::queueBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer) {
+ ANativeWindowBuffer* buffer) {
SurfaceTextureClient* c = getSelf(window);
return c->queueBuffer(buffer);
}
-int SurfaceTextureClient::query(ANativeWindow* window, int what, int* value) {
- SurfaceTextureClient* c = getSelf(window);
+int SurfaceTextureClient::query(const ANativeWindow* window,
+ int what, int* value) {
+ const SurfaceTextureClient* c = getSelf(window);
return c->query(what, value);
}
@@ -160,7 +161,7 @@
return BAD_VALUE;
}
-int SurfaceTextureClient::query(int what, int* value) {
+int SurfaceTextureClient::query(int what, int* value) const {
LOGV("SurfaceTextureClient::query");
Mutex::Autolock lock(mMutex);
switch (what) {
diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp
index db781de..753e933 100644
--- a/libs/gui/tests/SurfaceTextureClient_test.cpp
+++ b/libs/gui/tests/SurfaceTextureClient_test.cpp
@@ -113,7 +113,7 @@
TEST_F(SurfaceTextureClientTest, DefaultGeometryValues) {
sp<ANativeWindow> anw(mSTC);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(1, buf->width);
EXPECT_EQ(1, buf->height);
@@ -123,7 +123,7 @@
TEST_F(SurfaceTextureClientTest, BufferGeometryCanBeSet) {
sp<ANativeWindow> anw(mSTC);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 16, 8, PIXEL_FORMAT_RGB_565));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(16, buf->width);
@@ -134,7 +134,7 @@
TEST_F(SurfaceTextureClientTest, BufferGeometryDefaultSizeSetFormat) {
sp<ANativeWindow> anw(mSTC);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 0, 0, PIXEL_FORMAT_RGB_565));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(1, buf->width);
@@ -145,7 +145,7 @@
TEST_F(SurfaceTextureClientTest, BufferGeometrySetSizeDefaultFormat) {
sp<ANativeWindow> anw(mSTC);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 16, 8, 0));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(16, buf->width);
@@ -156,7 +156,7 @@
TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeUnset) {
sp<ANativeWindow> anw(mSTC);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 16, 8, 0));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(16, buf->width);
@@ -173,7 +173,7 @@
TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeChangedWithoutFormat) {
sp<ANativeWindow> anw(mSTC);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
EXPECT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 0, 0, PIXEL_FORMAT_RGB_565));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(1, buf->width);
@@ -191,7 +191,7 @@
TEST_F(SurfaceTextureClientTest, SurfaceTextureSetDefaultSize) {
sp<ANativeWindow> anw(mSTC);
sp<SurfaceTexture> st(mST);
- android_native_buffer_t* buf;
+ ANativeWindowBuffer* buf;
EXPECT_EQ(OK, st->setDefaultBufferSize(16, 8));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf));
EXPECT_EQ(16, buf->width);
@@ -203,7 +203,7 @@
TEST_F(SurfaceTextureClientTest, SurfaceTextureSetDefaultSizeAfterDequeue) {
sp<ANativeWindow> anw(mSTC);
sp<SurfaceTexture> st(mST);
- android_native_buffer_t* buf[2];
+ ANativeWindowBuffer* buf[2];
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf[0]));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf[1]));
EXPECT_NE(buf[0], buf[1]);
@@ -224,7 +224,7 @@
TEST_F(SurfaceTextureClientTest, SurfaceTextureSetDefaultSizeVsGeometry) {
sp<ANativeWindow> anw(mSTC);
sp<SurfaceTexture> st(mST);
- android_native_buffer_t* buf[2];
+ ANativeWindowBuffer* buf[2];
EXPECT_EQ(OK, st->setDefaultBufferSize(16, 8));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf[0]));
ASSERT_EQ(OK, anw->dequeueBuffer(anw.get(), &buf[1]));
diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp
index 6c71343..8747ba5 100644
--- a/libs/gui/tests/SurfaceTexture_test.cpp
+++ b/libs/gui/tests/SurfaceTexture_test.cpp
@@ -476,7 +476,7 @@
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
- android_native_buffer_t* anb;
+ ANativeWindowBuffer* anb;
ASSERT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
ASSERT_TRUE(anb != NULL);
@@ -524,7 +524,7 @@
ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
- android_native_buffer_t* anb;
+ ANativeWindowBuffer* anb;
ASSERT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
ASSERT_TRUE(anb != NULL);
@@ -583,7 +583,7 @@
ASSERT_EQ(NO_ERROR, native_window_set_crop(mANW.get(), &crop));
- android_native_buffer_t* anb;
+ ANativeWindowBuffer* anb;
ASSERT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
ASSERT_TRUE(anb != NULL);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 440a48b..35c8640 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -93,7 +93,7 @@
ASSERT_EQ(NO_ERROR, native_window_set_usage(anw.get(),
GRALLOC_USAGE_PROTECTED));
ASSERT_EQ(NO_ERROR, native_window_set_buffer_count(anw.get(), 3));
- android_native_buffer_t* buf = 0;
+ ANativeWindowBuffer* buf = 0;
for (int i = 0; i < 4; i++) {
// Loop to make sure SurfaceFlinger has retired a protected buffer.
ASSERT_EQ(NO_ERROR, anw->dequeueBuffer(anw.get(), &buf));
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index dc223f9..4393504 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -47,16 +47,16 @@
class NativeBuffer
: public EGLNativeBase<
- android_native_buffer_t,
+ ANativeWindowBuffer,
NativeBuffer,
LightRefBase<NativeBuffer> >
{
public:
NativeBuffer(int w, int h, int f, int u) : BASE() {
- android_native_buffer_t::width = w;
- android_native_buffer_t::height = h;
- android_native_buffer_t::format = f;
- android_native_buffer_t::usage = u;
+ ANativeWindowBuffer::width = w;
+ ANativeWindowBuffer::height = h;
+ ANativeWindowBuffer::format = f;
+ ANativeWindowBuffer::usage = u;
}
private:
friend class LightRefBase<NativeBuffer>;
@@ -201,7 +201,7 @@
}
int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
- android_native_buffer_t** buffer)
+ ANativeWindowBuffer** buffer)
{
FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
@@ -229,7 +229,7 @@
}
int FramebufferNativeWindow::lockBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer)
+ ANativeWindowBuffer* buffer)
{
FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
@@ -249,7 +249,7 @@
}
int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
- android_native_buffer_t* buffer)
+ ANativeWindowBuffer* buffer)
{
FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
@@ -270,10 +270,10 @@
return res;
}
-int FramebufferNativeWindow::query(ANativeWindow* window,
+int FramebufferNativeWindow::query(const ANativeWindow* window,
int what, int* value)
{
- FramebufferNativeWindow* self = getSelf(window);
+ const FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
framebuffer_device_t* fb = self->fbDev;
switch (what) {
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 97312a6..54a3ffa 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -33,7 +33,7 @@
namespace android {
// ===========================================================================
-// Buffer and implementation of android_native_buffer_t
+// Buffer and implementation of ANativeWindowBuffer
// ===========================================================================
GraphicBuffer::GraphicBuffer()
@@ -77,7 +77,7 @@
handle = inHandle;
}
-GraphicBuffer::GraphicBuffer(android_native_buffer_t* buffer, bool keepOwnership)
+GraphicBuffer::GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership)
: BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
mBufferMapper(GraphicBufferMapper::get()),
mInitCheck(NO_ERROR), mIndex(-1), mWrappedBuffer(buffer)
@@ -119,9 +119,9 @@
GraphicBufferAllocator::dumpToSystemLog();
}
-android_native_buffer_t* GraphicBuffer::getNativeBuffer() const
+ANativeWindowBuffer* GraphicBuffer::getNativeBuffer() const
{
- return static_cast<android_native_buffer_t*>(
+ return static_cast<ANativeWindowBuffer*>(
const_cast<GraphicBuffer*>(this));
}
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
index 1ffcd56..1123e16 100644
--- a/opengl/include/EGL/eglext.h
+++ b/opengl/include/EGL/eglext.h
@@ -225,7 +225,7 @@
#ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1
-struct android_native_buffer_t;
+struct ANativeWindowBuffer;
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */
#endif
diff --git a/opengl/libagl/TextureObjectManager.cpp b/opengl/libagl/TextureObjectManager.cpp
index bbb82fc..022de09 100644
--- a/opengl/libagl/TextureObjectManager.cpp
+++ b/opengl/libagl/TextureObjectManager.cpp
@@ -145,7 +145,7 @@
return NO_ERROR;
}
-status_t EGLTextureObject::setImage(android_native_buffer_t* native_buffer)
+status_t EGLTextureObject::setImage(ANativeWindowBuffer* native_buffer)
{
GGLSurface sur;
sur.version = sizeof(GGLSurface);
diff --git a/opengl/libagl/TextureObjectManager.h b/opengl/libagl/TextureObjectManager.h
index 70e3bef..de9e03e 100644
--- a/opengl/libagl/TextureObjectManager.h
+++ b/opengl/libagl/TextureObjectManager.h
@@ -48,7 +48,7 @@
~EGLTextureObject();
status_t setSurface(GGLSurface const* s);
- status_t setImage(android_native_buffer_t* buffer);
+ status_t setImage(ANativeWindowBuffer* buffer);
void setImageBits(void* vaddr) { surface.data = (GGLubyte*)vaddr; }
status_t reallocate(GLint level,
@@ -80,7 +80,7 @@
GLint crop_rect[4];
GLint generate_mipmap;
GLint direct;
- android_native_buffer_t* buffer;
+ ANativeWindowBuffer* buffer;
};
// ----------------------------------------------------------------------------
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 97e913b..0d03361 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -230,11 +230,11 @@
virtual EGLBoolean setSwapRectangle(EGLint l, EGLint t, EGLint w, EGLint h);
private:
- status_t lock(android_native_buffer_t* buf, int usage, void** vaddr);
- status_t unlock(android_native_buffer_t* buf);
+ status_t lock(ANativeWindowBuffer* buf, int usage, void** vaddr);
+ status_t unlock(ANativeWindowBuffer* buf);
ANativeWindow* nativeWindow;
- android_native_buffer_t* buffer;
- android_native_buffer_t* previousBuffer;
+ ANativeWindowBuffer* buffer;
+ ANativeWindowBuffer* previousBuffer;
gralloc_module_t const* module;
int width;
int height;
@@ -322,8 +322,8 @@
};
void copyBlt(
- android_native_buffer_t* dst, void* dst_vaddr,
- android_native_buffer_t* src, void const* src_vaddr,
+ ANativeWindowBuffer* dst, void* dst_vaddr,
+ ANativeWindowBuffer* src, void const* src_vaddr,
const Region& clip);
Rect dirtyRegion;
@@ -415,7 +415,7 @@
}
status_t egl_window_surface_v2_t::lock(
- android_native_buffer_t* buf, int usage, void** vaddr)
+ ANativeWindowBuffer* buf, int usage, void** vaddr)
{
int err;
@@ -425,7 +425,7 @@
return err;
}
-status_t egl_window_surface_v2_t::unlock(android_native_buffer_t* buf)
+status_t egl_window_surface_v2_t::unlock(ANativeWindowBuffer* buf)
{
if (!buf) return BAD_VALUE;
int err = NO_ERROR;
@@ -436,8 +436,8 @@
}
void egl_window_surface_v2_t::copyBlt(
- android_native_buffer_t* dst, void* dst_vaddr,
- android_native_buffer_t* src, void const* src_vaddr,
+ ANativeWindowBuffer* dst, void* dst_vaddr,
+ ANativeWindowBuffer* src, void const* src_vaddr,
const Region& clip)
{
// NOTE: dst and src must be the same format
@@ -2003,12 +2003,12 @@
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
}
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer;
+ ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*)buffer;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
- if (native_buffer->common.version != sizeof(android_native_buffer_t))
+ if (native_buffer->common.version != sizeof(ANativeWindowBuffer))
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
switch (native_buffer->format) {
@@ -2034,12 +2034,12 @@
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
}
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)img;
+ ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*)img;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
- if (native_buffer->common.version != sizeof(android_native_buffer_t))
+ if (native_buffer->common.version != sizeof(ANativeWindowBuffer))
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
native_buffer->common.decRef(&native_buffer->common);
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index eb96895..8eb17c4 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -126,7 +126,7 @@
for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; i++) {
if (c->rasterizer.state.texture[i].enable) {
texture_unit_t& u(c->textures.tmu[i]);
- android_native_buffer_t* native_buffer = u.texture->buffer;
+ ANativeWindowBuffer* native_buffer = u.texture->buffer;
if (native_buffer) {
c->rasterizer.procs.activeTexture(c, i);
hw_module_t const* pModule;
@@ -154,7 +154,7 @@
for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; i++) {
if (c->rasterizer.state.texture[i].enable) {
texture_unit_t& u(c->textures.tmu[i]);
- android_native_buffer_t* native_buffer = u.texture->buffer;
+ ANativeWindowBuffer* native_buffer = u.texture->buffer;
if (native_buffer) {
c->rasterizer.procs.activeTexture(c, i);
hw_module_t const* pModule;
@@ -1615,12 +1615,12 @@
return;
}
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+ ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*)image;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
ogles_error(c, GL_INVALID_VALUE);
return;
}
- if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+ if (native_buffer->common.version != sizeof(ANativeWindowBuffer)) {
ogles_error(c, GL_INVALID_VALUE);
return;
}
@@ -1643,12 +1643,12 @@
return;
}
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+ ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*)image;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
ogles_error(c, GL_INVALID_VALUE);
return;
}
- if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+ if (native_buffer->common.version != sizeof(ANativeWindowBuffer)) {
ogles_error(c, GL_INVALID_VALUE);
return;
}
diff --git a/opengl/libagl2/src/egl.cpp b/opengl/libagl2/src/egl.cpp
index ec5889d..0d02ce6 100644
--- a/opengl/libagl2/src/egl.cpp
+++ b/opengl/libagl2/src/egl.cpp
@@ -211,11 +211,11 @@
virtual EGLBoolean setSwapRectangle(EGLint l, EGLint t, EGLint w, EGLint h);
private:
- status_t lock(android_native_buffer_t* buf, int usage, void** vaddr);
- status_t unlock(android_native_buffer_t* buf);
+ status_t lock(ANativeWindowBuffer* buf, int usage, void** vaddr);
+ status_t unlock(ANativeWindowBuffer* buf);
ANativeWindow* nativeWindow;
- android_native_buffer_t* buffer;
- android_native_buffer_t* previousBuffer;
+ ANativeWindowBuffer* buffer;
+ ANativeWindowBuffer* previousBuffer;
gralloc_module_t const* module;
int width;
int height;
@@ -307,8 +307,8 @@
};
void copyBlt(
- android_native_buffer_t* dst, void* dst_vaddr,
- android_native_buffer_t* src, void const* src_vaddr,
+ ANativeWindowBuffer* dst, void* dst_vaddr,
+ ANativeWindowBuffer* src, void const* src_vaddr,
const Region& clip);
Rect dirtyRegion;
@@ -407,7 +407,7 @@
}
status_t egl_window_surface_v2_t::lock(
- android_native_buffer_t* buf, int usage, void** vaddr)
+ ANativeWindowBuffer* buf, int usage, void** vaddr)
{
int err;
@@ -417,7 +417,7 @@
return err;
}
-status_t egl_window_surface_v2_t::unlock(android_native_buffer_t* buf)
+status_t egl_window_surface_v2_t::unlock(ANativeWindowBuffer* buf)
{
if (!buf) return BAD_VALUE;
int err = NO_ERROR;
@@ -428,8 +428,8 @@
}
void egl_window_surface_v2_t::copyBlt(
- android_native_buffer_t* dst, void* dst_vaddr,
- android_native_buffer_t* src, void const* src_vaddr,
+ ANativeWindowBuffer* dst, void* dst_vaddr,
+ ANativeWindowBuffer* src, void const* src_vaddr,
const Region& clip)
{
// NOTE: dst and src must be the same format
@@ -2105,12 +2105,12 @@
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
}
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer;
+ ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*)buffer;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
- if (native_buffer->common.version != sizeof(android_native_buffer_t))
+ if (native_buffer->common.version != sizeof(ANativeWindowBuffer))
return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
switch (native_buffer->format) {
@@ -2136,12 +2136,12 @@
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
}
- android_native_buffer_t* native_buffer = (android_native_buffer_t*)img;
+ ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*)img;
if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
- if (native_buffer->common.version != sizeof(android_native_buffer_t))
+ if (native_buffer->common.version != sizeof(ANativeWindowBuffer))
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
native_buffer->common.decRef(&native_buffer->common);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7506f29..ad6ab8e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1094,15 +1094,15 @@
ssize_t SurfaceFlinger::addClientLayer(const sp<Client>& client,
const sp<LayerBaseClient>& lbc)
{
- Mutex::Autolock _l(mStateLock);
-
// attach this layer to the client
- ssize_t name = client->attachLayer(lbc);
+ size_t name = client->attachLayer(lbc);
+
+ Mutex::Autolock _l(mStateLock);
// add this layer to the current state list
addLayer_l(lbc);
- return name;
+ return ssize_t(name);
}
status_t SurfaceFlinger::removeLayer(const sp<LayerBase>& layer)
@@ -2381,15 +2381,17 @@
return NO_ERROR;
}
-ssize_t Client::attachLayer(const sp<LayerBaseClient>& layer)
+size_t Client::attachLayer(const sp<LayerBaseClient>& layer)
{
- int32_t name = android_atomic_inc(&mNameGenerator);
+ Mutex::Autolock _l(mLock);
+ size_t name = mNameGenerator++;
mLayers.add(name, layer);
return name;
}
void Client::detachLayer(const LayerBaseClient* layer)
{
+ Mutex::Autolock _l(mLock);
// we do a linear search here, because this doesn't happen often
const size_t count = mLayers.size();
for (size_t i=0 ; i<count ; i++) {
@@ -2399,9 +2401,11 @@
}
}
}
-sp<LayerBaseClient> Client::getLayerUser(int32_t i) const {
+sp<LayerBaseClient> Client::getLayerUser(int32_t i) const
+{
+ Mutex::Autolock _l(mLock);
sp<LayerBaseClient> lbc;
- const wp<LayerBaseClient>& layer(mLayers.valueFor(i));
+ wp<LayerBaseClient> layer(mLayers.valueFor(i));
if (layer != 0) {
lbc = layer.promote();
LOGE_IF(lbc==0, "getLayerUser(name=%d) is dead", int(i));
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 1b36d1c..3eb4c11 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -65,7 +65,7 @@
status_t initCheck() const;
// protected by SurfaceFlinger::mStateLock
- ssize_t attachLayer(const sp<LayerBaseClient>& layer);
+ size_t attachLayer(const sp<LayerBaseClient>& layer);
void detachLayer(const LayerBaseClient* layer);
sp<LayerBaseClient> getLayerUser(int32_t i) const;
@@ -81,9 +81,15 @@
virtual status_t destroySurface(SurfaceID surfaceId);
virtual status_t setState(int32_t count, const layer_state_t* states);
- DefaultKeyedVector< size_t, wp<LayerBaseClient> > mLayers;
+ // constant
sp<SurfaceFlinger> mFlinger;
- int32_t mNameGenerator;
+
+ // protected by mLock
+ DefaultKeyedVector< size_t, wp<LayerBaseClient> > mLayers;
+ size_t mNameGenerator;
+
+ // thread-safe
+ mutable Mutex mLock;
};
class UserClient : public BnSurfaceComposerClient
diff --git a/services/surfaceflinger/TextureManager.cpp b/services/surfaceflinger/TextureManager.cpp
index 9e24f90d..bb63c37 100644
--- a/services/surfaceflinger/TextureManager.cpp
+++ b/services/surfaceflinger/TextureManager.cpp
@@ -144,7 +144,7 @@
}
// construct an EGL_NATIVE_BUFFER_ANDROID
- android_native_buffer_t* clientBuf = buffer->getNativeBuffer();
+ ANativeWindowBuffer* clientBuf = buffer->getNativeBuffer();
// create the new EGLImageKHR
const EGLint attrs[] = {
diff --git a/services/surfaceflinger/tests/surface/surface.cpp b/services/surfaceflinger/tests/surface/surface.cpp
index 67ecf7e..5265f91 100644
--- a/services/surfaceflinger/tests/surface/surface.cpp
+++ b/services/surfaceflinger/tests/surface/surface.cpp
@@ -53,7 +53,7 @@
printf("window=%p\n", window);
int err = native_window_set_buffer_count(window, 8);
- android_native_buffer_t* buffer;
+ ANativeWindowBuffer* buffer;
for (int i=0 ; i<8 ; i++) {
window->dequeueBuffer(window, &buffer);