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

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

Issue 1144203004: Allow certain SP recorder classes to defer their "begin" operation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/LayerClipRecorder.h ('k') | Source/core/paint/PartPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/paint/LayerClipRecorder.h" 6 #include "core/paint/LayerClipRecorder.h"
7 7
8 #include "core/layout/ClipRect.h" 8 #include "core/layout/ClipRect.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/DeprecatedPaintLayer.h" 10 #include "core/paint/DeprecatedPaintLayer.h"
11 #include "platform/RuntimeEnabledFeatures.h" 11 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/geometry/IntRect.h" 12 #include "platform/geometry/IntRect.h"
13 #include "platform/graphics/GraphicsContext.h" 13 #include "platform/graphics/GraphicsContext.h"
14 #include "platform/graphics/GraphicsLayer.h" 14 #include "platform/graphics/GraphicsLayer.h"
15 #include "platform/graphics/paint/ClipRecorder.h" 15 #include "platform/graphics/paint/ClipRecorder.h"
16 #include "platform/graphics/paint/DisplayItemList.h" 16 #include "platform/graphics/paint/DisplayItemList.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 LayerClipRecorder::LayerClipRecorder(GraphicsContext& graphicsContext, DisplayIt em::Type clipType)
21 : m_graphicsContext(graphicsContext)
22 , m_layoutObject(nullptr)
23 , m_clipType(clipType)
24 , m_engaged(false)
25 {
26 }
27
20 LayerClipRecorder::LayerClipRecorder(GraphicsContext& graphicsContext, const Lay outBoxModelObject& layoutObject, DisplayItem::Type clipType, const ClipRect& cli pRect, 28 LayerClipRecorder::LayerClipRecorder(GraphicsContext& graphicsContext, const Lay outBoxModelObject& layoutObject, DisplayItem::Type clipType, const ClipRect& cli pRect,
21 const DeprecatedPaintLayerPaintingInfo* localPaintingInfo, const LayoutPoint & fragmentOffset, PaintLayerFlags paintFlags, BorderRadiusClippingRule rule) 29 const DeprecatedPaintLayerPaintingInfo* localPaintingInfo, const LayoutPoint & fragmentOffset, PaintLayerFlags paintFlags, BorderRadiusClippingRule rule)
22 : m_graphicsContext(graphicsContext) 30 : LayerClipRecorder(graphicsContext, clipType)
23 , m_layoutObject(layoutObject)
24 , m_clipType(clipType)
25 { 31 {
26 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 32 begin(layoutObject, clipRect, localPaintingInfo, fragmentOffset, paintFlags, rule);
27 OwnPtr<ClipDisplayItem> clipDisplayItem = ClipDisplayItem::create(layoutObje ct, clipType, snappedClipRect);
28 if (localPaintingInfo && clipRect.hasRadius())
29 collectRoundedRectClips(*layoutObject.layer(), *localPaintingInfo, graph icsContext, fragmentOffset, paintFlags, rule, clipDisplayItem->roundedRectClips( ));
30 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
31 clipDisplayItem->replay(graphicsContext);
32 } else {
33 ASSERT(m_graphicsContext.displayItemList());
34 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabl ed())
35 return;
36 m_graphicsContext.displayItemList()->add(clipDisplayItem.release());
37 }
38 } 33 }
39 34
40 static bool inContainingBlockChain(DeprecatedPaintLayer* startLayer, DeprecatedP aintLayer* endLayer) 35 static bool inContainingBlockChain(DeprecatedPaintLayer* startLayer, DeprecatedP aintLayer* endLayer)
41 { 36 {
42 if (startLayer == endLayer) 37 if (startLayer == endLayer)
43 return true; 38 return true;
44 39
45 LayoutView* view = startLayer->layoutObject()->view(); 40 LayoutView* view = startLayer->layoutObject()->view();
46 for (LayoutBlock* currentBlock = startLayer->layoutObject()->containingBlock (); currentBlock && currentBlock != view; currentBlock = currentBlock->containin gBlock()) { 41 for (LayoutBlock* currentBlock = startLayer->layoutObject()->containingBlock (); currentBlock && currentBlock != view; currentBlock = currentBlock->containin gBlock()) {
47 if (currentBlock->layer() == endLayer) 42 if (currentBlock->layer() == endLayer)
(...skipping 23 matching lines...) Expand all
71 roundedRectClips.append(layer->layoutObject()->style()->getRoundedIn nerBorderFor(LayoutRect(delta, LayoutSize(layer->size())))); 66 roundedRectClips.append(layer->layoutObject()->style()->getRoundedIn nerBorderFor(LayoutRect(delta, LayoutSize(layer->size()))));
72 } 67 }
73 68
74 if (layer == localPaintingInfo.rootLayer) 69 if (layer == localPaintingInfo.rootLayer)
75 break; 70 break;
76 } 71 }
77 } 72 }
78 73
79 LayerClipRecorder::~LayerClipRecorder() 74 LayerClipRecorder::~LayerClipRecorder()
80 { 75 {
76 if (!m_engaged)
77 return;
78
81 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 79 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
82 ASSERT(m_graphicsContext.displayItemList()); 80 ASSERT(m_graphicsContext.displayItemList());
83 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabl ed()) 81 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabl ed())
84 return; 82 return;
85 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipTyp e); 83 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipTyp e);
86 OwnPtr<EndClipDisplayItem> endClip = EndClipDisplayItem::create(m_layout Object, endType); 84 OwnPtr<EndClipDisplayItem> endClip = EndClipDisplayItem::create(*m_layou tObject, endType);
87 m_graphicsContext.displayItemList()->add(endClip.release()); 85 m_graphicsContext.displayItemList()->add(endClip.release());
88 } else { 86 } else {
89 m_graphicsContext.restore(); 87 m_graphicsContext.restore();
90 } 88 }
91 } 89 }
92 90
91 void LayerClipRecorder::begin(const LayoutBoxModelObject& layoutObject, const Cl ipRect& clipRect, const DeprecatedPaintLayerPaintingInfo* localPaintingInfo, con st LayoutPoint& fragmentOffset, PaintLayerFlags paintFlags, BorderRadiusClipping Rule rule)
92 {
93 ASSERT(!m_engaged);
94 m_engaged = true;
95 m_layoutObject = &layoutObject;
96
97 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
98 OwnPtr<ClipDisplayItem> clipDisplayItem = ClipDisplayItem::create(*m_layoutO bject, m_clipType, snappedClipRect);
99 if (localPaintingInfo && clipRect.hasRadius())
100 collectRoundedRectClips(*m_layoutObject->layer(), *localPaintingInfo, m_ graphicsContext, fragmentOffset, paintFlags, rule, clipDisplayItem->roundedRectC lips());
101 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
102 clipDisplayItem->replay(m_graphicsContext);
103 } else {
104 ASSERT(m_graphicsContext.displayItemList());
105 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabl ed())
106 return;
107 m_graphicsContext.displayItemList()->add(clipDisplayItem.release());
108 }
109 }
110
93 } // namespace blink 111 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/LayerClipRecorder.h ('k') | Source/core/paint/PartPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698