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

Adjust the in-angle in BisectingAngle() when the difference is -180

We would previously produce the same angle for 180 -> 0 transitions as
for 0 -> 180 (or similarly 90 -> -90 and -90 -> 90 respectively), which
isn't correct. Tweak the condition in BisectingAngle() to adjust the
in-angle when it is smaller than the out-angle to differentiate the two
cases.

Fixed: 1132525
Change-Id: I191e9e3d4889517f1188ec4a19e71beb8a966ed4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446729Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#815604}
parent 751b5844
......@@ -27,8 +27,10 @@
namespace blink {
static double BisectingAngle(double in_angle, double out_angle) {
double diff = in_angle - out_angle;
// WK193015: Prevent bugs due to angles being non-continuous.
if (fabs(in_angle - out_angle) > 180)
// Use an inclusive lower limit to not produce the same angle for both limits.
if (diff > 180 || diff <= -180)
in_angle += 360;
return (in_angle + out_angle) / 2;
}
......
......@@ -31,6 +31,7 @@
#include <algorithm>
#include <limits>
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/geometry/layout_point.h"
#include "third_party/blink/renderer/platform/geometry/layout_size.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
......@@ -41,7 +42,14 @@
namespace blink {
float FloatPoint::SlopeAngleRadians() const {
#if defined(OS_MAC)
// atan2f(...) returns less accurate results on Mac.
// 3.1415925 vs. 3.14159274 for atan2f(0, -50) as an example.
return static_cast<float>(
atan2(static_cast<double>(y_), static_cast<double>(x_)));
#else
return atan2f(y_, x_);
#endif
}
float FloatPoint::length() const {
......
<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml">
<title>orient='auto' with 180 degree turns</title>
<h:link rel="help" href="https://svgwg.org/svg2-draft/painting.html#RenderingMarkers"/>
<h:link rel="match" href="../../pservers/reftests/reference/green-100x100.svg"/>
<marker id="m" markerWidth="100" markerHeight="50" markerUnits="userSpaceOnUse"
orient="auto" refX="50" refY="50">
<path d="M50,-5L105,50h-110z" fill="green"/>
</marker>
<g marker-start="url(#m)">
<path d="M50,0v50z"/>
<path d="M100,50h-50z"/>
<path d="M50,100v-50z"/>
<path d="M0,50h50z"/>
</g>
</svg>
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