diff options
-rw-r--r-- | include/core/SkShader.h | 44 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 6 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.h | 3 | ||||
-rw-r--r-- | src/core/SkLocalMatrixShader.h | 9 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 4 |
5 files changed, 18 insertions, 48 deletions
diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 76b86a6cfe..28329be4aa 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -223,42 +223,15 @@ public: return (flags & kHasSpan16_Flag) != 0; } -#ifdef SK_SUPPORT_LEGACY_SHADERBITMAPTYPE -public: -#else -protected: -#endif /** - Gives method bitmap should be read to implement a shader. - Also determines number and interpretation of "extra" parameters returned - by asABitmap + * Returns true if this shader is just a bitmap, and if not null, returns the bitmap, + * localMatrix, and tilemodes. If this is not a bitmap, returns false and ignores the + * out-parameters. */ - enum BitmapType { - kNone_BitmapType, //<! Shader is not represented as a bitmap - kDefault_BitmapType,//<! Access bitmap using local coords transformed - }; - /** Optional methods for shaders that can pretend to be a bitmap/texture - to play along with opengl. Default just returns kNone_BitmapType and - ignores the out parameters. - - @param outTexture if non-NULL will be the bitmap representing the shader - after return. - @param outMatrix if non-NULL will be the matrix to apply to vertices - to access the bitmap after return. - @param xy if non-NULL will be the tile modes that should be - used to access the bitmap after return. - @param twoPointRadialParams Two extra return values needed for two point - radial bitmaps. The first is the x-offset of - the second point and the second is the radius - about the first point. - */ - virtual BitmapType asABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, - TileMode xy[2]) const; - -public: - bool isABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode xy[2]) const { - return this->asABitmap(bitmap, matrix, xy) == kDefault_BitmapType; + bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) const { + return this->onIsABitmap(outTexture, outMatrix, xy); } + bool isABitmap() const { return this->isABitmap(nullptr, nullptr, nullptr); } @@ -452,6 +425,11 @@ protected: virtual bool onAsLuminanceColor(SkColor*) const { return false; } + + virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const { + return false; + } + private: // This is essentially const, but not officially so it can be modified in // constructors. diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index c3b10184f4..97abbf9675 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -27,9 +27,7 @@ SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo fTileModeY = (uint8_t)tmy; } -SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture, - SkMatrix* texM, - TileMode xy[]) const { +bool SkBitmapProcShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[]) const { if (texture) { *texture = fRawBitmap; } @@ -40,7 +38,7 @@ SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture, xy[0] = (TileMode)fTileModeX; xy[1] = (TileMode)fTileModeY; } - return kDefault_BitmapType; + return true; } SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) { diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 4215b90efb..63985c06c5 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -20,9 +20,7 @@ public: SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty, const SkMatrix* localMatrix = nullptr); - // overrides from SkShader bool isOpaque() const override; - BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; size_t contextSize() const override; @@ -58,6 +56,7 @@ public: protected: void flatten(SkWriteBuffer&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; + bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; SkBitmap fRawBitmap; // experimental for RLE encoding uint8_t fTileModeX, fTileModeY; diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index 9c6a526f7b..a108259461 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -23,11 +23,6 @@ public: return fProxyShader->contextSize(); } - virtual BitmapType asABitmap(SkBitmap* bitmap, SkMatrix* matrix, - TileMode* mode) const override { - return fProxyShader->asABitmap(bitmap, matrix, mode); - } - GradientType asAGradient(GradientInfo* info) const override { return fProxyShader->asAGradient(info); } @@ -58,6 +53,10 @@ protected: void flatten(SkWriteBuffer&) const override; Context* onCreateContext(const ContextRec&, void*) const override; + bool onIsABitmap(SkBitmap* bitmap, SkMatrix* matrix, TileMode* mode) const override { + return fProxyShader->isABitmap(bitmap, matrix, mode); + } + private: SkAutoTUnref<SkShader> fProxyShader; diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index b3edf47dfd..2a1c28e0cf 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -206,10 +206,6 @@ SkShader::Context::MatrixClass SkShader::Context::ComputeMatrixClass(const SkMat ////////////////////////////////////////////////////////////////////////////// -SkShader::BitmapType SkShader::asABitmap(SkBitmap*, SkMatrix*, TileMode*) const { - return kNone_BitmapType; -} - SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { return kNone_GradientType; } |