Skip to content
Browse files

libs/ui: Add support for triple framebuffers

Change-Id: I90dd38deeeda9a3785b87286cc7d252c6f948750
  • Loading branch information...
1 parent b26bc99 commit bf8a82113ae8b9e188e92fc2d40b5c27b2d02ff9 Naseer Ahmed committed with Whitehawkx Jun 29, 2012
Showing with 15 additions and 8 deletions.
  1. +3 −2 include/ui/FramebufferNativeWindow.h
  2. +12 −6 libs/ui/FramebufferNativeWindow.cpp
View
5 include/ui/FramebufferNativeWindow.h
@@ -32,7 +32,8 @@
#include "SecHdmiClient.h"
#endif
-#define NUM_FRAME_BUFFERS 2
+#define MIN_NUM_FRAME_BUFFERS 2
+#define MAX_NUM_FRAME_BUFFERS 3
extern "C" EGLNativeWindowType android_createDisplaySurface(void);
@@ -81,7 +82,7 @@ class FramebufferNativeWindow
framebuffer_device_t* fbDev;
alloc_device_t* grDev;
- sp<NativeBuffer> buffers[NUM_FRAME_BUFFERS];
+ sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS];
sp<NativeBuffer> front;
mutable Mutex mutex;
View
18 libs/ui/FramebufferNativeWindow.cpp
@@ -97,8 +97,13 @@ FramebufferNativeWindow::FramebufferNativeWindow()
mUpdateOnDemand = (fbDev->setUpdateRect != 0);
// initialize the buffer FIFO
- mNumBuffers = NUM_FRAME_BUFFERS;
- mNumFreeBuffers = NUM_FRAME_BUFFERS;
+ if(fbDev->numFramebuffers >= MIN_NUM_FRAME_BUFFERS &&
+ fbDev->numFramebuffers <= MAX_NUM_FRAME_BUFFERS){
+ mNumBuffers = fbDev->numFramebuffers;
+ } else {
+ mNumBuffers = MIN_NUM_FRAME_BUFFERS;
+ }
+ mNumFreeBuffers = mNumBuffers;
mBufferHead = mNumBuffers-1;
/*
@@ -159,10 +164,11 @@ FramebufferNativeWindow::FramebufferNativeWindow()
FramebufferNativeWindow::~FramebufferNativeWindow()
{
if (grDev) {
- if (buffers[0] != NULL)
- grDev->free(grDev, buffers[0]->handle);
- if (buffers[1] != NULL)
- grDev->free(grDev, buffers[1]->handle);
+ for(int i = 0; i < mNumBuffers; i++) {
+ if (buffers[i] != NULL) {
+ grDev->free(grDev, buffers[i]->handle);
+ }
+ }
gralloc_close(grDev);
}

0 comments on commit bf8a821

Please sign in to comment.
Something went wrong with that request. Please try again.