Chromium Code Reviews| Index: src/core/SkBitmapProcShader.cpp |
| diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp |
| index 46cf7db136d93e8bd2391d134d17e009a666c706..0e06e37f9bd29226d2b494b19e45587bc826bc87 100644 |
| --- a/src/core/SkBitmapProcShader.cpp |
| +++ b/src/core/SkBitmapProcShader.cpp |
| @@ -97,39 +97,26 @@ static bool valid_for_drawing(const SkBitmap& bm) { |
| return true; |
| } |
| -bool SkBitmapProcShader::validInternal(const ContextRec& rec, SkMatrix* totalInverse, |
| - SkBitmapProcState* state) const { |
| +SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, void* storage) const { |
| + void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); |
| + SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState); |
| + |
| if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) { |
| - return false; |
| + return NULL; |
|
scroggo
2014/05/05 14:01:19
Don't we need to call SkBitmapProcState's destruct
reed1
2014/05/05 15:10:01
Rearranged to fix this.
|
| } |
| - |
| + |
| // Make sure we can use totalInverse as a cache. |
|
scroggo
2014/05/05 14:01:19
This comment no longer applies.
reed1
2014/05/05 15:10:01
Done.
|
| - SkMatrix totalInverseLocal; |
| - if (NULL == totalInverse) { |
| - totalInverse = &totalInverseLocal; |
| - } |
| - |
| + SkMatrix totalInverse; |
| // Do this first, so we know the matrix can be inverted. |
| - if (!this->INHERITED::validContext(rec, totalInverse)) { |
| - return false; |
| + if (!this->computeTotalInverse(rec, &totalInverse)) { |
| + return NULL; |
| } |
| - |
| + |
| SkASSERT(state); |
| state->fTileModeX = fTileModeX; |
| state->fTileModeY = fTileModeY; |
| state->fOrigBitmap = fRawBitmap; |
| - return state->chooseProcs(*totalInverse, *rec.fPaint); |
| -} |
| - |
| -bool SkBitmapProcShader::validContext(const ContextRec& rec, SkMatrix* totalInverse) const { |
| - SkBitmapProcState state; |
| - return this->validInternal(rec, totalInverse, &state); |
| -} |
| - |
| -SkShader::Context* SkBitmapProcShader::createContext(const ContextRec& rec, void* storage) const { |
| - void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); |
| - SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState); |
| - if (!this->validInternal(rec, NULL, state)) { |
| + if (!state->chooseProcs(totalInverse, *rec.fPaint)) { |
| state->~SkBitmapProcState(); |
| return NULL; |
| } |