- Revision
- 214763
- Author
- carlo...@webkit.org
- Date
- 2017-04-03 03:29:39 -0700 (Mon, 03 Apr 2017)
Log Message
Merge r214100 - [Cairo] Handle the blend mode in GraphicsContext::drawPattern
https://bugs.webkit.org/show_bug.cgi?id=169746
Reviewed by Žan Doberšek.
We are not taking into account the blend mode when passing the cairo operator to drawPatternToCairoContext().
This is based on patch by Žan Doberšek, just adding the toCairoOperator changes to make it easier to handle
it. Instead of checking everywhere if blend mode is Normal to decide whether to use toCairoOperator with
CompositeOperator or BlendMode, there's no a single toCairoOperator that receives both parameters, but BlendMode
is optional and defaults to Normal.
* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::toCairoCompositeOperator):
(WebCore::toCairoOperator):
* platform/graphics/cairo/CairoUtilities.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::setPlatformCompositeOperation):
(WebCore::GraphicsContext::drawPattern):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (214762 => 214763)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-04-03 10:28:12 UTC (rev 214762)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-04-03 10:29:39 UTC (rev 214763)
@@ -1,3 +1,24 @@
+2017-03-17 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [Cairo] Handle the blend mode in GraphicsContext::drawPattern
+ https://bugs.webkit.org/show_bug.cgi?id=169746
+
+ Reviewed by Žan Doberšek.
+
+ We are not taking into account the blend mode when passing the cairo operator to drawPatternToCairoContext().
+ This is based on patch by Žan Doberšek, just adding the toCairoOperator changes to make it easier to handle
+ it. Instead of checking everywhere if blend mode is Normal to decide whether to use toCairoOperator with
+ CompositeOperator or BlendMode, there's no a single toCairoOperator that receives both parameters, but BlendMode
+ is optional and defaults to Normal.
+
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ (WebCore::toCairoCompositeOperator):
+ (WebCore::toCairoOperator):
+ * platform/graphics/cairo/CairoUtilities.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::setPlatformCompositeOperation):
+ (WebCore::GraphicsContext::drawPattern):
+
2017-03-16 Simon Fraser <simon.fra...@apple.com>
RenderView::documentBeingDestroyed() needs a new name.
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (214762 => 214763)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2017-04-03 10:28:12 UTC (rev 214762)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2017-04-03 10:29:39 UTC (rev 214763)
@@ -108,7 +108,7 @@
}
}
-cairo_operator_t toCairoOperator(CompositeOperator op)
+static cairo_operator_t toCairoCompositeOperator(CompositeOperator op)
{
switch (op) {
case CompositeClear:
@@ -143,11 +143,12 @@
return CAIRO_OPERATOR_SOURCE;
}
}
-cairo_operator_t toCairoOperator(BlendMode blendOp)
+
+cairo_operator_t toCairoOperator(CompositeOperator op, BlendMode blendOp)
{
switch (blendOp) {
case BlendModeNormal:
- return CAIRO_OPERATOR_OVER;
+ return toCairoCompositeOperator(op);
case BlendModeMultiply:
return CAIRO_OPERATOR_MULTIPLY;
case BlendModeScreen:
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (214762 => 214763)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2017-04-03 10:28:12 UTC (rev 214762)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2017-04-03 10:29:39 UTC (rev 214763)
@@ -79,8 +79,7 @@
void setPathOnCairoContext(cairo_t* to, cairo_t* from);
void appendWebCorePathToCairoContext(cairo_t* context, const Path& path);
void appendRegionToCairoContext(cairo_t*, const cairo_region_t*);
-cairo_operator_t toCairoOperator(CompositeOperator op);
-cairo_operator_t toCairoOperator(BlendMode blendOp);
+cairo_operator_t toCairoOperator(CompositeOperator, BlendMode = BlendModeNormal);
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect);
RefPtr<cairo_surface_t> copyCairoImageSurface(cairo_surface_t*);
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (214762 => 214763)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-04-03 10:28:12 UTC (rev 214762)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2017-04-03 10:29:39 UTC (rev 214763)
@@ -1036,13 +1036,7 @@
if (paintingDisabled())
return;
- cairo_operator_t cairo_op;
- if (blendOp == BlendModeNormal)
- cairo_op = toCairoOperator(op);
- else
- cairo_op = toCairoOperator(blendOp);
-
- cairo_set_operator(platformContext()->cr(), cairo_op);
+ cairo_set_operator(platformContext()->cr(), toCairoOperator(op, blendOp));
}
void GraphicsContext::canvasClip(const Path& path, WindRule windRule)
@@ -1183,7 +1177,7 @@
return;
cairo_t* cr = platformContext()->cr();
- drawPatternToCairoContext(cr, surface.get(), IntSize(image.size()), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
+ drawPatternToCairoContext(cr, surface.get(), IntSize(image.size()), tileRect, patternTransform, phase, toCairoOperator(op, blendMode), destRect);
}
void GraphicsContext::setPlatformShouldAntialias(bool enable)