| 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" |
| 11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
| 12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
| 13 #include "GrProcOptInfo.h" | 13 #include "GrProcOptInfo.h" |
| 14 | 14 |
| 15 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, | 15 GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
| 16 const GrDrawTargetCaps& caps, | 16 GrGpu* gpu, |
| 17 const ScissorState& scissorState, | 17 const ScissorState& scissorState, |
| 18 const GrDeviceCoordTexture* dstCopy, | 18 const GrDeviceCoordTexture* dstCopy, |
| 19 GrGpu::DrawType drawType) | 19 GrGpu::DrawType drawType) { |
| 20 : fFinalized(false) { | 20 |
| 21 fDrawType = drawType; | |
| 22 GrBlendCoeff optSrcCoeff; | 21 GrBlendCoeff optSrcCoeff; |
| 23 GrBlendCoeff optDstCoeff; | 22 GrBlendCoeff optDstCoeff; |
| 24 GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &optSrcCoeff,
&optDstCoeff); | 23 GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &optSrcCoeff,
&optDstCoeff); |
| 25 | 24 |
| 26 // When path rendering the stencil settings are not always set on the draw s
tate | 25 // When path rendering the stencil settings are not always set on the draw s
tate |
| 27 // so we must check the draw type. In cases where we will skip drawing we si
mply return a | 26 // so we must check the draw type. In cases where we will skip drawing we si
mply return a |
| 28 // null GrOptDrawState. | 27 // null GrOptDrawState. |
| 29 if (GrDrawState::kSkipDraw_BlendOpt == blendOpt && GrGpu::kStencilPath_DrawT
ype != drawType) { | 28 if (GrDrawState::kSkipDraw_BlendOpt == blendOpt && GrGpu::kStencilPath_DrawT
ype != drawType) { |
| 30 // Set the fields that don't default init and return. The lack of a rend
er target will | 29 // Set the fields that don't default init and return. The lack of a rend
er target will |
| 31 // indicate that this can be skipped. | 30 // indicate that this can be skipped. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 fStencilSettings = drawState.getStencil(); | 45 fStencilSettings = drawState.getStencil(); |
| 47 fDrawFace = drawState.getDrawFace(); | 46 fDrawFace = drawState.getDrawFace(); |
| 48 fSrcBlend = optSrcCoeff; | 47 fSrcBlend = optSrcCoeff; |
| 49 fDstBlend = optDstCoeff; | 48 fDstBlend = optDstCoeff; |
| 50 | 49 |
| 51 // TODO move this out of optDrawState | 50 // TODO move this out of optDrawState |
| 52 if (dstCopy) { | 51 if (dstCopy) { |
| 53 fDstCopy = *dstCopy; | 52 fDstCopy = *dstCopy; |
| 54 } | 53 } |
| 55 | 54 |
| 55 GrProgramDesc::DescInfo descInfo; |
| 56 |
| 56 fFlags = 0; | 57 fFlags = 0; |
| 57 if (drawState.isHWAntialias()) { | 58 if (drawState.isHWAntialias()) { |
| 58 fFlags |= kHWAA_Flag; | 59 fFlags |= kHWAA_Flag; |
| 59 } | 60 } |
| 60 if (drawState.isColorWriteDisabled()) { | 61 if (drawState.isColorWriteDisabled()) { |
| 61 fFlags |= kDisableColorWrite_Flag; | 62 fFlags |= kDisableColorWrite_Flag; |
| 62 } | 63 } |
| 63 if (drawState.isDither()) { | 64 if (drawState.isDither()) { |
| 64 fFlags |= kDither_Flag; | 65 fFlags |= kDither_Flag; |
| 65 } | 66 } |
| 66 | 67 |
| 67 fDescInfo.fHasVertexColor = drawState.hasGeometryProcessor() && | 68 descInfo.fHasVertexColor = drawState.hasGeometryProcessor() && |
| 68 drawState.getGeometryProcessor()->hasVertexColor
(); | 69 drawState.getGeometryProcessor()->hasVertexColor(
); |
| 69 | 70 |
| 70 fDescInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() && | 71 descInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() && |
| 71 drawState.getGeometryProcessor()->hasVertexCo
verage(); | 72 drawState.getGeometryProcessor()->hasVertexCove
rage(); |
| 72 | 73 |
| 73 bool hasLocalCoords = drawState.hasGeometryProcessor() && | 74 bool hasLocalCoords = drawState.hasGeometryProcessor() && |
| 74 drawState.getGeometryProcessor()->hasLocalCoords(); | 75 drawState.getGeometryProcessor()->hasLocalCoords(); |
| 75 | 76 |
| 76 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(); | 77 const GrProcOptInfo& colorPOI = drawState.colorProcInfo(); |
| 77 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); | 78 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); |
| 78 fDescInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed(); | 79 descInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed(); |
| 79 fColor = colorPOI.inputColorToEffectiveStage(); | 80 fColor = colorPOI.inputColorToEffectiveStage(); |
| 80 if (colorPOI.removeVertexAttrib()) { | 81 if (colorPOI.removeVertexAttrib()) { |
| 81 fDescInfo.fHasVertexColor = false; | 82 descInfo.fHasVertexColor = false; |
| 82 } | 83 } |
| 83 | 84 |
| 84 // TODO: Once we can handle single or four channel input into coverage stage
s then we can use | 85 // TODO: Once we can handle single or four channel input into coverage stage
s then we can use |
| 85 // drawState's coverageProcInfo (like color above) to set this initial infor
mation. | 86 // drawState's coverageProcInfo (like color above) to set this initial infor
mation. |
| 86 int firstCoverageStageIdx = 0; | 87 int firstCoverageStageIdx = 0; |
| 87 fDescInfo.fInputCoverageIsUsed = true; | 88 descInfo.fInputCoverageIsUsed = true; |
| 88 fCoverage = drawState.getCoverage(); | 89 fCoverage = drawState.getCoverage(); |
| 89 | 90 |
| 90 this->adjustProgramForBlendOpt(drawState, blendOpt, &firstColorStageIdx, | 91 this->adjustProgramForBlendOpt(drawState, blendOpt, &descInfo, &firstColorSt
ageIdx, |
| 91 &firstCoverageStageIdx); | 92 &firstCoverageStageIdx); |
| 92 | 93 |
| 93 this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, ha
sLocalCoords); | 94 this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, ha
sLocalCoords, |
| 95 &descInfo); |
| 94 | 96 |
| 95 // Copy GeometryProcesssor from DS or ODS | 97 // Copy GeometryProcesssor from DS or ODS |
| 96 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) || | 98 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) || |
| 97 GrGpu::kStencilPath_DrawType || | 99 GrGpu::kStencilPath_DrawType || |
| 98 drawState.hasGeometryProcessor()); | 100 drawState.hasGeometryProcessor()); |
| 99 fGeometryProcessor.reset(drawState.getGeometryProcessor()); | 101 fGeometryProcessor.reset(drawState.getGeometryProcessor()); |
| 100 | 102 |
| 101 // Create XferProcessor from DS's XPFactory | 103 // Create XferProcessor from DS's XPFactory |
| 102 const GrXferProcessor* xpProcessor = drawState.getXPFactory()->createXferPro
cessor(); | 104 const GrXferProcessor* xpProcessor = drawState.getXPFactory()->createXferPro
cessor(); |
| 103 fXferProcessor.reset(xpProcessor); | 105 fXferProcessor.reset(xpProcessor); |
| 104 xpProcessor->unref(); | 106 xpProcessor->unref(); |
| 105 | 107 |
| 106 // Copy Stages from DS to ODS | 108 // Copy Stages from DS to ODS |
| 107 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { | 109 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { |
| 108 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 110 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
| 109 GrPendingFragmentStage, | 111 GrPendingFragmentStage, |
| 110 (drawState.fColorStages[i], hasLocalCoords)); | 112 (drawState.fColorStages[i], hasLocalCoords)); |
| 111 } | 113 } |
| 112 fNumColorStages = fFragmentStages.count(); | 114 fNumColorStages = fFragmentStages.count(); |
| 113 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i)
{ | 115 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i)
{ |
| 114 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 116 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
| 115 GrPendingFragmentStage, | 117 GrPendingFragmentStage, |
| 116 (drawState.fCoverageStages[i], hasLocalCoords)); | 118 (drawState.fCoverageStages[i], hasLocalCoords)); |
| 117 } | 119 } |
| 118 | 120 |
| 119 this->setOutputStateInfo(drawState, blendOpt, caps); | 121 this->setOutputStateInfo(drawState, blendOpt, *gpu->caps(), &descInfo); |
| 122 |
| 123 // now create a key |
| 124 gpu->buildProgramDesc(*this, descInfo, drawType, &fDesc); |
| 120 }; | 125 }; |
| 121 | 126 |
| 122 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, | 127 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
| 123 GrDrawState::BlendOpt blendOpt, | 128 GrDrawState::BlendOpt blendOpt, |
| 124 const GrDrawTargetCaps& caps) { | 129 const GrDrawTargetCaps& caps, |
| 130 GrProgramDesc::DescInfo* descInfo) { |
| 125 // Set this default and then possibly change our mind if there is coverage. | 131 // Set this default and then possibly change our mind if there is coverage. |
| 126 fDescInfo.fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; | 132 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; |
| 127 fDescInfo.fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; | 133 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; |
| 128 | 134 |
| 129 // Determine whether we should use dual source blending or shader code to ke
ep coverage | 135 // Determine whether we should use dual source blending or shader code to ke
ep coverage |
| 130 // separate from color. | 136 // separate from color. |
| 131 bool keepCoverageSeparate = !(GrDrawState::kCoverageAsAlpha_BlendOpt == blen
dOpt || | 137 bool keepCoverageSeparate = !(GrDrawState::kCoverageAsAlpha_BlendOpt == blen
dOpt || |
| 132 GrDrawState::kEmitCoverage_BlendOpt == blendOp
t); | 138 GrDrawState::kEmitCoverage_BlendOpt == blendOp
t); |
| 133 if (keepCoverageSeparate && !ds.hasSolidCoverage()) { | 139 if (keepCoverageSeparate && !ds.hasSolidCoverage()) { |
| 134 if (caps.dualSourceBlendingSupport()) { | 140 if (caps.dualSourceBlendingSupport()) { |
| 135 if (kZero_GrBlendCoeff == fDstBlend) { | 141 if (kZero_GrBlendCoeff == fDstBlend) { |
| 136 // write the coverage value to second color | 142 // write the coverage value to second color |
| 137 fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverage_Second
aryOutputType; | 143 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverage_Second
aryOutputType; |
| 138 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 144 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 139 } else if (kSA_GrBlendCoeff == fDstBlend) { | 145 } else if (kSA_GrBlendCoeff == fDstBlend) { |
| 140 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 146 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 141 fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISA_Sec
ondaryOutputType; | 147 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISA_Sec
ondaryOutputType; |
| 142 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 148 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 143 } else if (kSC_GrBlendCoeff == fDstBlend) { | 149 } else if (kSC_GrBlendCoeff == fDstBlend) { |
| 144 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 150 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 145 fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISC_Sec
ondaryOutputType; | 151 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISC_Sec
ondaryOutputType; |
| 146 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 152 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 147 } | 153 } |
| 148 } else if (fDescInfo.fReadsDst && | 154 } else if (descInfo->fReadsDst && |
| 149 kOne_GrBlendCoeff == fSrcBlend && | 155 kOne_GrBlendCoeff == fSrcBlend && |
| 150 kZero_GrBlendCoeff == fDstBlend) { | 156 kZero_GrBlendCoeff == fDstBlend) { |
| 151 fDescInfo.fPrimaryOutputType = GrProgramDesc::kCombineWithDst_Primar
yOutputType; | 157 descInfo->fPrimaryOutputType = GrProgramDesc::kCombineWithDst_Primar
yOutputType; |
| 152 } | 158 } |
| 153 } | 159 } |
| 154 } | 160 } |
| 155 | 161 |
| 156 void GrOptDrawState::adjustProgramForBlendOpt(const GrDrawState& ds, | 162 void GrOptDrawState::adjustProgramForBlendOpt(const GrDrawState& ds, |
| 157 GrDrawState::BlendOpt blendOpt, | 163 GrDrawState::BlendOpt blendOpt, |
| 164 GrProgramDesc::DescInfo* descInfo, |
| 158 int* firstColorStageIdx, | 165 int* firstColorStageIdx, |
| 159 int* firstCoverageStageIdx) { | 166 int* firstCoverageStageIdx) { |
| 160 switch (blendOpt) { | 167 switch (blendOpt) { |
| 161 case GrDrawState::kNone_BlendOpt: | 168 case GrDrawState::kNone_BlendOpt: |
| 162 case GrDrawState::kSkipDraw_BlendOpt: | 169 case GrDrawState::kSkipDraw_BlendOpt: |
| 163 case GrDrawState::kCoverageAsAlpha_BlendOpt: | 170 case GrDrawState::kCoverageAsAlpha_BlendOpt: |
| 164 break; | 171 break; |
| 165 case GrDrawState::kEmitCoverage_BlendOpt: | 172 case GrDrawState::kEmitCoverage_BlendOpt: |
| 166 fColor = 0xffffffff; | 173 fColor = 0xffffffff; |
| 167 fDescInfo.fInputColorIsUsed = true; | 174 descInfo->fInputColorIsUsed = true; |
| 168 *firstColorStageIdx = ds.numColorStages(); | 175 *firstColorStageIdx = ds.numColorStages(); |
| 169 fDescInfo.fHasVertexColor = false; | 176 descInfo->fHasVertexColor = false; |
| 170 break; | 177 break; |
| 171 case GrDrawState::kEmitTransBlack_BlendOpt: | 178 case GrDrawState::kEmitTransBlack_BlendOpt: |
| 172 fColor = 0; | 179 fColor = 0; |
| 173 fCoverage = 0xff; | 180 fCoverage = 0xff; |
| 174 fDescInfo.fInputColorIsUsed = true; | 181 descInfo->fInputColorIsUsed = true; |
| 175 fDescInfo.fInputCoverageIsUsed = true; | 182 descInfo->fInputCoverageIsUsed = true; |
| 176 *firstColorStageIdx = ds.numColorStages(); | 183 *firstColorStageIdx = ds.numColorStages(); |
| 177 *firstCoverageStageIdx = ds.numCoverageStages(); | 184 *firstCoverageStageIdx = ds.numCoverageStages(); |
| 178 fDescInfo.fHasVertexColor = false; | 185 descInfo->fHasVertexColor = false; |
| 179 fDescInfo.fHasVertexCoverage = false; | 186 descInfo->fHasVertexCoverage = false; |
| 180 break; | 187 break; |
| 181 } | 188 } |
| 182 } | 189 } |
| 183 | 190 |
| 184 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
readsFragPosition) { | 191 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
readsFragPosition) { |
| 185 if (stage.getProcessor()->willReadDstColor()) { | 192 if (stage.getProcessor()->willReadDstColor()) { |
| 186 *readsDst = true; | 193 *readsDst = true; |
| 187 } | 194 } |
| 188 if (stage.getProcessor()->willReadFragmentPosition()) { | 195 if (stage.getProcessor()->willReadFragmentPosition()) { |
| 189 *readsFragPosition = true; | 196 *readsFragPosition = true; |
| 190 } | 197 } |
| 191 } | 198 } |
| 192 | 199 |
| 193 void GrOptDrawState::getStageStats(const GrDrawState& ds, int firstColorStageIdx
, | 200 void GrOptDrawState::getStageStats(const GrDrawState& ds, int firstColorStageIdx
, |
| 194 int firstCoverageStageIdx, bool hasLocalCoord
s) { | 201 int firstCoverageStageIdx, bool hasLocalCoord
s, |
| 202 GrProgramDesc::DescInfo* descInfo) { |
| 195 // We will need a local coord attrib if there is one currently set on the op
tState and we are | 203 // We will need a local coord attrib if there is one currently set on the op
tState and we are |
| 196 // actually generating some effect code | 204 // actually generating some effect code |
| 197 fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords && | 205 descInfo->fRequiresLocalCoordAttrib = hasLocalCoords && |
| 198 ds.numTotalStages() - firstColorStageIdx - firstCoverageStageIdx > 0; | 206 ds.numTotalStages() - firstColorStageIdx - firstCoverageStageIdx > 0; |
| 199 | 207 |
| 200 fDescInfo.fReadsDst = false; | 208 descInfo->fReadsDst = false; |
| 201 fDescInfo.fReadsFragPosition = false; | 209 descInfo->fReadsFragPosition = false; |
| 202 | 210 |
| 203 for (int s = firstColorStageIdx; s < ds.numColorStages(); ++s) { | 211 for (int s = firstColorStageIdx; s < ds.numColorStages(); ++s) { |
| 204 const GrFragmentStage& stage = ds.getColorStage(s); | 212 const GrFragmentStage& stage = ds.getColorStage(s); |
| 205 get_stage_stats(stage, &fDescInfo.fReadsDst, &fDescInfo.fReadsFragPositi
on); | 213 get_stage_stats(stage, &descInfo->fReadsDst, &descInfo->fReadsFragPositi
on); |
| 206 } | 214 } |
| 207 for (int s = firstCoverageStageIdx; s < ds.numCoverageStages(); ++s) { | 215 for (int s = firstCoverageStageIdx; s < ds.numCoverageStages(); ++s) { |
| 208 const GrFragmentStage& stage = ds.getCoverageStage(s); | 216 const GrFragmentStage& stage = ds.getCoverageStage(s); |
| 209 get_stage_stats(stage, &fDescInfo.fReadsDst, &fDescInfo.fReadsFragPositi
on); | 217 get_stage_stats(stage, &descInfo->fReadsDst, &descInfo->fReadsFragPositi
on); |
| 210 } | 218 } |
| 211 if (ds.hasGeometryProcessor()) { | 219 if (ds.hasGeometryProcessor()) { |
| 212 const GrGeometryProcessor& gp = *ds.getGeometryProcessor(); | 220 const GrGeometryProcessor& gp = *ds.getGeometryProcessor(); |
| 213 fDescInfo.fReadsFragPosition = fDescInfo.fReadsFragPosition || gp.willRe
adFragmentPosition(); | 221 descInfo->fReadsFragPosition = descInfo->fReadsFragPosition || gp.willRe
adFragmentPosition(); |
| 214 } | 222 } |
| 215 } | 223 } |
| 216 | 224 |
| 217 void GrOptDrawState::finalize(GrGpu* gpu) { | |
| 218 gpu->buildProgramDesc(*this, fDescInfo, fDrawType, &fDesc); | |
| 219 fFinalized = true; | |
| 220 } | |
| 221 | |
| 222 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
| 223 | 226 |
| 224 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { | 227 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
| 225 if (!fDescInfo.fHasVertexColor && this->fColor != that.fColor) { | 228 if (this->fDesc != that.fDesc) { |
| 229 return false; |
| 230 } |
| 231 bool hasVertexColors = this->fDesc.header().fColorInput == GrProgramDesc::kA
ttribute_ColorInput; |
| 232 if (!hasVertexColors && this->fColor != that.fColor) { |
| 226 return false; | 233 return false; |
| 227 } | 234 } |
| 228 | 235 |
| 229 if (this->getRenderTarget() != that.getRenderTarget() || | 236 if (this->getRenderTarget() != that.getRenderTarget() || |
| 230 this->fFragmentStages.count() != that.fFragmentStages.count() || | |
| 231 this->fNumColorStages != that.fNumColorStages || | |
| 232 this->fScissorState != that.fScissorState || | 237 this->fScissorState != that.fScissorState || |
| 233 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || | 238 !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || |
| 234 this->fSrcBlend != that.fSrcBlend || | 239 this->fSrcBlend != that.fSrcBlend || |
| 235 this->fDstBlend != that.fDstBlend || | 240 this->fDstBlend != that.fDstBlend || |
| 236 this->fDrawType != that.fDrawType || | |
| 237 fDescInfo.fInputColorIsUsed != that.fDescInfo.fInputColorIsUsed || | |
| 238 fDescInfo.fInputCoverageIsUsed != that.fDescInfo.fInputCoverageIsUsed || | |
| 239 fDescInfo.fReadsDst != that.fDescInfo.fReadsDst || | |
| 240 fDescInfo.fReadsFragPosition != that.fDescInfo.fReadsFragPosition || | |
| 241 fDescInfo.fRequiresLocalCoordAttrib != that.fDescInfo.fRequiresLocalCoor
dAttrib || | |
| 242 fDescInfo.fPrimaryOutputType != that.fDescInfo.fPrimaryOutputType || | |
| 243 fDescInfo.fSecondaryOutputType != that.fDescInfo.fSecondaryOutputType || | |
| 244 this->fScissorState != that.fScissorState || | |
| 245 this->fBlendConstant != that.fBlendConstant || | 241 this->fBlendConstant != that.fBlendConstant || |
| 246 this->fFlags != that.fFlags || | 242 this->fFlags != that.fFlags || |
| 247 this->fStencilSettings != that.fStencilSettings || | 243 this->fStencilSettings != that.fStencilSettings || |
| 248 this->fDrawFace != that.fDrawFace || | 244 this->fDrawFace != that.fDrawFace || |
| 249 this->fDstCopy.texture() != that.fDstCopy.texture()) { | 245 this->fDstCopy.texture() != that.fDstCopy.texture()) { |
| 250 return false; | 246 return false; |
| 251 } | 247 } |
| 252 | 248 |
| 253 if (!fDescInfo.fHasVertexCoverage && this->fCoverage != that.fCoverage) { | 249 bool hasVertexCoverage = |
| 250 this->fDesc.header().fCoverageInput == GrProgramDesc::kAttribute_Col
orInput; |
| 251 if (!hasVertexCoverage && this->fCoverage != that.fCoverage) { |
| 254 return false; | 252 return false; |
| 255 } | 253 } |
| 256 | 254 |
| 257 if (this->hasGeometryProcessor()) { | 255 if (this->hasGeometryProcessor()) { |
| 258 if (!that.hasGeometryProcessor()) { | 256 if (!that.hasGeometryProcessor()) { |
| 259 return false; | 257 return false; |
| 260 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce
ssor())) { | 258 } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProce
ssor())) { |
| 261 return false; | 259 return false; |
| 262 } | 260 } |
| 263 } else if (that.hasGeometryProcessor()) { | 261 } else if (that.hasGeometryProcessor()) { |
| 264 return false; | 262 return false; |
| 265 } | 263 } |
| 266 | 264 |
| 267 // The program desc comparison should have already assured that the stage co
unts match. | 265 // The program desc comparison should have already assured that the stage co
unts match. |
| 268 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); | 266 SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
| 269 for (int i = 0; i < this->numFragmentStages(); i++) { | 267 for (int i = 0; i < this->numFragmentStages(); i++) { |
| 270 | 268 |
| 271 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 269 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
| 272 return false; | 270 return false; |
| 273 } | 271 } |
| 274 } | 272 } |
| 275 return true; | 273 return true; |
| 276 } | 274 } |
| 277 | 275 |
| OLD | NEW |