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 #include "SkLinearBitmapPipeline.h" | 8 #include "SkLinearBitmapPipeline.h" |
9 #include "SkPM4f.h" | 9 #include "SkPM4f.h" |
10 | 10 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (!fStrategy.maybeProcessSpan(span, fNext)) { | 266 if (!fStrategy.maybeProcessSpan(span, fNext)) { |
267 span_fallback(span, this); | 267 span_fallback(span, this); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 private: | 271 private: |
272 Next* const fNext; | 272 Next* const fNext; |
273 Strategy fStrategy; | 273 Strategy fStrategy; |
274 }; | 274 }; |
275 | 275 |
276 class SkippedStage final : public SkLinearBitmapPipeline::BilerpProcessorInterfa
ce { | |
277 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { | |
278 SkFAIL("Skipped stage."); | |
279 } | |
280 void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override { | |
281 SkFAIL("Skipped stage."); | |
282 } | |
283 void VECTORCALL bilerpList(Sk4s xs, Sk4s ys) override { | |
284 SkFAIL("Skipped stage."); | |
285 } | |
286 void pointSpan(Span span) override { | |
287 SkFAIL("Skipped stage."); | |
288 } | |
289 }; | |
290 | |
291 class TranslateMatrixStrategy { | 276 class TranslateMatrixStrategy { |
292 public: | 277 public: |
293 TranslateMatrixStrategy(SkVector offset) | 278 TranslateMatrixStrategy(SkVector offset) |
294 : fXOffset{X(offset)} | 279 : fXOffset{X(offset)} |
295 , fYOffset{Y(offset)} { } | 280 , fYOffset{Y(offset)} { } |
296 | 281 |
297 void processPoints(Sk4s* xs, Sk4s* ys) { | 282 void processPoints(Sk4s* xs, Sk4s* ys) { |
298 *xs = *xs + fXOffset; | 283 *xs = *xs + fXOffset; |
299 *ys = *ys + fYOffset; | 284 *ys = *ys + fYOffset; |
300 } | 285 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } else if (inverse.getScaleX() != 1.0f || inverse.getScaleY() != 1.0f) { | 368 } else if (inverse.getScaleX() != 1.0f || inverse.getScaleY() != 1.0f) { |
384 matrixProc->Initialize<ScaleMatrix<>>( | 369 matrixProc->Initialize<ScaleMatrix<>>( |
385 next, | 370 next, |
386 SkVector{inverse.getTranslateX(), inverse.getTranslateY()}, | 371 SkVector{inverse.getTranslateX(), inverse.getTranslateY()}, |
387 SkVector{inverse.getScaleX(), inverse.getScaleY()}); | 372 SkVector{inverse.getScaleX(), inverse.getScaleY()}); |
388 } else if (inverse.getTranslateX() != 0.0f || inverse.getTranslateY() != 0.0
f) { | 373 } else if (inverse.getTranslateX() != 0.0f || inverse.getTranslateY() != 0.0
f) { |
389 matrixProc->Initialize<TranslateMatrix<>>( | 374 matrixProc->Initialize<TranslateMatrix<>>( |
390 next, | 375 next, |
391 SkVector{inverse.getTranslateX(), inverse.getTranslateY()}); | 376 SkVector{inverse.getTranslateX(), inverse.getTranslateY()}); |
392 } else { | 377 } else { |
393 matrixProc->Initialize<SkippedStage>(); | |
394 return next; | 378 return next; |
395 } | 379 } |
396 return matrixProc->get(); | 380 return matrixProc->get(); |
397 } | 381 } |
398 | 382 |
399 template <typename Next = SkLinearBitmapPipeline::BilerpProcessorInterface> | 383 template <typename Next = SkLinearBitmapPipeline::BilerpProcessorInterface> |
400 class ExpandBilerp final : public SkLinearBitmapPipeline::PointProcessorInterfac
e { | 384 class ExpandBilerp final : public SkLinearBitmapPipeline::PointProcessorInterfac
e { |
401 public: | 385 public: |
402 ExpandBilerp(Next* next) : fNext{next} { } | 386 ExpandBilerp(Next* next) : fNext{next} { } |
403 | 387 |
(...skipping 24 matching lines...) Expand all Loading... |
428 | 412 |
429 private: | 413 private: |
430 Next* const fNext; | 414 Next* const fNext; |
431 }; | 415 }; |
432 | 416 |
433 static SkLinearBitmapPipeline::PointProcessorInterface* choose_filter( | 417 static SkLinearBitmapPipeline::PointProcessorInterface* choose_filter( |
434 SkLinearBitmapPipeline::BilerpProcessorInterface* next, | 418 SkLinearBitmapPipeline::BilerpProcessorInterface* next, |
435 SkFilterQuality filterQuailty, | 419 SkFilterQuality filterQuailty, |
436 SkLinearBitmapPipeline::FilterStage* filterProc) { | 420 SkLinearBitmapPipeline::FilterStage* filterProc) { |
437 if (SkFilterQuality::kNone_SkFilterQuality == filterQuailty) { | 421 if (SkFilterQuality::kNone_SkFilterQuality == filterQuailty) { |
438 filterProc->Initialize<SkippedStage>(); | |
439 return next; | 422 return next; |
440 } else { | 423 } else { |
441 filterProc->Initialize<ExpandBilerp<>>(next); | 424 filterProc->Initialize<ExpandBilerp<>>(next); |
442 return filterProc->get(); | 425 return filterProc->get(); |
443 } | 426 } |
444 } | 427 } |
445 | 428 |
446 class ClampStrategy { | 429 class ClampStrategy { |
447 public: | 430 public: |
448 ClampStrategy(X max) | 431 ClampStrategy(X max) |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 case SkShader::kClamp_TileMode: | 653 case SkShader::kClamp_TileMode: |
671 tileProcXOrBoth->Initialize<Clamp<>>(next, dimensions); | 654 tileProcXOrBoth->Initialize<Clamp<>>(next, dimensions); |
672 break; | 655 break; |
673 case SkShader::kRepeat_TileMode: | 656 case SkShader::kRepeat_TileMode: |
674 tileProcXOrBoth->Initialize<Repeat<>>(next, dimensions); | 657 tileProcXOrBoth->Initialize<Repeat<>>(next, dimensions); |
675 break; | 658 break; |
676 case SkShader::kMirror_TileMode: | 659 case SkShader::kMirror_TileMode: |
677 SkFAIL("Not implemented."); | 660 SkFAIL("Not implemented."); |
678 break; | 661 break; |
679 } | 662 } |
680 tileProcY->Initialize<SkippedStage>(); | |
681 } else { | 663 } else { |
682 switch (yMode) { | 664 switch (yMode) { |
683 case SkShader::kClamp_TileMode: | 665 case SkShader::kClamp_TileMode: |
684 tileProcY->Initialize<Clamp<>>(next, Y(dimensions)); | 666 tileProcY->Initialize<Clamp<>>(next, Y(dimensions)); |
685 break; | 667 break; |
686 case SkShader::kRepeat_TileMode: | 668 case SkShader::kRepeat_TileMode: |
687 tileProcY->Initialize<Repeat<>>(next, Y(dimensions)); | 669 tileProcY->Initialize<Repeat<>>(next, Y(dimensions)); |
688 break; | 670 break; |
689 case SkShader::kMirror_TileMode: | 671 case SkShader::kMirror_TileMode: |
690 SkFAIL("Not implemented."); | 672 SkFAIL("Not implemented."); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 | 916 |
935 void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) { | 917 void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) { |
936 SkASSERT(count > 0); | 918 SkASSERT(count > 0); |
937 fPixelStage->setDestination(dst); | 919 fPixelStage->setDestination(dst); |
938 // The count and length arguments start out in a precise relation in order t
o keep the | 920 // The count and length arguments start out in a precise relation in order t
o keep the |
939 // math correct through the different stages. Count is the number of pixel t
o produce. | 921 // math correct through the different stages. Count is the number of pixel t
o produce. |
940 // Since the code samples at pixel centers, length is the distance from the
center of the | 922 // Since the code samples at pixel centers, length is the distance from the
center of the |
941 // first pixel to the center of the last pixel. This implies that length is
count-1. | 923 // first pixel to the center of the last pixel. This implies that length is
count-1. |
942 fFirstStage->pointSpan(Span{SkPoint{x + 0.5f, y + 0.5f}, count - 1.0f, count
}); | 924 fFirstStage->pointSpan(Span{SkPoint{x + 0.5f, y + 0.5f}, count - 1.0f, count
}); |
943 } | 925 } |
OLD | NEW |