diff options
author | Jamie Gennis <jgennis@google.com> | 2012-06-13 16:32:25 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-06-20 15:48:30 -0700 |
commit | d8e812ce6fe9ae0388e98b08456e1d18b9498239 (patch) | |
tree | 49d694305ba98c49997e8d92ece28da939ad13ed /libs/ui/FramebufferNativeWindow.cpp | |
parent | f25e183a70bd631f75dce51e85b7d568472a0cdb (diff) | |
download | frameworks_native-d8e812ce6fe9ae0388e98b08456e1d18b9498239.zip frameworks_native-d8e812ce6fe9ae0388e98b08456e1d18b9498239.tar.gz frameworks_native-d8e812ce6fe9ae0388e98b08456e1d18b9498239.tar.bz2 |
Update ANativeWindow clients for sync
This change updates the uses of ANativeWindow to use the new ANW functions that
accept and return Sync HAL fence file descriptors.
Change-Id: I3ca648b6ac33f7360e86754f924aa072f95242f6
Diffstat (limited to 'libs/ui/FramebufferNativeWindow.cpp')
-rw-r--r-- | libs/ui/FramebufferNativeWindow.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp index dec99b6..84cb8f3 100644 --- a/libs/ui/FramebufferNativeWindow.cpp +++ b/libs/ui/FramebufferNativeWindow.cpp @@ -28,6 +28,7 @@ #include <utils/RefBase.h> #include <ui/ANativeObjectBase.h> +#include <ui/Fence.h> #include <ui/FramebufferNativeWindow.h> #include <ui/Rect.h> @@ -145,10 +146,13 @@ FramebufferNativeWindow::FramebufferNativeWindow() ANativeWindow::setSwapInterval = setSwapInterval; ANativeWindow::dequeueBuffer = dequeueBuffer; - ANativeWindow::lockBuffer = lockBuffer; ANativeWindow::queueBuffer = queueBuffer; ANativeWindow::query = query; ANativeWindow::perform = perform; + + ANativeWindow::dequeueBuffer_DEPRECATED = dequeueBuffer_DEPRECATED; + ANativeWindow::lockBuffer_DEPRECATED = lockBuffer_DEPRECATED; + ANativeWindow::queueBuffer_DEPRECATED = queueBuffer_DEPRECATED; } FramebufferNativeWindow::~FramebufferNativeWindow() @@ -207,9 +211,24 @@ int FramebufferNativeWindow::getCurrentBufferIndex() const return index; } -int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, +int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer) { + int fenceFd = -1; + int result = dequeueBuffer(window, buffer, &fenceFd); + sp<Fence> fence(new Fence(fenceFd)); + int waitResult = fence->wait(Fence::TIMEOUT_NEVER); + if (waitResult != OK) { + ALOGE("dequeueBuffer_DEPRECATED: Fence::wait returned an " + "error: %d", waitResult); + return waitResult; + } + return result; +} + +int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, + ANativeWindowBuffer** buffer, int* fenceFd) +{ FramebufferNativeWindow* self = getSelf(window); Mutex::Autolock _l(self->mutex); framebuffer_device_t* fb = self->fbDev; @@ -227,13 +246,15 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, self->mCurrentBufferIndex = index; *buffer = self->buffers[index].get(); + *fenceFd = -1; return 0; } -int FramebufferNativeWindow::lockBuffer(ANativeWindow* window, +int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer) { + // XXX: Can this code all get ripped out? Should it move to dequeueBuffer? FramebufferNativeWindow* self = getSelf(window); Mutex::Autolock _l(self->mutex); @@ -247,14 +268,23 @@ int FramebufferNativeWindow::lockBuffer(ANativeWindow* window, return NO_ERROR; } -int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, +int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer) { + return queueBuffer(window, buffer, -1); +} + +int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, + ANativeWindowBuffer* buffer, int fenceFd) +{ FramebufferNativeWindow* self = getSelf(window); Mutex::Autolock _l(self->mutex); framebuffer_device_t* fb = self->fbDev; buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle; + sp<Fence> fence(new Fence(fenceFd)); + fence->wait(Fence::TIMEOUT_NEVER); + const int index = self->mCurrentBufferIndex; int res = fb->post(fb, handle); self->front = static_cast<NativeBuffer*>(buffer); |