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

Unified Diff: Source/core/rendering/RenderLayerCompositor.cpp

Issue 23511004: mix-blend-mode implementation for accelerated layers - blink part (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adding the rendering part Created 7 years, 4 months 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: Source/core/rendering/RenderLayerCompositor.cpp
diff --git a/Source/core/rendering/RenderLayerCompositor.cpp b/Source/core/rendering/RenderLayerCompositor.cpp
index 7115eaf47758f6c6eb8cdb29755a4fd19f703ffa..134694740631c109509ef0841b8adaf768147170 100644
--- a/Source/core/rendering/RenderLayerCompositor.cpp
+++ b/Source/core/rendering/RenderLayerCompositor.cpp
@@ -180,6 +180,7 @@ struct CompositingState {
CompositingState(RenderLayer* compAncestor, bool testOverlap)
: m_compositingAncestor(compAncestor)
, m_subtreeIsCompositing(false)
+ , m_hasCompositedBlendingDescendents(false)
, m_testingOverlap(testOverlap)
#ifndef NDEBUG
, m_depth(0)
@@ -190,6 +191,7 @@ struct CompositingState {
CompositingState(const CompositingState& other)
: m_compositingAncestor(other.m_compositingAncestor)
, m_subtreeIsCompositing(other.m_subtreeIsCompositing)
+ , m_hasCompositedBlendingDescendents(other.m_hasCompositedBlendingDescendents)
, m_testingOverlap(other.m_testingOverlap)
#ifndef NDEBUG
, m_depth(other.m_depth + 1)
@@ -199,6 +201,7 @@ struct CompositingState {
RenderLayer* m_compositingAncestor;
bool m_subtreeIsCompositing;
+ bool m_hasCompositedBlendingDescendents;
bool m_testingOverlap;
#ifndef NDEBUG
int m_depth;
@@ -778,6 +781,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
// Clear the flag
layer->setHasCompositingDescendant(false);
+ layer->setShouldIsolateCompositedBlendingDescendants(false);
// Start by assuming this layer will not need to composite.
CompositingReasons reasonsToComposite = CompositingReasonNone;
@@ -912,6 +916,16 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
if (overlapMap && childState.m_compositingAncestor && !childState.m_compositingAncestor->isRootLayer())
addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds);
+ // According to http://dev.w3.org/fxtf/compositing-1/#csscompositingrules_CSS,
+ // an element that has blending applied, must blend with all the underlying
+ // content of the stacking context [CSS21] that element belongs to.
+ // We should isolate and accelerate the stacking contexts containing
+ // accelerated blending descendants
+ if (layer->isStackingContext())
+ layer->setShouldIsolateCompositedBlendingDescendants(childState.m_hasCompositedBlendingDescendents);
+ else
+ compositingState.m_hasCompositedBlendingDescendents = childState.m_hasCompositedBlendingDescendents;
+
// Now check for reasons to become composited that depend on the state of descendant layers.
CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(layer->renderer(), childState.m_subtreeIsCompositing, anyDescendantHas3DTransform);
reasonsToComposite |= subtreeCompositingReasons;
@@ -937,6 +951,8 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
// Subsequent layers in the parent's stacking context may also need to composite.
if (childState.m_subtreeIsCompositing)
compositingState.m_subtreeIsCompositing = true;
+ if (willBeComposited && layer->hasBlendMode())
+ compositingState.m_hasCompositedBlendingDescendents = true;
// Set the flag to say that this SC has compositing children.
layer->setHasCompositingDescendant(childState.m_subtreeIsCompositing);
@@ -1574,6 +1590,7 @@ bool RenderLayerCompositor::requiresOwnBackingStore(const RenderLayer* layer, co
| CompositingReasonMaskWithCompositedDescendants
| CompositingReasonFilterWithCompositedDescendants
| CompositingReasonBlendingWithCompositedDescendants
+ | CompositingReasonIsolateCompositedDescendants
| CompositingReasonPreserve3D; // preserve-3d has to create backing store to ensure that 3d-transformed elements intersect.
return layer->compositingReasons() & indirectReasonsThatNeedBacking;
}
@@ -1898,6 +1915,8 @@ CompositingReasons RenderLayerCompositor::subtreeReasonsForCompositing(RenderObj
if (hasCompositedDescendants) {
if (layer->transform())
subtreeReasons |= CompositingReasonTransformWithCompositedDescendants;
+ if (layer->shouldIsolateCompositedBlendingDescendants())
+ subtreeReasons |= CompositingReasonIsolateCompositedDescendants;
// If the implementation of createsGroup changes, we need to be aware of that in this part of code.
ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->hasFilter() || renderer->hasBlendMode()) == renderer->createsGroup());

Powered by Google App Engine
This is Rietveld 408576698