Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1085)

Unified Diff: src/gpu/GrDrawState.cpp

Issue 15780002: Replace GrDrawState::AutoDeviceCoordDraw with GrDrawState::AutoViewMatrixRestore::setIdentity(). s (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: update based on comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.cpp
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 2cc50f7dc463c7a3c5511d3d278433275b414e55..f114cccf8949d30eb18a8b8c3997c9d45a6926ba 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -8,6 +8,25 @@
#include "GrDrawState.h"
#include "GrPaint.h"
+bool GrDrawState::setIdentityViewMatrix() {
+ SkMatrix invVM;
+ bool inverted = false;
+ for (int s = 0; s < GrDrawState::kNumStages; ++s) {
+ if (this->isStageEnabled(s)) {
+ if (!inverted) {
+ if (!fCommon.fViewMatrix.invert(&invVM)) {
+ // sad trombone sound
+ return false;
+ }
+ inverted = true;
+ }
+ fStages[s].localCoordChange(invVM);
+ }
+ }
+ fCommon.fViewMatrix.reset();
+ return true;
+}
+
void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRenderTarget* rt) {
for (int i = 0; i < GrPaint::kMaxColorStages; ++i) {
int s = i + GrPaint::kFirstColorStage;
@@ -395,81 +414,59 @@ GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage,
void GrDrawState::AutoViewMatrixRestore::restore() {
if (NULL != fDrawState) {
- fDrawState->setViewMatrix(fViewMatrix);
+ fDrawState->fCommon.fViewMatrix = fViewMatrix;
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (fRestoreMask & (1 << s)) {
fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]);
}
}
+ fDrawState = NULL;
}
- fDrawState = NULL;
}
void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState,
const SkMatrix& preconcatMatrix) {
this->restore();
- fDrawState = drawState;
- if (NULL == drawState) {
+ if (NULL == drawState || preconcatMatrix.isIdentity()) {
return;
}
+ fDrawState = drawState;
fRestoreMask = 0;
fViewMatrix = drawState->getViewMatrix();
- drawState->preConcatViewMatrix(preconcatMatrix);
+ drawState->fCommon.fViewMatrix.preConcat(preconcatMatrix);
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (drawState->isStageEnabled(s)) {
fRestoreMask |= (1 << s);
- fDrawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]);
+ drawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]);
drawState->fStages[s].localCoordChange(preconcatMatrix);
}
}
}
-////////////////////////////////////////////////////////////////////////////////
-
-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;
}
+ if (drawState->getViewMatrix().isIdentity()) {
+ return true;
+ }
+
fViewMatrix = drawState->getViewMatrix();
fRestoreMask = 0;
- 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->viewMatrix()->reset();
+ if (!drawState->setIdentityViewMatrix()) {
+ return false;
+ }
+ fDrawState = drawState;
return true;
}
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698