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

Side by Side Diff: third_party/WebKit/Source/core/paint/LayerClipRecorder.cpp

Issue 2194273002: Fix border radius on composited children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update the comment on why we say an empty div can paint Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/LayerClipRecorder.h" 5 #include "core/paint/LayerClipRecorder.h"
6 6
7 #include "core/layout/ClipRect.h" 7 #include "core/layout/ClipRect.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/PaintLayer.h" 9 #include "core/paint/PaintLayer.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
11 #include "platform/graphics/GraphicsContext.h" 11 #include "platform/graphics/GraphicsContext.h"
12 #include "platform/graphics/GraphicsLayer.h" 12 #include "platform/graphics/GraphicsLayer.h"
13 #include "platform/graphics/paint/ClipRecorder.h" 13 #include "platform/graphics/paint/ClipRecorder.h"
14 #include "platform/graphics/paint/PaintController.h" 14 #include "platform/graphics/paint/PaintController.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 LayerClipRecorder::LayerClipRecorder( 18 LayerClipRecorder::LayerClipRecorder(GraphicsContext& graphicsContext,
19 GraphicsContext& graphicsContext, 19 const LayoutBoxModelObject& layoutObject,
20 const LayoutBoxModelObject& layoutObject, 20 DisplayItem::Type clipType,
21 DisplayItem::Type clipType, 21 const ClipRect& clipRect,
22 const ClipRect& clipRect, 22 const PaintLayer* clipRoot,
23 const PaintLayerPaintingInfo* localPaintingInfo, 23 const LayoutPoint& fragmentOffset,
24 const LayoutPoint& fragmentOffset, 24 PaintLayerFlags paintFlags,
25 PaintLayerFlags paintFlags, 25 BorderRadiusClippingRule rule)
26 BorderRadiusClippingRule rule)
27 : m_graphicsContext(graphicsContext), 26 : m_graphicsContext(graphicsContext),
28 m_layoutObject(layoutObject), 27 m_layoutObject(layoutObject),
29 m_clipType(clipType) { 28 m_clipType(clipType) {
30 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 29 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
31 Vector<FloatRoundedRect> roundedRects; 30 Vector<FloatRoundedRect> roundedRects;
32 if (localPaintingInfo && clipRect.hasRadius()) { 31 if (clipRoot && clipRect.hasRadius()) {
33 collectRoundedRectClips(*layoutObject.layer(), *localPaintingInfo, 32 collectRoundedRectClips(*layoutObject.layer(), clipRoot, graphicsContext,
34 graphicsContext, fragmentOffset, paintFlags, rule, 33 fragmentOffset, paintFlags, rule, roundedRects);
35 roundedRects);
36 } 34 }
37 35
38 m_graphicsContext.getPaintController().createAndAppend<ClipDisplayItem>( 36 m_graphicsContext.getPaintController().createAndAppend<ClipDisplayItem>(
39 layoutObject, m_clipType, snappedClipRect, roundedRects); 37 layoutObject, m_clipType, snappedClipRect, roundedRects);
40 } 38 }
41 39
42 static bool inContainingBlockChain(PaintLayer* startLayer, 40 static bool inContainingBlockChain(PaintLayer* startLayer,
43 PaintLayer* endLayer) { 41 PaintLayer* endLayer) {
44 if (startLayer == endLayer) 42 if (startLayer == endLayer)
45 return true; 43 return true;
46 44
47 LayoutView* view = startLayer->layoutObject()->view(); 45 LayoutView* view = startLayer->layoutObject()->view();
48 for (const LayoutBlock* currentBlock = 46 for (const LayoutBlock* currentBlock =
49 startLayer->layoutObject()->containingBlock(); 47 startLayer->layoutObject()->containingBlock();
50 currentBlock && currentBlock != view; 48 currentBlock && currentBlock != view;
51 currentBlock = currentBlock->containingBlock()) { 49 currentBlock = currentBlock->containingBlock()) {
52 if (currentBlock->layer() == endLayer) 50 if (currentBlock->layer() == endLayer)
53 return true; 51 return true;
54 } 52 }
55 53
56 return false; 54 return false;
57 } 55 }
58 56
59 void LayerClipRecorder::collectRoundedRectClips( 57 void LayerClipRecorder::collectRoundedRectClips(
60 PaintLayer& paintLayer, 58 PaintLayer& paintLayer,
61 const PaintLayerPaintingInfo& localPaintingInfo, 59 const PaintLayer* clipRoot,
62 GraphicsContext& context, 60 GraphicsContext& context,
63 const LayoutPoint& fragmentOffset, 61 const LayoutPoint& fragmentOffset,
64 PaintLayerFlags paintFlags, 62 PaintLayerFlags paintFlags,
65 BorderRadiusClippingRule rule, 63 BorderRadiusClippingRule rule,
66 Vector<FloatRoundedRect>& roundedRectClips) { 64 Vector<FloatRoundedRect>& roundedRectClips) {
67 // If the clip rect has been tainted by a border radius, then we have to walk 65 // If the clip rect has been tainted by a border radius, then we have to walk
68 // up our layer chain applying the clips from any layers with overflow. The 66 // up our layer chain applying the clips from any layers with overflow. The
69 // condition for being able to apply these clips is that the overflow object 67 // condition for being able to apply these clips is that the overflow object
70 // be in our containing block chain so we check that also. 68 // be in our containing block chain so we check that also.
71 for (PaintLayer* layer = rule == IncludeSelfForBorderRadius 69 for (PaintLayer* layer = rule == IncludeSelfForBorderRadius
72 ? &paintLayer 70 ? &paintLayer
73 : paintLayer.parent(); 71 : paintLayer.parent();
74 layer; layer = layer->parent()) { 72 layer; layer = layer->parent()) {
75 // Composited scrolling layers handle border-radius clip in the compositor 73 // Composited scrolling layers handle border-radius clip in the compositor
76 // via a mask layer. We do not want to apply a border-radius clip to the 74 // via a mask layer. We do not want to apply a border-radius clip to the
77 // layer contents itself, because that would require re-rastering every 75 // layer contents itself, because that would require re-rastering every
78 // frame to update the clip. We only want to make sure that the mask layer 76 // frame to update the clip. We only want to make sure that the mask layer
79 // is properly clipped so that it can in turn clip the scrolled contents in 77 // is properly clipped so that it can in turn clip the scrolled contents in
80 // the compositor. 78 // the compositor.
81 if (layer->needsCompositedScrolling() && 79 if (layer->needsCompositedScrolling() &&
82 !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)) 80 !(paintFlags & PaintLayerPaintingChildClippingMaskPhase ||
81 paintFlags & PaintLayerPaintingAncestorClippingMaskPhase))
83 break; 82 break;
84 83
85 if (layer->layoutObject()->hasOverflowClip() && 84 if (layer->layoutObject()->hasOverflowClip() &&
86 layer->layoutObject()->style()->hasBorderRadius() && 85 layer->layoutObject()->style()->hasBorderRadius() &&
87 inContainingBlockChain(&paintLayer, layer)) { 86 inContainingBlockChain(&paintLayer, layer)) {
88 LayoutPoint delta(fragmentOffset); 87 LayoutPoint delta(fragmentOffset);
89 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); 88 layer->convertToLayerCoords(clipRoot, delta);
90 89
91 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't 90 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't
92 // use a pre-snapped border rect for clipping, since 91 // use a pre-snapped border rect for clipping, since
93 // getRoundedInnerBorderFor assumes it has not been snapped yet. 92 // getRoundedInnerBorderFor assumes it has not been snapped yet.
94 LayoutSize size(layer->layoutBox() 93 LayoutSize size(layer->layoutBox()
95 ? toLayoutBox(layer->layoutObject())->size() 94 ? toLayoutBox(layer->layoutObject())->size()
96 : LayoutSize(layer->size())); 95 : LayoutSize(layer->size()));
97 roundedRectClips.append( 96 roundedRectClips.append(
98 layer->layoutObject()->style()->getRoundedInnerBorderFor( 97 layer->layoutObject()->style()->getRoundedInnerBorderFor(
99 LayoutRect(delta, size))); 98 LayoutRect(delta, size)));
100 } 99 }
101 100
102 if (layer == localPaintingInfo.rootLayer) 101 if (layer == clipRoot)
103 break; 102 break;
104 } 103 }
105 } 104 }
106 105
107 LayerClipRecorder::~LayerClipRecorder() { 106 LayerClipRecorder::~LayerClipRecorder() {
108 m_graphicsContext.getPaintController().endItem<EndClipDisplayItem>( 107 m_graphicsContext.getPaintController().endItem<EndClipDisplayItem>(
109 m_layoutObject, DisplayItem::clipTypeToEndClipType(m_clipType)); 108 m_layoutObject, DisplayItem::clipTypeToEndClipType(m_clipType));
110 } 109 }
111 110
112 } // namespace blink 111 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/LayerClipRecorder.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerClipper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698