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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerClipper.h

Issue 2238883006: SPv2: Use GeometryMapper to implement PaintLayerClipper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 30 matching lines...) Expand all
41 * If you do not delete the provisions above, a recipient may use your 41 * If you do not delete the provisions above, a recipient may use your
42 * version of this file under any of the LGPL, the MPL or the GPL. 42 * version of this file under any of the LGPL, the MPL or the GPL.
43 */ 43 */
44 44
45 #ifndef PaintLayerClipper_h 45 #ifndef PaintLayerClipper_h
46 #define PaintLayerClipper_h 46 #define PaintLayerClipper_h
47 47
48 #include "core/CoreExport.h" 48 #include "core/CoreExport.h"
49 #include "core/layout/ClipRectsCache.h" 49 #include "core/layout/ClipRectsCache.h"
50 #include "core/layout/ScrollEnums.h" 50 #include "core/layout/ScrollEnums.h"
51
52 #include "platform/graphics/paint/GeometryMapper.h"
53
51 #include "wtf/Allocator.h" 54 #include "wtf/Allocator.h"
52 55
53 namespace blink { 56 namespace blink {
54 57
55 class PaintLayer; 58 class PaintLayer;
56 59
57 enum ShouldRespectOverflowClipType { IgnoreOverflowClip, RespectOverflowClip }; 60 enum ShouldRespectOverflowClipType { IgnoreOverflowClip, RespectOverflowClip };
58 61
59 class ClipRectsContext { 62 class ClipRectsContext {
60 STACK_ALLOCATED(); 63 STACK_ALLOCATED();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 100
98 ClipRectsCacheSlot m_cacheSlot; 101 ClipRectsCacheSlot m_cacheSlot;
99 LayoutSize subPixelAccumulation; 102 LayoutSize subPixelAccumulation;
100 ShouldRespectOverflowClipType respectOverflowClip; 103 ShouldRespectOverflowClipType respectOverflowClip;
101 ShouldRespectOverflowClipType respectOverflowClipForViewport; 104 ShouldRespectOverflowClipType respectOverflowClipForViewport;
102 }; 105 };
103 106
104 // PaintLayerClipper is responsible for computing and caching clip 107 // PaintLayerClipper is responsible for computing and caching clip
105 // rects. 108 // rects.
106 // 109 //
110 // These clip rects have two types: background and foreground.
111 //
112 // The "background rect" for a PaintLayer is almost the same as its visual
113 // rect in the space of some ancestor PaintLayer (specified by rootLayer on Clip RectsContext).
114 // The only differences are that:
115 // * The unclipped rect at the start is LayoutRect::infiniteIntRect,
116 // rather than the local overflow bounds of the PaintLayer.
117 // * CSS clip, the extent of visualOverflowRect(), and SVG root viewport clipp ing is applied.
118 // Thus, for example if there are no clips then the background rect will be infi nite.
119 // Also, whether overflow clip of the ancestor should be applied is a parameter.
120 //
121 // The "foreground rect" for a PaintLayer is its "background rect", intersected
122 // with any clip applied by this PaintLayer to its children.
123
124 // Motivation for this class:
125 //
107 // The main reason for this cache is that we compute the clip rects during 126 // The main reason for this cache is that we compute the clip rects during
108 // a layout tree walk but need them during a paint tree walk (see example 127 // a layout tree walk but need them during a paint tree walk (see example
109 // below for some explanations). 128 // below for some explanations).
110 // 129 //
111 // A lot of complexity in this class come from the difference in inheritance 130 // A lot of complexity in this class come from the difference in inheritance
112 // between 'overflow' and 'clip': 131 // between 'overflow' and 'clip':
113 // * 'overflow' applies based on the containing blocks chain. 132 // * 'overflow' applies based on the containing blocks chain.
114 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow) 133 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow)
115 // * 'clip' applies to all descendants. 134 // * 'clip' applies to all descendants.
116 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip) 135 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip)
(...skipping 26 matching lines...) Expand all
143 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container, 162 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container,
144 // the clip will apply to both #inflow and #fixed. That's because 'clip' 163 // the clip will apply to both #inflow and #fixed. That's because 'clip'
145 // applies to any descendant, regardless of containing blocks. Note that 164 // applies to any descendant, regardless of containing blocks. Note that
146 // #container and #fixed are siblings in the paint tree but #container does 165 // #container and #fixed are siblings in the paint tree but #container does
147 // clip #fixed. This is the reason why we compute the painting clip rects during 166 // clip #fixed. This is the reason why we compute the painting clip rects during
148 // a layout tree walk and cache them for painting. 167 // a layout tree walk and cache them for painting.
149 class CORE_EXPORT PaintLayerClipper { 168 class CORE_EXPORT PaintLayerClipper {
150 DISALLOW_NEW(); 169 DISALLOW_NEW();
151 170
152 public: 171 public:
153 explicit PaintLayerClipper(const PaintLayer& layer) : m_layer(layer) {} 172 explicit PaintLayerClipper(const PaintLayer&, bool useGeometryMapper);
154 173
155 void clearClipRectsIncludingDescendants(); 174 void clearClipRectsIncludingDescendants();
156 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); 175 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot);
157 176
158 // Returns the background clip rect of the layer in the local coordinate 177 // Returns the background clip rect of the layer in the local coordinate
159 // space. Only looks for clips up to the given ancestor. 178 // space. Only looks for clips up to the given ancestor.
160 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; 179 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const;
161 180
181 // Computes the same thing as backgroundRect in calculateRects(), but sk
162 ClipRect backgroundClipRect(const ClipRectsContext&) const; 182 ClipRect backgroundClipRect(const ClipRectsContext&) const;
163 183
164 // This method figures out our layerBounds in coordinates relative to 184 // This method figures out our layerBounds in coordinates relative to
165 // |rootLayer|. It also computes our background and foreground clip rects 185 // |rootLayer|. It also computes our background and foreground clip rects
166 // for painting/event handling. 186 // for painting/event handling. Pass offsetFromRoot if known.
167 // Pass offsetFromRoot if known.
168 void calculateRects(const ClipRectsContext&, 187 void calculateRects(const ClipRectsContext&,
169 const LayoutRect& paintDirtyRect, 188 const LayoutRect& paintDirtyRect,
170 LayoutRect& layerBounds, 189 LayoutRect& layerBounds,
171 ClipRect& backgroundRect, 190 ClipRect& backgroundRect,
172 ClipRect& foregroundRect, 191 ClipRect& foregroundRect,
173 const LayoutPoint* offsetFromRoot = 0) const; 192 const LayoutPoint* offsetFromRoot = 0) const;
174 193
175 ClipRects& paintingClipRects(const PaintLayer* rootLayer, 194 ClipRects& paintingClipRects(const PaintLayer* rootLayer,
176 ShouldRespectOverflowClipType, 195 ShouldRespectOverflowClipType,
177 const LayoutSize& subpixelAccumulation) const; 196 const LayoutSize& subpixelAccumulation) const;
178 197
179 private: 198 private:
180 ClipRects& getClipRects(const ClipRectsContext&) const; 199 ClipRects& getClipRects(const ClipRectsContext&) const;
181 200
182 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; 201 void calculateClipRects(const ClipRectsContext&, ClipRects&) const;
183 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; 202 ClipRects* clipRectsIfCached(const ClipRectsContext&) const;
184 ClipRects& storeClipRectsInCache(const ClipRectsContext&, 203 ClipRects& storeClipRectsInCache(const ClipRectsContext&,
185 ClipRects* parentClipRects, 204 ClipRects* parentClipRects,
186 const ClipRects&) const; 205 const ClipRects&) const;
187 206
188 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; 207 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const;
189 208
190 bool shouldRespectOverflowClip(const ClipRectsContext&) const; 209 bool shouldRespectOverflowClip(const ClipRectsContext&) const;
191 210
211 ClipRect clipRectWithGeometryMapper(const ClipRectsContext&,
212 bool isForeground) const;
213 void mapLocalToRootWithGeometryMapper(const ClipRectsContext&,
214 LayoutRect& localRect) const;
215 void calculateRectsWithGeometryMapper(
216 const ClipRectsContext&,
217 const LayoutRect& paintDirtyRect,
218 LayoutRect& layerBounds,
219 ClipRect& backgroundRect,
220 ClipRect& foregroundRect,
221 const LayoutPoint* offsetFromRoot = 0) const;
222
223 ClipRect applyOverflowClipToBackgroundRectWithGeometryMapper(
224 const ClipRectsContext&,
225 const ClipRect&) const;
226
192 const PaintLayer& m_layer; 227 const PaintLayer& m_layer;
228 std::unique_ptr<GeometryMapper> m_geometryMapper;
193 }; 229 };
194 230
195 } // namespace blink 231 } // namespace blink
196 232
197 #endif // LayerClipper_h 233 #endif // LayerClipper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698