OLD | NEW |
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // Note: The span length has an unintuitive relation to the tile width.
The tile width is | 291 // Note: The span length has an unintuitive relation to the tile width.
The tile width is |
292 // a half open interval [tb, te), but the span is a closed interval [sb,
se]. In order to | 292 // a half open interval [tb, te), but the span is a closed interval [sb,
se]. In order to |
293 // compare the two, you need to convert the span to a half open interval
. This is done by | 293 // compare the two, you need to convert the span to a half open interval
. This is done by |
294 // adding dx to se. So, the span becomes: [sb, se + dx). Hence the + 1.0
f below. | 294 // adding dx to se. So, the span becomes: [sb, se + dx). Hence the + 1.0
f below. |
295 SkScalar div = (span.length() + 1.0f) / fXMax; | 295 SkScalar div = (span.length() + 1.0f) / fXMax; |
296 int32_t repeatCount = SkScalarFloorToInt(div); | 296 int32_t repeatCount = SkScalarFloorToInt(div); |
297 Span repeatableSpan{{0.0f, y}, fXMax - 1.0f, SkScalarFloorToInt(fXMax)}; | 297 Span repeatableSpan{{0.0f, y}, fXMax - 1.0f, SkScalarFloorToInt(fXMax)}; |
298 | 298 |
299 // Repeat the center section. | 299 // Repeat the center section. |
300 SkASSERT(0.0f <= repeatableSpan.startX() && repeatableSpan.endX() < fXMa
x); | 300 SkASSERT(0.0f <= repeatableSpan.startX() && repeatableSpan.endX() < fXMa
x); |
301 next->repeatSpan(repeatableSpan, repeatCount); | 301 if (repeatCount > 0) { |
| 302 next->repeatSpan(repeatableSpan, repeatCount); |
| 303 } |
302 | 304 |
303 // Calculate the advance past the center portion. | 305 // Calculate the advance past the center portion. |
304 SkScalar advance = SkScalar(repeatCount) * fXMax; | 306 SkScalar advance = SkScalar(repeatCount) * fXMax; |
305 | 307 |
306 // There may be some of the span left over. | 308 // There may be some of the span left over. |
307 span.breakAt(advance, 1.0f); | 309 span.breakAt(advance, 1.0f); |
308 | 310 |
309 // All on a single tile. | 311 // All on a single tile. |
310 if (!span.isEmpty()) { | 312 if (!span.isEmpty()) { |
311 span.offset(-advance); | 313 span.offset(-advance); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 415 |
414 private: | 416 private: |
415 SkScalar fYMax; | 417 SkScalar fYMax; |
416 Sk4f fYsMax; | 418 Sk4f fYsMax; |
417 Sk4f fYsCap; | 419 Sk4f fYsCap; |
418 Sk4f fYsDoubleInvMax; | 420 Sk4f fYsDoubleInvMax; |
419 }; | 421 }; |
420 | 422 |
421 } // namespace | 423 } // namespace |
422 #endif // SkLinearBitmapPipeline_tile_DEFINED | 424 #endif // SkLinearBitmapPipeline_tile_DEFINED |
OLD | NEW |