Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: src/core/SkPath.cpp

Issue 2021343004: Add a test for crbug 613918 and fix a style issue. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Minimize test and add a comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <cmath> 8 #include <cmath>
9 #include "SkBuffer.h" 9 #include "SkBuffer.h"
10 #include "SkCubicClipper.h" 10 #include "SkCubicClipper.h"
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 if (x < min) { 2806 if (x < min) {
2807 return 0; 2807 return 0;
2808 } 2808 }
2809 if (x > max) { 2809 if (x > max) {
2810 return dir; 2810 return dir;
2811 } 2811 }
2812 2812
2813 // compute the actual x(t) value 2813 // compute the actual x(t) value
2814 SkScalar t; 2814 SkScalar t;
2815 if (!SkCubicClipper::ChopMonoAtY(pts, y, &t)) { 2815 if (!SkCubicClipper::ChopMonoAtY(pts, y, &t)) {
2816 return 0; 2816 return 0;
2817 } 2817 }
2818 SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t); 2818 SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t);
2819 if (SkScalarNearlyEqual(xt, x)) { 2819 if (SkScalarNearlyEqual(xt, x)) {
2820 if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they' re start points 2820 if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they' re start points
2821 *onCurveCount += 1; 2821 *onCurveCount += 1;
2822 return 0; 2822 return 0;
2823 } 2823 }
2824 } 2824 }
2825 return xt < x ? dir : 0; 2825 return xt < x ? dir : 0;
2826 } 2826 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX) 3045 if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX)
3046 && !between(pts[2].fX, x, pts[3].fX)) { 3046 && !between(pts[2].fX, x, pts[3].fX)) {
3047 return; 3047 return;
3048 } 3048 }
3049 SkPoint dst[10]; 3049 SkPoint dst[10];
3050 int n = SkChopCubicAtYExtrema(pts, dst); 3050 int n = SkChopCubicAtYExtrema(pts, dst);
3051 for (int i = 0; i <= n; ++i) { 3051 for (int i = 0; i <= n; ++i) {
3052 SkPoint* c = &dst[i * 3]; 3052 SkPoint* c = &dst[i * 3];
3053 SkScalar t; 3053 SkScalar t;
3054 if (!SkCubicClipper::ChopMonoAtY(c, y, &t)) { 3054 if (!SkCubicClipper::ChopMonoAtY(c, y, &t)) {
3055 continue; 3055 continue;
3056 } 3056 }
3057 SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t); 3057 SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t);
3058 if (!SkScalarNearlyEqual(x, xt)) { 3058 if (!SkScalarNearlyEqual(x, xt)) {
3059 continue; 3059 continue;
3060 } 3060 }
3061 SkVector tangent; 3061 SkVector tangent;
3062 SkEvalCubicAt(c, t, nullptr, &tangent, nullptr); 3062 SkEvalCubicAt(c, t, nullptr, &tangent, nullptr);
3063 tangents->push(tangent); 3063 tangents->push(tangent);
3064 } 3064 }
3065 } 3065 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 } 3242 }
3243 } while (!done); 3243 } while (!done);
3244 return SkToBool(tangents.count()) ^ isInverse; 3244 return SkToBool(tangents.count()) ^ isInverse;
3245 } 3245 }
3246 3246
3247 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2, 3247 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2,
3248 SkScalar w, SkPoint pts[], int pow2) { 3248 SkScalar w, SkPoint pts[], int pow2) {
3249 const SkConic conic(p0, p1, p2, w); 3249 const SkConic conic(p0, p1, p2, w);
3250 return conic.chopIntoQuadsPOW2(pts, pow2); 3250 return conic.chopIntoQuadsPOW2(pts, pow2);
3251 } 3251 }
OLDNEW
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698