forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getPointAtLength() for arcs that decompose to multiple beziers
When an arc segment was decomposed into more than one cubic bezier segment, some "residue" (the length of the first part of the cubic that was "flat enough") would accumulate from any segments that followed the one that contained the point. This would make the computed |offset| incorrect. Switch to checking, for each bezier segment, if the we've passed the point (length) that we're querying, and skip adding anything for that bezier segment. Bug: 719516 Change-Id: I0c54e1a07be5fb5edddaded542df0ffd5b0a087c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1939979 Commit-Queue: Fredrik Söderquist <fs@opera.com> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/master@{#720539}
- Loading branch information
Fredrik Söderquist
authored and
Commit Bot
committed
Dec 2, 2019
1 parent
9faaf3c
commit b8cd2c2
Showing
5 changed files
with
52 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
third_party/blink/renderer/core/svg/svg_path_query_test.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/core/svg/svg_path_query.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "third_party/blink/renderer/core/svg/svg_path_byte_stream.h" | ||
#include "third_party/blink/renderer/core/svg/svg_path_utilities.h" | ||
#include "third_party/blink/renderer/platform/geometry/float_point.h" | ||
|
||
namespace blink { | ||
namespace { | ||
|
||
void PointsApproximatelyEqual(const FloatPoint& p1, | ||
const FloatPoint& p2, | ||
float epsilon) { | ||
EXPECT_NEAR(p1.X(), p2.X(), epsilon); | ||
EXPECT_NEAR(p1.Y(), p2.Y(), epsilon); | ||
} | ||
|
||
TEST(SVGPathQueryTest, PointAtLength_ArcDecomposedToMultipleCubics) { | ||
SVGPathByteStream path_stream; | ||
ASSERT_EQ(BuildByteStreamFromString("M56.2,66.2a174.8,174.8,0,1,0,276.0,-2.0", | ||
path_stream), | ||
SVGParseStatus::kNoError); | ||
|
||
const float step = 7.80249691f; | ||
PointsApproximatelyEqual(SVGPathQuery(path_stream).GetPointAtLength(0), | ||
FloatPoint(56.200f, 66.200f), 0.0005f); | ||
PointsApproximatelyEqual(SVGPathQuery(path_stream).GetPointAtLength(step), | ||
FloatPoint(51.594f, 72.497f), 0.0005f); | ||
PointsApproximatelyEqual(SVGPathQuery(path_stream).GetPointAtLength(2 * step), | ||
FloatPoint(47.270f, 78.991f), 0.0005f); | ||
PointsApproximatelyEqual(SVGPathQuery(path_stream).GetPointAtLength(3 * step), | ||
FloatPoint(43.239f, 85.671f), 0.0005f); | ||
} | ||
|
||
} // namespace | ||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters