Skip to content
Snippets Groups Projects
Commit be614f3c authored by Diego Wilson's avatar Diego Wilson Committed by Gerrit - the friendly Code Review server
Browse files

Remove gecko/HWC-multirect-visible-region.patch

Landed upstream \o/

Change-Id: Id5a678690e077b85a199cccc4d89043a2f6a73c5
parent 475fa7c0
No related merge requests found
diff --git a/widget/gonk/HwcComposer2D.cpp b/widget/gonk/HwcComposer2D.cpp
index 96a27ce..42f4b1e 100644
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -166,7 +166,7 @@ PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
//clip to buffer size
crop.IntersectRect(crop, aBufferRect);
- crop.RoundOut();
+ crop.RoundIn();
if (crop.IsEmpty()) {
LOGD("Skip layer");
@@ -175,7 +175,7 @@ PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
//propagate buffer clipping back to visible rect
visibleRectScreen = aTransform.TransformBounds(crop);
- visibleRectScreen.RoundOut();
+ visibleRectScreen.RoundIn();
// Map from layer space to buffer space
crop -= aBufferRect.TopLeft();
@@ -194,6 +194,54 @@ PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
}
/**
+ * Prepares hwc layer visible region required for hwc composition
+ *
+ * @param aVisible Input. Layer's unclipped visible region
+ * The origin is the top-left corner of the layer
+ * @param aTransform Input. Layer's transformation matrix
+ * It transforms from layer space to screen space
+ * @param aClip Input. A clipping rectangle.
+ * The origin is the top-left corner of the screen
+ * @param aBufferRect Input. The layer's buffer bounds
+ * The origin is the top-left corner of the layer
+ * @param aVisibleRegionScreen Output. Visible region in screen space.
+ * The origin is the top-left corner of the screen
+ * @return true if the layer should be rendered.
+ * false if the layer can be skipped
+ */
+static bool
+PrepareVisibleRegion(const nsIntRegion& aVisible, const gfxMatrix& aTransform,
+ nsIntRect aClip, nsIntRect aBufferRect,
+ std::vector<hwc_rect_t>* aVisibleRegionScreen) {
+
+ nsIntRegionRectIterator iter(aVisible);
+ bool isVisible = false;
+ while (const nsIntRect* visibleRect = iter.Next()) {
+ hwc_rect_t visibleRectScreen;
+
+ gfxRect gfxVisibleRect(*visibleRect);
+ gfxVisibleRect.IntersectRect(gfxVisibleRect, aBufferRect);
+ gfxRect gfxVisibleRectScreen = aTransform.TransformBounds(gfxVisibleRect);
+ gfxVisibleRectScreen.IntersectRect(gfxVisibleRectScreen, aClip);
+ gfxVisibleRectScreen.RoundIn();
+ if(gfxVisibleRectScreen.IsEmpty()) {
+ continue;
+ }
+ visibleRectScreen.left = gfxVisibleRectScreen.x;
+ visibleRectScreen.top = gfxVisibleRectScreen.y;
+ visibleRectScreen.right = gfxVisibleRectScreen.x + gfxVisibleRectScreen.width;
+ visibleRectScreen.bottom = gfxVisibleRectScreen.y + gfxVisibleRectScreen.height;
+ aVisibleRegionScreen->push_back(visibleRectScreen);
+ isVisible = true;
+ }
+ if(!isVisible) {
+ return false;
+ }
+
+ return true;
+}
+
+/**
* Calculates the layer's clipping rectangle
*
* @param aTransform Input. A transformation matrix
@@ -251,21 +299,11 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
}
float opacity = aLayer->GetEffectiveOpacity();
- if (opacity <= 0) {
- LOGD("Layer is fully transparent so skip rendering");
- return true;
- }
- else if (opacity < 1) {
+ if (opacity < 1) {
LOGD("Layer has planar semitransparency which is unsupported");
return false;
}
- if (visibleRegion.GetNumRects() > 1) {
- // FIXME/bug 808339
- LOGD("Layer has nontrivial visible region");
- return false;
- }
-
nsIntRect clip;
if (!CalculateClipRect(aParentTransform * aGLWorldTransform,
aLayer->GetEffectiveClipRect(),
@@ -330,7 +368,14 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
sp<GraphicBuffer> buffer = fillColor ? nullptr : GrallocBufferActor::GetFrom(*state.mSurface);
- nsIntRect visibleRect = visibleRegion.GetBounds();
+ nsIntRect visibleRect;
+ if (aLayer->Name() == "ShadowCanvasLayer" || aLayer->Name() == "ShadowImageLayer") {
+ visibleRect = nsIntRect(0, 0,
+ int(buffer->getWidth()), int(buffer->getHeight()));
+ }
+ else {
+ visibleRect = visibleRegion.GetBounds();
+ }
nsIntRect bufferRect;
if (fillColor) {
@@ -385,13 +430,33 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
hwcLayer.transform |= state.YFlipped() ? HWC_TRANSFORM_FLIP_V : 0;
hwc_region_t region;
- region.numRects = 1;
- region.rects = &(hwcLayer.displayFrame);
+ if (visibleRegion.GetNumRects() > 1) {
+ std::vector<hwc_rect_t> visibleRects;
+ mVisibleRegions.push_back(visibleRects);
+ if(!PrepareVisibleRegion(visibleRegion,
+ transform * aGLWorldTransform,
+ clip,
+ bufferRect,
+ &(mVisibleRegions.back()))) {
+ return true;
+ }
+ region.numRects = mVisibleRegions.back().size();
+ region.rects = &(mVisibleRegions.back()[0]);
+ }
+ else {
+ region.numRects = 1;
+ region.rects = &(hwcLayer.displayFrame);
+ }
hwcLayer.visibleRegionScreen = region;
} else {
hwcLayer.flags |= HWC_COLOR_FILL;
ColorLayer* colorLayer = static_cast<ColorLayer*>(layerGL->GetLayer());
- hwcLayer.transform = colorLayer->GetColor().Packed();
+ uint32_t color = colorLayer->GetColor().Packed();
+ if (((color >> 24) & 0xff) < 255) {
+ LOGD("Color layer has semitransparency which is unsupported");
+ return false;
+ }
+ hwcLayer.transform = color;
}
mList->numHwLayers++;
@@ -412,6 +477,8 @@ HwcComposer2D::TryRender(Layer* aRoot,
mList->numHwLayers = 0;
}
+ mVisibleRegions.clear();
+
if (!PrepareLayerList(aRoot,
mScreenRect,
gfxMatrix(),
diff --git a/widget/gonk/HwcComposer2D.h b/widget/gonk/HwcComposer2D.h
index 7c69af6..74b0578 100644
--- a/widget/gonk/HwcComposer2D.h
+++ b/widget/gonk/HwcComposer2D.h
@@ -20,6 +20,8 @@
#include "Composer2D.h"
#include "HWComposer.h"
#include "Layers.h"
+#include <vector>
+#include <list>
namespace mozilla {
@@ -54,6 +56,7 @@ private:
nsIntRect mScreenRect;
int mMaxLayerCount;
bool mColorFill;
+ std::list<std::vector<hwc_rect_t>> mVisibleRegions;
};
} // namespace mozilla
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment