egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrOptDrawState.h" |
| 9 | |
| 10 | #include "GrDrawState.h" |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 11 | #include "GrDrawTargetCaps.h" |
joshualitt | 4973d9d | 2014-11-08 09:24:25 -0800 | [diff] [blame] | 12 | #include "GrGpu.h" |
egdaniel | b6cbc38 | 2014-11-13 11:00:34 -0800 | [diff] [blame] | 13 | #include "GrProcOptInfo.h" |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 14 | #include "GrXferProcessor.h" |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 15 | |
egdaniel | 170f90b | 2014-09-16 12:54:40 -0700 | [diff] [blame] | 16 | GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 17 | GrColor color, |
| 18 | uint8_t coverage, |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 19 | const GrDrawTargetCaps& caps, |
joshualitt | 54e0c12 | 2014-11-19 09:38:51 -0800 | [diff] [blame] | 20 | const ScissorState& scissorState, |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 21 | const GrDeviceCoordTexture* dstCopy, |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 22 | GrGpu::DrawType drawType) |
| 23 | : fFinalized(false) { |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 24 | GrColor coverageColor = GrColorPackRGBA(coverage, coverage, coverage, coverage); |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 25 | fDrawType = drawType; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 26 | |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 27 | const GrProcOptInfo& colorPOI = drawState.colorProcInfo(color); |
| 28 | const GrProcOptInfo& coveragePOI = drawState.coverageProcInfo(coverageColor); |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 29 | |
| 30 | fColor = colorPOI.inputColorToEffectiveStage(); |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 31 | fCoverage = coverage; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 32 | |
| 33 | // Create XferProcessor from DS's XPFactory |
| 34 | SkAutoTUnref<GrXferProcessor> xferProcessor( |
| 35 | drawState.getXPFactory()->createXferProcessor(colorPOI, coveragePOI)); |
| 36 | |
| 37 | GrXferProcessor::OptFlags optFlags; |
| 38 | if (xferProcessor) { |
| 39 | fXferProcessor.reset(xferProcessor.get()); |
| 40 | |
| 41 | optFlags = xferProcessor->getOptimizations(colorPOI, |
| 42 | coveragePOI, |
| 43 | drawState.isCoverageDrawing(), |
| 44 | drawState.isColorWriteDisabled(), |
| 45 | drawState.getStencil().doesWrite(), |
| 46 | &fColor, |
| 47 | &fCoverage); |
| 48 | } |
bsalomon | b03c4a3 | 2014-11-20 09:56:11 -0800 | [diff] [blame] | 49 | |
| 50 | // When path rendering the stencil settings are not always set on the draw state |
| 51 | // so we must check the draw type. In cases where we will skip drawing we simply return a |
| 52 | // null GrOptDrawState. |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 53 | if (!xferProcessor || ((GrXferProcessor::kSkipDraw_OptFlag & optFlags) && |
| 54 | GrGpu::kStencilPath_DrawType != drawType)) { |
bsalomon | b03c4a3 | 2014-11-20 09:56:11 -0800 | [diff] [blame] | 55 | // Set the fields that don't default init and return. The lack of a render target will |
| 56 | // indicate that this can be skipped. |
| 57 | fFlags = 0; |
bsalomon | b03c4a3 | 2014-11-20 09:56:11 -0800 | [diff] [blame] | 58 | fDrawFace = GrDrawState::kInvalid_DrawFace; |
| 59 | fSrcBlend = kZero_GrBlendCoeff; |
| 60 | fDstBlend = kZero_GrBlendCoeff; |
| 61 | fBlendConstant = 0x0; |
| 62 | fViewMatrix.reset(); |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | fRenderTarget.reset(drawState.fRenderTarget.get()); |
| 67 | SkASSERT(fRenderTarget); |
joshualitt | 54e0c12 | 2014-11-19 09:38:51 -0800 | [diff] [blame] | 68 | fScissorState = scissorState; |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 69 | fViewMatrix = drawState.getViewMatrix(); |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 70 | fStencilSettings = drawState.getStencil(); |
bsalomon | 04ddf89 | 2014-11-19 12:36:22 -0800 | [diff] [blame] | 71 | fDrawFace = drawState.getDrawFace(); |
joshualitt | 9176e2c | 2014-11-20 07:28:52 -0800 | [diff] [blame] | 72 | // TODO move this out of optDrawState |
| 73 | if (dstCopy) { |
| 74 | fDstCopy = *dstCopy; |
| 75 | } |
| 76 | |
bsalomon | 04ddf89 | 2014-11-19 12:36:22 -0800 | [diff] [blame] | 77 | fFlags = 0; |
| 78 | if (drawState.isHWAntialias()) { |
| 79 | fFlags |= kHWAA_Flag; |
| 80 | } |
| 81 | if (drawState.isColorWriteDisabled()) { |
| 82 | fFlags |= kDisableColorWrite_Flag; |
| 83 | } |
| 84 | if (drawState.isDither()) { |
| 85 | fFlags |= kDither_Flag; |
| 86 | } |
| 87 | |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 88 | fDescInfo.fHasVertexColor = drawState.hasGeometryProcessor() && |
| 89 | drawState.getGeometryProcessor()->hasVertexColor(); |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 90 | |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 91 | fDescInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() && |
| 92 | drawState.getGeometryProcessor()->hasVertexCoverage(); |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 93 | |
| 94 | bool hasLocalCoords = drawState.hasGeometryProcessor() && |
| 95 | drawState.getGeometryProcessor()->hasLocalCoords(); |
egdaniel | 9cf45bf | 2014-10-08 06:49:10 -0700 | [diff] [blame] | 96 | |
egdaniel | 912b3d2 | 2014-11-17 07:45:53 -0800 | [diff] [blame] | 97 | int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 98 | fDescInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed(); |
egdaniel | 912b3d2 | 2014-11-17 07:45:53 -0800 | [diff] [blame] | 99 | if (colorPOI.removeVertexAttrib()) { |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 100 | fDescInfo.fHasVertexColor = false; |
egdaniel | 912b3d2 | 2014-11-17 07:45:53 -0800 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | // TODO: Once we can handle single or four channel input into coverage stages then we can use |
| 104 | // drawState's coverageProcInfo (like color above) to set this initial information. |
| 105 | int firstCoverageStageIdx = 0; |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 106 | fDescInfo.fInputCoverageIsUsed = true; |
egdaniel | 912b3d2 | 2014-11-17 07:45:53 -0800 | [diff] [blame] | 107 | |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 108 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 109 | GrXferProcessor::BlendInfo blendInfo; |
| 110 | fXferProcessor->getBlendInfo(&blendInfo); |
| 111 | fSrcBlend = blendInfo.fSrcBlend; |
| 112 | fDstBlend = blendInfo.fDstBlend; |
| 113 | fBlendConstant = blendInfo.fBlendConstant; |
| 114 | |
| 115 | this->adjustProgramFromOptimizations(drawState, optFlags, colorPOI, coveragePOI, |
| 116 | &firstColorStageIdx, &firstCoverageStageIdx); |
| 117 | |
| 118 | fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords; |
egdaniel | 9cf45bf | 2014-10-08 06:49:10 -0700 | [diff] [blame] | 119 | |
| 120 | // Copy GeometryProcesssor from DS or ODS |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 121 | SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) || |
| 122 | GrGpu::kStencilPath_DrawType || |
| 123 | drawState.hasGeometryProcessor()); |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 124 | fGeometryProcessor.reset(drawState.getGeometryProcessor()); |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 125 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 126 | // Copy Stages from DS to ODS |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 127 | for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { |
| 128 | SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
| 129 | GrPendingFragmentStage, |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 130 | (drawState.fColorStages[i], hasLocalCoords)); |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 131 | } |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 132 | |
egdaniel | d9aa218 | 2014-10-09 13:47:05 -0700 | [diff] [blame] | 133 | fNumColorStages = fFragmentStages.count(); |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 134 | for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) { |
| 135 | SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
| 136 | GrPendingFragmentStage, |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 137 | (drawState.fCoverageStages[i], hasLocalCoords)); |
egdaniel | 9cf45bf | 2014-10-08 06:49:10 -0700 | [diff] [blame] | 138 | } |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 139 | |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 140 | // let the GP init the batch tracker |
| 141 | if (drawState.hasGeometryProcessor()) { |
| 142 | GrGeometryProcessor::InitBT init; |
| 143 | init.fOutputColor = fDescInfo.fInputColorIsUsed; |
| 144 | init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed; |
| 145 | init.fColor = this->getColor(); |
| 146 | init.fCoverage = this->getCoverage(); |
| 147 | fGeometryProcessor->initBatchTracker(&fBatchTracker, init); |
| 148 | } |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 149 | |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 150 | this->setOutputStateInfo(drawState, coverageColor, optFlags, caps); |
joshualitt | 87f48d9 | 2014-12-04 10:41:40 -0800 | [diff] [blame] | 151 | } |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 152 | |
egdaniel | 9cf45bf | 2014-10-08 06:49:10 -0700 | [diff] [blame] | 153 | void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 154 | GrColor coverage, |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 155 | GrXferProcessor::OptFlags optFlags, |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 156 | const GrDrawTargetCaps& caps) { |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 157 | // Set this default and then possibly change our mind if there is coverage. |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 158 | fDescInfo.fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; |
| 159 | fDescInfo.fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 160 | |
bsalomon | 04ddf89 | 2014-11-19 12:36:22 -0800 | [diff] [blame] | 161 | // Determine whether we should use dual source blending or shader code to keep coverage |
| 162 | // separate from color. |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 163 | bool keepCoverageSeparate = !(optFlags & GrXferProcessor::kSetCoverageDrawing_OptFlag); |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 164 | if (keepCoverageSeparate && !ds.hasSolidCoverage(coverage)) { |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 165 | if (caps.dualSourceBlendingSupport()) { |
| 166 | if (kZero_GrBlendCoeff == fDstBlend) { |
| 167 | // write the coverage value to second color |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 168 | fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverage_SecondaryOutputType; |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 169 | fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 170 | } else if (kSA_GrBlendCoeff == fDstBlend) { |
| 171 | // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 172 | fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISA_SecondaryOutputType; |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 173 | fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 174 | } else if (kSC_GrBlendCoeff == fDstBlend) { |
| 175 | // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 176 | fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISC_SecondaryOutputType; |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 177 | fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 178 | } |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 179 | } else if (fDescInfo.fReadsDst && |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 180 | kOne_GrBlendCoeff == fSrcBlend && |
| 181 | kZero_GrBlendCoeff == fDstBlend) { |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 182 | fDescInfo.fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType; |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 183 | } |
| 184 | } |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 185 | } |
| 186 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 187 | void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, |
| 188 | GrXferProcessor::OptFlags flags, |
| 189 | const GrProcOptInfo& colorPOI, |
| 190 | const GrProcOptInfo& coveragePOI, |
| 191 | int* firstColorStageIdx, |
| 192 | int* firstCoverageStageIdx) { |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 193 | fDescInfo.fReadsDst = false; |
| 194 | fDescInfo.fReadsFragPosition = false; |
egdaniel | a7dc0a8 | 2014-09-17 08:25:05 -0700 | [diff] [blame] | 195 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 196 | if (flags & GrXferProcessor::kClearColorStages_OptFlag) { |
| 197 | fDescInfo.fInputColorIsUsed = true; |
| 198 | *firstColorStageIdx = ds.numColorStages(); |
| 199 | fDescInfo.fHasVertexColor = false; |
| 200 | } else { |
| 201 | fDescInfo.fReadsDst = colorPOI.readsDst(); |
| 202 | fDescInfo.fReadsFragPosition = colorPOI.readsFragPosition(); |
egdaniel | a7dc0a8 | 2014-09-17 08:25:05 -0700 | [diff] [blame] | 203 | } |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 204 | |
| 205 | if (flags & GrXferProcessor::kClearCoverageStages_OptFlag) { |
| 206 | fDescInfo.fInputCoverageIsUsed = true; |
| 207 | *firstCoverageStageIdx = ds.numCoverageStages(); |
| 208 | fDescInfo.fHasVertexCoverage = false; |
| 209 | } else { |
| 210 | if (coveragePOI.readsDst()) { |
| 211 | fDescInfo.fReadsDst = true; |
| 212 | } |
| 213 | if (coveragePOI.readsFragPosition()) { |
| 214 | fDescInfo.fReadsFragPosition = true; |
| 215 | } |
egdaniel | a7dc0a8 | 2014-09-17 08:25:05 -0700 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 219 | void GrOptDrawState::finalize(GrGpu* gpu) { |
| 220 | gpu->buildProgramDesc(*this, fDescInfo, fDrawType, &fDesc); |
| 221 | fFinalized = true; |
| 222 | } |
| 223 | |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 224 | //////////////////////////////////////////////////////////////////////////////// |
| 225 | |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 226 | bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 227 | if (fDescInfo != that.fDescInfo) { |
joshualitt | f78c60c | 2014-12-04 06:01:45 -0800 | [diff] [blame] | 228 | return false; |
| 229 | } |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 230 | |
| 231 | if (!fDescInfo.fHasVertexColor && this->fColor != that.fColor) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 232 | return false; |
| 233 | } |
| 234 | |
| 235 | if (this->getRenderTarget() != that.getRenderTarget() || |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 236 | this->fFragmentStages.count() != that.fFragmentStages.count() || |
| 237 | this->fNumColorStages != that.fNumColorStages || |
joshualitt | 54e0c12 | 2014-11-19 09:38:51 -0800 | [diff] [blame] | 238 | this->fScissorState != that.fScissorState || |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 239 | !this->fViewMatrix.cheapEqualTo(that.fViewMatrix) || |
| 240 | this->fSrcBlend != that.fSrcBlend || |
| 241 | this->fDstBlend != that.fDstBlend || |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 242 | this->fDrawType != that.fDrawType || |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 243 | this->fBlendConstant != that.fBlendConstant || |
bsalomon | 04ddf89 | 2014-11-19 12:36:22 -0800 | [diff] [blame] | 244 | this->fFlags != that.fFlags || |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 245 | this->fStencilSettings != that.fStencilSettings || |
joshualitt | 9176e2c | 2014-11-20 07:28:52 -0800 | [diff] [blame] | 246 | this->fDrawFace != that.fDrawFace || |
| 247 | this->fDstCopy.texture() != that.fDstCopy.texture()) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 248 | return false; |
| 249 | } |
| 250 | |
joshualitt | dafa4d0 | 2014-12-04 08:59:10 -0800 | [diff] [blame] | 251 | if (!fDescInfo.fHasVertexCoverage && this->fCoverage != that.fCoverage) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 252 | return false; |
| 253 | } |
| 254 | |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 255 | if (this->hasGeometryProcessor()) { |
| 256 | if (!that.hasGeometryProcessor()) { |
| 257 | return false; |
joshualitt | a5305a1 | 2014-10-10 17:47:00 -0700 | [diff] [blame] | 258 | } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProcessor())) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 259 | return false; |
| 260 | } |
| 261 | } else if (that.hasGeometryProcessor()) { |
| 262 | return false; |
| 263 | } |
| 264 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 265 | // The program desc comparison should have already assured that the stage counts match. |
| 266 | SkASSERT(this->numFragmentStages() == that.numFragmentStages()); |
egdaniel | d9aa218 | 2014-10-09 13:47:05 -0700 | [diff] [blame] | 267 | for (int i = 0; i < this->numFragmentStages(); i++) { |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 268 | |
| 269 | if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 270 | return false; |
| 271 | } |
| 272 | } |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 273 | return true; |
| 274 | } |
| 275 | |