From eefe9f971b77eff93e6551240342b4772e69546f Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Mon, 21 Aug 2017 11:39:15 -0400 Subject: 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 Reviewed-by: Yuqian Li Reviewed-by: Florin Malita --- src/core/SkBitmapProcState.cpp | 4 ++++ src/shaders/SkImageShader.cpp | 10 ++++++++-- src/shaders/SkImageShader.h | 3 ++- src/shaders/SkLocalMatrixShader.h | 5 +++++ src/shaders/SkPictureShader.cpp | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') 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, 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 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, -- cgit v1.2.3