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 | 9 |
10 #include "SkPM4f.h" | 10 #include "SkPM4f.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 sampleStage->Initialize<Sampler<Pixel8888LRGB, Placer>>(next, sr
cPixmap); | 451 sampleStage->Initialize<Sampler<Pixel8888LRGB, Placer>>(next, sr
cPixmap); |
452 } | 452 } |
453 break; | 453 break; |
454 case kBGRA_8888_SkColorType: | 454 case kBGRA_8888_SkColorType: |
455 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { | 455 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
456 sampleStage->Initialize<Sampler<Pixel8888SBGR, Placer>>(next, sr
cPixmap); | 456 sampleStage->Initialize<Sampler<Pixel8888SBGR, Placer>>(next, sr
cPixmap); |
457 } else { | 457 } else { |
458 sampleStage->Initialize<Sampler<Pixel8888LBGR, Placer>>(next, sr
cPixmap); | 458 sampleStage->Initialize<Sampler<Pixel8888LBGR, Placer>>(next, sr
cPixmap); |
459 } | 459 } |
460 break; | 460 break; |
| 461 case kIndex_8_SkColorType: |
| 462 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
| 463 sampleStage->Initialize<Sampler<PixelIndex8SRGB, Placer>>(next,
srcPixmap); |
| 464 } else { |
| 465 sampleStage->Initialize<Sampler<PixelIndex8LRGB, Placer>>(next,
srcPixmap); |
| 466 } |
| 467 break; |
461 default: | 468 default: |
462 SkFAIL("Not implemented. Unsupported src"); | 469 SkFAIL("Not implemented. Unsupported src"); |
463 break; | 470 break; |
464 } | 471 } |
465 return sampleStage->get(); | 472 return sampleStage->get(); |
466 } | 473 } |
467 | 474 |
468 SkLinearBitmapPipeline::BilerpProcessorInterface* choose_pixel_sampler( | 475 SkLinearBitmapPipeline::BilerpProcessorInterface* choose_pixel_sampler( |
469 Placer* next, | 476 Placer* next, |
470 SkFilterQuality filterQuality, | 477 SkFilterQuality filterQuality, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 if (inverse.getScaleX() >= 0.0f) { | 557 if (inverse.getScaleX() >= 0.0f) { |
551 adjustedInverse.setTranslateX( | 558 adjustedInverse.setTranslateX( |
552 nextafterf(inverse.getTranslateX(), std::floor(inverse.getTransl
ateX()))); | 559 nextafterf(inverse.getTranslateX(), std::floor(inverse.getTransl
ateX()))); |
553 } | 560 } |
554 if (inverse.getScaleY() >= 0.0f) { | 561 if (inverse.getScaleY() >= 0.0f) { |
555 adjustedInverse.setTranslateY( | 562 adjustedInverse.setTranslateY( |
556 nextafterf(inverse.getTranslateY(), std::floor(inverse.getTransl
ateY()))); | 563 nextafterf(inverse.getTranslateY(), std::floor(inverse.getTransl
ateY()))); |
557 } | 564 } |
558 } | 565 } |
559 | 566 |
| 567 // If it is an index 8 color type, the sampler converts to unpremul for bett
er fidelity. |
| 568 SkAlphaType alphaType = srcImageInfo.alphaType(); |
| 569 if (srcPixmap.colorType() == kIndex_8_SkColorType) { |
| 570 alphaType = kUnpremul_SkAlphaType; |
| 571 } |
| 572 |
560 // As the stages are built, the chooser function may skip a stage. For examp
le, with the | 573 // As the stages are built, the chooser function may skip a stage. For examp
le, with the |
561 // identity matrix, the matrix stage is skipped, and the tilerStage is the f
irst stage. | 574 // identity matrix, the matrix stage is skipped, and the tilerStage is the f
irst stage. |
562 auto placementStage = choose_pixel_placer(srcImageInfo.alphaType(), postAlph
a, &fPixelStage); | 575 auto placementStage = choose_pixel_placer(alphaType, postAlpha, &fPixelStage
); |
563 auto samplerStage = choose_pixel_sampler(placementStage, | 576 auto samplerStage = choose_pixel_sampler(placementStage, |
564 filterQuality, srcPixmap, &fSampl
eStage); | 577 filterQuality, srcPixmap, &fSampl
eStage); |
565 auto tilerStage = choose_tiler(samplerStage, | 578 auto tilerStage = choose_tiler(samplerStage, |
566 dimensions, xTile, yTile, filterQuality,
&fTiler); | 579 dimensions, xTile, yTile, filterQuality,
&fTiler); |
567 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixSta
ge); | 580 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixSta
ge); |
568 } | 581 } |
569 | 582 |
570 void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) { | 583 void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) { |
571 SkASSERT(count > 0); | 584 SkASSERT(count > 0); |
572 fPixelStage->setDestination(dst); | 585 fPixelStage->setDestination(dst); |
573 // The count and length arguments start out in a precise relation in order t
o keep the | 586 // The count and length arguments start out in a precise relation in order t
o keep the |
574 // math correct through the different stages. Count is the number of pixel t
o produce. | 587 // math correct through the different stages. Count is the number of pixel t
o produce. |
575 // Since the code samples at pixel centers, length is the distance from the
center of the | 588 // Since the code samples at pixel centers, length is the distance from the
center of the |
576 // first pixel to the center of the last pixel. This implies that length is
count-1. | 589 // first pixel to the center of the last pixel. This implies that length is
count-1. |
577 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); | 590 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); |
578 } | 591 } |
579 | 592 |
OLD | NEW |