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

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp

Issue 2741103005: Reland of duce copying of local data structures in GeometryMapper and PaintLayerClipper. (Closed)
Patch Set: Created 3 years, 9 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: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp b/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
index 8e234784b9e35c2199feb46c87fbe92891cf03b0..ec07bc05fce943325104f795d01ee3dba24dde8c 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
@@ -200,7 +200,8 @@
const PaintLayer& clippingRootLayer) const {
ClipRectsContext context(&clippingRootLayer, PaintingClipRects);
if (m_geometryMapper) {
- ClipRect clipRect = clipRectWithGeometryMapper(context, false);
+ ClipRect clipRect;
+ calculateClipRectWithGeometryMapper(context, false, clipRect);
applyOverflowClipToBackgroundRectWithGeometryMapper(context, clipRect);
LayoutRect premappedRect = clipRect.rect();
@@ -216,9 +217,9 @@
.paintProperties()
->localBorderBoxProperties()
->transform();
- FloatRect clippedRectInLocalSpace =
- m_geometryMapper->sourceToDestinationRect(
- FloatRect(premappedRect), clipRootLayerTransform, layerTransform);
+ FloatRect clippedRectInLocalSpace(premappedRect);
+ m_geometryMapper->sourceToDestinationRect(
+ clipRootLayerTransform, layerTransform, clippedRectInLocalSpace);
clippedRectInLocalSpace.moveBy(
-FloatPoint(m_layer.layoutObject().paintOffset()));
@@ -270,10 +271,11 @@
->localBorderBoxProperties()
->transform();
- FloatRect localRect(rectToMap);
- localRect.moveBy(FloatPoint(m_layer.layoutObject().paintOffset()));
- rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect(
- localRect, layerTransform, rootTransform));
+ FloatRect floatRect(rectToMap);
+ floatRect.moveBy(FloatPoint(m_layer.layoutObject().paintOffset()));
+ m_geometryMapper->sourceToDestinationRect(layerTransform, rootTransform,
+ floatRect);
+ rectToMap = LayoutRect(floatRect);
rectToMap.moveBy(-context.rootLayer->layoutObject().paintOffset());
rectToMap.move(context.subPixelAccumulation);
}
@@ -291,7 +293,7 @@
backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
} else {
- backgroundRect = clipRectWithGeometryMapper(context, false);
+ calculateClipRectWithGeometryMapper(context, false, backgroundRect);
backgroundRect.move(context.subPixelAccumulation);
backgroundRect.intersect(paintDirtyRect);
@@ -299,7 +301,7 @@
applyOverflowClipToBackgroundRectWithGeometryMapper(context,
backgroundRect);
- foregroundRect = clipRectWithGeometryMapper(context, true);
+ calculateClipRectWithGeometryMapper(context, true, foregroundRect);
foregroundRect.move(context.subPixelAccumulation);
foregroundRect.intersect(paintDirtyRect);
}
@@ -340,7 +342,7 @@
LayoutBoxModelObject& layoutObject = m_layer.layoutObject();
if (!isClippingRoot && m_layer.parent()) {
- backgroundRect = backgroundClipRect(context);
+ calculateBackgroundClipRect(context, backgroundRect);
backgroundRect.move(context.subPixelAccumulation);
backgroundRect.intersect(paintDirtyRect);
} else {
@@ -441,9 +443,10 @@
return parentRects.overflowClipRect();
}
-ClipRect PaintLayerClipper::clipRectWithGeometryMapper(
- const ClipRectsContext& context,
- bool isForeground) const {
+void PaintLayerClipper::calculateClipRectWithGeometryMapper(
+ const ClipRectsContext& context,
+ bool isForeground,
+ ClipRect& output) const {
DCHECK(m_geometryMapper);
const auto* properties = m_layer.layoutObject().paintProperties();
DCHECK(properties && properties->localBorderBoxProperties());
@@ -474,15 +477,12 @@
propertyTreeState.setClip(properties->overflowClip());
}
- FloatClipRect clippedRectInRootLayerSpace =
+ const FloatClipRect& clippedRectInRootLayerSpace =
m_geometryMapper->sourceToDestinationClipRect(
propertyTreeState, destinationPropertyTreeState);
- ClipRect clipRect(LayoutRect(clippedRectInRootLayerSpace.rect()));
- if (clippedRectInRootLayerSpace.hasRadius())
- clipRect.setHasRadius(true);
-
- clipRect.moveBy(-context.rootLayer->layoutObject().paintOffset());
- return clipRect;
+ output.setRect(clippedRectInRootLayerSpace);
+
+ output.moveBy(-context.rootLayer->layoutObject().paintOffset());
}
void PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper(
@@ -504,20 +504,23 @@
clip.intersect(layerBoundsWithVisualOverflow);
}
-ClipRect PaintLayerClipper::backgroundClipRect(
- const ClipRectsContext& context) const {
+void PaintLayerClipper::calculateBackgroundClipRect(
+ const ClipRectsContext& context,
+ ClipRect& output) const {
if (m_geometryMapper) {
// TODO(chrishtr): fix the underlying bug that causes this situation.
- if (!m_layer.layoutObject().paintProperties())
- return ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
-
- ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false);
+ if (!m_layer.layoutObject().paintProperties()) {
+ output.setRect(FloatClipRect());
+ return;
+ }
+
+ calculateClipRectWithGeometryMapper(context, false, output);
#ifdef CHECK_CLIP_RECTS
ClipRect testBackgroundClipRect =
PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context);
- CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect);
+ CHECK_RECTS_EQ(testBackgroundClipRect, output);
#endif
- return backgroundClipRect;
+ return;
}
DCHECK(m_layer.parent());
LayoutView* layoutView = m_layer.layoutObject().view();
@@ -531,17 +534,15 @@
.getOrCalculateClipRects(context, *parentClipRects);
}
- ClipRect result = backgroundClipRectForPosition(
+ output = backgroundClipRectForPosition(
*parentClipRects, m_layer.layoutObject().styleRef().position());
// Note: infinite clipRects should not be scrolled here, otherwise they will
// accidentally no longer be considered infinite.
if (parentClipRects->fixed() &&
&context.rootLayer->layoutObject() == layoutView &&
- result != LayoutRect(LayoutRect::infiniteIntRect()))
- result.move(LayoutSize(layoutView->frameView()->getScrollOffset()));
-
- return result;
+ output != LayoutRect(LayoutRect::infiniteIntRect()))
+ output.move(LayoutSize(layoutView->frameView()->getScrollOffset()));
}
void PaintLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context,
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698