OLD | NEW |
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // need blending. | 393 // need blending. |
394 return kDisableBlend_BlendOptFlag; | 394 return kDisableBlend_BlendOptFlag; |
395 } | 395 } |
396 return kNone_BlendOpt; | 396 return kNone_BlendOpt; |
397 } | 397 } |
398 | 398 |
399 //////////////////////////////////////////////////////////////////////////////// | 399 //////////////////////////////////////////////////////////////////////////////// |
400 | 400 |
401 void GrDrawState::AutoViewMatrixRestore::restore() { | 401 void GrDrawState::AutoViewMatrixRestore::restore() { |
402 if (NULL != fDrawState) { | 402 if (NULL != fDrawState) { |
403 GR_DEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 403 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
404 fDrawState->fCommon.fViewMatrix = fViewMatrix; | 404 fDrawState->fCommon.fViewMatrix = fViewMatrix; |
405 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); | 405 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); |
406 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; | 406 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; |
407 SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); | 407 SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); |
408 | 408 |
409 int i = 0; | 409 int i = 0; |
410 for (int s = 0; s < fNumColorStages; ++s, ++i) { | 410 for (int s = 0; s < fNumColorStages; ++s, ++i) { |
411 fDrawState->fColorStages[s].restoreCoordChange(fSavedCoordChanges[i]
); | 411 fDrawState->fColorStages[s].restoreCoordChange(fSavedCoordChanges[i]
); |
412 } | 412 } |
413 for (int s = 0; s < numCoverageStages; ++s, ++i) { | 413 for (int s = 0; s < numCoverageStages; ++s, ++i) { |
(...skipping 10 matching lines...) Expand all Loading... |
424 SkASSERT(NULL == fDrawState); | 424 SkASSERT(NULL == fDrawState); |
425 if (NULL == drawState || preconcatMatrix.isIdentity()) { | 425 if (NULL == drawState || preconcatMatrix.isIdentity()) { |
426 return; | 426 return; |
427 } | 427 } |
428 fDrawState = drawState; | 428 fDrawState = drawState; |
429 | 429 |
430 fViewMatrix = drawState->getViewMatrix(); | 430 fViewMatrix = drawState->getViewMatrix(); |
431 drawState->fCommon.fViewMatrix.preConcat(preconcatMatrix); | 431 drawState->fCommon.fViewMatrix.preConcat(preconcatMatrix); |
432 | 432 |
433 this->doEffectCoordChanges(preconcatMatrix); | 433 this->doEffectCoordChanges(preconcatMatrix); |
434 GR_DEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) | 434 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) |
435 } | 435 } |
436 | 436 |
437 bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) { | 437 bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) { |
438 this->restore(); | 438 this->restore(); |
439 | 439 |
440 if (NULL == drawState) { | 440 if (NULL == drawState) { |
441 return false; | 441 return false; |
442 } | 442 } |
443 | 443 |
444 if (drawState->getViewMatrix().isIdentity()) { | 444 if (drawState->getViewMatrix().isIdentity()) { |
445 return true; | 445 return true; |
446 } | 446 } |
447 | 447 |
448 fViewMatrix = drawState->getViewMatrix(); | 448 fViewMatrix = drawState->getViewMatrix(); |
449 if (0 == drawState->numTotalStages()) { | 449 if (0 == drawState->numTotalStages()) { |
450 drawState->fCommon.fViewMatrix.reset(); | 450 drawState->fCommon.fViewMatrix.reset(); |
451 fDrawState = drawState; | 451 fDrawState = drawState; |
452 fNumColorStages = 0; | 452 fNumColorStages = 0; |
453 fSavedCoordChanges.reset(0); | 453 fSavedCoordChanges.reset(0); |
454 GR_DEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) | 454 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) |
455 return true; | 455 return true; |
456 } else { | 456 } else { |
457 SkMatrix inv; | 457 SkMatrix inv; |
458 if (!fViewMatrix.invert(&inv)) { | 458 if (!fViewMatrix.invert(&inv)) { |
459 return false; | 459 return false; |
460 } | 460 } |
461 drawState->fCommon.fViewMatrix.reset(); | 461 drawState->fCommon.fViewMatrix.reset(); |
462 fDrawState = drawState; | 462 fDrawState = drawState; |
463 this->doEffectCoordChanges(inv); | 463 this->doEffectCoordChanges(inv); |
464 GR_DEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) | 464 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) |
465 return true; | 465 return true; |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co
ordChangeMatrix) { | 469 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co
ordChangeMatrix) { |
470 fSavedCoordChanges.reset(fDrawState->numTotalStages()); | 470 fSavedCoordChanges.reset(fDrawState->numTotalStages()); |
471 int i = 0; | 471 int i = 0; |
472 | 472 |
473 fNumColorStages = fDrawState->numColorStages(); | 473 fNumColorStages = fDrawState->numColorStages(); |
474 for (int s = 0; s < fNumColorStages; ++s, ++i) { | 474 for (int s = 0; s < fNumColorStages; ++s, ++i) { |
475 fDrawState->fColorStages[s].saveCoordChange(&fSavedCoordChanges[i]); | 475 fDrawState->fColorStages[s].saveCoordChange(&fSavedCoordChanges[i]); |
476 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); | 476 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); |
477 } | 477 } |
478 | 478 |
479 int numCoverageStages = fDrawState->numCoverageStages(); | 479 int numCoverageStages = fDrawState->numCoverageStages(); |
480 for (int s = 0; s < numCoverageStages; ++s, ++i) { | 480 for (int s = 0; s < numCoverageStages; ++s, ++i) { |
481 fDrawState->fCoverageStages[s].saveCoordChange(&fSavedCoordChanges[i]); | 481 fDrawState->fCoverageStages[s].saveCoordChange(&fSavedCoordChanges[i]); |
482 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); | 482 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); |
483 } | 483 } |
484 } | 484 } |
OLD | NEW |