diff options
author | Mike Reed <reed@google.com> | 2017-08-21 11:39:15 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-21 15:56:48 +0000 |
commit | eefe9f971b77eff93e6551240342b4772e69546f (patch) | |
tree | 5e8e4e5b173f091f11425e9fd6a8d28dbe76a0ad /src | |
parent | 766656d2a997372bda7295a9ffce3adf175dd85e (diff) |
use rasterpipeline if localmatrix is rotated or skewed for images
Bug: skia:
Change-Id: Ib269b5b9d79b055fe614aaacfd7e0d05d48f6085
Reviewed-on: https://skia-review.googlesource.com/33180
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Yuqian Li <liyuqian@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 4 | ||||
-rw-r--r-- | src/shaders/SkImageShader.cpp | 10 | ||||
-rw-r--r-- | src/shaders/SkImageShader.h | 3 | ||||
-rw-r--r-- | src/shaders/SkLocalMatrixShader.h | 5 | ||||
-rw-r--r-- | src/shaders/SkPictureShader.cpp | 2 |
5 files changed, 20 insertions, 4 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 4b7990c2ee..502f076a6f 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -79,7 +79,11 @@ static bool valid_for_filtering(unsigned dimension) { } bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) { +#ifdef SK_SUPPORT_LEGACY_LOCAL_ROTATE_SHADER SkASSERT(!inv.hasPerspective()); +#else + SkASSERT(inv.isScaleTranslate()); +#endif fPixmap.reset(); fInvMatrix = inv; diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 80751be34a..60412a0382 100644 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -62,7 +62,8 @@ bool SkImageShader::isOpaque() const { } bool SkImageShader::IsRasterPipelineOnly(const SkMatrix& ctm, SkColorType ct, SkAlphaType at, - SkShader::TileMode tx, SkShader::TileMode ty) { + SkShader::TileMode tx, SkShader::TileMode ty, + const SkMatrix& localM) { if (ct != kN32_SkColorType) { return true; } @@ -77,13 +78,18 @@ bool SkImageShader::IsRasterPipelineOnly(const SkMatrix& ctm, SkColorType ct, Sk if (!ctm.isScaleTranslate()) { return true; } +#ifndef SK_SUPPORT_LEGACY_LOCAL_ROTATE_SHADER + if (!localM.isScaleTranslate()) { + return true; + } +#endif return false; } bool SkImageShader::onIsRasterPipelineOnly(const SkMatrix& ctm) const { SkBitmapProvider provider(fImage.get(), nullptr); return IsRasterPipelineOnly(ctm, provider.info().colorType(), provider.info().alphaType(), - fTileModeX, fTileModeY); + fTileModeX, fTileModeY, this->getLocalMatrix()); } SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec, diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h index 8e592e504c..98856c9fa3 100644 --- a/src/shaders/SkImageShader.h +++ b/src/shaders/SkImageShader.h @@ -30,7 +30,8 @@ public: SkImageShader(sk_sp<SkImage>, TileMode tx, TileMode ty, const SkMatrix* localMatrix); static bool IsRasterPipelineOnly(const SkMatrix& ctm, SkColorType, SkAlphaType, - SkShader::TileMode tx, SkShader::TileMode ty); + SkShader::TileMode tx, SkShader::TileMode ty, + const SkMatrix& localM); protected: void flatten(SkWriteBuffer&) const override; diff --git a/src/shaders/SkLocalMatrixShader.h b/src/shaders/SkLocalMatrixShader.h index 407c30dc52..a88f95e3b2 100644 --- a/src/shaders/SkLocalMatrixShader.h +++ b/src/shaders/SkLocalMatrixShader.h @@ -63,7 +63,12 @@ protected: #endif bool onIsRasterPipelineOnly(const SkMatrix& ctm) const override { +#ifdef SK_SUPPORT_LEGACY_LOCAL_ROTATE_SHADER return as_SB(fProxyShader)->isRasterPipelineOnly(ctm); +#else + return as_SB(fProxyShader)->isRasterPipelineOnly(SkMatrix::Concat(ctm, + this->getLocalMatrix())); +#endif } private: diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp index a14c211fba..16f57675fc 100644 --- a/src/shaders/SkPictureShader.cpp +++ b/src/shaders/SkPictureShader.cpp @@ -293,7 +293,7 @@ sk_sp<SkShader> SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, con bool SkPictureShader::onIsRasterPipelineOnly(const SkMatrix& ctm) const { return SkImageShader::IsRasterPipelineOnly(ctm, kN32_SkColorType, kPremul_SkAlphaType, - fTmx, fTmy); + fTmx, fTmy, this->getLocalMatrix()); } bool SkPictureShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkArenaAlloc* alloc, |