diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2010-11-17 17:36:11 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-11-17 17:36:11 -0800 |
commit | d80661c129010f89e3b305797e1712f3d3481467 (patch) | |
tree | 51ff4a5182d245020633b54c21573ecb698105a9 /libs | |
parent | 0d9b02c47b7b52b963f09a01fee9717c49d6e06e (diff) | |
parent | 5e0690745a45f99d12d940dd4aaae814b00a429e (diff) | |
download | frameworks_base-d80661c129010f89e3b305797e1712f3d3481467.zip frameworks_base-d80661c129010f89e3b305797e1712f3d3481467.tar.gz frameworks_base-d80661c129010f89e3b305797e1712f3d3481467.tar.bz2 |
am 5e069074: am a15e4886: Merge "Framebuffer: Support variable number of framebuffers in the UI"
* commit '5e0690745a45f99d12d940dd4aaae814b00a429e':
Framebuffer: Support variable number of framebuffers in the UI
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ui/FramebufferNativeWindow.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp index a36d555..04a0195 100644 --- a/libs/ui/FramebufferNativeWindow.cpp +++ b/libs/ui/FramebufferNativeWindow.cpp @@ -83,6 +83,7 @@ FramebufferNativeWindow::FramebufferNativeWindow() if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { int stride; int err; + int i; err = framebuffer_open(module, &fbDev); LOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err)); @@ -96,27 +97,33 @@ FramebufferNativeWindow::FramebufferNativeWindow() mUpdateOnDemand = (fbDev->setUpdateRect != 0); // initialize the buffer FIFO - mNumBuffers = 2; - mNumFreeBuffers = 2; + mNumBuffers = NUM_FRAME_BUFFERS; + mNumFreeBuffers = NUM_FRAME_BUFFERS; mBufferHead = mNumBuffers-1; - buffers[0] = new NativeBuffer( - fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); - buffers[1] = new NativeBuffer( - fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); - - err = grDev->alloc(grDev, - fbDev->width, fbDev->height, fbDev->format, - GRALLOC_USAGE_HW_FB, &buffers[0]->handle, &buffers[0]->stride); - - LOGE_IF(err, "fb buffer 0 allocation failed w=%d, h=%d, err=%s", - fbDev->width, fbDev->height, strerror(-err)); - - err = grDev->alloc(grDev, - fbDev->width, fbDev->height, fbDev->format, - GRALLOC_USAGE_HW_FB, &buffers[1]->handle, &buffers[1]->stride); - LOGE_IF(err, "fb buffer 1 allocation failed w=%d, h=%d, err=%s", - fbDev->width, fbDev->height, strerror(-err)); + for (i = 0; i < mNumBuffers; i++) + { + buffers[i] = new NativeBuffer( + fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); + } + + for (i = 0; i < mNumBuffers; i++) + { + err = grDev->alloc(grDev, + fbDev->width, fbDev->height, fbDev->format, + GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride); + + LOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s", + i, fbDev->width, fbDev->height, strerror(-err)); + + if (err) + { + mNumBuffers = i; + mNumFreeBuffers = i; + mBufferHead = mNumBuffers-1; + break; + } + } const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi; |