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

Unified Diff: src/gpu/GrDrawTarget.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/GrDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index aa475b3ee6855dfe48e1491cb245877c656055ba..02bc8d740b92849bc3f2e960ede9d62b33af7d63 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -657,9 +657,10 @@ GrDrawTarget::AutoStateRestore::AutoStateRestore() {
}
GrDrawTarget::AutoStateRestore::AutoStateRestore(GrDrawTarget* target,
- ASRInit init) {
+ ASRInit init,
+ const SkMatrix* vm) {
fDrawTarget = NULL;
- this->set(target, init);
+ this->set(target, init, vm);
}
GrDrawTarget::AutoStateRestore::~AutoStateRestore() {
@@ -669,7 +670,31 @@ GrDrawTarget::AutoStateRestore::~AutoStateRestore() {
}
}
-void GrDrawTarget::AutoStateRestore::set(GrDrawTarget* target, ASRInit init) {
+void GrDrawTarget::AutoStateRestore::set(GrDrawTarget* target, ASRInit init, const SkMatrix* vm) {
+ GrAssert(NULL == fDrawTarget);
+ fDrawTarget = target;
+ fSavedState = target->drawState();
+ GrAssert(fSavedState);
+ fSavedState->ref();
+ if (kReset_ASRInit == init) {
+ if (NULL == vm) {
+ // calls the default cons
+ fTempState.init();
+ } else {
+ SkNEW_IN_TLAZY(&fTempState, GrDrawState, (*vm));
+ }
+ } else {
+ GrAssert(kPreserve_ASRInit == init);
+ if (NULL == vm) {
+ fTempState.set(*fSavedState);
+ } else {
+ SkNEW_IN_TLAZY(&fTempState, GrDrawState, (*fSavedState, *vm));
+ }
+ }
+ target->setDrawState(fTempState.get());
+}
+
+bool GrDrawTarget::AutoStateRestore::setIdentity(GrDrawTarget* target, ASRInit init) {
GrAssert(NULL == fDrawTarget);
fDrawTarget = target;
fSavedState = target->drawState();
@@ -682,8 +707,17 @@ void GrDrawTarget::AutoStateRestore::set(GrDrawTarget* target, ASRInit init) {
GrAssert(kPreserve_ASRInit == init);
// calls the copy cons
fTempState.set(*fSavedState);
+ if (!fTempState.get()->setIdentityViewMatrix()) {
+ // let go of any resources held by the temp
+ fTempState.get()->reset();
+ fDrawTarget = NULL;
+ fSavedState->unref();
+ fSavedState = NULL;
+ return false;
+ }
}
target->setDrawState(fTempState.get());
+ return true;
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698