egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 1 | /* |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 2 | * Copyright 2015 Google Inc. |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 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 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 8 | #include "GrPipeline.h" |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 9 | |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 10 | #include "GrAppliedClip.h" |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 11 | #include "GrCaps.h" |
joshualitt | 4973d9d | 2014-11-08 09:24:25 -0800 | [diff] [blame] | 12 | #include "GrGpu.h" |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 13 | #include "GrPipelineBuilder.h" |
egdaniel | b6cbc38 | 2014-11-13 11:00:34 -0800 | [diff] [blame] | 14 | #include "GrProcOptInfo.h" |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 15 | #include "GrRenderTargetContext.h" |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 16 | #include "GrRenderTargetOpList.h" |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 17 | #include "GrRenderTargetPriv.h" |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 18 | #include "GrXferProcessor.h" |
egdaniel | 3658f38 | 2014-09-15 07:01:59 -0700 | [diff] [blame] | 19 | |
Brian Salomon | 8952743 | 2016-12-16 09:52:16 -0500 | [diff] [blame] | 20 | #include "ops/GrOp.h" |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 21 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 22 | GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 23 | GrPipelineOptimizations* optimizations) { |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 24 | GrRenderTarget* rt = args.fRenderTargetContext->accessRenderTarget(); |
Robert Phillips | e60ad62 | 2016-11-17 10:22:48 -0500 | [diff] [blame] | 25 | if (!rt) { |
| 26 | return nullptr; |
| 27 | } |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 28 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 29 | GrPipeline* pipeline = new (memory) GrPipeline; |
robertphillips | 55fdccc | 2016-06-06 06:16:20 -0700 | [diff] [blame] | 30 | pipeline->fRenderTarget.reset(rt); |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 31 | SkASSERT(pipeline->fRenderTarget); |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 32 | pipeline->fScissorState = args.fAppliedClip->scissorState(); |
| 33 | pipeline->fWindowRectsState = args.fAppliedClip->windowRectsState(); |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 34 | pipeline->fUserStencilSettings = args.fUserStencil; |
| 35 | pipeline->fDrawFace = static_cast<int16_t>(args.fDrawFace); |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 36 | |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 37 | pipeline->fFlags = args.fFlags; |
| 38 | if (args.fProcessors->usesDistanceVectorField()) { |
dvonbeck | 9b03e7b | 2016-08-01 11:01:56 -0700 | [diff] [blame] | 39 | pipeline->fFlags |= kUsesDistanceVectorField_Flag; |
| 40 | } |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 41 | if (args.fAppliedClip->hasStencilClip()) { |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 42 | pipeline->fFlags |= kHasStencilClip_Flag; |
| 43 | } |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 44 | if (!args.fUserStencil->isDisabled(args.fAppliedClip->hasStencilClip())) { |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 45 | pipeline->fFlags |= kStencilEnabled_Flag; |
| 46 | } |
Brian Salomon | f87e2b9 | 2017-01-19 11:31:50 -0500 | [diff] [blame] | 47 | if (args.fProcessors->disableOutputConversionToSRGB()) { |
| 48 | pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag; |
| 49 | } |
| 50 | if (args.fProcessors->allowSRGBInputs()) { |
| 51 | pipeline->fFlags |= kAllowSRGBInputs_Flag; |
| 52 | } |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 53 | |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 54 | bool isHWAA = kHWAntialias_Flag & args.fFlags; |
| 55 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 56 | // Create XferProcessor from DS's XPFactory |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 57 | bool hasMixedSamples = args.fRenderTargetContext->hasMixedSamples() && |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 58 | (isHWAA || pipeline->isStencilEnabled()); |
| 59 | const GrXPFactory* xpFactory = args.fProcessors->xpFactory(); |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 60 | sk_sp<GrXferProcessor> xferProcessor; |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 61 | if (xpFactory) { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 62 | xferProcessor.reset(xpFactory->createXferProcessor( |
| 63 | args.fAnalysis, hasMixedSamples, &args.fDstTexture, *args.fCaps)); |
bsalomon | 2047b78 | 2015-12-21 13:12:54 -0800 | [diff] [blame] | 64 | if (!xferProcessor) { |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 65 | pipeline->~GrPipeline(); |
bsalomon | 2047b78 | 2015-12-21 13:12:54 -0800 | [diff] [blame] | 66 | return nullptr; |
| 67 | } |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 68 | } else { |
bsalomon | 2047b78 | 2015-12-21 13:12:54 -0800 | [diff] [blame] | 69 | // This may return nullptr in the common case of src-over implemented using hw blending. |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 70 | xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor( |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 71 | *args.fCaps, args.fAnalysis, hasMixedSamples, &args.fDstTexture)); |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 72 | } |
cdalton | 3ccf2e7 | 2016-05-06 09:41:16 -0700 | [diff] [blame] | 73 | GrColor overrideColor = GrColor_ILLEGAL; |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 74 | if (args.fAnalysis.fColorPOI.firstEffectiveProcessorIndex() != 0) { |
| 75 | overrideColor = args.fAnalysis.fColorPOI.inputColorToFirstEffectiveProccesor(); |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 76 | } |
| 77 | |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 78 | GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 79 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 80 | const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() : |
bsalomon | 2047b78 | 2015-12-21 13:12:54 -0800 | [diff] [blame] | 81 | &GrPorterDuffXPFactory::SimpleSrcOverXP(); |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 82 | optFlags = xpForOpts->getOptimizations( |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 83 | args.fAnalysis, args.fUserStencil->doesWrite(args.fAppliedClip->hasStencilClip()), |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 84 | &overrideColor, *args.fCaps); |
bsalomon | c8d3f57 | 2015-08-13 06:44:04 -0700 | [diff] [blame] | 85 | |
| 86 | // When path rendering the stencil settings are not always set on the GrPipelineBuilder |
| 87 | // so we must check the draw type. In cases where we will skip drawing we simply return a |
| 88 | // null GrPipeline. |
| 89 | if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 90 | pipeline->~GrPipeline(); |
bsalomon | c8d3f57 | 2015-08-13 06:44:04 -0700 | [diff] [blame] | 91 | return nullptr; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 92 | } |
bsalomon | b03c4a3 | 2014-11-20 09:56:11 -0800 | [diff] [blame] | 93 | |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 94 | // No need to have an override color if it isn't even going to be used. |
| 95 | if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { |
| 96 | overrideColor = GrColor_ILLEGAL; |
| 97 | } |
| 98 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 99 | pipeline->fXferProcessor.reset(xferProcessor.get()); |
bsalomon | b03c4a3 | 2014-11-20 09:56:11 -0800 | [diff] [blame] | 100 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 101 | int firstColorProcessorIdx = args.fAnalysis.fColorPOI.firstEffectiveProcessorIndex(); |
egdaniel | 912b3d2 | 2014-11-17 07:45:53 -0800 | [diff] [blame] | 102 | |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 103 | // TODO: Once we can handle single or four channel input into coverage GrFragmentProcessors |
| 104 | // then we can use GrPipelineBuilder's coverageProcInfo (like color above) to set this initial |
| 105 | // information. |
| 106 | int firstCoverageProcessorIdx = 0; |
egdaniel | 912b3d2 | 2014-11-17 07:45:53 -0800 | [diff] [blame] | 107 | |
Brian Salomon | bfd5183 | 2017-01-04 13:22:08 -0500 | [diff] [blame] | 108 | if ((optFlags & GrXferProcessor::kIgnoreColor_OptFlag) || |
| 109 | (optFlags & GrXferProcessor::kOverrideColor_OptFlag)) { |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 110 | firstColorProcessorIdx = args.fProcessors->numColorFragmentProcessors(); |
Brian Salomon | bfd5183 | 2017-01-04 13:22:08 -0500 | [diff] [blame] | 111 | } |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 112 | |
joshualitt | 290c09b | 2014-12-19 13:45:20 -0800 | [diff] [blame] | 113 | bool usesLocalCoords = false; |
| 114 | |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 115 | // Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 116 | pipeline->fNumColorProcessors = |
| 117 | args.fProcessors->numColorFragmentProcessors() - firstColorProcessorIdx; |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 118 | int numTotalProcessors = pipeline->fNumColorProcessors + |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 119 | args.fProcessors->numCoverageFragmentProcessors() - |
| 120 | firstCoverageProcessorIdx; |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 121 | if (args.fAppliedClip->clipCoverageFragmentProcessor()) { |
| 122 | ++numTotalProcessors; |
| 123 | } |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 124 | pipeline->fFragmentProcessors.reset(numTotalProcessors); |
| 125 | int currFPIdx = 0; |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 126 | for (int i = firstColorProcessorIdx; i < args.fProcessors->numColorFragmentProcessors(); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 127 | ++i, ++currFPIdx) { |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 128 | const GrFragmentProcessor* fp = args.fProcessors->colorFragmentProcessor(i); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 129 | pipeline->fFragmentProcessors[currFPIdx].reset(fp); |
joshualitt | 2fe7923 | 2015-08-05 12:02:27 -0700 | [diff] [blame] | 130 | usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 131 | } |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 132 | |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 133 | for (int i = firstCoverageProcessorIdx; i < args.fProcessors->numCoverageFragmentProcessors(); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 134 | ++i, ++currFPIdx) { |
Brian Salomon | 189098e7 | 2017-01-19 09:55:19 -0500 | [diff] [blame] | 135 | const GrFragmentProcessor* fp = args.fProcessors->coverageFragmentProcessor(i); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 136 | pipeline->fFragmentProcessors[currFPIdx].reset(fp); |
joshualitt | 2fe7923 | 2015-08-05 12:02:27 -0700 | [diff] [blame] | 137 | usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); |
egdaniel | 9cf45bf | 2014-10-08 06:49:10 -0700 | [diff] [blame] | 138 | } |
Brian Salomon | 652ecb5 | 2017-01-17 12:39:53 -0500 | [diff] [blame] | 139 | if (const GrFragmentProcessor* fp = args.fAppliedClip->clipCoverageFragmentProcessor()) { |
| 140 | pipeline->fFragmentProcessors[currFPIdx].reset(fp); |
| 141 | usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); |
| 142 | } |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 143 | |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 144 | // Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline. |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 145 | optimizations->fFlags = 0; |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 146 | if (GrColor_ILLEGAL != overrideColor) { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 147 | optimizations->fFlags |= GrPipelineOptimizations::kUseOverrideColor_Flag; |
| 148 | optimizations->fOverrideColor = overrideColor; |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 149 | } |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 150 | if (usesLocalCoords) { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 151 | optimizations->fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag; |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 152 | } |
| 153 | if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 154 | optimizations->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag; |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 155 | } |
bsalomon | 2d56303 | 2015-08-13 07:08:31 -0700 | [diff] [blame] | 156 | |
| 157 | GrXPFactory::InvariantBlendedColor blendedColor; |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 158 | if (xpFactory) { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 159 | xpFactory->getInvariantBlendedColor(args.fAnalysis.fColorPOI, &blendedColor); |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 160 | } else { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 161 | GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(args.fAnalysis.fColorPOI.color(), |
| 162 | args.fAnalysis.fColorPOI.validFlags(), |
| 163 | args.fAnalysis.fColorPOI.isOpaque(), |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 164 | &blendedColor); |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 165 | } |
bsalomon | 2d56303 | 2015-08-13 07:08:31 -0700 | [diff] [blame] | 166 | if (blendedColor.fWillBlendWithDst) { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 167 | optimizations->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; |
bsalomon | 2d56303 | 2015-08-13 07:08:31 -0700 | [diff] [blame] | 168 | } |
| 169 | |
bsalomon | c699873 | 2015-08-10 12:01:15 -0700 | [diff] [blame] | 170 | return pipeline; |
egdaniel | c064824 | 2014-09-22 13:17:02 -0700 | [diff] [blame] | 171 | } |
| 172 | |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 173 | static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRenderTarget* rt) { |
bsalomon | b58a2b4 | 2016-09-26 06:55:02 -0700 | [diff] [blame] | 174 | GrFragmentProcessor::TextureAccessIter iter(proc); |
Brian Salomon | 0bbecb2 | 2016-11-17 11:38:22 -0500 | [diff] [blame] | 175 | while (const GrProcessor::TextureSampler* sampler = iter.next()) { |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 176 | SkASSERT(rt->getLastOpList()); |
Brian Salomon | db4183d | 2016-11-17 12:48:40 -0500 | [diff] [blame] | 177 | rt->getLastOpList()->addDependency(sampler->texture()); |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
| 181 | void GrPipeline::addDependenciesTo(GrRenderTarget* rt) const { |
| 182 | for (int i = 0; i < fFragmentProcessors.count(); ++i) { |
| 183 | add_dependencies_for_processor(fFragmentProcessors[i].get(), rt); |
| 184 | } |
| 185 | |
bsalomon | 2047b78 | 2015-12-21 13:12:54 -0800 | [diff] [blame] | 186 | const GrXferProcessor& xfer = this->getXferProcessor(); |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 187 | |
Brian Salomon | 0bbecb2 | 2016-11-17 11:38:22 -0500 | [diff] [blame] | 188 | for (int i = 0; i < xfer.numTextureSamplers(); ++i) { |
Brian Salomon | db4183d | 2016-11-17 12:48:40 -0500 | [diff] [blame] | 189 | GrTexture* texture = xfer.textureSampler(i).texture(); |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 190 | SkASSERT(rt->getLastOpList()); |
| 191 | rt->getLastOpList()->addDependency(texture); |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 195 | //////////////////////////////////////////////////////////////////////////////// |
| 196 | |
bsalomon | 7312ff8 | 2016-09-12 08:55:38 -0700 | [diff] [blame] | 197 | bool GrPipeline::AreEqual(const GrPipeline& a, const GrPipeline& b) { |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 198 | SkASSERT(&a != &b); |
joshualitt | 8cab9a7 | 2015-07-16 09:13:50 -0700 | [diff] [blame] | 199 | |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 200 | if (a.getRenderTarget() != b.getRenderTarget() || |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 201 | a.fFragmentProcessors.count() != b.fFragmentProcessors.count() || |
| 202 | a.fNumColorProcessors != b.fNumColorProcessors || |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 203 | a.fScissorState != b.fScissorState || |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 204 | !a.fWindowRectsState.cheapEqualTo(b.fWindowRectsState) || |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 205 | a.fFlags != b.fFlags || |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 206 | a.fUserStencilSettings != b.fUserStencilSettings || |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 207 | a.fDrawFace != b.fDrawFace) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 208 | return false; |
| 209 | } |
| 210 | |
bsalomon | 2047b78 | 2015-12-21 13:12:54 -0800 | [diff] [blame] | 211 | // Most of the time both are nullptr |
| 212 | if (a.fXferProcessor.get() || b.fXferProcessor.get()) { |
| 213 | if (!a.getXferProcessor().isEqual(b.getXferProcessor())) { |
| 214 | return false; |
| 215 | } |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 216 | } |
| 217 | |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 218 | for (int i = 0; i < a.numFragmentProcessors(); i++) { |
bsalomon | 7312ff8 | 2016-09-12 08:55:38 -0700 | [diff] [blame] | 219 | if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i))) { |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 220 | return false; |
| 221 | } |
| 222 | } |
egdaniel | 89af44a | 2014-09-26 06:15:04 -0700 | [diff] [blame] | 223 | return true; |
| 224 | } |