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

Side by Side 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: undo unrelated change 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrDrawState.h" 8 #include "GrDrawState.h"
9 #include "GrPaint.h" 9 #include "GrPaint.h"
10 10
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]) ; 391 fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]) ;
392 } 392 }
393 } 393 }
394 } 394 }
395 fDrawState = NULL; 395 fDrawState = NULL;
396 } 396 }
397 397
398 void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState, 398 void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState,
399 const SkMatrix& preconcatMatrix) { 399 const SkMatrix& preconcatMatrix) {
400 this->restore(); 400 this->restore();
401 401
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
402 fDrawState = drawState; 402 if (NULL == drawState || preconcatMatrix.isIdentity()) {
403 if (NULL == drawState) {
404 return; 403 return;
405 } 404 }
405 fDrawState = drawState;
406 406
407 fRestoreMask = 0; 407 fRestoreMask = 0;
408 fViewMatrix = drawState->getViewMatrix(); 408 fViewMatrix = drawState->getViewMatrix();
409 drawState->preConcatViewMatrix(preconcatMatrix); 409 drawState->preConcatViewMatrix(preconcatMatrix);
410 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 410 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
411 if (drawState->isStageEnabled(s)) { 411 if (drawState->isStageEnabled(s)) {
412 fRestoreMask |= (1 << s); 412 fRestoreMask |= (1 << s);
413 fDrawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]); 413 fDrawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]);
414 drawState->fStages[s].localCoordChange(preconcatMatrix); 414 drawState->fStages[s].localCoordChange(preconcatMatrix);
415 } 415 }
416 } 416 }
417 } 417 }
418 418
419 //////////////////////////////////////////////////////////////////////////////// 419 bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) {
420
421 void GrDrawState::AutoDeviceCoordDraw::restore() {
422 if (NULL != fDrawState) {
423 fDrawState->setViewMatrix(fViewMatrix);
424 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
425 if (fRestoreMask & (1 << s)) {
426 fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]) ;
427 }
428 }
429 }
430 fDrawState = NULL;
431 }
432
433 bool GrDrawState::AutoDeviceCoordDraw::set(GrDrawState* drawState) {
434 GrAssert(NULL != drawState);
435
436 this->restore(); 420 this->restore();
437 421
438 fDrawState = drawState; 422 if (NULL == drawState) {
439 if (NULL == fDrawState) {
440 return false; 423 return false;
441 } 424 }
442 425
426 if (drawState->getViewMatrix().isIdentity()) {
427 return true;
428 }
429
430 fRestoreMask = 0;
443 fViewMatrix = drawState->getViewMatrix(); 431 fViewMatrix = drawState->getViewMatrix();
444 fRestoreMask = 0;
445 SkMatrix invVM; 432 SkMatrix invVM;
446 bool inverted = false; 433 bool inverted = false;
447
448 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 434 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
449 if (drawState->isStageEnabled(s)) { 435 if (drawState->isStageEnabled(s)) {
450 if (!inverted && !fViewMatrix.invert(&invVM)) { 436 if (!inverted && !fViewMatrix.invert(&invVM)) {
451 // sad trombone sound 437 // sad trombone sound
452 fDrawState = NULL;
453 return false; 438 return false;
454 } else { 439 } else {
455 inverted = true; 440 inverted = true;
456 } 441 }
457 fRestoreMask |= (1 << s); 442 fRestoreMask |= (1 << s);
458 GrEffectStage* stage = drawState->fStages + s; 443 drawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]);
459 stage->saveCoordChange(&fSavedCoordChanges[s]); 444 drawState->fStages[s].localCoordChange(invVM);
460 stage->localCoordChange(invVM);
461 } 445 }
462 } 446 }
463 drawState->viewMatrix()->reset(); 447 drawState->viewMatrix()->reset();
448 fDrawState = drawState;
464 return true; 449 return true;
465 } 450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698