diff options
author | 2014-05-09 20:28:11 +0000 | |
---|---|---|
committer | 2014-05-09 20:28:11 +0000 | |
commit | 96fb7489ba46909c3f81bb2d94755e7d4ccb5fad (patch) | |
tree | 1f2608698d1ebf11eae79b705aefef5b6ed6e2e2 /src/core | |
parent | 68867b3db2172c2a542fde1b8b1a08f22d6b9b83 (diff) |
add localmatrix parameter to shader's asNewEffect
BUG=skia:
R=bsalomon@google.com, dominikg@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/278963002
git-svn-id: http://skia.googlecode.com/svn/trunk@14686 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 10 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.h | 2 | ||||
-rw-r--r-- | src/core/SkLocalMatrixShader.cpp | 9 | ||||
-rw-r--r-- | src/core/SkPictureShader.cpp | 7 | ||||
-rw-r--r-- | src/core/SkPictureShader.h | 2 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 2 |
6 files changed, 23 insertions, 9 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 00d938be27..d726a46f11 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -393,7 +393,8 @@ static SkScalar get_combined_min_stretch(const SkMatrix& viewMatrix, const SkMat } } -GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint) const { +GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint, + const SkMatrix* localMatrix) const { SkMatrix matrix; matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); @@ -401,6 +402,13 @@ GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& if (!this->getLocalMatrix().invert(&lmInverse)) { return NULL; } + if (localMatrix) { + SkMatrix inv; + if (!localMatrix->invert(&inv)) { + return NULL; + } + lmInverse.postConcat(inv); + } matrix.preConcat(lmInverse); SkShader::TileMode tm[] = { diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 8d31256469..80e4550279 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -31,7 +31,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) #if SK_SUPPORT_GPU - GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; + GrEffectRef* asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const SK_OVERRIDE; #endif class BitmapProcShaderContext : public SkShader::Context { diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp index 802e72ef3f..7af025c442 100644 --- a/src/core/SkLocalMatrixShader.cpp +++ b/src/core/SkLocalMatrixShader.cpp @@ -30,8 +30,13 @@ public: } // TODO: need to augment this API to pass in a localmatrix (which we can augment) - virtual GrEffectRef* asNewEffect(GrContext* ctx, const SkPaint& paint) const SK_OVERRIDE { - return fProxyShader->asNewEffect(ctx, paint); + virtual GrEffectRef* asNewEffect(GrContext* ctx, const SkPaint& paint, + const SkMatrix* localMatrix) const SK_OVERRIDE { + SkMatrix tmp = fProxyLocalMatrix; + if (localMatrix) { + tmp.preConcat(*localMatrix); + } + return fProxyShader->asNewEffect(ctx, paint, &tmp); } virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const SK_OVERRIDE { diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 9655e85bd1..300a65329b 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -192,11 +192,12 @@ void SkPictureShader::toString(SkString* str) const { #endif #if SK_SUPPORT_GPU -GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint) const { - SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix(), NULL)); +GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint, + const SkMatrix* localMatrix) const { + SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix(), localMatrix)); if (!bitmapShader) { return NULL; } - return bitmapShader->asNewEffect(context, paint); + return bitmapShader->asNewEffect(context, paint, NULL); } #endif diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h index 27fb674b01..936a69ebe0 100644 --- a/src/core/SkPictureShader.h +++ b/src/core/SkPictureShader.h @@ -30,7 +30,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) #if SK_SUPPORT_GPU - GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; + GrEffectRef* asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const SK_OVERRIDE; #endif protected: diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index ebe1a74cc2..75a5fdbd36 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -211,7 +211,7 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { return kNone_GradientType; } -GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { +GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const { return NULL; } |