OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #ifndef GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
10 | 10 |
11 #include "GrBlend.h" | 11 #include "GrBlend.h" |
12 #include "GrOptDrawState.h" | |
13 #include "GrProgramResource.h" | 12 #include "GrProgramResource.h" |
14 #include "GrRODrawState.h" | 13 #include "GrRODrawState.h" |
15 #include "effects/GrSimpleTextureEffect.h" | 14 #include "effects/GrSimpleTextureEffect.h" |
16 | 15 |
| 16 class GrOptDrawState; |
| 17 |
17 /** | 18 /** |
18 * Modifiable subclass derived from GrRODrawState. The majority of the data that
represents a draw | 19 * Modifiable subclass derived from GrRODrawState. The majority of the data that
represents a draw |
19 * state is stored in the parent class. GrDrawState contains methods for setting
, adding to, etc. | 20 * state is stored in the parent class. GrDrawState contains methods for setting
, adding to, etc. |
20 * various data members of the draw state. This class is used to configure the s
tate used when | 21 * various data members of the draw state. This class is used to configure the s
tate used when |
21 * issuing draws via GrDrawTarget. | 22 * issuing draws via GrDrawTarget. |
22 */ | 23 */ |
23 class GrDrawState : public GrRODrawState { | 24 class GrDrawState : public GrRODrawState { |
24 public: | 25 public: |
25 SK_DECLARE_INST_COUNT(GrDrawState) | 26 SK_DECLARE_INST_COUNT(GrDrawState) |
26 | 27 |
(...skipping 13 matching lines...) Expand all Loading... |
40 GrDrawState(const GrDrawState& state) : INHERITED(), fCachedOptState(NULL) { | 41 GrDrawState(const GrDrawState& state) : INHERITED(), fCachedOptState(NULL) { |
41 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 42 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
42 *this = state; | 43 *this = state; |
43 } | 44 } |
44 | 45 |
45 /** | 46 /** |
46 * Copies another draw state with a preconcat to the view matrix. | 47 * Copies another draw state with a preconcat to the view matrix. |
47 **/ | 48 **/ |
48 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix); | 49 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix); |
49 | 50 |
50 virtual ~GrDrawState() { | 51 virtual ~GrDrawState(); |
51 SkSafeUnref(fCachedOptState); | |
52 SkASSERT(0 == fBlockEffectRemovalCnt); | |
53 } | |
54 | 52 |
55 /** | 53 /** |
56 * Resets to the default state. GrEffects will be removed from all stages. | 54 * Resets to the default state. GrEffects will be removed from all stages. |
57 */ | 55 */ |
58 void reset() { this->onReset(NULL); } | 56 void reset() { this->onReset(NULL); } |
59 | 57 |
60 void reset(const SkMatrix& initialViewMatrix) { this->onReset(&initialViewMa
trix); } | 58 void reset(const SkMatrix& initialViewMatrix) { this->onReset(&initialViewMa
trix); } |
61 | 59 |
62 /** | 60 /** |
63 * Initializes the GrDrawState based on a GrPaint, view matrix and render ta
rget. Note that | 61 * Initializes the GrDrawState based on a GrPaint, view matrix and render ta
rget. Note that |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 543 |
546 /** | 544 /** |
547 * Returns a snapshot of the current optimized state. If the current drawSta
te has a valid | 545 * Returns a snapshot of the current optimized state. If the current drawSta
te has a valid |
548 * cached optimiezed state it will simply return a pointer to it otherwise i
t will create a new | 546 * cached optimiezed state it will simply return a pointer to it otherwise i
t will create a new |
549 * GrOptDrawState. In all cases the GrOptDrawState is reffed and ownership i
s given to the | 547 * GrOptDrawState. In all cases the GrOptDrawState is reffed and ownership i
s given to the |
550 * caller. | 548 * caller. |
551 */ | 549 */ |
552 GrOptDrawState* createOptState() const; | 550 GrOptDrawState* createOptState() const; |
553 | 551 |
554 private: | 552 private: |
555 void invalidateOptState() const { | 553 void invalidateOptState() const; |
556 SkSafeSetNull(fCachedOptState); | |
557 fBlendOptFlags = kInvalid_BlendOptFlag; | |
558 } | |
559 | 554 |
560 void onReset(const SkMatrix* initialViewMatrix); | 555 void onReset(const SkMatrix* initialViewMatrix); |
561 | 556 |
562 void invalidateBlendOptFlags() { | |
563 fBlendOptFlags = kInvalid_BlendOptFlag; | |
564 } | |
565 | |
566 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 557 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
567 // This is used to assert that this condition holds. | 558 // This is used to assert that this condition holds. |
568 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 559 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
569 | 560 |
570 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); | 561 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
571 | 562 |
572 mutable GrOptDrawState* fCachedOptState; | 563 mutable GrOptDrawState* fCachedOptState; |
573 | 564 |
574 typedef GrRODrawState INHERITED; | 565 typedef GrRODrawState INHERITED; |
575 }; | 566 }; |
576 | 567 |
577 #endif | 568 #endif |
OLD | NEW |