- Revision
- 191617
- Author
- [email protected]
- Date
- 2015-10-26 21:03:38 -0700 (Mon, 26 Oct 2015)
Log Message
Remove redundant GraphicsContext::clip(const Path&, WindRule)
https://bugs.webkit.org/show_bug.cgi?id=150584
Reviewed by Tim Horton.
GraphicsContext had both clipPath(const Path&, WindRule) and clip(const Path&, WindRule),
which were mostly the same other than GraphicsContext::clipPath() not clipping if the path
was empty (added, I think by mistake, in r72926), and not calling m_data->clip().
Make clipPath() be the winner, and have it behave like clip() with empty paths, and call m_data->clip().
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::clipRoundedRect):
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::clip): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::canvasClip):
(WebCore::GraphicsContext::clip): Deleted.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBoxShadow): Making a path, calling addRoundedRect() and then clipping
to the path is the same as context.clipRoundedRect().
* rendering/mathml/RenderMathMLRadicalOperator.cpp:
(WebCore::RenderMathMLRadicalOperator::paint):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (191616 => 191617)
--- trunk/Source/WebCore/ChangeLog 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/ChangeLog 2015-10-27 04:03:38 UTC (rev 191617)
@@ -1,3 +1,32 @@
+2015-10-26 Simon Fraser <[email protected]>
+
+ Remove redundant GraphicsContext::clip(const Path&, WindRule)
+ https://bugs.webkit.org/show_bug.cgi?id=150584
+
+ Reviewed by Tim Horton.
+
+ GraphicsContext had both clipPath(const Path&, WindRule) and clip(const Path&, WindRule),
+ which were mostly the same other than GraphicsContext::clipPath() not clipping if the path
+ was empty (added, I think by mistake, in r72926), and not calling m_data->clip().
+
+ Make clipPath() be the winner, and have it behave like clip() with empty paths, and call m_data->clip().
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::clipRoundedRect):
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::clipPath):
+ (WebCore::GraphicsContext::clip): Deleted.
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::clipPath):
+ (WebCore::GraphicsContext::canvasClip):
+ (WebCore::GraphicsContext::clip): Deleted.
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintBoxShadow): Making a path, calling addRoundedRect() and then clipping
+ to the path is the same as context.clipRoundedRect().
+ * rendering/mathml/RenderMathMLRadicalOperator.cpp:
+ (WebCore::RenderMathMLRadicalOperator::paint):
+
2015-10-26 Zalan Bujtas <[email protected]>
Floating box is misplaced after content change.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (191616 => 191617)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2015-10-27 04:03:38 UTC (rev 191617)
@@ -461,7 +461,7 @@
Path path;
path.addRoundedRect(rect);
- clip(path);
+ clipPath(path);
}
void GraphicsContext::clipOutRoundedRect(const FloatRoundedRect& rect)
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (191616 => 191617)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2015-10-27 04:03:38 UTC (rev 191617)
@@ -331,7 +331,7 @@
void clipOut(const FloatRect&);
void clipOutRoundedRect(const FloatRoundedRect&);
- void clipPath(const Path&, WindRule);
+ void clipPath(const Path&, WindRule = RULE_EVENODD);
void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
void clipToImageBuffer(ImageBuffer&, const FloatRect&);
@@ -413,8 +413,6 @@
void setDrawLuminanceMask(bool drawLuminanceMask) { m_state.drawLuminanceMask = drawLuminanceMask; }
bool drawLuminanceMask() const { return m_state.drawLuminanceMask; }
- WEBCORE_EXPORT void clip(const Path&, WindRule = RULE_EVENODD);
-
// This clip function is used only by <canvas> code. It allows
// implementations to handle clipping on the canvas differently since
// the discipline is different.
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (191616 => 191617)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2015-10-27 04:03:38 UTC (rev 191617)
@@ -494,8 +494,13 @@
cairo_t* cr = platformContext()->cr();
if (!path.isNull())
setPathOnCairoContext(cr, path.platformPath()->context());
+
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
cairo_clip(cr);
+ cairo_set_fill_rule(cr, savedFillRule);
+
+ m_data->clip(path);
}
IntRect GraphicsContext::clipBounds() const
@@ -960,30 +965,9 @@
cairo_set_operator(platformContext()->cr(), cairo_op);
}
-void GraphicsContext::clip(const Path& path, WindRule windRule)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = platformContext()->cr();
- if (!path.isNull()) {
- cairo_path_t* pathCopy = cairo_copy_path(path.platformPath()->context());
- cairo_append_path(cr, pathCopy);
- cairo_path_destroy(pathCopy);
- }
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- if (windRule == RULE_NONZERO)
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
- else
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
- m_data->clip(path);
-}
-
void GraphicsContext::canvasClip(const Path& path, WindRule windRule)
{
- clip(path, windRule);
+ clipPath(path, windRule);
}
void GraphicsContext::clipOut(const Path& path)
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (191616 => 191617)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2015-10-27 04:03:38 UTC (rev 191617)
@@ -982,20 +982,20 @@
if (paintingDisabled())
return;
- // Why does clipping to an empty path do nothing?
- // Why is this different from GraphicsContext::clip(const Path&).
+ CGContextRef context = platformContext();
if (path.isEmpty())
- return;
+ CGContextClipToRect(context, CGRectZero);
+ else {
+ CGContextBeginPath(platformContext());
+ CGContextAddPath(platformContext(), path.platformPath());
- CGContextRef context = platformContext();
-
- CGContextBeginPath(platformContext());
- CGContextAddPath(platformContext(), path.platformPath());
-
- if (clipRule == RULE_EVENODD)
- CGContextEOClip(context);
- else
- CGContextClip(context);
+ if (clipRule == RULE_EVENODD)
+ CGContextEOClip(context);
+ else
+ CGContextClip(context);
+ }
+
+ m_data->clip(path);
}
IntRect GraphicsContext::clipBounds() const
@@ -1234,31 +1234,9 @@
}
}
-void GraphicsContext::clip(const Path& path, WindRule fillRule)
-{
- if (paintingDisabled())
- return;
- CGContextRef context = platformContext();
-
- // CGContextClip does nothing if the path is empty, so in this case, we
- // instead clip against a zero rect to reduce the clipping region to
- // nothing - which is the intended behavior of clip() if the path is empty.
- if (path.isEmpty())
- CGContextClipToRect(context, CGRectZero);
- else {
- CGContextBeginPath(context);
- CGContextAddPath(context, path.platformPath());
- if (fillRule == RULE_NONZERO)
- CGContextClip(context);
- else
- CGContextEOClip(context);
- }
- m_data->clip(path);
-}
-
void GraphicsContext::canvasClip(const Path& path, WindRule fillRule)
{
- clip(path, fillRule);
+ clipPath(path, fillRule);
}
void GraphicsContext::clipOut(const Path& path)
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (191616 => 191617)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2015-10-27 04:03:38 UTC (rev 191617)
@@ -2346,9 +2346,7 @@
GraphicsContextStateSaver stateSaver(context);
if (hasBorderRadius) {
- Path path;
- path.addRoundedRect(pixelSnappedBorderRect);
- context.clip(path);
+ context.clipRoundedRect(pixelSnappedBorderRect);
pixelSnappedRoundedHole.shrinkRadii(shadowSpread);
} else
context.clip(pixelSnappedBorderRect.rect());
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp (191616 => 191617)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp 2015-10-27 00:55:35 UTC (rev 191616)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp 2015-10-27 04:03:38 UTC (rev 191617)
@@ -152,14 +152,14 @@
GraphicsContextStateSaver maskStateSaver(info.context());
// Build a mask to draw the thick part of the root.
- Path mask;
+ Path maskPath;
- mask.moveTo(overbarLeftPoint);
- mask.addLineTo(bottomPoint);
- mask.addLineTo(dipLeftPoint);
- mask.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
+ maskPath.moveTo(overbarLeftPoint);
+ maskPath.addLineTo(bottomPoint);
+ maskPath.addLineTo(dipLeftPoint);
+ maskPath.addLineTo(FloatPoint(2 * dipLeftPoint.x() - leftEnd.x(), 2 * dipLeftPoint.y() - leftEnd.y()));
- info.context().clip(mask);
+ info.context().clipPath(maskPath);
// Draw the thick part of the root.
info.context().setStrokeThickness(gRadicalThickLineThicknessEms * style().fontSize());