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

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

Issue 2691843003: Make round-caps line segments convex
Patch Set: Created 3 years, 10 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 | no next file » | 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 "SkStrokerPriv.h" 8 #include "SkStrokerPriv.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 11
12 static void ButtCapper(SkPath* path, const SkPoint& pivot, const SkVector& norma l, 12 static void ButtCapper(SkPath* path, const SkPoint& pivot, const SkVector& norma l,
13 const SkPoint& stop, SkPath*) { 13 const SkPoint& stop, SkPath*) {
14 path->lineTo(stop.fX, stop.fY); 14 path->lineTo(stop.fX, stop.fY);
15 } 15 }
16 16
17 static void RoundCapper(SkPath* path, const SkPoint& pivot, const SkVector& norm al, 17 static void RoundCapper(SkPath* path, const SkPoint& pivot, const SkVector& norm al,
18 const SkPoint& stop, SkPath*) { 18 const SkPoint& stop, SkPath*) {
19 SkVector parallel; 19 SkVector parallel;
20 normal.rotateCW(&parallel); 20 normal.rotateCW(&parallel);
21 21
22 SkPoint projectedCenter = pivot + parallel; 22 SkPoint projectedCenter = pivot + parallel;
23 23
24 path->conicTo(projectedCenter + normal, projectedCenter, SK_ScalarRoot2Over2 ); 24 path->conicTo(pivot + (parallel + normal) * 0.999, projectedCenter, SK_Scala rRoot2Over2);
25 path->conicTo(projectedCenter - normal, stop, SK_ScalarRoot2Over2); 25 path->conicTo(pivot + (parallel - normal) * 0.999, stop, SK_ScalarRoot2Over2 );
26 } 26 }
27 27
28 static void SquareCapper(SkPath* path, const SkPoint& pivot, const SkVector& nor mal, 28 static void SquareCapper(SkPath* path, const SkPoint& pivot, const SkVector& nor mal,
29 const SkPoint& stop, SkPath* otherPath) { 29 const SkPoint& stop, SkPath* otherPath) {
30 SkVector parallel; 30 SkVector parallel;
31 normal.rotateCW(&parallel); 31 normal.rotateCW(&parallel);
32 32
33 if (otherPath) { 33 if (otherPath) {
34 path->setLastPt(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY); 34 path->setLastPt(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY);
35 path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY); 35 path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 SkStrokerPriv::JoinProc SkStrokerPriv::JoinFactory(SkPaint::Join join) { 222 SkStrokerPriv::JoinProc SkStrokerPriv::JoinFactory(SkPaint::Join join) {
223 const SkStrokerPriv::JoinProc gJoiners[] = { 223 const SkStrokerPriv::JoinProc gJoiners[] = {
224 MiterJoiner, RoundJoiner, BluntJoiner 224 MiterJoiner, RoundJoiner, BluntJoiner
225 }; 225 };
226 226
227 SkASSERT((unsigned)join < SkPaint::kJoinCount); 227 SkASSERT((unsigned)join < SkPaint::kJoinCount);
228 return gJoiners[join]; 228 return gJoiners[join];
229 } 229 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698