Diff
Modified: trunk/Source/WebCore/ChangeLog (224807 => 224808)
--- trunk/Source/WebCore/ChangeLog 2017-11-14 08:49:13 UTC (rev 224807)
+++ trunk/Source/WebCore/ChangeLog 2017-11-14 08:50:12 UTC (rev 224808)
@@ -1,3 +1,31 @@
+2017-11-14 Zan Dobersek <zdober...@igalia.com>
+
+ [Cairo] Move simpler draw operations from GraphicsContextCairo to CairoOperations
+ https://bugs.webkit.org/show_bug.cgi?id=179614
+
+ Reviewed by Carlos Garcia Campos.
+
+ Move operations that perform simpler drawing to the CairoOperations
+ file. This isolates the Cairo code and encapsulates operation work
+ into a limited scope. This patch only covers drawing patterns,
+ rectangles, document marker lines and ellipses. A missing forward
+ declaration for the drawGlyphs() function is also added in the
+ CairoOperations header.
+
+ No new tests -- no change in behavior.
+
+ * platform/graphics/cairo/CairoOperations.cpp:
+ (WebCore::Cairo::drawPattern):
+ (WebCore::Cairo::drawRect):
+ (WebCore::Cairo::drawLineForDocumentMarker):
+ (WebCore::Cairo::drawEllipse):
+ * platform/graphics/cairo/CairoOperations.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::drawRect):
+ (WebCore::GraphicsContext::drawEllipse):
+ (WebCore::GraphicsContext::drawLineForDocumentMarker):
+ (WebCore::GraphicsContext::drawPattern):
+
2017-11-13 Joseph Pecoraro <pecor...@apple.com>
Give a ServiceWorker WebContentProcess a different display name
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (224807 => 224808)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2017-11-14 08:49:13 UTC (rev 224807)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2017-11-14 08:50:12 UTC (rev 224808)
@@ -35,6 +35,7 @@
#if USE(CAIRO)
+#include "DrawErrorUnderline.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "GraphicsContext.h"
@@ -553,6 +554,77 @@
cairo_restore(cr);
}
+void drawPattern(PlatformContextCairo& platformContext, Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, CompositeOperator compositeOperator, BlendMode blendMode)
+{
+ if (auto surface = image.nativeImageForCurrentFrame())
+ drawPatternToCairoContext(platformContext.cr(), surface.get(), IntSize(image.size()), tileRect, patternTransform, phase, toCairoOperator(compositeOperator, blendMode), destRect);
+}
+
+void drawRect(PlatformContextCairo& platformContext, const FloatRect& rect, float borderThickness, const GraphicsContextState& state)
+{
+ // FIXME: how should borderThickness be used?
+ UNUSED_PARAM(borderThickness);
+
+ cairo_t* cr = platformContext.cr();
+ cairo_save(cr);
+
+ fillRectWithColor(cr, rect, state.fillColor);
+
+ if (state.strokeStyle != NoStroke) {
+ setSourceRGBAFromColor(cr, state.strokeColor);
+ FloatRect r(rect);
+ r.inflate(-.5f);
+ cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
+ cairo_set_line_width(cr, 1.0); // borderThickness?
+ cairo_stroke(cr);
+ }
+
+ cairo_restore(cr);
+}
+
+void drawLineForDocumentMarker(PlatformContextCairo& platformContext, const FloatPoint& origin, float width, GraphicsContext::DocumentMarkerLineStyle style)
+{
+ if (style != GraphicsContext::DocumentMarkerSpellingLineStyle
+ && style != GraphicsContext::DocumentMarkerGrammarLineStyle)
+ return;
+
+ cairo_t* cr = platformContext.cr();
+ cairo_save(cr);
+
+ if (style == GraphicsContext::DocumentMarkerSpellingLineStyle)
+ cairo_set_source_rgb(cr, 1, 0, 0);
+ else if (style == GraphicsContext::DocumentMarkerGrammarLineStyle)
+ cairo_set_source_rgb(cr, 0, 1, 0);
+
+ drawErrorUnderline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness);
+ cairo_restore(cr);
+}
+
+void drawEllipse(PlatformContextCairo& platformContext, const FloatRect& rect, const GraphicsContextState& state)
+{
+ cairo_t* cr = platformContext.cr();
+
+ cairo_save(cr);
+ float yRadius = .5 * rect.height();
+ float xRadius = .5 * rect.width();
+ cairo_translate(cr, rect.x() + xRadius, rect.y() + yRadius);
+ cairo_scale(cr, xRadius, yRadius);
+ cairo_arc(cr, 0., 0., 1., 0., 2 * piFloat);
+ cairo_restore(cr);
+
+ if (state.fillColor.isVisible()) {
+ setSourceRGBAFromColor(cr, state.fillColor);
+ cairo_fill_preserve(cr);
+ }
+
+ if (state.strokeStyle != NoStroke) {
+ setSourceRGBAFromColor(cr, state.strokeColor);
+ cairo_set_line_width(cr, state.strokeThickness);
+ cairo_stroke(cr);
+ } else
+ cairo_new_path(cr);
+}
+
void drawFocusRing(PlatformContextCairo& platformContext, const Path& path, float width, const Color& color)
{
// FIXME: We should draw paths that describe a rectangle with rounded corners
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h (224807 => 224808)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h 2017-11-14 08:49:13 UTC (rev 224807)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.h 2017-11-14 08:50:12 UTC (rev 224808)
@@ -93,6 +93,14 @@
void strokePath(PlatformContextCairo&, const Path&, const GraphicsContextState&, GraphicsContext&);
void clearRect(PlatformContextCairo&, const FloatRect&);
+void drawGlyphs(GraphicsContext&, const GraphicsContextState&, bool, const FloatPoint&, cairo_scaled_font_t*, double, const Vector<cairo_glyph_t>&, float, GraphicsContext&);
+
+void drawPattern(PlatformContextCairo&, Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, CompositeOperator, BlendMode);
+
+void drawRect(PlatformContextCairo&, const FloatRect&, float, const GraphicsContextState&);
+void drawLineForDocumentMarker(PlatformContextCairo&, const FloatPoint&, float, GraphicsContext::DocumentMarkerLineStyle);
+void drawEllipse(PlatformContextCairo&, const FloatRect&, const GraphicsContextState&);
+
void drawFocusRing(PlatformContextCairo&, const Path&, float, const Color&);
void drawFocusRing(PlatformContextCairo&, const Vector<FloatRect>&, float, const Color&);
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (224807 => 224808)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-11-14 08:49:13 UTC (rev 224807)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-11-14 08:50:12 UTC (rev 224808)
@@ -38,7 +38,6 @@
#include "AffineTransform.h"
#include "CairoUtilities.h"
#include "DisplayListRecorder.h"
-#include "DrawErrorUnderline.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "FloatRoundedRect.h"
@@ -238,22 +237,8 @@
}
ASSERT(!rect.isEmpty());
-
- cairo_t* cr = platformContext()->cr();
- cairo_save(cr);
-
- fillRectWithColor(cr, rect, fillColor());
-
- if (strokeStyle() != NoStroke) {
- setSourceRGBAFromColor(cr, strokeColor());
- FloatRect r(rect);
- r.inflate(-.5f);
- cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
- cairo_set_line_width(cr, 1.0); // borderThickness?
- cairo_stroke(cr);
- }
-
- cairo_restore(cr);
+ ASSERT(hasPlatformContext());
+ Cairo::drawRect(*platformContext(), rect, borderThickness, state());
}
void GraphicsContext::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
@@ -375,26 +360,8 @@
return;
}
- cairo_t* cr = platformContext()->cr();
- cairo_save(cr);
- float yRadius = .5 * rect.height();
- float xRadius = .5 * rect.width();
- cairo_translate(cr, rect.x() + xRadius, rect.y() + yRadius);
- cairo_scale(cr, xRadius, yRadius);
- cairo_arc(cr, 0., 0., 1., 0., 2 * piFloat);
- cairo_restore(cr);
-
- if (fillColor().isVisible()) {
- setSourceRGBAFromColor(cr, fillColor());
- cairo_fill_preserve(cr);
- }
-
- if (strokeStyle() != NoStroke) {
- setSourceRGBAFromColor(cr, strokeColor());
- cairo_set_line_width(cr, strokeThickness());
- cairo_stroke(cr);
- } else
- cairo_new_path(cr);
+ ASSERT(hasPlatformContext());
+ Cairo::drawEllipse(*platformContext(), rect, state());
}
void GraphicsContext::fillPath(const Path& path)
@@ -592,24 +559,13 @@
if (paintingDisabled())
return;
- cairo_t* cr = platformContext()->cr();
- cairo_save(cr);
-
- switch (style) {
- case DocumentMarkerSpellingLineStyle:
- cairo_set_source_rgb(cr, 1, 0, 0);
- break;
- case DocumentMarkerGrammarLineStyle:
- cairo_set_source_rgb(cr, 0, 1, 0);
- break;
- default:
- cairo_restore(cr);
+ if (m_impl) {
+ m_impl->drawLineForDocumentMarker(origin, width, style);
return;
}
- drawErrorUnderline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness);
-
- cairo_restore(cr);
+ ASSERT(hasPlatformContext());
+ Cairo::drawLineForDocumentMarker(*platformContext(), origin, width, style);
}
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
@@ -932,22 +888,18 @@
Cairo::fillRectWithRoundedHole(*platformContext(), rect, roundedHoleRect, state(), *this);
}
-void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode)
+void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator compositeOperator, BlendMode blendMode)
{
if (paintingDisabled())
return;
if (m_impl) {
- m_impl->drawPattern(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode);
+ m_impl->drawPattern(image, destRect, tileRect, patternTransform, phase, spacing, compositeOperator, blendMode);
return;
}
- RefPtr<cairo_surface_t> surface = image.nativeImageForCurrentFrame();
- if (!surface) // If it's too early we won't have an image yet.
- return;
-
- cairo_t* cr = platformContext()->cr();
- drawPatternToCairoContext(cr, surface.get(), IntSize(image.size()), tileRect, patternTransform, phase, toCairoOperator(op, blendMode), destRect);
+ ASSERT(hasPlatformContext());
+ Cairo::drawPattern(*platformContext(), image, destRect, tileRect, patternTransform, phase, compositeOperator, blendMode);
}
void GraphicsContext::setPlatformShouldAntialias(bool enable)