Bug 920654 - Enable plane alpha support for HWC layers in newer H/W Composer. r=mwu, r=dwilson
authorSushil Chauhan <sushilchauhan@codeaurora.org>
Tue, 15 Oct 2013 15:37:13 -0700
changeset 151008 c92ba82eb05488e212b9fdc1da75d1a990315c29
parent 151007 bdce774ee8866c42cf6d257668de772cb065df3a
child 151009 061dae9890420af6c6b05ff8e6e43814576cf418
push id25474
push userryanvm@gmail.com
push dateWed, 16 Oct 2013 21:01:39 +0000
treeherdermozilla-central@66af8b3096a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu, dwilson
bugs920654
milestone27.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 920654 - Enable plane alpha support for HWC layers in newer H/W Composer. r=mwu, r=dwilson
widget/gonk/HwcComposer2D.cpp
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -152,21 +152,23 @@ HwcComposer2D::PrepareLayerList(Layer* a
 
     bool fillColor = false;
 
     const nsIntRegion& visibleRegion = aLayer->GetEffectiveVisibleRegion();
     if (visibleRegion.IsEmpty()) {
         return true;
     }
 
-    float opacity = aLayer->GetEffectiveOpacity();
-    if (opacity < 1) {
+    uint8_t opacity = std::min(0xFF, (int)(aLayer->GetEffectiveOpacity() * 256.0));
+#if ANDROID_VERSION < 18
+    if (opacity < 0xFF) {
         LOGD("%s Layer has planar semitransparency which is unsupported", aLayer->Name());
         return false;
     }
+#endif
 
     nsIntRect clip;
     if (!HwcUtils::CalculateClipRect(aParentTransform * aGLWorldTransform,
                                      aLayer->GetEffectiveClipRect(),
                                      aClip,
                                      &clip))
     {
         LOGD("%s Clip rect is empty. Skip layer", aLayer->Name());
@@ -271,17 +273,17 @@ HwcComposer2D::PrepareLayerList(Layer* a
     hwcLayer.flags = 0;
     hwcLayer.hints = 0;
     hwcLayer.blending = HWC_BLENDING_PREMULT;
 #if ANDROID_VERSION >= 18
     hwcLayer.compositionType = HWC_FRAMEBUFFER;
 
     hwcLayer.acquireFenceFd = -1;
     hwcLayer.releaseFenceFd = -1;
-    hwcLayer.planeAlpha = 0xFF; // Until plane alpha is enabled
+    hwcLayer.planeAlpha = opacity;
 #else
     hwcLayer.compositionType = HwcUtils::HWC_USE_COPYBIT;
 #endif
 
     if (!fillColor) {
         if (state.FormatRBSwapped()) {
             if (!mRBSwapSupport) {
                 LOGD("No R/B swap support in H/W Composer");