Remove SkShader virtual method validContext
patch from issue 267923005
BUG=skia:
R=scroggo@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/261773005
git-svn-id: http://skia.googlecode.com/svn/trunk@14573 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 67dd581..8e6112a 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -6,6 +6,7 @@
*/
#include "SkBitmapProcShader.h"
+#include "SkEmptyShader.h"
#include "SkReadBuffer.h"
#include "SkMallocPixelRef.h"
#include "SkPaint.h"
@@ -44,23 +45,25 @@
}
}
-bool SkShader::computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) const {
- const SkMatrix* m = &matrix;
+bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse) const {
+ const SkMatrix* m = rec.fMatrix;
SkMatrix total;
if (this->hasLocalMatrix()) {
- total.setConcat(matrix, this->getLocalMatrix());
+ total.setConcat(*m, this->getLocalMatrix());
m = &total;
}
-
return m->invert(totalInverse);
}
-bool SkShader::validContext(const ContextRec& rec, SkMatrix* totalInverse) const {
- return this->computeTotalInverse(*rec.fMatrix, totalInverse);
+SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) const {
+ if (!this->computeTotalInverse(rec, NULL)) {
+ return NULL;
+ }
+ return this->onCreateContext(rec, storage);
}
-SkShader::Context* SkShader::createContext(const ContextRec&, void* storage) const {
+SkShader::Context* SkShader::onCreateContext(const ContextRec&, void*) const {
return NULL;
}
@@ -71,11 +74,9 @@
SkShader::Context::Context(const SkShader& shader, const ContextRec& rec)
: fShader(shader)
{
- SkASSERT(fShader.validContext(rec));
-
// Because the context parameters must be valid at this point, we know that the matrix is
// invertible.
- SkAssertResult(fShader.computeTotalInverse(*rec.fMatrix, &fTotalInverse));
+ SkAssertResult(fShader.computeTotalInverse(rec, &fTotalInverse));
fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse);
fPaintAlpha = rec.fPaint->getAlpha();
@@ -188,6 +189,10 @@
return NULL;
}
+SkShader* SkShader::CreateEmptyShader() {
+ return SkNEW(SkEmptyShader);
+}
+
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
const SkMatrix* localMatrix) {
return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
@@ -246,11 +251,7 @@
return SkGetPackedA32(fPMColor);
}
-SkShader::Context* SkColorShader::createContext(const ContextRec& rec, void* storage) const {
- if (!this->validContext(rec)) {
- return NULL;
- }
-
+SkShader::Context* SkColorShader::onCreateContext(const ContextRec& rec, void* storage) const {
return SkNEW_PLACEMENT_ARGS(storage, ColorShaderContext, (*this, rec));
}