Bug 921369 - GonkDisplay takes care of Framebuffer supporting only BRGA format. r=mwu
authorVincent Lin <vlin@mozilla.com>
Thu, 03 Oct 2013 10:26:30 +0800
changeset 149957 b62de18b545fee20d093b0228c759dde5c51500d
parent 149956 1bf11c407d099cd07faa5b6cdcae7cd6f198e503
child 149958 0744a7b07dea4751007fb432072af43492da5d7e
push idunknown
push userunknown
push dateunknown
reviewersmwu
bugs921369
milestone27.0a1
Bug 921369 - GonkDisplay takes care of Framebuffer supporting only BRGA format. r=mwu
widget/gonk/libdisplay/GonkDisplayJB.cpp
--- a/widget/gonk/libdisplay/GonkDisplayJB.cpp
+++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp
@@ -99,34 +99,43 @@ GonkDisplayJB::GonkDisplayJB()
 
     err = hw_get_module(POWER_HARDWARE_MODULE_ID,
                                            (hw_module_t const**)&mPowerModule);
     if (!err)
         mPowerModule->init(mPowerModule);
     ALOGW_IF(err, "Couldn't load %s module (%s)", POWER_HARDWARE_MODULE_ID, strerror(-err));
 
     mAlloc = new GraphicBufferAlloc();
+
+    status_t error;
+    uint32_t usage = GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER;
+    mBootAnimBuffer = mAlloc->createGraphicBuffer(mWidth, mHeight, surfaceformat, usage, &error);
+    if (error != NO_ERROR || !mBootAnimBuffer.get()) {
+        ALOGI("Trying to create BRGA format framebuffer");
+        surfaceformat = HAL_PIXEL_FORMAT_BGRA_8888;
+        mBootAnimBuffer = mAlloc->createGraphicBuffer(mWidth, mHeight, surfaceformat, usage, &error);
+    }
+
     mFBSurface = new FramebufferSurface(0, mWidth, mHeight, surfaceformat, mAlloc);
 
 #if ANDROID_VERSION == 17
     sp<SurfaceTextureClient> stc = new SurfaceTextureClient(static_cast<sp<ISurfaceTexture> >(mFBSurface->getBufferQueue()));
 #else
     sp<Surface> stc = new Surface(static_cast<sp<IGraphicBufferProducer> >(mFBSurface->getBufferQueue()));
 #endif
     mSTClient = stc;
 
     mList = (hwc_display_contents_1_t *)malloc(sizeof(*mList) + (sizeof(hwc_layer_1_t)*2));
     if (mHwc)
         mHwc->blank(mHwc, HWC_DISPLAY_PRIMARY, 0);
 
-    status_t error;
-    mBootAnimBuffer = mAlloc->createGraphicBuffer(mWidth, mHeight, surfaceformat, GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER, &error);
-    if (error == NO_ERROR && mBootAnimBuffer.get())
+    if (error == NO_ERROR && mBootAnimBuffer.get()) {
+        ALOGI("Starting bootanimation with (%d) format framebuffer", surfaceformat);
         StartBootAnimation();
-    else
+    } else
         ALOGW("Couldn't show bootanimation (%s)", strerror(-error));
 }
 
 GonkDisplayJB::~GonkDisplayJB()
 {
     if (mHwc)
         hwc_close_1(mHwc);
     if (mFBDevice)