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 #include "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
11 | 11 |
12 //////////////////////////////////////////////////////////////////////////////s | 12 //////////////////////////////////////////////////////////////////////////////s |
13 | 13 |
14 bool GrDrawState::State::HaveCompatibleState(const State& a, const State& b, | |
15 bool explicitLocalCoords) { | |
16 if (a.fColorStages.count() != b.fColorStages.count() || | |
17 a.fCoverageStages.count() != b.fCoverageStages.count() || | |
18 a.fSrcBlend != b.fSrcBlend || | |
19 a.fDstBlend != b.fDstBlend) { | |
20 return false; | |
21 } | |
22 for (int i = 0; i < a.fColorStages.count(); i++) { | |
23 if (!GrEffectStage::AreCompatible(a.fColorStages[i], b.fColorStages[i], | |
24 explicitLocalCoords)) { | |
25 return false; | |
26 } | |
27 } | |
28 for (int i = 0; i < a.fCoverageStages.count(); i++) { | |
29 if (!GrEffectStage::AreCompatible(a.fCoverageStages[i], b.fCoverageStage
s[i], | |
30 explicitLocalCoords)) { | |
31 return false; | |
32 } | |
33 } | |
34 return true; | |
35 } | |
36 //////////////////////////////////////////////////////////////////////////////s | |
37 GrDrawState::CombinedState GrDrawState::CombineIfPossible( | 14 GrDrawState::CombinedState GrDrawState::CombineIfPossible( |
38 const GrDrawState& a, const GrDrawState& b, const GrDrawTargetCaps& caps) { | 15 const GrDrawState& a, const GrDrawState& b, const GrDrawTargetCaps& caps) { |
39 | 16 |
40 bool usingVertexColors = a.hasColorVertexAttribute(); | 17 bool usingVertexColors = a.hasColorVertexAttribute(); |
41 if (!usingVertexColors && a.fColor != b.fColor) { | 18 if (!usingVertexColors && a.fColor != b.fColor) { |
42 return kIncompatible_CombinedState; | 19 return kIncompatible_CombinedState; |
43 } | 20 } |
44 | 21 |
45 if (a.fRenderTarget.get() != b.fRenderTarget.get() || | 22 if (a.fRenderTarget.get() != b.fRenderTarget.get() || |
| 23 a.fColorStages.count() != b.fColorStages.count() || |
| 24 a.fCoverageStages.count() != b.fCoverageStages.count() || |
46 !a.fViewMatrix.cheapEqualTo(b.fViewMatrix) || | 25 !a.fViewMatrix.cheapEqualTo(b.fViewMatrix) || |
| 26 a.fSrcBlend != b.fSrcBlend || |
| 27 a.fDstBlend != b.fDstBlend || |
47 a.fBlendConstant != b.fBlendConstant || | 28 a.fBlendConstant != b.fBlendConstant || |
48 a.fFlagBits != b.fFlagBits || | 29 a.fFlagBits != b.fFlagBits || |
49 a.fVACount != b.fVACount || | 30 a.fVACount != b.fVACount || |
50 memcmp(a.fVAPtr, b.fVAPtr, a.fVACount * sizeof(GrVertexAttrib)) || | 31 memcmp(a.fVAPtr, b.fVAPtr, a.fVACount * sizeof(GrVertexAttrib)) || |
51 a.fStencilSettings != b.fStencilSettings || | 32 a.fStencilSettings != b.fStencilSettings || |
52 a.fDrawFace != b.fDrawFace) { | 33 a.fDrawFace != b.fDrawFace) { |
53 return kIncompatible_CombinedState; | 34 return kIncompatible_CombinedState; |
54 } | 35 } |
55 | 36 |
56 bool usingVertexCoverage = a.hasCoverageVertexAttribute(); | 37 bool usingVertexCoverage = a.hasCoverageVertexAttribute(); |
57 if (!usingVertexCoverage && a.fCoverage != b.fCoverage) { | 38 if (!usingVertexCoverage && a.fCoverage != b.fCoverage) { |
58 return kIncompatible_CombinedState; | 39 return kIncompatible_CombinedState; |
59 } | 40 } |
60 | 41 |
61 bool explicitLocalCoords = a.hasLocalCoordAttribute(); | 42 bool explicitLocalCoords = a.hasLocalCoordAttribute(); |
| 43 for (int i = 0; i < a.numColorStages(); i++) { |
| 44 if (!GrEffectStage::AreCompatible(a.getColorStage(i), b.getColorStage(i)
, |
| 45 explicitLocalCoords)) { |
| 46 return kIncompatible_CombinedState; |
| 47 } |
| 48 } |
| 49 for (int i = 0; i < a.numCoverageStages(); i++) { |
| 50 if (!GrEffectStage::AreCompatible(a.getCoverageStage(i), b.getCoverageSt
age(i), |
| 51 explicitLocalCoords)) { |
| 52 return kIncompatible_CombinedState; |
| 53 } |
| 54 } |
62 | 55 |
63 SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices, | 56 SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices, |
64 b.fFixedFunctionVertexAttribIndices, | 57 b.fFixedFunctionVertexAttribIndices, |
65 sizeof(a.fFixedFunctionVertexAttribIndices))); | 58 sizeof(a.fFixedFunctionVertexAttribIndices))); |
66 if (!State::HaveCompatibleState(a.fState, b.fState, explicitLocalCoords)) { | |
67 return kIncompatible_CombinedState; | |
68 } | |
69 | 59 |
70 if (usingVertexColors) { | 60 if (usingVertexColors) { |
71 // If one is opaque and the other is not then the combined state is not
opaque. Moreover, | 61 // If one is opaque and the other is not then the combined state is not
opaque. Moreover, |
72 // if the opaqueness affects the ability to get color/coverage blending
correct then we | 62 // if the opaqueness affects the ability to get color/coverage blending
correct then we |
73 // don't combine the draw states. | 63 // don't combine the draw states. |
74 bool aIsOpaque = (kVertexColorsAreOpaque_Hint & a.fHints); | 64 bool aIsOpaque = (kVertexColorsAreOpaque_Hint & a.fHints); |
75 bool bIsOpaque = (kVertexColorsAreOpaque_Hint & b.fHints); | 65 bool bIsOpaque = (kVertexColorsAreOpaque_Hint & b.fHints); |
76 if (aIsOpaque != bIsOpaque) { | 66 if (aIsOpaque != bIsOpaque) { |
77 const GrDrawState* opaque; | 67 const GrDrawState* opaque; |
78 const GrDrawState* nonOpaque; | 68 const GrDrawState* nonOpaque; |
(...skipping 16 matching lines...) Expand all Loading... |
95 return kAOrB_CombinedState; | 85 return kAOrB_CombinedState; |
96 } | 86 } |
97 | 87 |
98 //////////////////////////////////////////////////////////////////////////////s | 88 //////////////////////////////////////////////////////////////////////////////s |
99 | 89 |
100 GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatr
ix) { | 90 GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatr
ix) { |
101 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 91 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
102 *this = state; | 92 *this = state; |
103 if (!preConcatMatrix.isIdentity()) { | 93 if (!preConcatMatrix.isIdentity()) { |
104 for (int i = 0; i < this->numColorStages(); ++i) { | 94 for (int i = 0; i < this->numColorStages(); ++i) { |
105 fState.fColorStages[i].localCoordChange(preConcatMatrix); | 95 fColorStages[i].localCoordChange(preConcatMatrix); |
106 } | 96 } |
107 for (int i = 0; i < this->numCoverageStages(); ++i) { | 97 for (int i = 0; i < this->numCoverageStages(); ++i) { |
108 fState.fCoverageStages[i].localCoordChange(preConcatMatrix); | 98 fCoverageStages[i].localCoordChange(preConcatMatrix); |
109 } | 99 } |
110 this->invalidateBlendOptFlags(); | 100 this->invalidateBlendOptFlags(); |
111 } | 101 } |
112 } | 102 } |
113 | 103 |
114 GrDrawState& GrDrawState::operator=(const GrDrawState& that) { | 104 GrDrawState& GrDrawState::operator=(const GrDrawState& that) { |
115 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); | 105 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
116 this->setRenderTarget(that.fRenderTarget.get()); | 106 this->setRenderTarget(that.fRenderTarget.get()); |
117 fColor = that.fColor; | 107 fColor = that.fColor; |
118 fViewMatrix = that.fViewMatrix; | 108 fViewMatrix = that.fViewMatrix; |
| 109 fSrcBlend = that.fSrcBlend; |
| 110 fDstBlend = that.fDstBlend; |
119 fBlendConstant = that.fBlendConstant; | 111 fBlendConstant = that.fBlendConstant; |
120 fFlagBits = that.fFlagBits; | 112 fFlagBits = that.fFlagBits; |
121 fVACount = that.fVACount; | 113 fVACount = that.fVACount; |
122 fVAPtr = that.fVAPtr; | 114 fVAPtr = that.fVAPtr; |
123 fStencilSettings = that.fStencilSettings; | 115 fStencilSettings = that.fStencilSettings; |
124 fCoverage = that.fCoverage; | 116 fCoverage = that.fCoverage; |
125 fDrawFace = that.fDrawFace; | 117 fDrawFace = that.fDrawFace; |
| 118 fColorStages = that.fColorStages; |
| 119 fCoverageStages = that.fCoverageStages; |
126 fOptSrcBlend = that.fOptSrcBlend; | 120 fOptSrcBlend = that.fOptSrcBlend; |
127 fOptDstBlend = that.fOptDstBlend; | 121 fOptDstBlend = that.fOptDstBlend; |
128 fBlendOptFlags = that.fBlendOptFlags; | 122 fBlendOptFlags = that.fBlendOptFlags; |
129 | 123 |
130 fState = that.fState; | |
131 fHints = that.fHints; | 124 fHints = that.fHints; |
132 | 125 |
133 memcpy(fFixedFunctionVertexAttribIndices, | 126 memcpy(fFixedFunctionVertexAttribIndices, |
134 that.fFixedFunctionVertexAttribIndices, | 127 that.fFixedFunctionVertexAttribIndices, |
135 sizeof(fFixedFunctionVertexAttribIndices)); | 128 sizeof(fFixedFunctionVertexAttribIndices)); |
136 return *this; | 129 return *this; |
137 } | 130 } |
138 | 131 |
139 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { | 132 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
140 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); | 133 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
141 fState.reset(); | 134 fColorStages.reset(); |
| 135 fCoverageStages.reset(); |
142 | 136 |
143 fRenderTarget.reset(NULL); | 137 fRenderTarget.reset(NULL); |
144 | 138 |
145 this->setDefaultVertexAttribs(); | 139 this->setDefaultVertexAttribs(); |
146 | 140 |
147 fColor = 0xffffffff; | 141 fColor = 0xffffffff; |
148 if (NULL == initialViewMatrix) { | 142 if (NULL == initialViewMatrix) { |
149 fViewMatrix.reset(); | 143 fViewMatrix.reset(); |
150 } else { | 144 } else { |
151 fViewMatrix = *initialViewMatrix; | 145 fViewMatrix = *initialViewMatrix; |
152 } | 146 } |
| 147 fSrcBlend = kOne_GrBlendCoeff; |
| 148 fDstBlend = kZero_GrBlendCoeff; |
153 fBlendConstant = 0x0; | 149 fBlendConstant = 0x0; |
154 fFlagBits = 0x0; | 150 fFlagBits = 0x0; |
155 fStencilSettings.setDisabled(); | 151 fStencilSettings.setDisabled(); |
156 fCoverage = 0xffffffff; | 152 fCoverage = 0xff; |
157 fDrawFace = kBoth_DrawFace; | 153 fDrawFace = kBoth_DrawFace; |
158 | 154 |
159 fHints = 0; | 155 fHints = 0; |
160 | 156 |
161 this->invalidateBlendOptFlags(); | 157 this->invalidateBlendOptFlags(); |
162 } | 158 } |
163 | 159 |
164 bool GrDrawState::setIdentityViewMatrix() { | 160 bool GrDrawState::setIdentityViewMatrix() { |
165 if (this->numTotalStages()) { | 161 if (this->numTotalStages()) { |
166 SkMatrix invVM; | 162 SkMatrix invVM; |
167 if (!fViewMatrix.invert(&invVM)) { | 163 if (!fViewMatrix.invert(&invVM)) { |
168 // sad trombone sound | 164 // sad trombone sound |
169 return false; | 165 return false; |
170 } | 166 } |
171 for (int s = 0; s < this->numColorStages(); ++s) { | 167 for (int s = 0; s < this->numColorStages(); ++s) { |
172 fState.fColorStages[s].localCoordChange(invVM); | 168 fColorStages[s].localCoordChange(invVM); |
173 } | 169 } |
174 for (int s = 0; s < this->numCoverageStages(); ++s) { | 170 for (int s = 0; s < this->numCoverageStages(); ++s) { |
175 fState.fCoverageStages[s].localCoordChange(invVM); | 171 fCoverageStages[s].localCoordChange(invVM); |
176 } | 172 } |
177 } | 173 } |
178 fViewMatrix.reset(); | 174 fViewMatrix.reset(); |
179 return true; | 175 return true; |
180 } | 176 } |
181 | 177 |
182 void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende
rTarget* rt) { | 178 void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende
rTarget* rt) { |
183 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); | 179 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
184 | 180 |
185 fState.reset(); | 181 fColorStages.reset(); |
| 182 fCoverageStages.reset(); |
186 | 183 |
187 for (int i = 0; i < paint.numColorStages(); ++i) { | 184 for (int i = 0; i < paint.numColorStages(); ++i) { |
188 fState.fColorStages.push_back(paint.getColorStage(i)); | 185 fColorStages.push_back(paint.getColorStage(i)); |
189 } | 186 } |
190 | 187 |
191 for (int i = 0; i < paint.numCoverageStages(); ++i) { | 188 for (int i = 0; i < paint.numCoverageStages(); ++i) { |
192 fState.fCoverageStages.push_back(paint.getCoverageStage(i)); | 189 fCoverageStages.push_back(paint.getCoverageStage(i)); |
193 } | 190 } |
194 | 191 |
195 this->setRenderTarget(rt); | 192 this->setRenderTarget(rt); |
196 | 193 |
197 fViewMatrix = vm; | 194 fViewMatrix = vm; |
198 | 195 |
199 // These have no equivalent in GrPaint, set them to defaults | 196 // These have no equivalent in GrPaint, set them to defaults |
200 fBlendConstant = 0x0; | 197 fBlendConstant = 0x0; |
201 fDrawFace = kBoth_DrawFace; | 198 fDrawFace = kBoth_DrawFace; |
202 fStencilSettings.setDisabled(); | 199 fStencilSettings.setDisabled(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 if (this->isCoverageDrawing()) { | 426 if (this->isCoverageDrawing()) { |
430 return true; | 427 return true; |
431 } | 428 } |
432 | 429 |
433 GrColor coverage; | 430 GrColor coverage; |
434 uint32_t validComponentFlags; | 431 uint32_t validComponentFlags; |
435 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. | 432 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. |
436 if (this->hasCoverageVertexAttribute()) { | 433 if (this->hasCoverageVertexAttribute()) { |
437 validComponentFlags = 0; | 434 validComponentFlags = 0; |
438 } else { | 435 } else { |
439 coverage = fCoverage; | 436 coverage = this->getCoverageColor(); |
440 validComponentFlags = kRGBA_GrColorComponentFlags; | 437 validComponentFlags = kRGBA_GrColorComponentFlags; |
441 } | 438 } |
442 | 439 |
443 // Run through the coverage stages and see if the coverage will be all ones
at the end. | 440 // Run through the coverage stages and see if the coverage will be all ones
at the end. |
444 for (int s = 0; s < this->numCoverageStages(); ++s) { | 441 for (int s = 0; s < this->numCoverageStages(); ++s) { |
445 const GrEffect* effect = this->getCoverageStage(s).getEffect(); | 442 const GrEffect* effect = this->getCoverageStage(s).getEffect(); |
446 effect->getConstantColorComponents(&coverage, &validComponentFlags); | 443 effect->getConstantColorComponents(&coverage, &validComponentFlags); |
447 } | 444 } |
448 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff =
= coverage); | 445 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff =
= coverage); |
449 } | 446 } |
450 | 447 |
451 //////////////////////////////////////////////////////////////////////////////// | 448 //////////////////////////////////////////////////////////////////////////////// |
452 | 449 |
453 // Some blend modes allow folding a fractional coverage value into the color's a
lpha channel, while | 450 // Some blend modes allow folding a fractional coverage value into the color's a
lpha channel, while |
454 // others will blend incorrectly. | 451 // others will blend incorrectly. |
455 bool GrDrawState::canTweakAlphaForCoverage() const { | 452 bool GrDrawState::canTweakAlphaForCoverage() const { |
456 /* | 453 /* |
457 The fractional coverage is f. | 454 The fractional coverage is f. |
458 The src and dst coeffs are Cs and Cd. | 455 The src and dst coeffs are Cs and Cd. |
459 The dst and src colors are S and D. | 456 The dst and src colors are S and D. |
460 We want the blend to compute: f*Cs*S + (f*Cd + (1-f))D. By tweaking the sou
rce color's alpha | 457 We want the blend to compute: f*Cs*S + (f*Cd + (1-f))D. By tweaking the sou
rce color's alpha |
461 we're replacing S with S'=fS. It's obvious that that first term will always
be ok. The second | 458 we're replacing S with S'=fS. It's obvious that that first term will always
be ok. The second |
462 term can be rearranged as [1-(1-Cd)f]D. By substituting in the various poss
ibilities for Cd we | 459 term can be rearranged as [1-(1-Cd)f]D. By substituting in the various poss
ibilities for Cd we |
463 find that only 1, ISA, and ISC produce the correct destination when applied
to S' and D. | 460 find that only 1, ISA, and ISC produce the correct destination when applied
to S' and D. |
464 Also, if we're directly rendering coverage (isCoverageDrawing) then coverag
e is treated as | 461 Also, if we're directly rendering coverage (isCoverageDrawing) then coverag
e is treated as |
465 color by definition. | 462 color by definition. |
466 */ | 463 */ |
467 return kOne_GrBlendCoeff == fState.fDstBlend || | 464 return kOne_GrBlendCoeff == fDstBlend || |
468 kISA_GrBlendCoeff == fState.fDstBlend || | 465 kISA_GrBlendCoeff == fDstBlend || |
469 kISC_GrBlendCoeff == fState.fDstBlend || | 466 kISC_GrBlendCoeff == fDstBlend || |
470 this->isCoverageDrawing(); | 467 this->isCoverageDrawing(); |
471 } | 468 } |
472 | 469 |
473 GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, | 470 GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, |
474 GrBlendCoeff* srcCoeff, | 471 GrBlendCoeff* srcCoeff, |
475 GrBlendCoeff* dstCoeff) con
st { | 472 GrBlendCoeff* dstCoeff) con
st { |
476 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; | 473 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; |
477 if (NULL == srcCoeff) { | 474 if (NULL == srcCoeff) { |
478 srcCoeff = &bogusSrcCoeff; | 475 srcCoeff = &bogusSrcCoeff; |
479 } | 476 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 fVACount = drawState->fVACount; | 595 fVACount = drawState->fVACount; |
599 fDrawState->setDefaultVertexAttribs(); | 596 fDrawState->setDefaultVertexAttribs(); |
600 } | 597 } |
601 | 598 |
602 //////////////////////////////////////////////////////////////////////////////s | 599 //////////////////////////////////////////////////////////////////////////////s |
603 | 600 |
604 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { | 601 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
605 if (NULL != fDrawState) { | 602 if (NULL != fDrawState) { |
606 int m = fDrawState->numColorStages() - fColorEffectCnt; | 603 int m = fDrawState->numColorStages() - fColorEffectCnt; |
607 SkASSERT(m >= 0); | 604 SkASSERT(m >= 0); |
608 fDrawState->fState.fColorStages.pop_back_n(m); | 605 fDrawState->fColorStages.pop_back_n(m); |
609 | 606 |
610 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; | 607 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; |
611 SkASSERT(n >= 0); | 608 SkASSERT(n >= 0); |
612 fDrawState->fState.fCoverageStages.pop_back_n(n); | 609 fDrawState->fCoverageStages.pop_back_n(n); |
613 if (m + n > 0) { | 610 if (m + n > 0) { |
614 fDrawState->invalidateBlendOptFlags(); | 611 fDrawState->invalidateBlendOptFlags(); |
615 } | 612 } |
616 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 613 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
617 } | 614 } |
618 fDrawState = ds; | 615 fDrawState = ds; |
619 if (NULL != ds) { | 616 if (NULL != ds) { |
620 fColorEffectCnt = ds->numColorStages(); | 617 fColorEffectCnt = ds->numColorStages(); |
621 fCoverageEffectCnt = ds->numCoverageStages(); | 618 fCoverageEffectCnt = ds->numCoverageStages(); |
622 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) | 619 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) |
623 } | 620 } |
624 } | 621 } |
625 | 622 |
626 //////////////////////////////////////////////////////////////////////////////// | 623 //////////////////////////////////////////////////////////////////////////////// |
627 | 624 |
628 void GrDrawState::AutoViewMatrixRestore::restore() { | 625 void GrDrawState::AutoViewMatrixRestore::restore() { |
629 if (NULL != fDrawState) { | 626 if (NULL != fDrawState) { |
630 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 627 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
631 fDrawState->fViewMatrix = fViewMatrix; | 628 fDrawState->fViewMatrix = fViewMatrix; |
632 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); | 629 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); |
633 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; | 630 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; |
634 SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); | 631 SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); |
635 | 632 |
636 int i = 0; | 633 int i = 0; |
637 for (int s = 0; s < fNumColorStages; ++s, ++i) { | 634 for (int s = 0; s < fNumColorStages; ++s, ++i) { |
638 fDrawState->fState.fColorStages[s].restoreCoordChange(fSavedCoordCha
nges[i]); | 635 fDrawState->fColorStages[s].restoreCoordChange(fSavedCoordChanges[i]
); |
639 } | 636 } |
640 for (int s = 0; s < numCoverageStages; ++s, ++i) { | 637 for (int s = 0; s < numCoverageStages; ++s, ++i) { |
641 fDrawState->fState.fCoverageStages[s].restoreCoordChange(fSavedCoord
Changes[i]); | 638 fDrawState->fCoverageStages[s].restoreCoordChange(fSavedCoordChanges
[i]); |
642 } | 639 } |
643 fDrawState = NULL; | 640 fDrawState = NULL; |
644 } | 641 } |
645 } | 642 } |
646 | 643 |
647 void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState, | 644 void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState, |
648 const SkMatrix& preconcatMatrix) { | 645 const SkMatrix& preconcatMatrix) { |
649 this->restore(); | 646 this->restore(); |
650 | 647 |
651 SkASSERT(NULL == fDrawState); | 648 SkASSERT(NULL == fDrawState); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 } | 690 } |
694 } | 691 } |
695 | 692 |
696 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co
ordChangeMatrix) { | 693 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co
ordChangeMatrix) { |
697 fSavedCoordChanges.reset(fDrawState->numTotalStages()); | 694 fSavedCoordChanges.reset(fDrawState->numTotalStages()); |
698 int i = 0; | 695 int i = 0; |
699 | 696 |
700 fNumColorStages = fDrawState->numColorStages(); | 697 fNumColorStages = fDrawState->numColorStages(); |
701 for (int s = 0; s < fNumColorStages; ++s, ++i) { | 698 for (int s = 0; s < fNumColorStages; ++s, ++i) { |
702 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); | 699 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); |
703 fDrawState->fState.fColorStages[s].localCoordChange(coordChangeMatrix); | 700 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); |
704 } | 701 } |
705 | 702 |
706 int numCoverageStages = fDrawState->numCoverageStages(); | 703 int numCoverageStages = fDrawState->numCoverageStages(); |
707 for (int s = 0; s < numCoverageStages; ++s, ++i) { | 704 for (int s = 0; s < numCoverageStages; ++s, ++i) { |
708 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]); | 705 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]); |
709 fDrawState->fState.fCoverageStages[s].localCoordChange(coordChangeMatrix
); | 706 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); |
710 } | 707 } |
711 } | 708 } |
OLD | NEW |