Bug 898897 - Update GonkDisplayJB to support JB MR2, r=vlad
authorMichael Wu <mwu@mozilla.com>
Tue, 30 Jul 2013 13:36:53 -0400
changeset 140534 c5e63e3e1c707bdf923bf74b65af8dabb2e1dad5
parent 140533 b1e5310b809582f2594cfe04034d23c7fe7bfd0b
child 140535 6477592cb57496da9b1cebe26548d8ed524a4948
push id25032
push userryanvm@gmail.com
push dateTue, 30 Jul 2013 22:07:36 +0000
treeherdermozilla-central@60bf7ceba890 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs898897
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 898897 - Update GonkDisplayJB to support JB MR2, r=vlad
widget/gonk/libdisplay/FramebufferSurface.cpp
widget/gonk/libdisplay/GonkDisplayJB.cpp
widget/gonk/libdisplay/moz.build
--- a/widget/gonk/libdisplay/FramebufferSurface.cpp
+++ b/widget/gonk/libdisplay/FramebufferSurface.cpp
@@ -24,17 +24,16 @@
 
 #include <utils/String8.h>
 
 #include <ui/Rect.h>
 
 #include <EGL/egl.h>
 
 #include <hardware/hardware.h>
-#include <gui/SurfaceTextureClient.h>
 #include <ui/GraphicBuffer.h>
 
 #include "FramebufferSurface.h"
 #include "GraphicBufferAlloc.h"
 
 #ifndef NUM_FRAMEBUFFER_SURFACE_BUFFERS
 #define NUM_FRAMEBUFFER_SURFACE_BUFFERS (2)
 #endif
--- a/widget/gonk/libdisplay/GonkDisplayJB.cpp
+++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp
@@ -9,17 +9,17 @@
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "GonkDisplayJB.h"
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer.h>
 #include <hardware/power.h>
 #include <suspend/autosuspend.h>
 
 #include "GraphicBufferAlloc.h"
 #include "BootAnimation.h"
@@ -94,17 +94,17 @@ GonkDisplayJB::GonkDisplayJB()
                                            (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();
     mFBSurface = new FramebufferSurface(0, mWidth, mHeight, surfaceformat, mAlloc);
 
-    sp<SurfaceTextureClient> stc = new SurfaceTextureClient(static_cast<sp<ISurfaceTexture> >(mFBSurface->getBufferQueue()));
+    sp<Surface> stc = new Surface(static_cast<sp<IGraphicBufferProducer> >(mFBSurface->getBufferQueue()));
     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);
@@ -161,18 +161,18 @@ GonkDisplayJB::GetHWCDevice()
 }
 
 bool
 GonkDisplayJB::SwapBuffers(EGLDisplay dpy, EGLSurface sur)
 {
     StopBootAnimation();
     mBootAnimBuffer = nullptr;
 
-    mList->dpy = dpy;
-    mList->sur = sur;
+    mList->outbuf = nullptr;
+    mList->outbufAcquireFenceFd = -1;
     eglSwapBuffers(dpy, sur);
     return Post(mFBSurface->lastHandle, mFBSurface->lastFenceFD);
 }
 
 bool
 GonkDisplayJB::Post(buffer_handle_t buf, int fence)
 {
     if (!mHwc) {
@@ -184,30 +184,34 @@ GonkDisplayJB::Post(buffer_handle_t buf,
     hwc_display_contents_1_t *displays[HWC_NUM_DISPLAY_TYPES] = {NULL};
     const hwc_rect_t r = { 0, 0, mWidth, mHeight };
     displays[HWC_DISPLAY_PRIMARY] = mList;
     mList->retireFenceFd = -1;
     mList->numHwLayers = 2;
     mList->flags = HWC_GEOMETRY_CHANGED;
     mList->hwLayers[0].compositionType = HWC_BACKGROUND;
     mList->hwLayers[0].hints = 0;
-    mList->hwLayers[0].flags = 0;
+    /* Skip this layer so the hwc module doesn't complain about null handles */
+    mList->hwLayers[0].flags = HWC_SKIP_LAYER;
     mList->hwLayers[0].backgroundColor = {0};
+    /* hwc module checks displayFrame even though it shouldn't */
+    mList->hwLayers[0].displayFrame = r;
     mList->hwLayers[1].compositionType = HWC_FRAMEBUFFER_TARGET;
     mList->hwLayers[1].hints = 0;
     mList->hwLayers[1].flags = 0;
     mList->hwLayers[1].handle = buf;
     mList->hwLayers[1].transform = 0;
     mList->hwLayers[1].blending = HWC_BLENDING_PREMULT;
     mList->hwLayers[1].sourceCrop = r;
     mList->hwLayers[1].displayFrame = r;
     mList->hwLayers[1].visibleRegionScreen.numRects = 1;
-    mList->hwLayers[1].visibleRegionScreen.rects = &mList->hwLayers[0].sourceCrop;
+    mList->hwLayers[1].visibleRegionScreen.rects = &mList->hwLayers[1].sourceCrop;
     mList->hwLayers[1].acquireFenceFd = fence;
     mList->hwLayers[1].releaseFenceFd = -1;
+    mList->hwLayers[1].planeAlpha = 0xFF;
     mHwc->prepare(mHwc, HWC_NUM_DISPLAY_TYPES, displays);
     int err = mHwc->set(mHwc, HWC_NUM_DISPLAY_TYPES, displays);
     mFBSurface->setReleaseFenceFd(mList->hwLayers[1].releaseFenceFd);
     if (mList->retireFenceFd >= 0)
         close(mList->retireFenceFd);
     return !err;
 }
 
--- a/widget/gonk/libdisplay/moz.build
+++ b/widget/gonk/libdisplay/moz.build
@@ -15,17 +15,17 @@
 # limitations under the License.
 
 MODULE = 'display'
 
 CPP_SOURCES += [
     'BootAnimation.cpp',
 ]
 
-if CONFIG['ANDROID_VERSION'] == '17':
+if CONFIG['ANDROID_VERSION'] == '18':
     CPP_SOURCES += [
         'FramebufferSurface.cpp',
         'GraphicBufferAlloc.cpp',
         'GonkDisplayJB.cpp',
     ]
 elif CONFIG['ANDROID_VERSION'] == '15':
     CPP_SOURCES += [
         'GonkDisplayICS.cpp'