diff options
-rw-r--r-- | include/surfaceflinger/Surface.h | 16 | ||||
-rw-r--r-- | include/ui/FramebufferNativeWindow.h | 14 | ||||
-rw-r--r-- | include/ui/egl/android_natives.h | 42 | ||||
-rw-r--r-- | libs/rs/rs.spec | 2 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 4 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 4 | ||||
-rw-r--r-- | libs/surfaceflinger_client/Surface.cpp | 36 | ||||
-rw-r--r-- | libs/ui/FramebufferNativeWindow.cpp | 36 | ||||
-rw-r--r-- | native/include/android/native_window.h | 33 | ||||
-rw-r--r-- | opengl/include/EGL/eglplatform.h | 5 | ||||
-rw-r--r-- | opengl/libagl/egl.cpp | 10 |
11 files changed, 120 insertions, 82 deletions
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h index f333911..4fd0681 100644 --- a/include/surfaceflinger/Surface.h +++ b/include/surfaceflinger/Surface.h @@ -131,7 +131,7 @@ private: // --------------------------------------------------------------------------- class Surface - : public EGLNativeBase<android_native_window_t, Surface, RefBase> + : public EGLNativeBase<ANativeWindow, Surface, RefBase> { public: struct SurfaceInfo { @@ -195,14 +195,14 @@ private: /* - * android_native_window_t hooks + * ANativeWindow hooks */ - static int setSwapInterval(android_native_window_t* window, int interval); - static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer); - 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, ...); + 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 perform(ANativeWindow* window, int operation, ...); int dequeueBuffer(android_native_buffer_t** buffer); int lockBuffer(android_native_buffer_t* buffer); diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h index 8ea3ab9..0f4594f 100644 --- a/include/ui/FramebufferNativeWindow.h +++ b/include/ui/FramebufferNativeWindow.h @@ -43,7 +43,7 @@ class NativeBuffer; class FramebufferNativeWindow : public EGLNativeBase< - android_native_window_t, + ANativeWindow, FramebufferNativeWindow, LightRefBase<FramebufferNativeWindow> > { @@ -59,12 +59,12 @@ public: private: friend class LightRefBase<FramebufferNativeWindow>; ~FramebufferNativeWindow(); // this class cannot be overloaded - static int setSwapInterval(android_native_window_t* window, int interval); - static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer); - 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, ...); + 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 perform(ANativeWindow* window, int operation, ...); framebuffer_device_t* fbDev; alloc_device_t* grDev; diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h index 171f3df..ca89b06 100644 --- a/include/ui/egl/android_natives.h +++ b/include/ui/egl/android_natives.h @@ -22,6 +22,8 @@ #include <hardware/gralloc.h> +#include <android/native_window.h> + #ifdef __cplusplus extern "C" { #endif @@ -90,19 +92,19 @@ enum { NATIVE_WINDOW_API_EGL = 1 }; -typedef struct android_native_window_t +struct ANativeWindow { #ifdef __cplusplus - android_native_window_t() + ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) { common.magic = ANDROID_NATIVE_WINDOW_MAGIC; - common.version = sizeof(android_native_window_t); + common.version = sizeof(ANativeWindow); memset(common.reserved, 0, sizeof(common.reserved)); } - // Implement the methods that sp<android_native_window_t> expects so that it - // can be used to automatically refcount android_native_window_t's. + // 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)); } @@ -135,7 +137,7 @@ typedef struct android_native_window_t * * Returns 0 on success or -errno on error. */ - int (*setSwapInterval)(struct android_native_window_t* window, + int (*setSwapInterval)(struct ANativeWindow* window, int interval); /* @@ -145,7 +147,7 @@ typedef struct android_native_window_t * * Returns 0 on success or -errno on error. */ - int (*dequeueBuffer)(struct android_native_window_t* window, + int (*dequeueBuffer)(struct ANativeWindow* window, struct android_native_buffer_t** buffer); /* @@ -155,7 +157,7 @@ typedef struct android_native_window_t * * Returns 0 on success or -errno on error. */ - int (*lockBuffer)(struct android_native_window_t* window, + int (*lockBuffer)(struct ANativeWindow* window, struct android_native_buffer_t* buffer); /* * hook called by EGL when modifications to the render buffer are done. @@ -165,7 +167,7 @@ typedef struct android_native_window_t * * Returns 0 on success or -errno on error. */ - int (*queueBuffer)(struct android_native_window_t* window, + int (*queueBuffer)(struct ANativeWindow* window, struct android_native_buffer_t* buffer); /* @@ -173,13 +175,13 @@ typedef struct android_native_window_t * * Returns 0 on success or -errno on error. */ - int (*query)(struct android_native_window_t* window, + 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 - * android_native_window_t while keeping backward binary compatibility. + * ANativeWindow while keeping backward binary compatibility. * * This hook should not be called directly, instead use the helper functions * defined below. @@ -197,12 +199,14 @@ typedef struct android_native_window_t * */ - int (*perform)(struct android_native_window_t* window, + int (*perform)(struct ANativeWindow* window, int operation, ... ); void* reserved_proc[3]; -} android_native_window_t; +}; +// Backwards compatibility... please switch to ANativeWindow. +typedef struct ANativeWindow android_native_window_t; /* * native_window_set_usage(..., usage) @@ -216,7 +220,7 @@ typedef struct android_native_window_t */ static inline int native_window_set_usage( - android_native_window_t* window, int usage) + ANativeWindow* window, int usage) { return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); } @@ -228,7 +232,7 @@ static inline int native_window_set_usage( * can happen if it's connected to some other API. */ static inline int native_window_connect( - android_native_window_t* window, int api) + ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_CONNECT, api); } @@ -240,7 +244,7 @@ static inline int native_window_connect( * first place. */ static inline int native_window_disconnect( - android_native_window_t* window, int api) + ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_DISCONNECT, api); } @@ -258,7 +262,7 @@ static inline int native_window_disconnect( * out of the buffer's bound or if the window is invalid. */ static inline int native_window_set_crop( - android_native_window_t* window, + ANativeWindow* window, android_native_rect_t const * crop) { return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); @@ -269,7 +273,7 @@ static inline int native_window_set_crop( * Sets the number of buffers associated with this native window. */ static inline int native_window_set_buffer_count( - android_native_window_t* window, + ANativeWindow* window, size_t bufferCount) { return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); @@ -287,7 +291,7 @@ static inline int native_window_set_buffer_count( * */ static inline int native_window_set_buffers_geometry( - android_native_window_t* window, + ANativeWindow* window, int w, int h, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index cb9937c..5ae8d01 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -29,7 +29,7 @@ ContextResume { ContextSetSurface { param uint32_t width param uint32_t height - param android_native_window_t *sur + param ANativeWindow *sur } ContextDump { diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index d8a9a99..596f533 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -473,7 +473,7 @@ Context::~Context() objDestroyOOBDestroy(); } -void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) +void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) { rsAssert(mIsGraphicsContext); @@ -888,7 +888,7 @@ void rsi_ContextResume(Context *rsc) rsc->resume(); } -void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, android_native_window_t *sur) +void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur) { rsc->setSurface(w, h, sur); } diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 82c3687..709730e 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -98,7 +98,7 @@ public: void pause(); void resume(); - void setSurface(uint32_t w, uint32_t h, android_native_window_t *sur); + void setSurface(uint32_t w, uint32_t h, ANativeWindow *sur); void setPriority(int32_t p); void assignName(ObjectBase *obj, const char *name, uint32_t len); @@ -246,7 +246,7 @@ private: static void * threadProc(void *); - android_native_window_t *mWndSurface; + ANativeWindow *mWndSurface; Vector<ObjectBase *> mNames; diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp index 8617d94a..dc6332c 100644 --- a/libs/surfaceflinger_client/Surface.cpp +++ b/libs/surfaceflinger_client/Surface.cpp @@ -387,21 +387,21 @@ sp<Surface> Surface::readFromParcel( void Surface::init() { - android_native_window_t::setSwapInterval = setSwapInterval; - android_native_window_t::dequeueBuffer = dequeueBuffer; - android_native_window_t::lockBuffer = lockBuffer; - android_native_window_t::queueBuffer = queueBuffer; - android_native_window_t::query = query; - android_native_window_t::perform = perform; + ANativeWindow::setSwapInterval = setSwapInterval; + ANativeWindow::dequeueBuffer = dequeueBuffer; + ANativeWindow::lockBuffer = lockBuffer; + ANativeWindow::queueBuffer = queueBuffer; + ANativeWindow::query = query; + ANativeWindow::perform = perform; DisplayInfo dinfo; SurfaceComposerClient::getDisplayInfo(0, &dinfo); - const_cast<float&>(android_native_window_t::xdpi) = dinfo.xdpi; - const_cast<float&>(android_native_window_t::ydpi) = dinfo.ydpi; + const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi; + const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi; // FIXME: set real values here - const_cast<int&>(android_native_window_t::minSwapInterval) = 1; - const_cast<int&>(android_native_window_t::maxSwapInterval) = 1; - const_cast<uint32_t&>(android_native_window_t::flags) = 0; + const_cast<int&>(ANativeWindow::minSwapInterval) = 1; + const_cast<int&>(ANativeWindow::maxSwapInterval) = 1; + const_cast<uint32_t&>(ANativeWindow::flags) = 0; mConnected = 0; mSwapRectangle.makeInvalid(); @@ -485,35 +485,35 @@ sp<ISurface> Surface::getISurface() const { // ---------------------------------------------------------------------------- -int Surface::setSwapInterval(android_native_window_t* window, int interval) { +int Surface::setSwapInterval(ANativeWindow* window, int interval) { return 0; } -int Surface::dequeueBuffer(android_native_window_t* window, +int Surface::dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer) { Surface* self = getSelf(window); return self->dequeueBuffer(buffer); } -int Surface::lockBuffer(android_native_window_t* window, +int Surface::lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer) { Surface* self = getSelf(window); return self->lockBuffer(buffer); } -int Surface::queueBuffer(android_native_window_t* window, +int Surface::queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer) { Surface* self = getSelf(window); return self->queueBuffer(buffer); } -int Surface::query(android_native_window_t* window, +int Surface::query(ANativeWindow* window, int what, int* value) { Surface* self = getSelf(window); return self->query(what, value); } -int Surface::perform(android_native_window_t* window, +int Surface::perform(ANativeWindow* window, int operation, ...) { va_list args; va_start(args, operation); @@ -803,7 +803,7 @@ status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking) { if (getConnectedApi()) { LOGE("Surface::lock(%p) failed. Already connected to another API", - (android_native_window_t*)this); + (ANativeWindow*)this); CallStack stack; stack.update(); stack.dump(""); diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp index 52380a0..6f8948d 100644 --- a/libs/ui/FramebufferNativeWindow.cpp +++ b/libs/ui/FramebufferNativeWindow.cpp @@ -67,7 +67,7 @@ private: * This implements the (main) framebuffer management. This class is used * mostly by SurfaceFlinger, but also by command line GL application. * - * In fact this is an implementation of android_native_window_t on top of + * In fact this is an implementation of ANativeWindow on top of * the framebuffer. * * Currently it is pretty simple, it manages only two buffers (the front and @@ -117,23 +117,23 @@ FramebufferNativeWindow::FramebufferNativeWindow() LOGE_IF(err, "fb buffer 1 allocation failed w=%d, h=%d, err=%s", fbDev->width, fbDev->height, strerror(-err)); - const_cast<uint32_t&>(android_native_window_t::flags) = fbDev->flags; - const_cast<float&>(android_native_window_t::xdpi) = fbDev->xdpi; - const_cast<float&>(android_native_window_t::ydpi) = fbDev->ydpi; - const_cast<int&>(android_native_window_t::minSwapInterval) = + const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; + const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi; + const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi; + const_cast<int&>(ANativeWindow::minSwapInterval) = fbDev->minSwapInterval; - const_cast<int&>(android_native_window_t::maxSwapInterval) = + const_cast<int&>(ANativeWindow::maxSwapInterval) = fbDev->maxSwapInterval; } else { LOGE("Couldn't get gralloc module"); } - android_native_window_t::setSwapInterval = setSwapInterval; - android_native_window_t::dequeueBuffer = dequeueBuffer; - android_native_window_t::lockBuffer = lockBuffer; - android_native_window_t::queueBuffer = queueBuffer; - android_native_window_t::query = query; - android_native_window_t::perform = perform; + ANativeWindow::setSwapInterval = setSwapInterval; + ANativeWindow::dequeueBuffer = dequeueBuffer; + ANativeWindow::lockBuffer = lockBuffer; + ANativeWindow::queueBuffer = queueBuffer; + ANativeWindow::query = query; + ANativeWindow::perform = perform; } FramebufferNativeWindow::~FramebufferNativeWindow() @@ -168,13 +168,13 @@ status_t FramebufferNativeWindow::compositionComplete() } int FramebufferNativeWindow::setSwapInterval( - android_native_window_t* window, int interval) + ANativeWindow* window, int interval) { framebuffer_device_t* fb = getSelf(window)->fbDev; return fb->setSwapInterval(fb, interval); } -int FramebufferNativeWindow::dequeueBuffer(android_native_window_t* window, +int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer) { FramebufferNativeWindow* self = getSelf(window); @@ -196,7 +196,7 @@ int FramebufferNativeWindow::dequeueBuffer(android_native_window_t* window, return 0; } -int FramebufferNativeWindow::lockBuffer(android_native_window_t* window, +int FramebufferNativeWindow::lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer) { FramebufferNativeWindow* self = getSelf(window); @@ -210,7 +210,7 @@ int FramebufferNativeWindow::lockBuffer(android_native_window_t* window, return NO_ERROR; } -int FramebufferNativeWindow::queueBuffer(android_native_window_t* window, +int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer) { FramebufferNativeWindow* self = getSelf(window); @@ -224,7 +224,7 @@ int FramebufferNativeWindow::queueBuffer(android_native_window_t* window, return res; } -int FramebufferNativeWindow::query(android_native_window_t* window, +int FramebufferNativeWindow::query(ANativeWindow* window, int what, int* value) { FramebufferNativeWindow* self = getSelf(window); @@ -245,7 +245,7 @@ int FramebufferNativeWindow::query(android_native_window_t* window, return BAD_VALUE; } -int FramebufferNativeWindow::perform(android_native_window_t* window, +int FramebufferNativeWindow::perform(ANativeWindow* window, int operation, ...) { switch (operation) { diff --git a/native/include/android/native_window.h b/native/include/android/native_window.h new file mode 100644 index 0000000..e6d5fea --- /dev/null +++ b/native/include/android/native_window.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_NATIVE_WINDOW_H +#define ANDROID_NATIVE_WINDOW_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct ANativeWindow; +typedef struct ANativeWindow ANativeWindow; + + +#ifdef __cplusplus +}; +#endif + +#endif // ANDROID_NATIVE_WINDOW_H diff --git a/opengl/include/EGL/eglplatform.h b/opengl/include/EGL/eglplatform.h index a2c6a7d..25d7697 100644 --- a/opengl/include/EGL/eglplatform.h +++ b/opengl/include/EGL/eglplatform.h @@ -91,10 +91,11 @@ typedef Window EGLNativeWindowType; #elif defined(ANDROID) -struct android_native_window_t; +#include <android/native_window.h> + struct egl_native_pixmap_t; -typedef struct android_native_window_t* EGLNativeWindowType; +typedef struct ANativeWindow* EGLNativeWindowType; typedef struct egl_native_pixmap_t* EGLNativePixmapType; typedef void* EGLNativeDisplayType; diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp index 7cb01d0..54d7307 100644 --- a/opengl/libagl/egl.cpp +++ b/opengl/libagl/egl.cpp @@ -213,7 +213,7 @@ struct egl_window_surface_v2_t : public egl_surface_t egl_window_surface_v2_t( EGLDisplay dpy, EGLConfig config, int32_t depthFormat, - android_native_window_t* window); + ANativeWindow* window); ~egl_window_surface_v2_t(); @@ -235,7 +235,7 @@ struct egl_window_surface_v2_t : public egl_surface_t private: status_t lock(android_native_buffer_t* buf, int usage, void** vaddr); status_t unlock(android_native_buffer_t* buf); - android_native_window_t* nativeWindow; + ANativeWindow* nativeWindow; android_native_buffer_t* buffer; android_native_buffer_t* previousBuffer; gralloc_module_t const* module; @@ -355,7 +355,7 @@ private: egl_window_surface_v2_t::egl_window_surface_v2_t(EGLDisplay dpy, EGLConfig config, int32_t depthFormat, - android_native_window_t* window) + ANativeWindow* window) : egl_surface_t(dpy, config, depthFormat), nativeWindow(window), buffer(0), previousBuffer(0), module(0), blitengine(0), bits(NULL) @@ -1300,7 +1300,7 @@ static EGLSurface createWindowSurface(EGLDisplay dpy, EGLConfig config, if (!(surfaceType & EGL_WINDOW_BIT)) return setError(EGL_BAD_MATCH, EGL_NO_SURFACE); - if (static_cast<android_native_window_t*>(window)->common.magic != + if (static_cast<ANativeWindow*>(window)->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) { return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); } @@ -1323,7 +1323,7 @@ static EGLSurface createWindowSurface(EGLDisplay dpy, EGLConfig config, egl_surface_t* surface; surface = new egl_window_surface_v2_t(dpy, config, depthFormat, - static_cast<android_native_window_t*>(window)); + static_cast<ANativeWindow*>(window)); if (!surface->initCheck()) { // there was a problem in the ctor, the error |