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

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

Issue 2671853003: [SPInvalidation] Use GeometryMapper in PaintLayerClipper for paint. (Closed)
Patch Set: none Created 3 years, 10 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 intersection(newClip, clipRects.posClipRect()).setIsClippedByClipCss()); 107 intersection(newClip, clipRects.posClipRect()).setIsClippedByClipCss());
108 clipRects.setOverflowClipRect( 108 clipRects.setOverflowClipRect(
109 intersection(newClip, clipRects.overflowClipRect()) 109 intersection(newClip, clipRects.overflowClipRect())
110 .setIsClippedByClipCss()); 110 .setIsClippedByClipCss());
111 clipRects.setFixedClipRect(intersection(newClip, clipRects.fixedClipRect()) 111 clipRects.setFixedClipRect(intersection(newClip, clipRects.fixedClipRect())
112 .setIsClippedByClipCss()); 112 .setIsClippedByClipCss());
113 } 113 }
114 } 114 }
115 115
116 PaintLayerClipper::PaintLayerClipper(const PaintLayer& layer, 116 PaintLayerClipper::PaintLayerClipper(const PaintLayer& layer,
117 bool useGeometryMapper) 117 GeometryMapper* geometryMapper)
118 : m_layer(layer), 118 : m_layer(layer), m_geometryMapper(geometryMapper) {}
119 m_geometryMapper(useGeometryMapper ? new GeometryMapper : nullptr) {}
120 119
121 ClipRects* PaintLayerClipper::clipRectsIfCached( 120 ClipRects* PaintLayerClipper::clipRectsIfCached(
122 const ClipRectsContext& context) const { 121 const ClipRectsContext& context) const {
123 DCHECK(context.usesCache()); 122 DCHECK(context.usesCache());
124 if (!m_layer.clipRectsCache()) 123 if (!m_layer.clipRectsCache())
125 return nullptr; 124 return nullptr;
126 ClipRectsCache::Entry& entry = 125 ClipRectsCache::Entry& entry =
127 m_layer.clipRectsCache()->get(context.cacheSlot()); 126 m_layer.clipRectsCache()->get(context.cacheSlot());
128 // FIXME: We used to ASSERT that we always got a consistent root layer. 127 // FIXME: We used to ASSERT that we always got a consistent root layer.
129 // We should add a test that has an inconsistent root. See 128 // We should add a test that has an inconsistent root. See
(...skipping 29 matching lines...) Expand all
159 } 158 }
160 159
161 ClipRects& PaintLayerClipper::getClipRects( 160 ClipRects& PaintLayerClipper::getClipRects(
162 const ClipRectsContext& context) const { 161 const ClipRectsContext& context) const {
163 if (ClipRects* result = clipRectsIfCached(context)) 162 if (ClipRects* result = clipRectsIfCached(context))
164 return *result; 163 return *result;
165 // Note that it's important that we call getClipRects on our parent 164 // Note that it's important that we call getClipRects on our parent
166 // before we call calculateClipRects so that calculateClipRects will hit 165 // before we call calculateClipRects so that calculateClipRects will hit
167 // the cache. 166 // the cache.
168 ClipRects* parentClipRects = nullptr; 167 ClipRects* parentClipRects = nullptr;
169 if (context.rootLayer != &m_layer && m_layer.parent()) 168 if (context.rootLayer != &m_layer && m_layer.parent()) {
170 parentClipRects = &m_layer.parent()->clipper().getClipRects(context); 169 parentClipRects =
170 &m_layer.parent()->clipper(m_geometryMapper).getClipRects(context);
171 }
171 RefPtr<ClipRects> clipRects = ClipRects::create(); 172 RefPtr<ClipRects> clipRects = ClipRects::create();
172 calculateClipRects(context, *clipRects); 173 calculateClipRects(context, *clipRects);
173 return storeClipRectsInCache(context, parentClipRects, *clipRects); 174 return storeClipRectsInCache(context, parentClipRects, *clipRects);
174 } 175 }
175 176
176 void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) { 177 void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) {
177 if (cacheSlot == NumberOfClipRectsCacheSlots) 178 if (cacheSlot == NumberOfClipRectsCacheSlots)
178 m_layer.clearClipRectsCache(); 179 m_layer.clearClipRectsCache();
179 else if (ClipRectsCache* cache = m_layer.clipRectsCache()) 180 else if (ClipRectsCache* cache = m_layer.clipRectsCache())
180 cache->clear(cacheSlot); 181 cache->clear(cacheSlot);
181
182 if (m_geometryMapper)
183 m_geometryMapper.reset(new GeometryMapper);
184 } 182 }
185 183
186 void PaintLayerClipper::clearClipRectsIncludingDescendants() { 184 void PaintLayerClipper::clearClipRectsIncludingDescendants() {
187 clearClipRectsIncludingDescendants(NumberOfClipRectsCacheSlots); 185 clearClipRectsIncludingDescendants(NumberOfClipRectsCacheSlots);
188 } 186 }
189 187
190 void PaintLayerClipper::clearClipRectsIncludingDescendants( 188 void PaintLayerClipper::clearClipRectsIncludingDescendants(
191 ClipRectsCacheSlot cacheSlot) { 189 ClipRectsCacheSlot cacheSlot) {
192 std::stack<const PaintLayer*> layers; 190 std::stack<const PaintLayer*> layers;
193 layers.push(&m_layer); 191 layers.push(&m_layer);
194 192
195 while (!layers.empty()) { 193 while (!layers.empty()) {
196 const PaintLayer* currentLayer = layers.top(); 194 const PaintLayer* currentLayer = layers.top();
197 layers.pop(); 195 layers.pop();
198 currentLayer->clipper().clearCache(cacheSlot); 196 currentLayer->clipper(m_geometryMapper).clearCache(cacheSlot);
199 for (const PaintLayer* layer = currentLayer->firstChild(); layer; 197 for (const PaintLayer* layer = currentLayer->firstChild(); layer;
200 layer = layer->nextSibling()) 198 layer = layer->nextSibling())
201 layers.push(layer); 199 layers.push(layer);
202 } 200 }
203 } 201 }
204 202
205 LayoutRect PaintLayerClipper::localClipRect( 203 LayoutRect PaintLayerClipper::localClipRect(
206 const PaintLayer& clippingRootLayer) const { 204 const PaintLayer& clippingRootLayer) const {
207 ClipRectsContext context(&clippingRootLayer, PaintingClipRects); 205 ClipRectsContext context(&clippingRootLayer, PaintingClipRects);
208 if (m_geometryMapper) { 206 if (m_geometryMapper) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 393
396 bool isClippingRoot = &m_layer == context.rootLayer; 394 bool isClippingRoot = &m_layer == context.rootLayer;
397 395
398 // For transformed layers, the root layer was shifted to be us, so there is no 396 // For transformed layers, the root layer was shifted to be us, so there is no
399 // need to examine the parent. We want to cache clip rects with us as the 397 // need to examine the parent. We want to cache clip rects with us as the
400 // root. 398 // root.
401 PaintLayer* parentLayer = !isClippingRoot ? m_layer.parent() : nullptr; 399 PaintLayer* parentLayer = !isClippingRoot ? m_layer.parent() : nullptr;
402 // Ensure that our parent's clip has been calculated so that we can examine 400 // Ensure that our parent's clip has been calculated so that we can examine
403 // the values. 401 // the values.
404 if (parentLayer) { 402 if (parentLayer) {
405 parentLayer->clipper().getOrCalculateClipRects(context, clipRects); 403 parentLayer->clipper(m_geometryMapper)
404 .getOrCalculateClipRects(context, clipRects);
406 } else { 405 } else {
407 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); 406 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
408 } 407 }
409 408
410 adjustClipRectsForChildren(layoutObject, clipRects); 409 adjustClipRectsForChildren(layoutObject, clipRects);
411 410
412 if (shouldClipOverflow(context) || layoutObject.hasClip()) { 411 if (shouldClipOverflow(context) || layoutObject.hasClip()) {
413 // This offset cannot use convertToLayerCoords, because sometimes our 412 // This offset cannot use convertToLayerCoords, because sometimes our
414 // rootLayer may be across some transformed layer boundary, for example, in 413 // rootLayer may be across some transformed layer boundary, for example, in
415 // the PaintLayerCompositor overlapMap, where clipRects are needed in view 414 // the PaintLayerCompositor overlapMap, where clipRects are needed in view
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 PaintLayerClipper(m_layer, false).backgroundClipRect(context); 504 PaintLayerClipper(m_layer, false).backgroundClipRect(context);
506 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); 505 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect);
507 #endif 506 #endif
508 return backgroundClipRect; 507 return backgroundClipRect;
509 } 508 }
510 DCHECK(m_layer.parent()); 509 DCHECK(m_layer.parent());
511 LayoutView* layoutView = m_layer.layoutObject()->view(); 510 LayoutView* layoutView = m_layer.layoutObject()->view();
512 DCHECK(layoutView); 511 DCHECK(layoutView);
513 512
514 RefPtr<ClipRects> parentClipRects = ClipRects::create(); 513 RefPtr<ClipRects> parentClipRects = ClipRects::create();
515 if (&m_layer == context.rootLayer) 514 if (&m_layer == context.rootLayer) {
516 parentClipRects->reset(LayoutRect(LayoutRect::infiniteIntRect())); 515 parentClipRects->reset(LayoutRect(LayoutRect::infiniteIntRect()));
517 else 516 } else {
518 m_layer.parent()->clipper().getOrCalculateClipRects(context, 517 m_layer.parent()
519 *parentClipRects); 518 ->clipper(m_geometryMapper)
519 .getOrCalculateClipRects(context, *parentClipRects);
520 }
520 521
521 ClipRect result = backgroundClipRectForPosition( 522 ClipRect result = backgroundClipRectForPosition(
522 *parentClipRects, m_layer.layoutObject()->styleRef().position()); 523 *parentClipRects, m_layer.layoutObject()->styleRef().position());
523 524
524 // Note: infinite clipRects should not be scrolled here, otherwise they will 525 // Note: infinite clipRects should not be scrolled here, otherwise they will
525 // accidentally no longer be considered infinite. 526 // accidentally no longer be considered infinite.
526 if (parentClipRects->fixed() && 527 if (parentClipRects->fixed() &&
527 context.rootLayer->layoutObject() == layoutView && 528 context.rootLayer->layoutObject() == layoutView &&
528 result != LayoutRect(LayoutRect::infiniteIntRect())) 529 result != LayoutRect(LayoutRect::infiniteIntRect()))
529 result.move(LayoutSize(layoutView->frameView()->getScrollOffset())); 530 result.move(LayoutSize(layoutView->frameView()->getScrollOffset()));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 const LayoutSize& subpixelAccumulation) const { 573 const LayoutSize& subpixelAccumulation) const {
573 DCHECK(!m_geometryMapper); 574 DCHECK(!m_geometryMapper);
574 ClipRectsContext context(rootLayer, PaintingClipRects, 575 ClipRectsContext context(rootLayer, PaintingClipRects,
575 IgnoreOverlayScrollbarSize, subpixelAccumulation); 576 IgnoreOverlayScrollbarSize, subpixelAccumulation);
576 if (respectOverflowClip == IgnoreOverflowClip) 577 if (respectOverflowClip == IgnoreOverflowClip)
577 context.setIgnoreOverflowClip(); 578 context.setIgnoreOverflowClip();
578 return getClipRects(context); 579 return getClipRects(context);
579 } 580 }
580 581
581 } // namespace blink 582 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698