add default impl for context methods on shader

These are reasonable return values, since both of these methods can return a known value (0)
which means that no context can be created. This also makes it easier for chrome's subclasses
which already do not want to create a context, but having them actually overridden makes
changing the virtual signatures much harder.

BUG=skia:
R=scroggo@google.com, dominikg@google.com, reed@chromium.org

Author: reed@google.com

Review URL: https://codereview.chromium.org/262703002

git-svn-id: http://skia.googlecode.com/svn/trunk@14491 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-30 23:29:02 +00:00
parent 374a6e7427
commit f3e505984d
2 changed files with 17 additions and 2 deletions

View File

@ -207,16 +207,22 @@ public:
* Create the actual object that does the shading.
* Returns NULL if validContext() returns false.
* Size of storage must be >= contextSize.
* Your subclass must also override contextSize() if it overrides createContext().
*
* Base class implementation returns NULL.
*/
virtual Context* createContext(const SkBitmap& device,
const SkPaint& paint,
const SkMatrix& matrix,
void* storage) const = 0;
void* storage) const;
/**
* Return the size of a Context returned by createContext.
*
* Override this if your subclass overrides createContext, to return the correct size of
* your subclass' context.
*/
virtual size_t contextSize() const = 0;
virtual size_t contextSize() const;
/**
* Helper to check the flags to know if it is legal to call shadeSpan16()

View File

@ -63,6 +63,15 @@ bool SkShader::validContext(const SkBitmap& device,
return this->computeTotalInverse(matrix, totalInverse);
}
SkShader::Context* SkShader::createContext(const SkBitmap&, const SkPaint&, const SkMatrix&,
void* storage) const {
return NULL;
}
size_t SkShader::contextSize() const {
return 0;
}
SkShader::Context::Context(const SkShader& shader, const SkBitmap& device,
const SkPaint& paint, const SkMatrix& matrix)
: fShader(shader)