From 189060aaca390b0788fe8cb7115f8afca51dd85d Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Tue, 3 Dec 2019 21:36:29 +0000 Subject: [PATCH] switch over to new enum SkPathFillType TBR= Change-Id: I4607f91a8efb87202d68311894f67bc69a8f8e8a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1948487 Commit-Queue: Mike Reed Reviewed-by: Florin Malita Reviewed-by: Chris Harrelson Reviewed-by: James Cook Reviewed-by: Mitsuru Oshima Reviewed-by: Robert Liao Cr-Commit-Position: refs/heads/master@{#721177} --- ash/public/cpp/network_icon_image_source.cc | 2 +- skia/config/SkUserConfig.h | 4 ---- skia/ext/benchmarking_canvas.cc | 6 +++--- .../blink/renderer/core/paint/box_border_painter.cc | 2 +- .../blink/renderer/core/paint/svg_shape_painter.cc | 10 +++++----- .../blink/renderer/core/paint/svg_shape_painter.h | 2 +- .../canvas/canvas2d/base_rendering_context_2d.cc | 10 +++++----- .../canvas/canvas2d/base_rendering_context_2d.h | 2 +- .../blink/renderer/platform/graphics/graphics_types.h | 4 ++-- .../blink/renderer/platform/graphics/logging_canvas.cc | 10 +++++----- third_party/blink/renderer/platform/graphics/path.cc | 2 +- .../blink/renderer/platform/graphics/skia/skia_utils.h | 10 +++++----- ui/gfx/paint_vector_icon.cc | 2 +- ui/gfx/path_mac.mm | 8 ++++---- ui/gfx/path_mac_unittest.mm | 4 ++-- ui/views/controls/menu/menu_scroll_view_container.cc | 2 +- 16 files changed, 38 insertions(+), 42 deletions(-) diff --git a/ash/public/cpp/network_icon_image_source.cc b/ash/public/cpp/network_icon_image_source.cc index 5dfd2d02ece3d6..937ad42c4156f8 100644 --- a/ash/public/cpp/network_icon_image_source.cc +++ b/ash/public/cpp/network_icon_image_source.cc @@ -29,7 +29,7 @@ constexpr int kSignalStrengthImageBgAlpha = 0x4D; SkPath CreateArcPath(gfx::RectF oval, float start_angle, float sweep_angle) { SkPath path; path.setIsVolatile(true); - path.setFillType(SkPath::kWinding_FillType); + path.setFillType(SkPathFillType::kWinding); path.moveTo(oval.CenterPoint().x(), oval.CenterPoint().y()); path.arcTo(gfx::RectFToSkRect(oval), start_angle, sweep_angle, false); path.close(); diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h index 3b5e5799cee1c6..178c02752baa1c 100644 --- a/skia/config/SkUserConfig.h +++ b/skia/config/SkUserConfig.h @@ -215,10 +215,6 @@ SK_API void SkDebugf_FileLine(const char* file, #define SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS #endif -#ifndef SK_SUPPORT_LEGACY_PATH_FILLTYPE_ENUM -#define SK_SUPPORT_LEGACY_PATH_FILLTYPE_ENUM -#endif - // Max. verb count for paths rendered by the edge-AA tessellating path renderer. #define GR_AA_TESSELLATOR_MAX_VERB_COUNT 100 diff --git a/skia/ext/benchmarking_canvas.cc b/skia/ext/benchmarking_canvas.cc index e13b161bb652b0..97caba5e88a721 100644 --- a/skia/ext/benchmarking_canvas.cc +++ b/skia/ext/benchmarking_canvas.cc @@ -267,9 +267,9 @@ std::unique_ptr AsValue(const SkPath& path) { static const char* gFillStrings[] = { "winding", "even-odd", "inverse-winding", "inverse-even-odd" }; - DCHECK_LT(static_cast(path.getFillType()), - SK_ARRAY_COUNT(gFillStrings)); - val->SetString("fill-type", gFillStrings[path.getFillType()]); + size_t index = static_cast(path.getFillType()); + DCHECK_LT(index, SK_ARRAY_COUNT(gFillStrings)); + val->SetString("fill-type", gFillStrings[index]); static const char* gConvexityStrings[] = { "Unknown", "Convex", "Concave" }; DCHECK_LT(static_cast(path.getConvexityType()), diff --git a/third_party/blink/renderer/core/paint/box_border_painter.cc b/third_party/blink/renderer/core/paint/box_border_painter.cc index a15c2715d7b717..eace1c00a236c0 100644 --- a/third_party/blink/renderer/core/paint/box_border_painter.cc +++ b/third_party/blink/renderer/core/paint/box_border_painter.cc @@ -330,7 +330,7 @@ void DrawBleedAdjustedDRRect(GraphicsContext& context, // int rect for the clip, in device space). SkPath path; path.addRRect(inner); - path.setFillType(SkPath::kInverseWinding_FillType); + path.setFillType(SkPathFillType::kInverseWinding); PaintFlags flags; flags.setColor(color.Rgb()); diff --git a/third_party/blink/renderer/core/paint/svg_shape_painter.cc b/third_party/blink/renderer/core/paint/svg_shape_painter.cc index b2eeaceb048f79..0aea12af64bae4 100644 --- a/third_party/blink/renderer/core/paint/svg_shape_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_shape_painter.cc @@ -34,8 +34,8 @@ static bool SetupNonScalingStrokeContext( return true; } -static SkPath::FillType FillRuleFromStyle(const PaintInfo& paint_info, - const SVGComputedStyle& svg_style) { +static SkPathFillType FillRuleFromStyle(const PaintInfo& paint_info, + const SVGComputedStyle& svg_style) { return WebCoreWindRuleToSkFillType(paint_info.IsRenderingClipPathAsMaskImage() ? svg_style.ClipRule() : svg_style.FillRule()); @@ -145,7 +145,7 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) { class PathWithTemporaryWindingRule { public: - PathWithTemporaryWindingRule(Path& path, SkPath::FillType fill_type) + PathWithTemporaryWindingRule(Path& path, SkPathFillType fill_type) : path_(const_cast(path.GetSkPath())) { saved_fill_type_ = path_.getFillType(); path_.setFillType(fill_type); @@ -156,12 +156,12 @@ class PathWithTemporaryWindingRule { private: SkPath& path_; - SkPath::FillType saved_fill_type_; + SkPathFillType saved_fill_type_; }; void SVGShapePainter::FillShape(GraphicsContext& context, const PaintFlags& flags, - SkPath::FillType fill_type) { + SkPathFillType fill_type) { switch (layout_svg_shape_.GeometryCodePath()) { case kRectGeometryFastPath: context.DrawRect(layout_svg_shape_.ObjectBoundingBox(), flags, diff --git a/third_party/blink/renderer/core/paint/svg_shape_painter.h b/third_party/blink/renderer/core/paint/svg_shape_painter.h index 9c3ce8820718f2..7be80f488358bc 100644 --- a/third_party/blink/renderer/core/paint/svg_shape_painter.h +++ b/third_party/blink/renderer/core/paint/svg_shape_painter.h @@ -28,7 +28,7 @@ class SVGShapePainter { void Paint(const PaintInfo&); private: - void FillShape(GraphicsContext&, const PaintFlags&, SkPath::FillType); + void FillShape(GraphicsContext&, const PaintFlags&, SkPathFillType); void StrokeShape(GraphicsContext&, const PaintFlags&); void PaintMarkers(const PaintInfo&, const FloatRect& bounding_box); diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc index 57dcff692cfeb6..78833214386948 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc @@ -609,7 +609,7 @@ bool BaseRenderingContext2D::IsFullCanvasCompositeMode(SkBlendMode op) { void BaseRenderingContext2D::DrawPathInternal( const Path& path, CanvasRenderingContext2DState::PaintType paint_type, - SkPath::FillType fill_type) { + SkPathFillType fill_type) { if (path.IsEmpty()) return; @@ -633,14 +633,14 @@ void BaseRenderingContext2D::DrawPathInternal( bounds, paint_type); } -static SkPath::FillType ParseWinding(const String& winding_rule_string) { +static SkPathFillType ParseWinding(const String& winding_rule_string) { if (winding_rule_string == "nonzero") - return SkPath::kWinding_FillType; + return SkPathFillType::kWinding; if (winding_rule_string == "evenodd") - return SkPath::kEvenOdd_FillType; + return SkPathFillType::kEvenOdd; NOTREACHED(); - return SkPath::kEvenOdd_FillType; + return SkPathFillType::kEvenOdd; } void BaseRenderingContext2D::fill(const String& winding_rule_string) { diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h index d9546859f75ae1..53c5a939a9362a 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h +++ b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h @@ -386,7 +386,7 @@ class MODULES_EXPORT BaseRenderingContext2D : public GarbageCollectedMixin, void DrawPathInternal(const Path&, CanvasRenderingContext2DState::PaintType, - SkPath::FillType = SkPath::kWinding_FillType); + SkPathFillType = SkPathFillType::kWinding); void DrawImageInternal(cc::PaintCanvas*, CanvasImageSource*, Image*, diff --git a/third_party/blink/renderer/platform/graphics/graphics_types.h b/third_party/blink/renderer/platform/graphics/graphics_types.h index 425cd594c29974..237d6c5ac940ef 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_types.h +++ b/third_party/blink/renderer/platform/graphics/graphics_types.h @@ -197,8 +197,8 @@ enum ColorFilter { }; enum WindRule { - RULE_NONZERO = SkPath::kWinding_FillType, - RULE_EVENODD = SkPath::kEvenOdd_FillType + RULE_NONZERO = static_cast(SkPathFillType::kWinding), + RULE_EVENODD = static_cast(SkPathFillType::kEvenOdd) }; PLATFORM_EXPORT String CompositeOperatorName(CompositeOperator, BlendMode); diff --git a/third_party/blink/renderer/platform/graphics/logging_canvas.cc b/third_party/blink/renderer/platform/graphics/logging_canvas.cc index 170261690ac2d7..b22ea1d9e6dc5a 100644 --- a/third_party/blink/renderer/platform/graphics/logging_canvas.cc +++ b/third_party/blink/renderer/platform/graphics/logging_canvas.cc @@ -169,15 +169,15 @@ std::unique_ptr ObjectForSkRRect(const SkRRect& rrect) { return rrect_item; } -String FillTypeName(SkPath::FillType type) { +String FillTypeName(SkPathFillType type) { switch (type) { - case SkPath::kWinding_FillType: + case SkPathFillType::kWinding: return "Winding"; - case SkPath::kEvenOdd_FillType: + case SkPathFillType::kEvenOdd: return "EvenOdd"; - case SkPath::kInverseWinding_FillType: + case SkPathFillType::kInverseWinding: return "InverseWinding"; - case SkPath::kInverseEvenOdd_FillType: + case SkPathFillType::kInverseEvenOdd: return "InverseEvenOdd"; default: NOTREACHED(); diff --git a/third_party/blink/renderer/platform/graphics/path.cc b/third_party/blink/renderer/platform/graphics/path.cc index a116f6f4367e7f..f45069b7a155e8 100644 --- a/third_party/blink/renderer/platform/graphics/path.cc +++ b/third_party/blink/renderer/platform/graphics/path.cc @@ -73,7 +73,7 @@ bool Path::Contains(const FloatPoint& point, WindRule rule) const { return false; SkScalar x = point.X(); SkScalar y = point.Y(); - SkPath::FillType fill_type = WebCoreWindRuleToSkFillType(rule); + SkPathFillType fill_type = WebCoreWindRuleToSkFillType(rule); if (path_.getFillType() != fill_type) { SkPath tmp(path_); tmp.setFillType(fill_type); diff --git a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h index f6edaa4ada58b5..b5f81ee0f40a9e 100644 --- a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h +++ b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h @@ -95,14 +95,14 @@ inline bool WebCoreFloatNearlyEqual(float a, float b) { WebCoreFloatToSkScalar(b)); } -inline SkPath::FillType WebCoreWindRuleToSkFillType(WindRule rule) { - return static_cast(rule); +inline SkPathFillType WebCoreWindRuleToSkFillType(WindRule rule) { + return static_cast(rule); } -inline WindRule SkFillTypeToWindRule(SkPath::FillType fill_type) { +inline WindRule SkFillTypeToWindRule(SkPathFillType fill_type) { switch (fill_type) { - case SkPath::kWinding_FillType: - case SkPath::kEvenOdd_FillType: + case SkPathFillType::kWinding: + case SkPathFillType::kEvenOdd: return static_cast(fill_type); default: NOTREACHED(); diff --git a/ui/gfx/paint_vector_icon.cc b/ui/gfx/paint_vector_icon.cc index 17b4efac7b7736..d69b25bcf1bcd6 100644 --- a/ui/gfx/paint_vector_icon.cc +++ b/ui/gfx/paint_vector_icon.cc @@ -234,7 +234,7 @@ void PaintPath(Canvas* canvas, const CommandType command_type = parser.CurrentCommand(); auto start_new_path = [&paths]() { paths.push_back(SkPath()); - paths.back().setFillType(SkPath::kEvenOdd_FillType); + paths.back().setFillType(SkPathFillType::kEvenOdd); }; auto start_new_flags = [&flags_array, &color]() { flags_array.push_back(cc::PaintFlags()); diff --git a/ui/gfx/path_mac.mm b/ui/gfx/path_mac.mm index 3cf70eeeea801f..e74aa2906a2aff 100644 --- a/ui/gfx/path_mac.mm +++ b/ui/gfx/path_mac.mm @@ -108,14 +108,14 @@ void ConvertQuadToCubicBezier(NSPoint quad[3], NSPoint cubic[4]) { // Set up the fill type. switch (path.getFillType()) { - case SkPath::kWinding_FillType: + case SkPathFillType::kWinding: [result setWindingRule:NSNonZeroWindingRule]; break; - case SkPath::kEvenOdd_FillType: + case SkPathFillType::kEvenOdd: [result setWindingRule:NSEvenOddWindingRule]; break; - case SkPath::kInverseWinding_FillType: - case SkPath::kInverseEvenOdd_FillType: + case SkPathFillType::kInverseWinding: + case SkPathFillType::kInverseEvenOdd: NOTREACHED() << "NSBezierCurve does not support inverse fill types."; break; } diff --git a/ui/gfx/path_mac_unittest.mm b/ui/gfx/path_mac_unittest.mm index 522e7ce5045d9f..0953cc82d68488 100644 --- a/ui/gfx/path_mac_unittest.mm +++ b/ui/gfx/path_mac_unittest.mm @@ -97,11 +97,11 @@ Rect GetBoundingBox(NSBezierPath* path) { // Check that the returned NSBezierPath has the correct winding rule. TEST(CreateNSBezierPathFromSkPathTest, FillType) { SkPath path; - path.setFillType(SkPath::kWinding_FillType); + path.setFillType(SkPathFillType::kWinding); NSBezierPath* result = CreateNSBezierPathFromSkPath(path); EXPECT_EQ(NSNonZeroWindingRule, [result windingRule]); - path.setFillType(SkPath::kEvenOdd_FillType); + path.setFillType(SkPathFillType::kEvenOdd); result = CreateNSBezierPathFromSkPath(path); EXPECT_EQ(NSEvenOddWindingRule, [result windingRule]); } diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc index 1b084be1b7b7c2..02cc9cc4d75aef 100644 --- a/ui/views/controls/menu/menu_scroll_view_container.cc +++ b/ui/views/controls/menu/menu_scroll_view_container.cc @@ -98,7 +98,7 @@ class MenuScrollButton : public View { y_bottom = y + config.scroll_arrow_height; } SkPath path; - path.setFillType(SkPath::kWinding_FillType); + path.setFillType(SkPathFillType::kWinding); path.moveTo(SkIntToScalar(x), SkIntToScalar(y)); path.lineTo(SkIntToScalar(x_left), SkIntToScalar(y_bottom)); path.lineTo(SkIntToScalar(x_right), SkIntToScalar(y_bottom));