Index: src/core/SkComposeShader.cpp |
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp |
index df8215c1a223b5449a3b26edf93214faf4978b6a..fef9e3652769d9e5916a80b855e4dc46d1c5d013 100644 |
--- a/src/core/SkComposeShader.cpp |
+++ b/src/core/SkComposeShader.cpp |
@@ -73,36 +73,7 @@ void SkComposeShader::flatten(SkWriteBuffer& buffer) const { |
buffer.writeFlattenable(fMode); |
} |
-/* We call validContext/createContext on our two worker shaders. |
- However, we always let them see opaque alpha, and if the paint |
- really is translucent, then we apply that after the fact. |
- |
- */ |
-bool SkComposeShader::validContext(const ContextRec& rec, SkMatrix* totalInverse) const { |
- if (!this->INHERITED::validContext(rec, totalInverse)) { |
- return false; |
- } |
- |
- // we preconcat our localMatrix (if any) with the device matrix |
- // before calling our sub-shaders |
- |
- SkMatrix tmpM; |
- tmpM.setConcat(*rec.fMatrix, this->getLocalMatrix()); |
- |
- ContextRec newRec(rec); |
- newRec.fMatrix = &tmpM; |
- |
- return fShaderA->validContext(newRec) && fShaderB->validContext(newRec); |
-} |
- |
-SkShader::Context* SkComposeShader::createContext(const ContextRec& rec, void* storage) const { |
- if (!this->validContext(rec)) { |
- return NULL; |
- } |
- |
- // TODO : must fix this to not "cheat" and modify fPaint |
- SkAutoAlphaRestore restore(const_cast<SkPaint*>(rec.fPaint), 0xFF); |
- |
+SkShader::Context* SkComposeShader::onCreateContext(const ContextRec& rec, void* storage) const { |
char* aStorage = (char*) storage + sizeof(ComposeShaderContext); |
char* bStorage = aStorage + fShaderA->contextSize(); |
@@ -117,11 +88,9 @@ SkShader::Context* SkComposeShader::createContext(const ContextRec& rec, void* s |
SkShader::Context* contextA = fShaderA->createContext(newRec, aStorage); |
SkShader::Context* contextB = fShaderB->createContext(newRec, bStorage); |
- |
- // Both functions must succeed; otherwise validContext should have returned |
- // false. |
- SkASSERT(contextA); |
- SkASSERT(contextB); |
+ if (!contextA || !contextB) { |
+ return NULL; |
+ } |
return SkNEW_PLACEMENT_ARGS(storage, ComposeShaderContext, (*this, rec, contextA, contextB)); |
} |