| 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 | 9 |
| 10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
| 11 #include "GrOptDrawState.h" | 11 #include "GrOptDrawState.h" |
| 12 #include "GrPaint.h" | 12 #include "GrPaint.h" |
| 13 #include "GrProcOptInfo.h" | 13 #include "GrProcOptInfo.h" |
| 14 #include "GrXferProcessor.h" |
| 15 #include "effects/GrPorterDuffXferProcessor.h" |
| 14 | 16 |
| 15 //////////////////////////////////////////////////////////////////////////////s | 17 /////////////////////////////////////////////////////////////////////////////// |
| 16 | 18 |
| 17 bool GrDrawState::isEqual(const GrDrawState& that) const { | 19 bool GrDrawState::isEqual(const GrDrawState& that) const { |
| 18 bool usingVertexColors = this->hasColorVertexAttribute(); | 20 bool usingVertexColors = this->hasColorVertexAttribute(); |
| 19 if (!usingVertexColors && this->fColor != that.fColor) { | 21 if (!usingVertexColors && this->fColor != that.fColor) { |
| 20 return false; | 22 return false; |
| 21 } | 23 } |
| 22 | 24 |
| 23 if (this->getRenderTarget() != that.getRenderTarget() || | 25 if (this->getRenderTarget() != that.getRenderTarget() || |
| 24 this->fColorStages.count() != that.fColorStages.count() || | 26 this->fColorStages.count() != that.fColorStages.count() || |
| 25 this->fCoverageStages.count() != that.fCoverageStages.count() || | 27 this->fCoverageStages.count() != that.fCoverageStages.count() || |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 fColor = that.fColor; | 87 fColor = that.fColor; |
| 86 fViewMatrix = that.fViewMatrix; | 88 fViewMatrix = that.fViewMatrix; |
| 87 fSrcBlend = that.fSrcBlend; | 89 fSrcBlend = that.fSrcBlend; |
| 88 fDstBlend = that.fDstBlend; | 90 fDstBlend = that.fDstBlend; |
| 89 fBlendConstant = that.fBlendConstant; | 91 fBlendConstant = that.fBlendConstant; |
| 90 fFlagBits = that.fFlagBits; | 92 fFlagBits = that.fFlagBits; |
| 91 fStencilSettings = that.fStencilSettings; | 93 fStencilSettings = that.fStencilSettings; |
| 92 fCoverage = that.fCoverage; | 94 fCoverage = that.fCoverage; |
| 93 fDrawFace = that.fDrawFace; | 95 fDrawFace = that.fDrawFace; |
| 94 fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get())); | 96 fGeometryProcessor.reset(SkSafeRef(that.fGeometryProcessor.get())); |
| 97 fXPFactory.reset(SkRef(that.getXPFactory())); |
| 95 fColorStages = that.fColorStages; | 98 fColorStages = that.fColorStages; |
| 96 fCoverageStages = that.fCoverageStages; | 99 fCoverageStages = that.fCoverageStages; |
| 97 | 100 |
| 98 fHints = that.fHints; | 101 fHints = that.fHints; |
| 99 | 102 |
| 100 fColorProcInfoValid = that.fColorProcInfoValid; | 103 fColorProcInfoValid = that.fColorProcInfoValid; |
| 101 fCoverageProcInfoValid = that.fCoverageProcInfoValid; | 104 fCoverageProcInfoValid = that.fCoverageProcInfoValid; |
| 102 if (fColorProcInfoValid) { | 105 if (fColorProcInfoValid) { |
| 103 fColorProcInfo = that.fColorProcInfo; | 106 fColorProcInfo = that.fColorProcInfo; |
| 104 } | 107 } |
| 105 if (fCoverageProcInfoValid) { | 108 if (fCoverageProcInfoValid) { |
| 106 fCoverageProcInfo = that.fCoverageProcInfo; | 109 fCoverageProcInfo = that.fCoverageProcInfo; |
| 107 } | 110 } |
| 108 return *this; | 111 return *this; |
| 109 } | 112 } |
| 110 | 113 |
| 111 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { | 114 void GrDrawState::onReset(const SkMatrix* initialViewMatrix) { |
| 112 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); | 115 SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages()); |
| 113 fRenderTarget.reset(NULL); | 116 fRenderTarget.reset(NULL); |
| 114 | 117 |
| 115 fGeometryProcessor.reset(NULL); | 118 fGeometryProcessor.reset(NULL); |
| 119 fXPFactory.reset(GrPorterDuffXPFactory::Create(kOne_GrBlendCoeff, |
| 120 kZero_GrBlendCoeff)); |
| 116 fColorStages.reset(); | 121 fColorStages.reset(); |
| 117 fCoverageStages.reset(); | 122 fCoverageStages.reset(); |
| 118 | 123 |
| 119 fColor = 0xffffffff; | 124 fColor = 0xffffffff; |
| 120 if (NULL == initialViewMatrix) { | 125 if (NULL == initialViewMatrix) { |
| 121 fViewMatrix.reset(); | 126 fViewMatrix.reset(); |
| 122 } else { | 127 } else { |
| 123 fViewMatrix = *initialViewMatrix; | 128 fViewMatrix = *initialViewMatrix; |
| 124 } | 129 } |
| 125 fSrcBlend = kOne_GrBlendCoeff; | 130 fSrcBlend = kOne_GrBlendCoeff; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 fCoverageStages.reset(); | 167 fCoverageStages.reset(); |
| 163 | 168 |
| 164 for (int i = 0; i < paint.numColorStages(); ++i) { | 169 for (int i = 0; i < paint.numColorStages(); ++i) { |
| 165 fColorStages.push_back(paint.getColorStage(i)); | 170 fColorStages.push_back(paint.getColorStage(i)); |
| 166 } | 171 } |
| 167 | 172 |
| 168 for (int i = 0; i < paint.numCoverageStages(); ++i) { | 173 for (int i = 0; i < paint.numCoverageStages(); ++i) { |
| 169 fCoverageStages.push_back(paint.getCoverageStage(i)); | 174 fCoverageStages.push_back(paint.getCoverageStage(i)); |
| 170 } | 175 } |
| 171 | 176 |
| 177 fXPFactory.reset(SkRef(paint.getXPFactory())); |
| 178 |
| 179 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); |
| 172 this->setRenderTarget(rt); | 180 this->setRenderTarget(rt); |
| 173 | 181 |
| 174 fViewMatrix = vm; | 182 fViewMatrix = vm; |
| 175 | 183 |
| 176 // These have no equivalent in GrPaint, set them to defaults | 184 // These have no equivalent in GrPaint, set them to defaults |
| 177 fBlendConstant = 0x0; | 185 fBlendConstant = 0x0; |
| 178 fDrawFace = kBoth_DrawFace; | 186 fDrawFace = kBoth_DrawFace; |
| 179 fStencilSettings.setDisabled(); | 187 fStencilSettings.setDisabled(); |
| 180 fFlagBits = 0; | 188 fFlagBits = 0; |
| 181 fHints = 0; | 189 fHints = 0; |
| 182 | 190 |
| 183 // Enable the clip bit | 191 // Enable the clip bit |
| 184 this->enableState(GrDrawState::kClip_StateBit); | 192 this->enableState(GrDrawState::kClip_StateBit); |
| 185 | 193 |
| 186 this->setColor(paint.getColor()); | 194 this->setColor(paint.getColor()); |
| 187 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); | 195 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); |
| 188 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); | 196 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); |
| 189 | 197 |
| 190 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); | |
| 191 this->setCoverage(0xFF); | 198 this->setCoverage(0xFF); |
| 192 fColorProcInfoValid = false; | 199 fColorProcInfoValid = false; |
| 193 fCoverageProcInfoValid = false; | 200 fCoverageProcInfoValid = false; |
| 194 } | 201 } |
| 195 | 202 |
| 196 //////////////////////////////////////////////////////////////////////////////// | 203 //////////////////////////////////////////////////////////////////////////////// |
| 197 | 204 |
| 198 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { | 205 bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const { |
| 199 if (caps.dualSourceBlendingSupport()) { | 206 if (caps.dualSourceBlendingSupport()) { |
| 200 return true; | 207 return true; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } else { | 552 } else { |
| 546 flags = kRGBA_GrColorComponentFlags; | 553 flags = kRGBA_GrColorComponentFlags; |
| 547 color = this->getCoverageColor(); | 554 color = this->getCoverageColor(); |
| 548 } | 555 } |
| 549 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->n
umCoverageStages(), | 556 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->n
umCoverageStages(), |
| 550 color, flags, true, fGeometryPro
cessor.get()); | 557 color, flags, true, fGeometryPro
cessor.get()); |
| 551 fCoverageProcInfoValid = true; | 558 fCoverageProcInfoValid = true; |
| 552 } | 559 } |
| 553 } | 560 } |
| 554 | 561 |
| OLD | NEW |