Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3947)

Unified Diff: cc/layer_tree_host_common.cc

Issue 11316171: Don't create render passes for transparent images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing code review. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layer_tree_host_common.cc
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index ca7d45050f85c0857e5f88a4def5818ef1b5374e..771a6ae47ab590372751bcd11e64b414cd4cd6ff 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -141,6 +141,26 @@ static gfx::Rect calculateVisibleContentRect(LayerType* layer)
return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx::Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform());
}
+// Note that this function is short circuiting for speed. When the number of
+// descendants that draw content is >1, the result if guaranteed to by >1 but
danakj 2012/11/27 01:57:49 nit: "to be"
+// not the actual number of descendants that draw content.
+template<typename LayerType>
+static int getNumDescendantsDrawContent(LayerType* layer)
+{
+ typedef LayerType* LayerTypePtr;
+ const typename LayerType::LayerList& children = layer->children();
+
+ int result = 0;
+ for (size_t i = 0; i < children.size(); ++i) {
+ if (children[i]->drawsContent())
+ ++result;
+ result += getNumDescendantsDrawContent(LayerTypePtr(children[i]));
+ if (result > 1)
+ return result;
+ }
+ return result;
+}
+
static bool isScaleOrTranslation(const WebTransformationMatrix& m)
{
return !m.m12() && !m.m13() && !m.m14()
@@ -247,7 +267,8 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
return true;
// Cache this value, because otherwise it walks the entire subtree several times.
- bool descendantDrawsContent = layer->descendantDrawsContent();
+ int numDescendantsDrawContent = getNumDescendantsDrawContent(layer);
+ bool descendantDrawsContent = numDescendantsDrawContent > 0;
// If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but it is
// treated as a 3D object by its parent (i.e. parent does preserve-3d).
@@ -259,7 +280,8 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
return true;
// If the layer has opacity != 1 and does not have a preserves-3d transform style.
- if (layer->opacity() != 1 && !layer->preserves3D() && descendantDrawsContent)
+ if (layer->opacity() != 1 && !layer->preserves3D() && descendantDrawsContent
+ && (layer->drawsContent() || numDescendantsDrawContent > 1))
shawnsingh 2012/11/27 07:16:10 Sorry, I'm not following why this is our desired s
return true;
return false;
@@ -484,10 +506,10 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
gfx::Rect clipRectForSubtree;
bool subtreeShouldBeClipped = false;
-
+
float drawOpacity = layer->opacity();
bool drawOpacityIsAnimating = layer->opacityIsAnimating();
- if (layer->parent() && layer->parent()->preserves3D()) {
+ if (layer->parent()) {
drawOpacity *= layer->parent()->drawOpacity();
drawOpacityIsAnimating |= layer->parent()->drawOpacityIsAnimating();
}

Powered by Google App Engine
This is Rietveld 408576698