From 949be32b671304d5281ac0abbf30dcf4ebaa9eaf Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 13 Jul 2011 17:39:11 -0700 Subject: move lock/unlock implementaion outside of Surface into SurfaceTextureClient This makes ANativeWindow_lock/ANativeWindow_unlockAndPost work with ANativeWindows implemented by Surface and SurfaceTextureClient. Also, Surface now inherits directly from SurfaceTextureClient. Bug: 5003724 Change-Id: I9f285877c7bae9a262e9a7af91c2bae78804b2ef --- native/android/native_window.cpp | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'native/android/native_window.cpp') diff --git a/native/android/native_window.cpp b/native/android/native_window.cpp index 2c0e88e..5c016c4 100644 --- a/native/android/native_window.cpp +++ b/native/android/native_window.cpp @@ -81,39 +81,9 @@ int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds) { - int type = -1; - if (window->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &type) != 0 || - type != NATIVE_WINDOW_SURFACE) { - return BAD_VALUE; - } - - Region dirtyRegion; - Region* dirtyParam = NULL; - if (inOutDirtyBounds != NULL) { - dirtyRegion.set(*(Rect*)inOutDirtyBounds); - dirtyParam = &dirtyRegion; - } - - Surface::SurfaceInfo info; - status_t res = static_cast(window)->lock(&info, dirtyParam); - if (res != OK) { - return -1; - } - - outBuffer->width = (int32_t)info.w; - outBuffer->height = (int32_t)info.h; - outBuffer->stride = (int32_t)info.s; - outBuffer->format = (int32_t)info.format; - outBuffer->bits = info.bits; - - if (inOutDirtyBounds != NULL) { - *inOutDirtyBounds = dirtyRegion.getBounds(); - } - - return 0; + return window->perform(window, NATIVE_WINDOW_LOCK, outBuffer, inOutDirtyBounds); } int32_t ANativeWindow_unlockAndPost(ANativeWindow* window) { - status_t res = static_cast(window)->unlockAndPost(); - return res == android::OK ? 0 : -1; + return window->perform(window, NATIVE_WINDOW_UNLOCK_AND_POST); } -- cgit v1.1