Chromium Code Reviews| Index: src/gpu/GrDrawState.cpp |
| diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp |
| index a3850b087e7abcabbdcc45ce65c07124a29bc3c2..ae4e675ab80b1c20dbe25449d097a940b32868f0 100644 |
| --- a/src/gpu/GrDrawState.cpp |
| +++ b/src/gpu/GrDrawState.cpp |
| @@ -399,10 +399,10 @@ void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState, |
| const SkMatrix& preconcatMatrix) { |
| this->restore(); |
|
robertphillips
2013/05/22 23:47:01
is it right to abort if preconcatMatrix is I? Coul
bsalomon
2013/05/23 12:52:02
Good point! I'll audit the current callers. If non
|
| - fDrawState = drawState; |
| - if (NULL == drawState) { |
| + if (NULL == drawState || preconcatMatrix.isIdentity()) { |
| return; |
| } |
| + fDrawState = drawState; |
| fRestoreMask = 0; |
| fViewMatrix = drawState->getViewMatrix(); |
| @@ -416,50 +416,35 @@ void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState, |
| } |
| } |
| -//////////////////////////////////////////////////////////////////////////////// |
| - |
| -void GrDrawState::AutoDeviceCoordDraw::restore() { |
| - if (NULL != fDrawState) { |
| - fDrawState->setViewMatrix(fViewMatrix); |
| - for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
| - if (fRestoreMask & (1 << s)) { |
| - fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]); |
| - } |
| - } |
| - } |
| - fDrawState = NULL; |
| -} |
| - |
| -bool GrDrawState::AutoDeviceCoordDraw::set(GrDrawState* drawState) { |
| - GrAssert(NULL != drawState); |
| - |
| +bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) { |
| this->restore(); |
| - fDrawState = drawState; |
| - if (NULL == fDrawState) { |
| + if (NULL == drawState) { |
| return false; |
| } |
| - fViewMatrix = drawState->getViewMatrix(); |
| + if (drawState->getViewMatrix().isIdentity()) { |
| + return true; |
| + } |
| + |
| fRestoreMask = 0; |
| + fViewMatrix = drawState->getViewMatrix(); |
| SkMatrix invVM; |
| bool inverted = false; |
| - |
| for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
| if (drawState->isStageEnabled(s)) { |
| if (!inverted && !fViewMatrix.invert(&invVM)) { |
| // sad trombone sound |
| - fDrawState = NULL; |
| return false; |
| } else { |
| inverted = true; |
| } |
| fRestoreMask |= (1 << s); |
| - GrEffectStage* stage = drawState->fStages + s; |
| - stage->saveCoordChange(&fSavedCoordChanges[s]); |
| - stage->localCoordChange(invVM); |
| + drawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]); |
| + drawState->fStages[s].localCoordChange(invVM); |
| } |
| } |
| drawState->viewMatrix()->reset(); |
| + fDrawState = drawState; |
| return true; |
| } |