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

Side by Side Diff: src/core/SkLinearBitmapPipeline_tile.h

Issue 1757193002: Add test cases for Clamp and Repeat tiles. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simplify span breakAt usage, by making breakAt consistant for +/- dx. Created 4 years, 9 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 | « src/core/SkLinearBitmapPipeline_core.h ('k') | tests/SkLinearBitmapPipelineTest.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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
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 #ifndef SkLinearBitmapPipeline_tile_DEFINED 8 #ifndef SkLinearBitmapPipeline_tile_DEFINED
9 #define SkLinearBitmapPipeline_tile_DEFINED 9 #define SkLinearBitmapPipeline_tile_DEFINED
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Span middle = span.breakAt(xMax, dx); 93 Span middle = span.breakAt(xMax, dx);
94 if (!middle.isEmpty()) { 94 if (!middle.isEmpty()) {
95 next->pointSpan(middle); 95 next->pointSpan(middle);
96 } 96 }
97 if (!span.isEmpty()) { 97 if (!span.isEmpty()) {
98 span.clampToSinglePixel({xMax - 1, y}); 98 span.clampToSinglePixel({xMax - 1, y});
99 next->pointSpan(span); 99 next->pointSpan(span);
100 } 100 }
101 } else { 101 } else {
102 Span rightClamped = span.breakAt(xMax, dx); 102 Span rightClamped = span.breakAt(xMax, dx);
103
103 if (!rightClamped.isEmpty()) { 104 if (!rightClamped.isEmpty()) {
104 rightClamped.clampToSinglePixel({xMax - 1, y}); 105 rightClamped.clampToSinglePixel({xMax - 1, y});
105 next->pointSpan(rightClamped); 106 next->pointSpan(rightClamped);
106 } 107 }
107 Span middle = span.breakAt(xMin, dx); 108 Span middle = span.breakAt(xMin, dx);
108 if (!middle.isEmpty()) { 109 if (!middle.isEmpty()) {
109 next->pointSpan(middle); 110 next->pointSpan(middle);
110 } 111 }
111 if (!span.isEmpty()) { 112 if (!span.isEmpty()) {
112 span.clampToSinglePixel({xMin, y}); 113 span.clampToSinglePixel({xMin, y});
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // 192 //
192 // Overall Strategy: 193 // Overall Strategy:
193 // While the span hangs over the edge of the tile, draw the span coverin g the tile then 194 // While the span hangs over the edge of the tile, draw the span coverin g the tile then
194 // slide the span over to the next tile. 195 // slide the span over to the next tile.
195 196
196 // The guard could have been count > 0, but then a bunch of math would b e done in the 197 // The guard could have been count > 0, but then a bunch of math would b e done in the
197 // common case. 198 // common case.
198 199
199 Span span({x, y}, length, count); 200 Span span({x, y}, length, count);
200 if (dx > 0) { 201 if (dx > 0) {
201 while (!span.isEmpty() && span.endX() > xMax) { 202 while (!span.isEmpty() && span.endX() >= xMax) {
202 Span toDraw = span.breakAt(xMax, dx); 203 Span toDraw = span.breakAt(xMax, dx);
203 next->pointSpan(toDraw); 204 next->pointSpan(toDraw);
204 span.offset(-xMax); 205 span.offset(-xMax);
205 } 206 }
206 } else { 207 } else {
207 while (!span.isEmpty() && span.endX() < xMin) { 208 while (!span.isEmpty() && span.endX() < xMin) {
208 Span toDraw = span.breakAt(xMin, dx); 209 Span toDraw = span.breakAt(xMin, dx);
209 next->pointSpan(toDraw); 210 next->pointSpan(toDraw);
210 span.offset(xMax); 211 span.offset(xMax);
211 } 212 }
(...skipping 17 matching lines...) Expand all
229 return x - std::floor(x / base) * base; 230 return x - std::floor(x / base) * base;
230 } 231 }
231 const Sk4s fXMax{0.0f}; 232 const Sk4s fXMax{0.0f};
232 const Sk4s fXInvMax{0.0f}; 233 const Sk4s fXInvMax{0.0f};
233 const Sk4s fYMax{0.0f}; 234 const Sk4s fYMax{0.0f};
234 const Sk4s fYInvMax{0.0f}; 235 const Sk4s fYInvMax{0.0f};
235 }; 236 };
236 237
237 } // namespace 238 } // namespace
238 #endif // SkLinearBitmapPipeline_tile_DEFINED 239 #endif // SkLinearBitmapPipeline_tile_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkLinearBitmapPipeline_core.h ('k') | tests/SkLinearBitmapPipelineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698