| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrOptDrawState.h" | 8 #include "GrOptDrawState.h" |
| 9 | 9 |
| 10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 fStencilSettings = drawState.getStencil(); | 28 fStencilSettings = drawState.getStencil(); |
| 29 fDrawFace = (DrawFace)drawState.getDrawFace(); | 29 fDrawFace = (DrawFace)drawState.getDrawFace(); |
| 30 fBlendOptFlags = blendOptFlags; | 30 fBlendOptFlags = blendOptFlags; |
| 31 fSrcBlend = optSrcCoeff; | 31 fSrcBlend = optSrcCoeff; |
| 32 fDstBlend = optDstCoeff; | 32 fDstBlend = optDstCoeff; |
| 33 | 33 |
| 34 memcpy(fFixedFunctionVertexAttribIndices, | 34 memcpy(fFixedFunctionVertexAttribIndices, |
| 35 drawState.getFixedFunctionVertexAttribIndices(), | 35 drawState.getFixedFunctionVertexAttribIndices(), |
| 36 sizeof(fFixedFunctionVertexAttribIndices)); | 36 sizeof(fFixedFunctionVertexAttribIndices)); |
| 37 | 37 |
| 38 | |
| 39 fInputColorIsUsed = true; | 38 fInputColorIsUsed = true; |
| 40 fInputCoverageIsUsed = true; | 39 fInputCoverageIsUsed = true; |
| 41 | 40 |
| 41 fFirstColorStageIdx = 0; |
| 42 fFirstCoverageStageIdx = 0; |
| 43 fFixedFunctionVAToRemove = 0; |
| 44 |
| 45 this->computeEffectiveColorStages(drawState); |
| 46 this->computeEffectiveCoverageStages(drawState); |
| 47 this->adjustFromBlendOpts(drawState); |
| 48 this->removeFixedFunctionVertexAttribs(); |
| 49 this->getStageStats(drawState); |
| 50 this->setOutputStateInfo(drawState, caps); |
| 51 |
| 52 // Copy GeometryProcesssor from DS or ODS |
| 42 if (drawState.hasGeometryProcessor()) { | 53 if (drawState.hasGeometryProcessor()) { |
| 43 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom
etryProcessor()))); | 54 fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeom
etryProcessor()))); |
| 44 } else { | 55 } else { |
| 45 fGeometryProcessor.reset(NULL); | 56 fGeometryProcessor.reset(NULL); |
| 46 } | 57 } |
| 47 | 58 |
| 48 this->copyEffectiveColorStages(drawState); | 59 // Copy Color Stages from DS to ODS |
| 49 this->copyEffectiveCoverageStages(drawState); | 60 if (fFirstColorStageIdx < drawState.numColorStages()) { |
| 50 this->adjustFromBlendOpts(); | 61 fColorStages.reset(&drawState.getColorStage(fFirstColorStageIdx), |
| 51 this->getStageStats(); | 62 drawState.numColorStages() - fFirstColorStageIdx); |
| 52 this->setOutputStateInfo(caps); | 63 } else { |
| 64 fColorStages.reset(); |
| 65 } |
| 66 |
| 67 // Copy Coverage Stages from DS to ODS |
| 68 if (drawState.numCoverageStages() > 0 && fSeparateCoverageFromColor) { |
| 69 fCoverageStages.reset(&drawState.getCoverageStage(fFirstCoverageStageIdx
), |
| 70 drawState.numCoverageStages() - fFirstCoverageStag
eIdx); |
| 71 } else { |
| 72 fCoverageStages.reset(); |
| 73 if (drawState.numCoverageStages() > 0) { |
| 74 // TODO: Once we have flag to know if we only multiply on stages, on
ly push coverage |
| 75 // into color stages if everything is multipy |
| 76 fColorStages.push_back_n(drawState.numCoverageStages() - fFirstCover
ageStageIdx, |
| 77 &drawState.getCoverageStage(fFirstCoverageS
tageIdx)); |
| 78 } |
| 79 } |
| 53 }; | 80 }; |
| 54 | 81 |
| 55 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra
wTargetCaps& caps, | 82 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, const GrDra
wTargetCaps& caps, |
| 56 GrGpu::DrawType drawType) { | 83 GrGpu::DrawType drawType) { |
| 57 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa
chedCapsID) { | 84 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa
chedCapsID) { |
| 58 GrBlendCoeff srcCoeff; | 85 GrBlendCoeff srcCoeff; |
| 59 GrBlendCoeff dstCoeff; | 86 GrBlendCoeff dstCoeff; |
| 60 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, | 87 BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false, |
| 61 &srcCo
eff, | 88 &srcCo
eff, |
| 62 &dstCo
eff); | 89 &dstCo
eff); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 &srcCo
eff, | 108 &srcCo
eff, |
| 82 &dstCo
eff); | 109 &dstCo
eff); |
| 83 SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, caps)
== | 110 SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, caps)
== |
| 84 *drawState.fCachedOptState); | 111 *drawState.fCachedOptState); |
| 85 #endif | 112 #endif |
| 86 } | 113 } |
| 87 drawState.fCachedOptState->ref(); | 114 drawState.fCachedOptState->ref(); |
| 88 return drawState.fCachedOptState; | 115 return drawState.fCachedOptState; |
| 89 } | 116 } |
| 90 | 117 |
| 91 void GrOptDrawState::setOutputStateInfo(const GrDrawTargetCaps& caps) { | 118 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, const GrDrawTarge
tCaps& caps) { |
| 92 // Set this default and then possibly change our mind if there is coverage. | 119 // Set this default and then possibly change our mind if there is coverage. |
| 93 fPrimaryOutputType = kModulate_PrimaryOutputType; | 120 fPrimaryOutputType = kModulate_PrimaryOutputType; |
| 94 fSecondaryOutputType = kNone_SecondaryOutputType; | 121 fSecondaryOutputType = kNone_SecondaryOutputType; |
| 95 | 122 |
| 96 // If we do have coverage determine whether it matters. | 123 // If we do have coverage determine whether it matters. |
| 97 bool separateCoverageFromColor = this->hasGeometryProcessor(); | 124 fSeparateCoverageFromColor = this->hasGeometryProcessor(); |
| 98 if (!this->isCoverageDrawing() && | 125 if (!this->isCoverageDrawing() && |
| 99 (this->numCoverageStages() > 0 || | 126 (ds.numCoverageStages() - fFirstCoverageStageIdx > 0 || |
| 100 this->hasGeometryProcessor() || | 127 ds.hasGeometryProcessor() || |
| 101 this->hasCoverageVertexAttribute())) { | 128 this->hasCoverageVertexAttribute())) { |
| 102 | 129 |
| 103 if (caps.dualSourceBlendingSupport()) { | 130 if (caps.dualSourceBlendingSupport()) { |
| 104 if (kZero_GrBlendCoeff == fDstBlend) { | 131 if (kZero_GrBlendCoeff == fDstBlend) { |
| 105 // write the coverage value to second color | 132 // write the coverage value to second color |
| 106 fSecondaryOutputType = kCoverage_SecondaryOutputType; | 133 fSecondaryOutputType = kCoverage_SecondaryOutputType; |
| 107 separateCoverageFromColor = true; | 134 fSeparateCoverageFromColor = true; |
| 108 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 135 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 109 } else if (kSA_GrBlendCoeff == fDstBlend) { | 136 } else if (kSA_GrBlendCoeff == fDstBlend) { |
| 110 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 137 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 111 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; | 138 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; |
| 112 separateCoverageFromColor = true; | 139 fSeparateCoverageFromColor = true; |
| 113 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 140 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 114 } else if (kSC_GrBlendCoeff == fDstBlend) { | 141 } else if (kSC_GrBlendCoeff == fDstBlend) { |
| 115 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 142 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 116 fSecondaryOutputType = kCoverageISC_SecondaryOutputType; | 143 fSecondaryOutputType = kCoverageISC_SecondaryOutputType; |
| 117 separateCoverageFromColor = true; | 144 fSeparateCoverageFromColor = true; |
| 118 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 145 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 119 } | 146 } |
| 120 } else if (fReadsDst && | 147 } else if (fReadsDst && |
| 121 kOne_GrBlendCoeff == fSrcBlend && | 148 kOne_GrBlendCoeff == fSrcBlend && |
| 122 kZero_GrBlendCoeff == fDstBlend) { | 149 kZero_GrBlendCoeff == fDstBlend) { |
| 123 fPrimaryOutputType = kCombineWithDst_PrimaryOutputType; | 150 fPrimaryOutputType = kCombineWithDst_PrimaryOutputType; |
| 124 separateCoverageFromColor = true; | 151 fSeparateCoverageFromColor = true; |
| 125 } | 152 } |
| 126 } | 153 } |
| 127 | |
| 128 // TODO: Once we have flag to know if we only multiply on stages, only push
coverage into color | |
| 129 // stages if everything is multipy | |
| 130 if (!separateCoverageFromColor) { | |
| 131 for (int s = 0; s < this->numCoverageStages(); ++s) { | |
| 132 fColorStages.push_back(this->getCoverageStage(s)); | |
| 133 } | |
| 134 fCoverageStages.reset(); | |
| 135 } | |
| 136 } | 154 } |
| 137 | 155 |
| 138 void GrOptDrawState::adjustFromBlendOpts() { | 156 void GrOptDrawState::adjustFromBlendOpts(const GrDrawState& ds) { |
| 139 | |
| 140 switch (fBlendOptFlags) { | 157 switch (fBlendOptFlags) { |
| 141 case kNone_BlendOpt: | 158 case kNone_BlendOpt: |
| 142 case kSkipDraw_BlendOptFlag: | 159 case kSkipDraw_BlendOptFlag: |
| 143 break; | 160 break; |
| 144 case kCoverageAsAlpha_BlendOptFlag: | 161 case kCoverageAsAlpha_BlendOptFlag: |
| 145 fFlagBits |= kCoverageDrawing_StateBit; | 162 fFlagBits |= kCoverageDrawing_StateBit; |
| 146 break; | 163 break; |
| 147 case kEmitCoverage_BlendOptFlag: | 164 case kEmitCoverage_BlendOptFlag: |
| 148 fColor = 0xffffffff; | 165 fColor = 0xffffffff; |
| 149 fInputColorIsUsed = true; | 166 fInputColorIsUsed = true; |
| 150 fColorStages.reset(); | 167 fFirstColorStageIdx = ds.numColorStages(); |
| 151 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB
inding); | 168 fFixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; |
| 152 break; | 169 break; |
| 153 case kEmitTransBlack_BlendOptFlag: | 170 case kEmitTransBlack_BlendOptFlag: |
| 154 fColor = 0; | 171 fColor = 0; |
| 155 fCoverage = 0xff; | 172 fCoverage = 0xff; |
| 156 fInputColorIsUsed = true; | 173 fInputColorIsUsed = true; |
| 157 fInputCoverageIsUsed = true; | 174 fInputCoverageIsUsed = true; |
| 158 fColorStages.reset(); | 175 fFirstColorStageIdx = ds.numColorStages(); |
| 159 fCoverageStages.reset(); | 176 fFirstCoverageStageIdx = ds.numCoverageStages(); |
| 160 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB
inding | | 177 fFixedFunctionVAToRemove |= (0x1 << kColor_GrVertexAttribBinding | |
| 161 0x1 << kCoverage_GrVertexAttr
ibBinding); | 178 0x1 << kCoverage_GrVertexAttribBinding)
; |
| 162 break; | 179 break; |
| 163 default: | 180 default: |
| 164 SkFAIL("Unknown BlendOptFlag"); | 181 SkFAIL("Unknown BlendOptFlag"); |
| 165 | |
| 166 } | 182 } |
| 167 } | 183 } |
| 168 | 184 |
| 169 void GrOptDrawState::removeFixedFunctionVertexAttribs(uint8_t removeVAFlag) { | 185 void GrOptDrawState::removeFixedFunctionVertexAttribs() { |
| 170 int numToRemove = 0; | 186 int numToRemove = 0; |
| 171 uint8_t maskCheck = 0x1; | 187 uint8_t maskCheck = 0x1; |
| 172 // Count the number of vertex attributes that we will actually remove | 188 // Count the number of vertex attributes that we will actually remove |
| 173 for (int i = 0; i < kGrFixedFunctionVertexAttribBindingCnt; ++i) { | 189 for (int i = 0; i < kGrFixedFunctionVertexAttribBindingCnt; ++i) { |
| 174 if ((maskCheck & removeVAFlag) && -1 != fFixedFunctionVertexAttribIndice
s[i]) { | 190 if ((maskCheck & fFixedFunctionVAToRemove) && -1 != fFixedFunctionVertex
AttribIndices[i]) { |
| 175 ++numToRemove; | 191 ++numToRemove; |
| 176 } | 192 } |
| 177 maskCheck <<= 1; | 193 maskCheck <<= 1; |
| 178 } | 194 } |
| 179 | 195 |
| 180 fOptVA.reset(fVACount - numToRemove); | 196 fOptVA.reset(fVACount - numToRemove); |
| 181 | 197 |
| 182 GrVertexAttrib* dst = fOptVA.get(); | 198 GrVertexAttrib* dst = fOptVA.get(); |
| 183 const GrVertexAttrib* src = fVAPtr; | 199 const GrVertexAttrib* src = fVAPtr; |
| 184 | 200 |
| 185 for (int i = 0, newIdx = 0; i < fVACount; ++i, ++src) { | 201 for (int i = 0, newIdx = 0; i < fVACount; ++i, ++src) { |
| 186 const GrVertexAttrib& currAttrib = *src; | 202 const GrVertexAttrib& currAttrib = *src; |
| 187 if (currAttrib.fBinding < kGrFixedFunctionVertexAttribBindingCnt) { | 203 if (currAttrib.fBinding < kGrFixedFunctionVertexAttribBindingCnt) { |
| 188 uint8_t maskCheck = 0x1 << currAttrib.fBinding; | 204 uint8_t maskCheck = 0x1 << currAttrib.fBinding; |
| 189 if (maskCheck & removeVAFlag) { | 205 if (maskCheck & fFixedFunctionVAToRemove) { |
| 190 SkASSERT(-1 != fFixedFunctionVertexAttribIndices[currAttrib.fBin
ding]); | 206 SkASSERT(-1 != fFixedFunctionVertexAttribIndices[currAttrib.fBin
ding]); |
| 191 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = -1; | 207 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = -1; |
| 192 continue; | 208 continue; |
| 193 } | 209 } |
| 194 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = newIdx; | 210 fFixedFunctionVertexAttribIndices[currAttrib.fBinding] = newIdx; |
| 195 } | 211 } |
| 196 memcpy(dst, src, sizeof(GrVertexAttrib)); | 212 memcpy(dst, src, sizeof(GrVertexAttrib)); |
| 197 ++newIdx; | 213 ++newIdx; |
| 198 ++dst; | 214 ++dst; |
| 199 } | 215 } |
| 200 fVACount -= numToRemove; | 216 fVACount -= numToRemove; |
| 201 fVAPtr = fOptVA.get(); | 217 fVAPtr = fOptVA.get(); |
| 202 } | 218 } |
| 203 | 219 |
| 204 void GrOptDrawState::copyEffectiveColorStages(const GrDrawState& ds) { | 220 void GrOptDrawState::computeEffectiveColorStages(const GrDrawState& ds) { |
| 205 int firstColorStage = 0; | |
| 206 | |
| 207 // Set up color and flags for ConstantColorComponent checks | 221 // Set up color and flags for ConstantColorComponent checks |
| 208 GrProcessor::InvariantOutput inout; | 222 GrProcessor::InvariantOutput inout; |
| 209 inout.fIsSingleComponent = false; | 223 inout.fIsSingleComponent = false; |
| 210 if (!this->hasColorVertexAttribute()) { | 224 if (!this->hasColorVertexAttribute()) { |
| 211 inout.fColor = ds.getColor(); | 225 inout.fColor = ds.getColor(); |
| 212 inout.fValidFlags = kRGBA_GrColorComponentFlags; | 226 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
| 213 } else { | 227 } else { |
| 214 if (ds.vertexColorsAreOpaque()) { | 228 if (ds.vertexColorsAreOpaque()) { |
| 215 inout.fColor = 0xFF << GrColor_SHIFT_A; | 229 inout.fColor = 0xFF << GrColor_SHIFT_A; |
| 216 inout.fValidFlags = kA_GrColorComponentFlag; | 230 inout.fValidFlags = kA_GrColorComponentFlag; |
| 217 } else { | 231 } else { |
| 218 inout.fValidFlags = 0; | 232 inout.fValidFlags = 0; |
| 219 // not strictly necessary but we get false alarms from tools about u
ninit. | 233 // not strictly necessary but we get false alarms from tools about u
ninit. |
| 220 inout.fColor = 0; | 234 inout.fColor = 0; |
| 221 } | 235 } |
| 222 } | 236 } |
| 223 | 237 |
| 224 for (int i = 0; i < ds.numColorStages(); ++i) { | 238 for (int i = 0; i < ds.numColorStages(); ++i) { |
| 225 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); | 239 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); |
| 226 if (!fp->willUseInputColor()) { | 240 if (!fp->willUseInputColor()) { |
| 227 firstColorStage = i; | 241 fFirstColorStageIdx = i; |
| 228 fInputColorIsUsed = false; | 242 fInputColorIsUsed = false; |
| 229 } | 243 } |
| 230 fp->computeInvariantOutput(&inout); | 244 fp->computeInvariantOutput(&inout); |
| 231 if (kRGBA_GrColorComponentFlags == inout.fValidFlags) { | 245 if (kRGBA_GrColorComponentFlags == inout.fValidFlags) { |
| 232 firstColorStage = i + 1; | 246 fFirstColorStageIdx = i + 1; |
| 233 fColor = inout.fColor; | 247 fColor = inout.fColor; |
| 234 fInputColorIsUsed = true; | 248 fInputColorIsUsed = true; |
| 235 this->removeFixedFunctionVertexAttribs(0x1 << kColor_GrVertexAttribB
inding); | 249 fFixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; |
| 236 } | 250 } |
| 237 } | 251 } |
| 238 if (firstColorStage < ds.numColorStages()) { | |
| 239 fColorStages.reset(&ds.getColorStage(firstColorStage), | |
| 240 ds.numColorStages() - firstColorStage); | |
| 241 } else { | |
| 242 fColorStages.reset(); | |
| 243 } | |
| 244 } | 252 } |
| 245 | 253 |
| 246 void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) { | 254 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds) { |
| 247 int firstCoverageStage = 0; | |
| 248 | |
| 249 // We do not try to optimize out constantColor coverage effects here. It is
extremely rare | 255 // We do not try to optimize out constantColor coverage effects here. It is
extremely rare |
| 250 // to have a coverage effect that returns a constant value for all four chan
nels. Thus we | 256 // to have a coverage effect that returns a constant value for all four chan
nels. Thus we |
| 251 // save having to make extra virtual calls by not checking for it. | 257 // save having to make extra virtual calls by not checking for it. |
| 252 | 258 |
| 253 // Don't do any optimizations on coverage stages. It should not be the case
where we do not use | 259 // Don't do any optimizations on coverage stages. It should not be the case
where we do not use |
| 254 // input coverage in an effect | 260 // input coverage in an effect |
| 255 #ifdef OptCoverageStages | 261 #ifdef OptCoverageStages |
| 256 for (int i = 0; i < ds.numCoverageStages(); ++i) { | 262 for (int i = 0; i < ds.numCoverageStages(); ++i) { |
| 257 const GrProcessor* processor = ds.getCoverageStage(i).getProcessor(); | 263 const GrProcessor* processor = ds.getCoverageStage(i).getProcessor(); |
| 258 if (!processor->willUseInputColor()) { | 264 if (!processor->willUseInputColor()) { |
| 259 firstCoverageStage = i; | 265 fFirstCoverageStageIdx = i; |
| 260 fInputCoverageIsUsed = false; | 266 fInputCoverageIsUsed = false; |
| 261 } | 267 } |
| 262 } | 268 } |
| 263 #endif | 269 #endif |
| 264 if (ds.numCoverageStages() > 0) { | |
| 265 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage), | |
| 266 ds.numCoverageStages() - firstCoverageStage); | |
| 267 } else { | |
| 268 fCoverageStages.reset(); | |
| 269 } | |
| 270 } | 270 } |
| 271 | 271 |
| 272 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
readsFragPosition) { | 272 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
readsFragPosition) { |
| 273 if (stage.getProcessor()->willReadDstColor()) { | 273 if (stage.getProcessor()->willReadDstColor()) { |
| 274 *readsDst = true; | 274 *readsDst = true; |
| 275 } | 275 } |
| 276 if (stage.getProcessor()->willReadFragmentPosition()) { | 276 if (stage.getProcessor()->willReadFragmentPosition()) { |
| 277 *readsFragPosition = true; | 277 *readsFragPosition = true; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 void GrOptDrawState::getStageStats() { | 281 void GrOptDrawState::getStageStats(const GrDrawState& ds) { |
| 282 // We will need a local coord attrib if there is one currently set on the op
tState and we are | 282 // We will need a local coord attrib if there is one currently set on the op
tState and we are |
| 283 // actually generating some effect code | 283 // actually generating some effect code |
| 284 fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && this->numTotal
Stages() > 0; | 284 fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && |
| 285 ds.numTotalStages() - fFirstColorStageIdx - fFirstCoverageStageIdx > 0; |
| 285 | 286 |
| 286 fReadsDst = false; | 287 fReadsDst = false; |
| 287 fReadsFragPosition = false; | 288 fReadsFragPosition = false; |
| 288 | 289 |
| 289 for (int s = 0; s < this->numColorStages(); ++s) { | 290 for (int s = fFirstColorStageIdx; s < ds.numColorStages(); ++s) { |
| 290 const GrFragmentStage& stage = this->getColorStage(s); | 291 const GrFragmentStage& stage = ds.getColorStage(s); |
| 291 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); | 292 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); |
| 292 } | 293 } |
| 293 for (int s = 0; s < this->numCoverageStages(); ++s) { | 294 for (int s = fFirstCoverageStageIdx; s < ds.numCoverageStages(); ++s) { |
| 294 const GrFragmentStage& stage = this->getCoverageStage(s); | 295 const GrFragmentStage& stage = ds.getCoverageStage(s); |
| 295 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); | 296 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); |
| 296 } | 297 } |
| 297 if (this->hasGeometryProcessor()) { | 298 if (ds.hasGeometryProcessor()) { |
| 298 const GrGeometryStage& stage = *this->getGeometryProcessor(); | 299 const GrGeometryStage& stage = *ds.getGeometryProcessor(); |
| 299 fReadsFragPosition = fReadsFragPosition || stage.getProcessor()->willRea
dFragmentPosition(); | 300 fReadsFragPosition = fReadsFragPosition || stage.getProcessor()->willRea
dFragmentPosition(); |
| 300 } | 301 } |
| 301 } | 302 } |
| 302 | 303 |
| 303 //////////////////////////////////////////////////////////////////////////////// | 304 //////////////////////////////////////////////////////////////////////////////// |
| 304 | 305 |
| 305 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { | 306 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
| 306 return this->isEqual(that); | 307 return this->isEqual(that); |
| 307 } | 308 } |
| 308 | 309 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 367 } |
| 367 } | 368 } |
| 368 | 369 |
| 369 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, | 370 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, |
| 370 that.fFixedFunctionVertexAttribIndices, | 371 that.fFixedFunctionVertexAttribIndices, |
| 371 sizeof(this->fFixedFunctionVertexAttribIndices))); | 372 sizeof(this->fFixedFunctionVertexAttribIndices))); |
| 372 | 373 |
| 373 return true; | 374 return true; |
| 374 } | 375 } |
| 375 | 376 |
| OLD | NEW |