OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef GrDrawTarget_DEFINED | 10 #ifndef GrDrawTarget_DEFINED |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 * Default ASR will have no effect unless set() is subsequently called. | 481 * Default ASR will have no effect unless set() is subsequently called. |
482 */ | 482 */ |
483 AutoStateRestore(); | 483 AutoStateRestore(); |
484 | 484 |
485 /** | 485 /** |
486 * Saves the state on target. The state will be restored when the ASR | 486 * Saves the state on target. The state will be restored when the ASR |
487 * is destroyed. If this constructor is used do not call set(). | 487 * is destroyed. If this constructor is used do not call set(). |
488 * | 488 * |
489 * @param init Should the newly installed GrDrawState be a copy of the | 489 * @param init Should the newly installed GrDrawState be a copy of the |
490 * previous state or a default-initialized GrDrawState. | 490 * previous state or a default-initialized GrDrawState. |
| 491 * @param viewMatrix Optional view matrix. If init = kPreserve then the
draw state's |
| 492 * matrix will be preconcat'ed with the param. All sta
ges will be |
| 493 updated to compensate for the matrix change. If ini
t == kReset |
| 494 then the draw state's matrix will be this matrix. |
491 */ | 495 */ |
492 AutoStateRestore(GrDrawTarget* target, ASRInit init); | 496 AutoStateRestore(GrDrawTarget* target, ASRInit init, const SkMatrix* vie
wMatrix = NULL); |
493 | 497 |
494 ~AutoStateRestore(); | 498 ~AutoStateRestore(); |
495 | 499 |
496 /** | 500 /** |
497 * Saves the state on target. The state will be restored when the ASR | 501 * Saves the state on target. The state will be restored when the ASR |
498 * is destroyed. This should only be called once per ASR object and only | 502 * is destroyed. This should only be called once per ASR object and only |
499 * when the default constructor was used. For nested saves use multiple | 503 * when the default constructor was used. For nested saves use multiple |
500 * ASR objects. | 504 * ASR objects. |
501 * | 505 * |
502 * @param init Should the newly installed GrDrawState be a copy of the | 506 * @param init Should the newly installed GrDrawState be a copy of the |
503 * previous state or a default-initialized GrDrawState. | 507 * previous state or a default-initialized GrDrawState. |
| 508 * @param viewMatrix Optional view matrix. If init = kPreserve then the
draw state's |
| 509 * matrix will be preconcat'ed with the param. All sta
ges will be |
| 510 updated to compensate for the matrix change. If ini
t == kReset |
| 511 then the draw state's matrix will be this matrix. |
504 */ | 512 */ |
505 void set(GrDrawTarget* target, ASRInit init); | 513 void set(GrDrawTarget* target, ASRInit init, const SkMatrix* viewMatrix
= NULL); |
| 514 |
| 515 /** |
| 516 * Like set() but makes the view matrix identity. When init is kReset it
is as though |
| 517 * NULL was passed to set's viewMatrix param. When init is kPreserve it
is as though |
| 518 * the inverse view matrix was passed. If kPreserve is passed and the dr
aw state's matrix |
| 519 * is not invertible then this may fail. |
| 520 */ |
| 521 bool setIdentity(GrDrawTarget* target, ASRInit init); |
506 | 522 |
507 private: | 523 private: |
508 GrDrawTarget* fDrawTarget; | 524 GrDrawTarget* fDrawTarget; |
509 SkTLazy<GrDrawState> fTempState; | 525 SkTLazy<GrDrawState> fTempState; |
510 GrDrawState* fSavedState; | 526 GrDrawState* fSavedState; |
511 }; | 527 }; |
512 | 528 |
513 //////////////////////////////////////////////////////////////////////////// | 529 //////////////////////////////////////////////////////////////////////////// |
514 | 530 |
515 class AutoReleaseGeometry : ::GrNoncopyable { | 531 class AutoReleaseGeometry : ::GrNoncopyable { |
516 public: | 532 public: |
517 AutoReleaseGeometry(GrDrawTarget* target, | 533 AutoReleaseGeometry(GrDrawTarget* target, |
518 int vertexCount, | 534 int vertexCount, |
519 int indexCount); | 535 int indexCount); |
520 AutoReleaseGeometry(); | 536 AutoReleaseGeometry(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 GrDrawTarget* fTarget; | 595 GrDrawTarget* fTarget; |
580 GrDrawState::AutoVertexAttribRestore fAttribRestore; | 596 GrDrawState::AutoVertexAttribRestore fAttribRestore; |
581 }; | 597 }; |
582 | 598 |
583 /** | 599 /** |
584 * Combination of AutoGeometryPush and AutoStateRestore. The vertex attribs
will be in default | 600 * Combination of AutoGeometryPush and AutoStateRestore. The vertex attribs
will be in default |
585 * state regardless of ASRInit value. | 601 * state regardless of ASRInit value. |
586 */ | 602 */ |
587 class AutoGeometryAndStatePush : ::GrNoncopyable { | 603 class AutoGeometryAndStatePush : ::GrNoncopyable { |
588 public: | 604 public: |
589 AutoGeometryAndStatePush(GrDrawTarget* target, ASRInit init) | 605 AutoGeometryAndStatePush(GrDrawTarget* target, |
590 : fState(target, init){ | 606 ASRInit init, |
| 607 const SkMatrix* viewMatrix = NULL) |
| 608 : fState(target, init, viewMatrix) { |
591 GrAssert(NULL != target); | 609 GrAssert(NULL != target); |
592 fTarget = target; | 610 fTarget = target; |
593 target->pushGeometrySource(); | 611 target->pushGeometrySource(); |
594 if (kPreserve_ASRInit == init) { | 612 if (kPreserve_ASRInit == init) { |
595 target->drawState()->setDefaultVertexAttribs(); | 613 target->drawState()->setDefaultVertexAttribs(); |
596 } | 614 } |
597 } | 615 } |
598 | 616 |
599 ~AutoGeometryAndStatePush() { fTarget->popGeometrySource(); } | 617 ~AutoGeometryAndStatePush() { fTarget->popGeometrySource(); } |
600 | 618 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 const GrClipData* fClip; | 846 const GrClipData* fClip; |
829 GrDrawState* fDrawState; | 847 GrDrawState* fDrawState; |
830 GrDrawState fDefaultDraw
State; | 848 GrDrawState fDefaultDraw
State; |
831 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 849 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
832 GrContext* fContext; | 850 GrContext* fContext; |
833 | 851 |
834 typedef GrRefCnt INHERITED; | 852 typedef GrRefCnt INHERITED; |
835 }; | 853 }; |
836 | 854 |
837 #endif | 855 #endif |
OLD | NEW |