Log Message
[Cairo] Remove PlatformPathCairo https://bugs.webkit.org/show_bug.cgi?id=208807
Reviewed by Darin Adler. We have a class CairoPath defined in PlatformPathCairo.h that simply wraps a cairo_t. We can use the cairo_t directly as PlatformPath and simplify the cairo path implementation. * platform/SourcesCairo.txt: * platform/graphics/Path.h: (WebCore::Path::platformPath const): * platform/graphics/cairo/CairoOperations.cpp: (WebCore::Cairo::fillRectWithRoundedHole): (WebCore::Cairo::fillPath): (WebCore::Cairo::strokePath): (WebCore::Cairo::clipPath): * platform/graphics/cairo/CairoUtilities.cpp: (WebCore::appendWebCorePathToCairoContext): * platform/graphics/cairo/FontCairo.cpp: (WebCore::Font::platformPathForGlyph const): * platform/graphics/cairo/PathCairo.cpp: (WebCore::Path::Path): (WebCore::Path::ensurePlatformPath): (WebCore::Path::operator=): (WebCore::Path::clear): (WebCore::Path::isEmptySlowCase const): (WebCore::Path::currentPointSlowCase const): (WebCore::Path::translate): (WebCore::Path::moveToSlowCase): (WebCore::Path::addLineToSlowCase): (WebCore::Path::addRect): (WebCore::Path::addQuadCurveTo): (WebCore::Path::addBezierCurveTo): (WebCore::Path::addArcSlowCase): (WebCore::Path::addArcTo): (WebCore::Path::addEllipse): (WebCore::Path::addPath): (WebCore::Path::closeSubpath): (WebCore::Path::boundingRectSlowCase const): (WebCore::Path::strokeBoundingRect const): (WebCore::Path::contains const): (WebCore::Path::strokeContains const): (WebCore::Path::applySlowCase const): (WebCore::Path::transform): * platform/graphics/cairo/PlatformPathCairo.cpp: Removed. * platform/graphics/cairo/PlatformPathCairo.h: Removed.
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/platform/SourcesCairo.txt
- trunk/Source/WebCore/platform/graphics/Path.h
- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
- trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp
Removed Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (258203 => 258204)
--- trunk/Source/WebCore/ChangeLog 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/ChangeLog 2020-03-10 13:50:26 UTC (rev 258204)
@@ -1,3 +1,52 @@
+2020-03-10 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [Cairo] Remove PlatformPathCairo
+ https://bugs.webkit.org/show_bug.cgi?id=208807
+
+ Reviewed by Darin Adler.
+
+ We have a class CairoPath defined in PlatformPathCairo.h that simply wraps a cairo_t. We can use the cairo_t
+ directly as PlatformPath and simplify the cairo path implementation.
+
+ * platform/SourcesCairo.txt:
+ * platform/graphics/Path.h:
+ (WebCore::Path::platformPath const):
+ * platform/graphics/cairo/CairoOperations.cpp:
+ (WebCore::Cairo::fillRectWithRoundedHole):
+ (WebCore::Cairo::fillPath):
+ (WebCore::Cairo::strokePath):
+ (WebCore::Cairo::clipPath):
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ (WebCore::appendWebCorePathToCairoContext):
+ * platform/graphics/cairo/FontCairo.cpp:
+ (WebCore::Font::platformPathForGlyph const):
+ * platform/graphics/cairo/PathCairo.cpp:
+ (WebCore::Path::Path):
+ (WebCore::Path::ensurePlatformPath):
+ (WebCore::Path::operator=):
+ (WebCore::Path::clear):
+ (WebCore::Path::isEmptySlowCase const):
+ (WebCore::Path::currentPointSlowCase const):
+ (WebCore::Path::translate):
+ (WebCore::Path::moveToSlowCase):
+ (WebCore::Path::addLineToSlowCase):
+ (WebCore::Path::addRect):
+ (WebCore::Path::addQuadCurveTo):
+ (WebCore::Path::addBezierCurveTo):
+ (WebCore::Path::addArcSlowCase):
+ (WebCore::Path::addArcTo):
+ (WebCore::Path::addEllipse):
+ (WebCore::Path::addPath):
+ (WebCore::Path::closeSubpath):
+ (WebCore::Path::boundingRectSlowCase const):
+ (WebCore::Path::strokeBoundingRect const):
+ (WebCore::Path::contains const):
+ (WebCore::Path::strokeContains const):
+ (WebCore::Path::applySlowCase const):
+ (WebCore::Path::transform):
+ * platform/graphics/cairo/PlatformPathCairo.cpp: Removed.
+ * platform/graphics/cairo/PlatformPathCairo.h: Removed.
+
2020-03-10 youenn fablet <you...@apple.com>
[iOS] Make sure a MediStreamTrack clone does not interrupt the being cloned track
Modified: trunk/Source/WebCore/platform/SourcesCairo.txt (258203 => 258204)
--- trunk/Source/WebCore/platform/SourcesCairo.txt 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/SourcesCairo.txt 2020-03-10 13:50:26 UTC (rev 258204)
@@ -40,5 +40,4 @@
platform/graphics/cairo/PathCairo.cpp
platform/graphics/cairo/PatternCairo.cpp
platform/graphics/cairo/PlatformContextCairo.cpp
-platform/graphics/cairo/PlatformPathCairo.cpp
platform/graphics/cairo/RefPtrCairo.cpp
Modified: trunk/Source/WebCore/platform/graphics/Path.h (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/Path.h 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/Path.h 2020-03-10 13:50:26 UTC (rev 258204)
@@ -55,12 +55,8 @@
}
#elif USE(CAIRO)
+#include "RefPtrCairo.h"
-namespace WebCore {
-class CairoPath;
-}
-typedef WebCore::CairoPath PlatformPath;
-
#elif USE(WINGDI)
namespace WebCore {
@@ -74,6 +70,7 @@
#endif
+#if !USE(CAIRO)
typedef PlatformPath* PlatformPathPtr;
#if USE(CG)
@@ -83,6 +80,7 @@
#else
using PlatformPathStorageType = PlatformPathPtr;
#endif
+#endif
namespace WTF {
class TextStream;
@@ -188,11 +186,18 @@
PlatformPathPtr platformPath() const { return m_path.get(); }
#elif USE(CG)
WEBCORE_EXPORT PlatformPathPtr platformPath() const;
+#elif USE(CAIRO)
+ cairo_t* cairoPath() const { return m_path.get(); }
#else
PlatformPathPtr platformPath() const { return m_path; }
#endif
+
// ensurePlatformPath() will allocate a PlatformPath if it has not yet been and will never return null.
+#if USE(CAIRO)
+ cairo_t* ensureCairoPath();
+#else
WEBCORE_EXPORT PlatformPathPtr ensurePlatformPath();
+#endif
WEBCORE_EXPORT void apply(const PathApplierFunction&) const;
void transform(const AffineTransform&);
@@ -251,7 +256,11 @@
void swap(Path&);
#endif
+#if USE(CAIRO)
+ RefPtr<cairo_t> m_path;
+#else
mutable PlatformPathStorageType m_path;
+#endif
#if USE(DIRECT2D)
Vector<ID2D1Geometry*> m_geometries;
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2020-03-10 13:50:26 UTC (rev 258204)
@@ -46,7 +46,6 @@
#include "ImageBuffer.h"
#include "Path.h"
#include "PlatformContextCairo.h"
-#include "PlatformPathCairo.h"
#include "ShadowBlur.h"
#include <algorithm>
#include <cairo.h>
@@ -780,7 +779,7 @@
cairo_t* cr = platformContext.cr();
cairo_save(cr);
- setPathOnCairoContext(platformContext.cr(), path.platformPath()->context());
+ setPathOnCairoContext(platformContext.cr(), path.cairoPath());
fillCurrentCairoPath(platformContext, fillSource);
cairo_restore(cr);
}
@@ -789,7 +788,7 @@
{
cairo_t* cr = platformContext.cr();
- setPathOnCairoContext(cr, path.platformPath()->context());
+ setPathOnCairoContext(cr, path.cairoPath());
drawPathShadow(platformContext, fillSource, { }, shadowState, Fill);
fillCurrentCairoPath(platformContext, fillSource);
}
@@ -812,7 +811,7 @@
{
cairo_t* cr = platformContext.cr();
- setPathOnCairoContext(cr, path.platformPath()->context());
+ setPathOnCairoContext(cr, path.cairoPath());
drawPathShadow(platformContext, { }, strokeSource, shadowState, Stroke);
prepareForStroking(cr, strokeSource, PreserveAlpha);
cairo_stroke(cr);
@@ -1285,7 +1284,7 @@
cairo_t* cr = platformContext.cr();
if (!path.isNull())
- setPathOnCairoContext(cr, path.platformPath()->context());
+ setPathOnCairoContext(cr, path.cairoPath());
cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, clipRule == WindRule::EvenOdd ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2020-03-10 13:50:26 UTC (rev 258204)
@@ -35,7 +35,6 @@
#include "FloatRect.h"
#include "IntRect.h"
#include "Path.h"
-#include "PlatformPathCairo.h"
#include "RefPtrCairo.h"
#include "Region.h"
#include <wtf/Assertions.h>
@@ -109,7 +108,7 @@
{
if (path.isEmpty())
return;
- appendPathToCairoContext(context, path.platformPath()->context());
+ appendPathToCairoContext(context, path.cairoPath());
}
void appendRegionToCairoContext(cairo_t* to, const cairo_region_t* region)
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2020-03-10 13:50:26 UTC (rev 258204)
@@ -43,7 +43,6 @@
#include "ImageBuffer.h"
#include "Pattern.h"
#include "PlatformContextCairo.h"
-#include "PlatformPathCairo.h"
#include "ShadowBlur.h"
namespace WebCore {
@@ -83,16 +82,16 @@
Path Font::platformPathForGlyph(Glyph glyph) const
{
Path path;
- path.ensurePlatformPath();
+ cairo_t* cr = path.ensureCairoPath();
cairo_glyph_t cairoGlyph = { glyph, 0, 0 };
- cairo_set_scaled_font(path.platformPath()->context(), platformData().scaledFont());
- cairo_glyph_path(path.platformPath()->context(), &cairoGlyph, 1);
+ cairo_set_scaled_font(cr, platformData().scaledFont());
+ cairo_glyph_path(cr, &cairoGlyph, 1);
float syntheticBoldOffset = this->syntheticBoldOffset();
if (syntheticBoldOffset) {
- cairo_translate(path.platformPath()->context(), syntheticBoldOffset, 0);
- cairo_glyph_path(path.platformPath()->context(), &cairoGlyph, 1);
+ cairo_translate(cr, syntheticBoldOffset, 0);
+ cairo_glyph_path(cr, &cairoGlyph, 1);
}
return path;
}
Modified: trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2020-03-10 13:50:26 UTC (rev 258204)
@@ -5,7 +5,7 @@
2005, 2007 Apple Inc. All Rights reserved.
2007 Alp Toker <a...@atoker.com>
2008 Dirk Schulze <k...@webkit.org>
- 2011 Igalia S.L.
+ 2011, 2020 Igalia S.L.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -31,7 +31,6 @@
#include "CairoUtilities.h"
#include "FloatRect.h"
#include "GraphicsContextImplCairo.h"
-#include "PlatformPathCairo.h"
#include "StrokeStyleApplier.h"
#include <math.h>
#include <wtf/MathExtras.h>
@@ -39,40 +38,30 @@
namespace WebCore {
-Path::Path()
- : m_path(0)
-{
-}
+Path::Path() = default;
-Path::~Path()
-{
- if (m_path)
- delete m_path;
-}
+Path::~Path() = default;
+Path::Path(Path&&) = default;
+
+Path& Path::operator=(Path&&) = default;
+
Path::Path(const Path& other)
- : m_path(0)
{
if (other.isNull())
return;
- cairo_t* cr = ensurePlatformPath()->context();
- auto pathCopy = cairo_copy_path(other.platformPath()->context());
+ cairo_t* cr = ensureCairoPath();
+ auto pathCopy = cairo_copy_path(other.m_path.get());
cairo_append_path(cr, pathCopy);
cairo_path_destroy(pathCopy);
}
-
-Path::Path(Path&& other)
-{
- m_path = other.m_path;
- other.m_path = nullptr;
-}
-PlatformPathPtr Path::ensurePlatformPath()
+cairo_t* Path::ensureCairoPath()
{
if (!m_path)
- m_path = new CairoPath();
- return m_path;
+ m_path = adoptRef(cairo_create(adoptRef(cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1)).get()));
+ return m_path.get();
}
Path& Path::operator=(const Path& other)
@@ -81,31 +70,18 @@
return *this;
if (other.isNull()) {
- if (m_path) {
- delete m_path;
- m_path = 0;
- }
- } else {
- clear();
- cairo_t* cr = ensurePlatformPath()->context();
- auto pathCopy = cairo_copy_path(other.platformPath()->context());
- cairo_append_path(cr, pathCopy);
- cairo_path_destroy(pathCopy);
+ m_path = nullptr;
+ return *this;
}
+ clear();
+ cairo_t* cr = ensureCairoPath();
+ auto pathCopy = cairo_copy_path(other.m_path.get());
+ cairo_append_path(cr, pathCopy);
+ cairo_path_destroy(pathCopy);
+
return *this;
}
-
-Path& Path::operator=(Path&& other)
-{
- if (this == &other)
- return *this;
- if (m_path)
- delete m_path;
- m_path = other.m_path;
- other.m_path = nullptr;
- return *this;
-}
void Path::clear()
{
@@ -112,14 +88,13 @@
if (isNull())
return;
- cairo_t* cr = platformPath()->context();
- cairo_identity_matrix(cr);
- cairo_new_path(cr);
+ cairo_identity_matrix(m_path.get());
+ cairo_new_path(m_path.get());
}
bool Path::isEmptySlowCase() const
{
- return !cairo_has_current_point(platformPath()->context());
+ return !cairo_has_current_point(m_path.get());
}
FloatPoint Path::currentPointSlowCase() const
@@ -127,63 +102,54 @@
// FIXME: Is this the correct way?
double x;
double y;
- cairo_get_current_point(platformPath()->context(), &x, &y);
+ cairo_get_current_point(m_path.get(), &x, &y);
return FloatPoint(x, y);
}
void Path::translate(const FloatSize& p)
{
- cairo_t* cr = ensurePlatformPath()->context();
- cairo_translate(cr, -p.width(), -p.height());
+ cairo_translate(ensureCairoPath(), -p.width(), -p.height());
}
void Path::moveToSlowCase(const FloatPoint& p)
{
- cairo_t* cr = ensurePlatformPath()->context();
- cairo_move_to(cr, p.x(), p.y());
+ cairo_move_to(ensureCairoPath(), p.x(), p.y());
}
void Path::addLineToSlowCase(const FloatPoint& p)
{
- cairo_t* cr = ensurePlatformPath()->context();
- cairo_line_to(cr, p.x(), p.y());
+ cairo_line_to(ensureCairoPath(), p.x(), p.y());
}
void Path::addRect(const FloatRect& rect)
{
- cairo_t* cr = ensurePlatformPath()->context();
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_rectangle(ensureCairoPath(), rect.x(), rect.y(), rect.width(), rect.height());
}
-/*
- * inspired by libsvg-cairo
- */
void Path::addQuadCurveToSlowCase(const FloatPoint& controlPoint, const FloatPoint& point)
{
- cairo_t* cr = ensurePlatformPath()->context();
double x, y;
double x1 = controlPoint.x();
double y1 = controlPoint.y();
double x2 = point.x();
double y2 = point.y();
+ cairo_t* cr = ensureCairoPath();
cairo_get_current_point(cr, &x, &y);
cairo_curve_to(cr,
- x + 2.0 / 3.0 * (x1 - x), y + 2.0 / 3.0 * (y1 - y),
- x2 + 2.0 / 3.0 * (x1 - x2), y2 + 2.0 / 3.0 * (y1 - y2),
- x2, y2);
+ x + 2.0 / 3.0 * (x1 - x), y + 2.0 / 3.0 * (y1 - y),
+ x2 + 2.0 / 3.0 * (x1 - x2), y2 + 2.0 / 3.0 * (y1 - y2),
+ x2, y2);
}
void Path::addBezierCurveToSlowCase(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3)
{
- cairo_t* cr = ensurePlatformPath()->context();
- cairo_curve_to(cr, controlPoint1.x(), controlPoint1.y(),
- controlPoint2.x(), controlPoint2.y(),
- controlPoint3.x(), controlPoint3.y());
+ cairo_curve_to(ensureCairoPath(), controlPoint1.x(), controlPoint1.y(),
+ controlPoint2.x(), controlPoint2.y(), controlPoint3.x(), controlPoint3.y());
}
void Path::addArcSlowCase(const FloatPoint& p, float r, float startAngle, float endAngle, bool anticlockwise)
{
- cairo_t* cr = ensurePlatformPath()->context();
+ cairo_t* cr = ensureCairoPath();
float sweep = endAngle - startAngle;
const float twoPI = 2 * piFloat;
if ((sweep <= -twoPI || sweep >= twoPI)
@@ -213,10 +179,8 @@
if (isEmpty())
return;
- cairo_t* cr = platformPath()->context();
-
double x0, y0;
- cairo_get_current_point(cr, &x0, &y0);
+ cairo_get_current_point(m_path.get(), &x0, &y0);
FloatPoint p0(x0, y0);
// Draw only a straight line to p1 if any of the points are equal or the radius is zero
@@ -223,7 +187,7 @@
// or the points are collinear (triangle that the points form has area of zero value).
if ((p1.x() == p0.x() && p1.y() == p0.y()) || (p1.x() == p2.x() && p1.y() == p2.y()) || !radius
|| !areaOfTriangleFormedByPoints(p0, p1, p2)) {
- cairo_line_to(cr, p1.x(), p1.y());
+ cairo_line_to(m_path.get(), p1.x(), p1.y());
return;
}
@@ -231,11 +195,10 @@
FloatPoint p1p2((p2.x() - p1.x()),(p2.y() - p1.y()));
float p1p0_length = std::hypot(p1p0.x(), p1p0.y());
float p1p2_length = std::hypot(p1p2.x(), p1p2.y());
-
double cos_phi = (p1p0.x() * p1p2.x() + p1p0.y() * p1p2.y()) / (p1p0_length * p1p2_length);
// all points on a line logic
if (cos_phi == -1) {
- cairo_line_to(cr, p1.x(), p1.y());
+ cairo_line_to(m_path.get(), p1.x(), p1.y());
return;
}
if (cos_phi == 1) {
@@ -243,7 +206,7 @@
unsigned int max_length = 65535;
double factor_max = max_length / p1p0_length;
FloatPoint ep((p0.x() + factor_max * p1p0.x()), (p0.y() + factor_max * p1p0.y()));
- cairo_line_to(cr, ep.x(), ep.y());
+ cairo_line_to(m_path.get(), ep.x(), ep.y());
return;
}
@@ -283,7 +246,7 @@
if ((sa < ea) && ((ea - sa) > piDouble))
anticlockwise = true;
- cairo_line_to(cr, t_p1p0.x(), t_p1p0.y());
+ cairo_line_to(m_path.get(), t_p1p0.x(), t_p1p0.y());
addArc(p, radius, sa, ea, anticlockwise);
}
@@ -290,7 +253,7 @@
void Path::addEllipse(FloatPoint point, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise)
{
- cairo_t* cr = ensurePlatformPath()->context();
+ cairo_t* cr = ensureCairoPath();
cairo_save(cr);
cairo_translate(cr, point.x(), point.y());
cairo_rotate(cr, rotation);
@@ -306,7 +269,7 @@
void Path::addEllipse(const FloatRect& rect)
{
- cairo_t* cr = ensurePlatformPath()->context();
+ cairo_t* cr = ensureCairoPath();
cairo_save(cr);
float yRadius = .5 * rect.height();
float xRadius = .5 * rect.width();
@@ -325,26 +288,24 @@
if (cairo_matrix_invert(&matrix) != CAIRO_STATUS_SUCCESS)
return;
- cairo_t* cr = path.platformPath()->context();
+ cairo_t* cr = path.cairoPath();
cairo_save(cr);
cairo_transform(cr, &matrix);
auto pathCopy = cairo_copy_path(cr);
cairo_restore(cr);
- cairo_append_path(ensurePlatformPath()->context(), pathCopy);
+ cairo_append_path(ensureCairoPath(), pathCopy);
cairo_path_destroy(pathCopy);
}
void Path::closeSubpath()
{
- cairo_t* cr = ensurePlatformPath()->context();
- cairo_close_path(cr);
+ cairo_close_path(ensureCairoPath());
}
FloatRect Path::boundingRectSlowCase() const
{
- cairo_t* cr = platformPath()->context();
double x0, x1, y0, y1;
- cairo_path_extents(cr, &x0, &y0, &x1, &y1);
+ cairo_path_extents(m_path.get(), &x0, &y0, &x1, &y1);
return FloatRect(x0, y0, x1 - x0, y1 - y0);
}
@@ -354,14 +315,13 @@
if (isNull())
return FloatRect();
- cairo_t* cr = platformPath()->context();
if (applier) {
- GraphicsContext gc(GraphicsContextImplCairo::createFactory(cr));
+ GraphicsContext gc(GraphicsContextImplCairo::createFactory(m_path.get()));
applier->strokeStyle(&gc);
}
double x0, x1, y0, y1;
- cairo_stroke_extents(cr, &x0, &y0, &x1, &y1);
+ cairo_stroke_extents(m_path.get(), &x0, &y0, &x1, &y1);
return FloatRect(x0, y0, x1 - x0, y1 - y0);
}
@@ -369,11 +329,11 @@
{
if (isNull() || !std::isfinite(point.x()) || !std::isfinite(point.y()))
return false;
- cairo_t* cr = platformPath()->context();
- cairo_fill_rule_t cur = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, rule == WindRule::EvenOdd ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- bool contains = cairo_in_fill(cr, point.x(), point.y());
- cairo_set_fill_rule(cr, cur);
+
+ cairo_fill_rule_t cur = cairo_get_fill_rule(m_path.get());
+ cairo_set_fill_rule(m_path.get(), rule == WindRule::EvenOdd ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+ bool contains = cairo_in_fill(m_path.get(), point.x(), point.y());
+ cairo_set_fill_rule(m_path.get(), cur);
return contains;
}
@@ -382,19 +342,17 @@
if (isNull())
return false;
- cairo_t* cr = platformPath()->context();
{
- GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(cr));
+ GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(m_path.get()));
applier.strokeStyle(&graphicsContext);
}
- return cairo_in_stroke(cr, point.x(), point.y());
+ return cairo_in_stroke(m_path.get(), point.x(), point.y());
}
void Path::applySlowCase(const PathApplierFunction& function) const
{
- cairo_t* cr = platformPath()->context();
- auto pathCopy = cairo_copy_path(cr);
+ auto pathCopy = cairo_copy_path(m_path.get());
cairo_path_data_t* data;
PathElement pathElement;
@@ -434,10 +392,9 @@
void Path::transform(const AffineTransform& transform)
{
- cairo_t* cr = ensurePlatformPath()->context();
cairo_matrix_t matrix = toCairoMatrix(transform);
cairo_matrix_invert(&matrix);
- cairo_transform(cr, &matrix);
+ cairo_transform(ensureCairoPath(), &matrix);
}
bool Path::isNull() const
Deleted: trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp 2020-03-10 13:50:26 UTC (rev 258204)
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2011 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "PlatformPathCairo.h"
-
-#if USE(CAIRO)
-
-#include <cairo.h>
-
-namespace WebCore {
-
-CairoPath::CairoPath()
-{
- // cairo_t takes its own reference of the surface, meaning we don't have to keep one.
- auto surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1));
- m_context = adoptRef(cairo_create(surface.get()));
-}
-
-} // namespace WebCore
-
-#endif // USE(CAIRO)
Deleted: trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h (258203 => 258204)
--- trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h 2020-03-10 13:21:51 UTC (rev 258203)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h 2020-03-10 13:50:26 UTC (rev 258204)
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp.to...@collabora.co.uk>
- * Copyright (C) 2010 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#if USE(CAIRO)
-
-#include "RefPtrCairo.h"
-
-namespace WebCore {
-
-// This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
-class CairoPath {
-public:
- CairoPath();
- ~CairoPath() = default;
-
- cairo_t* context() { return m_context.get(); }
-
-private:
- RefPtr<cairo_t> m_context;
-};
-
-} // namespace WebCore
-
-#endif // USE(CAIRO)
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes