clean up some SkRasterPipelineBlitter TODOs
1) remove the note about maybe implementing bitV()... we have.
2) rename append_load_d() to append_load_dst() to match how the
stages are named (a long time ago they used to end with _d...)
3) move unpremul handling to append_load_dst() and append_store()
to make it a bit easier to see how they nest with sRGB
4) remove append_blend()... it's now just SkBlendMode_AppendStages()
Change-Id: Ic3280b66d8c1f26ef18a55044392f7d18fc29a75
Reviewed-on: https://skia-review.googlesource.com/42280
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index 1444b8f..5de16b1 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -46,14 +46,9 @@
void blitRect (int x, int y, int width, int height) override;
void blitV (int x, int y, int height, SkAlpha alpha) override;
- // TODO: The default implementations of the other blits look fine,
- // but some of them like blitV could probably benefit from custom
- // blits using something like a SkRasterPipeline::runFew() method.
-
private:
- void append_load_d(SkRasterPipeline*) const;
- void append_blend (SkRasterPipeline*) const;
- void append_store (SkRasterPipeline*) const;
+ void append_load_dst(SkRasterPipeline*) const;
+ void append_store (SkRasterPipeline*) const;
// If we have an burst context, use it to fill our shader buffer.
void burst_shade(int x, int y, int w);
@@ -230,7 +225,7 @@
return blitter;
}
-void SkRasterPipelineBlitter::append_load_d(SkRasterPipeline* p) const {
+void SkRasterPipelineBlitter::append_load_dst(SkRasterPipeline* p) const {
switch (fDst.info().colorType()) {
case kGray_8_SkColorType: p->append(SkRasterPipeline::load_g8_dst, &fDstPtr); break;
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::load_a8_dst, &fDstPtr); break;
@@ -244,9 +239,15 @@
if (fDst.info().gammaCloseToSRGB()) {
p->append_from_srgb_dst(fDst.info().alphaType());
}
+ if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
+ p->append(SkRasterPipeline::premul_dst);
+ }
}
void SkRasterPipelineBlitter::append_store(SkRasterPipeline* p) const {
+ if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
+ p->append(SkRasterPipeline::unpremul);
+ }
if (fDst.info().gammaCloseToSRGB()) {
p->append(SkRasterPipeline::to_srgb);
}
@@ -272,16 +273,6 @@
}
}
-void SkRasterPipelineBlitter::append_blend(SkRasterPipeline* p) const {
- if (fDst.info().alphaType() == kUnpremul_SkAlphaType) { // TODO: move to append_load_d
- p->append(SkRasterPipeline::premul_dst);
- }
- SkBlendMode_AppendStages(fBlend, p);
- if (fDst.info().alphaType() == kUnpremul_SkAlphaType) { // TODO: move to append_store
- p->append(SkRasterPipeline::unpremul);
- }
-}
-
void SkRasterPipelineBlitter::burst_shade(int x, int y, int w) {
SkASSERT(fBurstCtx);
if (w > SkToInt(fShaderBuffer.size())) {
@@ -322,8 +313,8 @@
p.append(SkRasterPipeline::srcover_rgba_8888, &fDstPtr);
} else {
if (fBlend != SkBlendMode::kSrc) {
- this->append_load_d(&p);
- this->append_blend(&p);
+ this->append_load_dst(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
}
this->append_store(&p);
}
@@ -348,11 +339,11 @@
p.extend(fColorPipeline);
if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/false)) {
p.append(SkRasterPipeline::scale_1_float, &fCurrentCoverage);
- this->append_load_d(&p);
- this->append_blend(&p);
+ this->append_load_dst(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
} else {
- this->append_load_d(&p);
- this->append_blend(&p);
+ this->append_load_dst(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
p.append(SkRasterPipeline::lerp_1_float, &fCurrentCoverage);
}
@@ -414,11 +405,11 @@
p.extend(fColorPipeline);
if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/false)) {
p.append(SkRasterPipeline::scale_u8, &fMaskPtr);
- this->append_load_d(&p);
- this->append_blend(&p);
+ this->append_load_dst(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
} else {
- this->append_load_d(&p);
- this->append_blend(&p);
+ this->append_load_dst(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
p.append(SkRasterPipeline::lerp_u8, &fMaskPtr);
}
this->append_store(&p);
@@ -429,12 +420,12 @@
p.extend(fColorPipeline);
if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/true)) {
// Somewhat unusually, scale_565 needs dst loaded first.
- this->append_load_d(&p);
+ this->append_load_dst(&p);
p.append(SkRasterPipeline::scale_565, &fMaskPtr);
- this->append_blend(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
} else {
- this->append_load_d(&p);
- this->append_blend(&p);
+ this->append_load_dst(&p);
+ SkBlendMode_AppendStages(fBlend, &p);
p.append(SkRasterPipeline::lerp_565, &fMaskPtr);
}
this->append_store(&p);