diff options
author | Mike Klein <mtklein@chromium.org> | 2016-12-09 16:25:44 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-09 22:05:24 +0000 |
commit | b0b17d1e5375a65b8956a8990d63e0d02357fdaf (patch) | |
tree | 65c9b3487dd577006e4c5608b5f6d13579298f00 /src/image | |
parent | 21aa35f0aac9a091d01ad50dcdc44271dc2a13ed (diff) |
bicubic, attempt gazillion
- explicitly separate bilinear_ stages in x and y too
BUG=skia:
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: Ib7b4f9d26ea6abe9171068e92424479d811ee606
Reviewed-on: https://skia-review.googlesource.com/5636
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImageShader.cpp | 50 | ||||
-rw-r--r-- | src/image/SkImageShaderContext.h | 3 |
2 files changed, 44 insertions, 9 deletions
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp index 528c5729d8..7a1522b99a 100644 --- a/src/image/SkImageShader.cpp +++ b/src/image/SkImageShader.cpp @@ -279,7 +279,7 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal auto quality = paint.getFilterQuality(); SkBitmapProvider provider(fImage.get(), dst); - SkDefaultBitmapController controller; + SkDefaultBitmapController controller(SkDefaultBitmapController::CanShadeHQ::kYes); std::unique_ptr<SkBitmapController::State> state { controller.requestBitmap(provider, matrix, quality) }; @@ -293,7 +293,8 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal auto info = pm.info(); // When the matrix is just an integer translate, bilerp == nearest neighbor. - if (matrix.getType() <= SkMatrix::kTranslate_Mask && + if (quality == kLow_SkFilterQuality && + matrix.getType() <= SkMatrix::kTranslate_Mask && matrix.getTranslateX() == (int)matrix.getTranslateX() && matrix.getTranslateY() == (int)matrix.getTranslateY()) { quality = kNone_SkFilterQuality; @@ -353,20 +354,48 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal } }; - auto sample = [&](SkRasterPipeline::StockStage sampler) { - p->append(sampler, ctx); + auto sample = [&](SkRasterPipeline::StockStage setup_x, + SkRasterPipeline::StockStage setup_y) { + p->append(setup_x, ctx); + p->append(setup_y, ctx); append_tiling_and_gather(); p->append(SkRasterPipeline::accumulate, ctx); }; if (quality == kNone_SkFilterQuality) { append_tiling_and_gather(); + } else if (quality == kLow_SkFilterQuality) { + p->append(SkRasterPipeline::save_xy, ctx); + + sample(SkRasterPipeline::bilinear_nx, SkRasterPipeline::bilinear_ny); + sample(SkRasterPipeline::bilinear_px, SkRasterPipeline::bilinear_ny); + sample(SkRasterPipeline::bilinear_nx, SkRasterPipeline::bilinear_py); + sample(SkRasterPipeline::bilinear_px, SkRasterPipeline::bilinear_py); + + p->append(SkRasterPipeline::move_dst_src); } else { p->append(SkRasterPipeline::save_xy, ctx); - sample(SkRasterPipeline::bilinear_nn); - sample(SkRasterPipeline::bilinear_np); - sample(SkRasterPipeline::bilinear_pn); - sample(SkRasterPipeline::bilinear_pp); + + sample(SkRasterPipeline::bicubic_n3x, SkRasterPipeline::bicubic_n3y); + sample(SkRasterPipeline::bicubic_n1x, SkRasterPipeline::bicubic_n3y); + sample(SkRasterPipeline::bicubic_p1x, SkRasterPipeline::bicubic_n3y); + sample(SkRasterPipeline::bicubic_p3x, SkRasterPipeline::bicubic_n3y); + + sample(SkRasterPipeline::bicubic_n3x, SkRasterPipeline::bicubic_n1y); + sample(SkRasterPipeline::bicubic_n1x, SkRasterPipeline::bicubic_n1y); + sample(SkRasterPipeline::bicubic_p1x, SkRasterPipeline::bicubic_n1y); + sample(SkRasterPipeline::bicubic_p3x, SkRasterPipeline::bicubic_n1y); + + sample(SkRasterPipeline::bicubic_n3x, SkRasterPipeline::bicubic_p1y); + sample(SkRasterPipeline::bicubic_n1x, SkRasterPipeline::bicubic_p1y); + sample(SkRasterPipeline::bicubic_p1x, SkRasterPipeline::bicubic_p1y); + sample(SkRasterPipeline::bicubic_p3x, SkRasterPipeline::bicubic_p1y); + + sample(SkRasterPipeline::bicubic_n3x, SkRasterPipeline::bicubic_p3y); + sample(SkRasterPipeline::bicubic_n1x, SkRasterPipeline::bicubic_p3y); + sample(SkRasterPipeline::bicubic_p1x, SkRasterPipeline::bicubic_p3y); + sample(SkRasterPipeline::bicubic_p3x, SkRasterPipeline::bicubic_p3y); + p->append(SkRasterPipeline::move_dst_src); } @@ -383,5 +412,10 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal if (info.colorType() == kAlpha_8_SkColorType || info.alphaType() == kUnpremul_SkAlphaType) { p->append(SkRasterPipeline::premul); } + if (quality > kLow_SkFilterQuality) { + // Bicubic filtering naturally produces out of range values on both sides. + p->append(SkRasterPipeline::clamp_0); + p->append(SkRasterPipeline::clamp_a); + } return append_gamut_transform(p, scratch, info.colorSpace(), dst); } diff --git a/src/image/SkImageShaderContext.h b/src/image/SkImageShaderContext.h index b0652900dd..3dae6c5da7 100644 --- a/src/image/SkImageShaderContext.h +++ b/src/image/SkImageShaderContext.h @@ -30,7 +30,8 @@ struct SkImageShaderContext { float y[8]; float fx[8]; float fy[8]; - float scale[8]; + float scalex[8]; + float scaley[8]; }; #endif//SkImageShaderContext_DEFINED |