diff options
author | Mike Klein <mtklein@chromium.org> | 2017-05-19 12:01:01 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-22 14:28:15 +0000 |
commit | b35cb3143e1f999095af28e0de2ace3ff4ef6b9e (patch) | |
tree | 255abc2b09f9652a686e450657530c3ccb79f7cd /src/core/SkDraw_vertices.cpp | |
parent | 1859f69d20e433b86714e5b9002121f2b20a5fc6 (diff) |
refactor SkRasterPipelineBlitter
This refactors the factories so that the create-from-paint factory is a
front-patch to the create-from-shader-pipeline factory. Feature-wise,
we make the pre-baked shader pipeline responsible for modulating by
paint alpha; the factory only adds when creating from the paint.
We can fold the alpha into the colors in drawVertices, which makes it
run a bit faster, dropping the need for a scale_1_float runtime stage.
This causes a few invisible diffs on the "vertices" GM, but everything
else draws the same.
Change-Id: I3eeacc9aafbce2023ab18991bbb68c35645e9387
Reviewed-on: https://skia-review.googlesource.com/17395
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkDraw_vertices.cpp')
-rw-r--r-- | src/core/SkDraw_vertices.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/core/SkDraw_vertices.cpp b/src/core/SkDraw_vertices.cpp index 9735fa8a25..ceeb3c2ddc 100644 --- a/src/core/SkDraw_vertices.cpp +++ b/src/core/SkDraw_vertices.cpp @@ -257,9 +257,9 @@ void SkTriColorShader::TriColorShaderContext::shadeSpan4f(int x, int y, SkPM4f d #ifndef SK_IGNORE_TO_STRING void SkTriColorShader::toString(SkString* str) const { str->append("SkTriColorShader: ("); - + this->INHERITED::toString(str); - + str->append(")"); } #endif @@ -472,6 +472,17 @@ void SkDraw::drawVertices(SkVertices::VertexMode vmode, int count, // SkPM4f* dstColors = convert_colors(colors, count, fDst.colorSpace(), &alloc); + bool is_opaque; + if (paint.getAlpha() == 0xff) { + is_opaque = compute_is_opaque(colors, count); + } else { + is_opaque = false; + Sk4f alpha = paint.getAlpha() * (1/255.0f); + for (int i = 0; i < count; i++) { + (dstColors[i].to4f() * alpha).store(dstColors + i); + } + } + shaderPipeline.append(SkRasterPipeline::matrix_4x3, &matrix43); // In theory we should never need to clamp. However, either due to imprecision in our // matrix43, or the scan converter passing us pixel centers that in fact are not within @@ -480,9 +491,8 @@ void SkDraw::drawVertices(SkVertices::VertexMode vmode, int count, shaderPipeline.append(SkRasterPipeline::clamp_0); shaderPipeline.append(SkRasterPipeline::clamp_a); - bool is_opaque = compute_is_opaque(colors, count), - wants_dither = paint.isDither(); - auto blitter = SkCreateRasterPipelineBlitter(fDst, paint, *fMatrix, shaderPipeline, + bool wants_dither = paint.isDither(); + auto blitter = SkCreateRasterPipelineBlitter(fDst, paint, shaderPipeline, is_opaque, wants_dither, &alloc); SkASSERT(!blitter->isNullBlitter()); |