Reshuffle FramebufferSurface
FramebufferSurface no longer speaks directly to the FB HAL. Now
everything goes through HWComposer (which may or may not be
connected to a hardware composer).
Added display index arg to some query methods.
Change-Id: Id3e157d2d4e3555d33afbb703e518b6e92e2d6d5
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index f85f604..5fba3f6 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -33,21 +33,12 @@
#include <ui/GraphicBuffer.h>
#include "DisplayHardware/FramebufferSurface.h"
+#include "DisplayHardware/HWComposer.h"
// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
-sp<FramebufferSurface> FramebufferSurface::create() {
- sp<FramebufferSurface> result = new FramebufferSurface();
- if (result->fbDev == NULL) {
- result = NULL;
- }
- return result;
-}
-
-// ----------------------------------------------------------------------------
-
class GraphicBufferAlloc : public BnGraphicBufferAlloc {
public:
GraphicBufferAlloc() { };
@@ -66,36 +57,21 @@
*
*/
-FramebufferSurface::FramebufferSurface():
+FramebufferSurface::FramebufferSurface(HWComposer& hwc) :
ConsumerBase(new BufferQueue(true, new GraphicBufferAlloc())),
- fbDev(0),
mCurrentBufferSlot(-1),
- mCurrentBuffer(0)
+ mCurrentBuffer(0),
+ mHwc(hwc)
{
- hw_module_t const* module;
-
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
- int stride;
- int err;
- int i;
- err = framebuffer_open(module, &fbDev);
- ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
-
- // bail out if we can't initialize the modules
- if (!fbDev)
- return;
-
- mName = "FramebufferSurface";
- mBufferQueue->setConsumerName(mName);
- mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_FB |
- GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER);
- mBufferQueue->setDefaultBufferFormat(fbDev->format);
- mBufferQueue->setDefaultBufferSize(fbDev->width, fbDev->height);
- mBufferQueue->setSynchronousMode(true);
- mBufferQueue->setDefaultMaxBufferCount(NUM_FRAME_BUFFERS);
- } else {
- ALOGE("Couldn't get gralloc module");
- }
+ mName = "FramebufferSurface";
+ mBufferQueue->setConsumerName(mName);
+ mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_FB |
+ GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER);
+ mBufferQueue->setDefaultBufferFormat(mHwc.getFormat(HWC_DISPLAY_PRIMARY));
+ mBufferQueue->setDefaultBufferSize(mHwc.getResolutionX(HWC_DISPLAY_PRIMARY),
+ mHwc.getResolutionY(HWC_DISPLAY_PRIMARY));
+ mBufferQueue->setSynchronousMode(true);
+ mBufferQueue->setDefaultMaxBufferCount(NUM_FRAME_BUFFERS);
}
status_t FramebufferSurface::nextBuffer(sp<GraphicBuffer>* buffer) {
@@ -145,12 +121,7 @@
return NO_ERROR;
}
-FramebufferSurface::~FramebufferSurface() {
- if (fbDev) {
- framebuffer_close(fbDev);
- }
-}
-
+// Overrides ConsumerBase::onFrameAvailable(), does not call base class impl.
void FramebufferSurface::onFrameAvailable() {
// XXX: The following code is here temporarily as part of the transition
// away from the framebuffer HAL.
@@ -161,7 +132,7 @@
strerror(-err), err);
return;
}
- err = fbDev->post(fbDev, buf->handle);
+ err = mHwc.fbPost(buf->handle);
if (err != NO_ERROR) {
ALOGE("error posting framebuffer: %d", err);
}
@@ -181,19 +152,11 @@
status_t FramebufferSurface::compositionComplete()
{
- if (fbDev->compositionComplete) {
- return fbDev->compositionComplete(fbDev);
- }
- return INVALID_OPERATION;
+ return mHwc.fbCompositionComplete();
}
void FramebufferSurface::dump(String8& result) {
- if (fbDev->common.version >= 1 && fbDev->dump) {
- const size_t SIZE = 4096;
- char buffer[SIZE];
- fbDev->dump(fbDev, buffer, SIZE);
- result.append(buffer);
- }
+ mHwc.fbDump(result);
ConsumerBase::dump(result);
}