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

Side by Side Diff: src/effects/SkDashPathEffect.cpp

Issue 798093002: improve cull, so we don't create empty segments (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 "SkDashPathEffect.h" 8 #include "SkDashPathEffect.h"
9 9
10 #include "SkDashPathPriv.h" 10 #include "SkDashPathPriv.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (dx) { 87 if (dx) {
88 SkASSERT(dx && !dy); 88 SkASSERT(dx && !dy);
89 SkScalar minX = pts[0].fX; 89 SkScalar minX = pts[0].fX;
90 SkScalar maxX = pts[1].fX; 90 SkScalar maxX = pts[1].fX;
91 91
92 if (dx < 0) { 92 if (dx < 0) {
93 SkTSwap(minX, maxX); 93 SkTSwap(minX, maxX);
94 } 94 }
95 95
96 SkASSERT(minX < maxX); 96 SkASSERT(minX < maxX);
97 if (maxX < bounds.fLeft || minX > bounds.fRight) { 97 if (maxX <= bounds.fLeft || minX >= bounds.fRight) {
98 return false; 98 return false;
99 } 99 }
100 100
101 // Now we actually perform the chop, removing the excess to the left and 101 // Now we actually perform the chop, removing the excess to the left and
102 // right of the bounds (keeping our new line "in phase" with the dash, 102 // right of the bounds (keeping our new line "in phase" with the dash,
103 // hence the (mod intervalLength). 103 // hence the (mod intervalLength).
104 104
105 if (minX < bounds.fLeft) { 105 if (minX < bounds.fLeft) {
106 minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, intervalLengt h); 106 minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, intervalLengt h);
107 } 107 }
(...skipping 10 matching lines...) Expand all
118 } else { 118 } else {
119 SkASSERT(dy && !dx); 119 SkASSERT(dy && !dx);
120 SkScalar minY = pts[0].fY; 120 SkScalar minY = pts[0].fY;
121 SkScalar maxY = pts[1].fY; 121 SkScalar maxY = pts[1].fY;
122 122
123 if (dy < 0) { 123 if (dy < 0) {
124 SkTSwap(minY, maxY); 124 SkTSwap(minY, maxY);
125 } 125 }
126 126
127 SkASSERT(minY < maxY); 127 SkASSERT(minY < maxY);
128 if (maxY < bounds.fTop || minY > bounds.fBottom) { 128 if (maxY <= bounds.fTop || minY >= bounds.fBottom) {
129 return false; 129 return false;
130 } 130 }
131 131
132 // Now we actually perform the chop, removing the excess to the top and 132 // Now we actually perform the chop, removing the excess to the top and
133 // bottom of the bounds (keeping our new line "in phase" with the dash, 133 // bottom of the bounds (keeping our new line "in phase" with the dash,
134 // hence the (mod intervalLength). 134 // hence the (mod intervalLength).
135 135
136 if (minY < bounds.fTop) { 136 if (minY < bounds.fTop) {
137 minY = bounds.fTop - SkScalarMod(bounds.fTop - minY, intervalLength) ; 137 minY = bounds.fTop - SkScalarMod(bounds.fTop - minY, intervalLength) ;
138 } 138 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 362
363 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { 363 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
364 const SkScalar phase = buffer.readScalar(); 364 const SkScalar phase = buffer.readScalar();
365 uint32_t count = buffer.getArrayCount(); 365 uint32_t count = buffer.getArrayCount();
366 SkAutoSTArray<32, SkScalar> intervals(count); 366 SkAutoSTArray<32, SkScalar> intervals(count);
367 if (buffer.readScalarArray(intervals.get(), count)) { 367 if (buffer.readScalarArray(intervals.get(), count)) {
368 return Create(intervals.get(), SkToInt(count), phase); 368 return Create(intervals.get(), SkToInt(count), phase);
369 } 369 }
370 return NULL; 370 return NULL;
371 } 371 }
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