Revert of switch to isABitmap, deprecate SK_SUPPORT_LEGACY_SHADERBITMAPTYPE (patchset #3 id:40001 of https://codereview.chromium.org/1311963007/ )

Reason for revert:
Broke the Android canary:

  https://internal.skia.org/builders/crimson-cherry-474438/builds/124

Original issue's description:
> switch to isABitmap, deprecate SK_SUPPORT_LEGACY_SHADERBITMAPTYPE
>
> BUG=skia:
> TBR=
>
> Committed: https://skia.googlesource.com/skia/+/2d126b5c45e65a67a9945afa9294038a8eb3f2c8

TBR=reed@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1309943004
This commit is contained in:
scroggo 2015-09-08 06:24:08 -07:00 committed by Commit bot
parent 1512029900
commit ff390c9bdd
5 changed files with 48 additions and 18 deletions

View File

@ -223,15 +223,42 @@ public:
return (flags & kHasSpan16_Flag) != 0;
}
#ifdef SK_SUPPORT_LEGACY_SHADERBITMAPTYPE
public:
#else
protected:
#endif
/**
* 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.
Gives method bitmap should be read to implement a shader.
Also determines number and interpretation of "extra" parameters returned
by asABitmap
*/
bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) const {
return this->onIsABitmap(outTexture, outMatrix, xy);
}
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() const {
return this->isABitmap(nullptr, nullptr, nullptr);
}
@ -425,11 +452,6 @@ 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.

View File

@ -27,7 +27,9 @@ SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, TileMode tmx, TileMo
fTileModeY = (uint8_t)tmy;
}
bool SkBitmapProcShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[]) const {
SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture,
SkMatrix* texM,
TileMode xy[]) const {
if (texture) {
*texture = fRawBitmap;
}
@ -38,7 +40,7 @@ bool SkBitmapProcShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode
xy[0] = (TileMode)fTileModeX;
xy[1] = (TileMode)fTileModeY;
}
return true;
return kDefault_BitmapType;
}
SkFlattenable* SkBitmapProcShader::CreateProc(SkReadBuffer& buffer) {

View File

@ -20,7 +20,9 @@ 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;
@ -56,7 +58,6 @@ 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;

View File

@ -23,6 +23,11 @@ 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);
}
@ -53,10 +58,6 @@ 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;

View File

@ -206,6 +206,10 @@ 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;
}