Commit ef24657e authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Use base::Optional<> for non-scaling-stroke in SVGShapePainter

Change-Id: I0f7eac3f7af6a1763024a844d01c66a043d074a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502479
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821391}
parent b276d414
...@@ -23,15 +23,16 @@ ...@@ -23,15 +23,16 @@
namespace blink { namespace blink {
static bool SetupNonScalingStrokeContext( static base::Optional<AffineTransform> SetupNonScalingStrokeContext(
AffineTransform& stroke_transform, const LayoutSVGShape& layout_svg_shape,
GraphicsContextStateSaver& state_saver) { GraphicsContextStateSaver& state_saver) {
if (!stroke_transform.IsInvertible()) const AffineTransform& non_scaling_stroke_transform =
return false; layout_svg_shape.NonScalingStrokeTransform();
if (!non_scaling_stroke_transform.IsInvertible())
return base::nullopt;
state_saver.Save(); state_saver.Save();
state_saver.Context().ConcatCTM(stroke_transform.Inverse()); state_saver.Context().ConcatCTM(non_scaling_stroke_transform.Inverse());
return true; return non_scaling_stroke_transform;
} }
static SkPathFillType FillRuleFromStyle(const PaintInfo& paint_info, static SkPathFillType FillRuleFromStyle(const PaintInfo& paint_info,
...@@ -85,27 +86,23 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) { ...@@ -85,27 +86,23 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) {
case PT_STROKE: case PT_STROKE:
if (svg_style.HasVisibleStroke()) { if (svg_style.HasVisibleStroke()) {
GraphicsContextStateSaver state_saver(paint_info.context, false); GraphicsContextStateSaver state_saver(paint_info.context, false);
AffineTransform non_scaling_transform; base::Optional<AffineTransform> non_scaling_transform;
const AffineTransform* additional_paint_server_transform =
nullptr;
if (layout_svg_shape_.HasNonScalingStroke()) { if (layout_svg_shape_.HasNonScalingStroke()) {
non_scaling_transform =
layout_svg_shape_.NonScalingStrokeTransform();
if (!SetupNonScalingStrokeContext(non_scaling_transform,
state_saver))
return;
// Non-scaling stroke needs to reset the transform back to the // Non-scaling stroke needs to reset the transform back to the
// host transform. // host transform.
additional_paint_server_transform = &non_scaling_transform; non_scaling_transform = SetupNonScalingStrokeContext(
layout_svg_shape_, state_saver);
if (!non_scaling_transform)
return;
} }
PaintFlags stroke_flags; PaintFlags stroke_flags;
if (!SVGObjectPainter(layout_svg_shape_) if (!SVGObjectPainter(layout_svg_shape_)
.PreparePaint(paint_info, layout_svg_shape_.StyleRef(), .PreparePaint(
kApplyToStrokeMode, stroke_flags, paint_info, layout_svg_shape_.StyleRef(),
additional_paint_server_transform)) kApplyToStrokeMode, stroke_flags,
base::OptionalOrNullptr(non_scaling_transform)))
break; break;
stroke_flags.setAntiAlias(should_anti_alias); stroke_flags.setAntiAlias(should_anti_alias);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment