OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrPipeline.h" | 8 #include "GrPipeline.h" |
9 | 9 |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
13 #include "GrPipelineBuilder.h" | 13 #include "GrPipelineBuilder.h" |
14 #include "GrProcOptInfo.h" | 14 #include "GrProcOptInfo.h" |
15 #include "GrXferProcessor.h" | 15 #include "GrXferProcessor.h" |
16 | 16 |
17 #include "batches/GrBatch.h" | 17 #include "batches/GrBatch.h" |
18 | 18 |
19 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, | 19 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, |
20 GrPipelineOptimizations* opts) { | 20 GrXPOverridesForBatch* overrides) { |
21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; | 21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; |
22 | 22 |
23 // Create XferProcessor from DS's XPFactory | 23 // Create XferProcessor from DS's XPFactory |
24 const GrXPFactory* xpFactory = builder.getXPFactory(); | 24 const GrXPFactory* xpFactory = builder.getXPFactory(); |
25 SkAutoTUnref<GrXferProcessor> xferProcessor; | 25 SkAutoTUnref<GrXferProcessor> xferProcessor; |
26 if (xpFactory) { | 26 if (xpFactory) { |
27 xferProcessor.reset(xpFactory->createXferProcessor(args.fColorPOI, | 27 xferProcessor.reset(xpFactory->createXferProcessor(args.fColorPOI, |
28 args.fCoveragePOI, | 28 args.fCoveragePOI, |
29 builder.hasMixedSampl
es(), | 29 builder.hasMixedSampl
es(), |
30 &args.fDstTexture, | 30 &args.fDstTexture, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 for (int i = firstCoverageProcessorIdx; i < builder.numCoverageFragmentProce
ssors(); | 112 for (int i = firstCoverageProcessorIdx; i < builder.numCoverageFragmentProce
ssors(); |
113 ++i, ++currFPIdx) { | 113 ++i, ++currFPIdx) { |
114 const GrFragmentProcessor* fp = builder.getCoverageFragmentProcessor(i); | 114 const GrFragmentProcessor* fp = builder.getCoverageFragmentProcessor(i); |
115 pipeline->fFragmentProcessors[currFPIdx].reset(fp); | 115 pipeline->fFragmentProcessors[currFPIdx].reset(fp); |
116 usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); | 116 usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); |
117 } | 117 } |
118 | 118 |
119 // Setup info we need to pass to GrPrimitiveProcessors that are used with th
is GrPipeline. | 119 // Setup info we need to pass to GrPrimitiveProcessors that are used with th
is GrPipeline. |
120 opts->fFlags = 0; | 120 overrides->fFlags = 0; |
121 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { | 121 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { |
122 opts->fFlags |= GrPipelineOptimizations::kReadsColor_Flag; | 122 overrides->fFlags |= GrXPOverridesForBatch::kReadsColor_Flag; |
123 } | 123 } |
124 if (GrColor_ILLEGAL != overrideColor) { | 124 if (GrColor_ILLEGAL != overrideColor) { |
125 opts->fFlags |= GrPipelineOptimizations::kUseOverrideColor_Flag; | 125 overrides->fFlags |= GrXPOverridesForBatch::kUseOverrideColor_Flag; |
126 opts->fOverrideColor = overrideColor; | 126 overrides->fOverrideColor = overrideColor; |
127 } | 127 } |
128 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag)) { | 128 if (!SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag)) { |
129 opts->fFlags |= GrPipelineOptimizations::kReadsCoverage_Flag; | 129 overrides->fFlags |= GrXPOverridesForBatch::kReadsCoverage_Flag; |
130 } | 130 } |
131 if (usesLocalCoords) { | 131 if (usesLocalCoords) { |
132 opts->fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag; | 132 overrides->fFlags |= GrXPOverridesForBatch::kReadsLocalCoords_Flag; |
133 } | 133 } |
134 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag))
{ | 134 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag))
{ |
135 opts->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag;
| 135 overrides->fFlags |= GrXPOverridesForBatch::kCanTweakAlphaForCoverage_Fl
ag; |
136 } | 136 } |
137 | 137 |
138 GrXPFactory::InvariantBlendedColor blendedColor; | 138 GrXPFactory::InvariantBlendedColor blendedColor; |
139 if (xpFactory) { | 139 if (xpFactory) { |
140 xpFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); | 140 xpFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); |
141 } else { | 141 } else { |
142 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(args.fColorPOI.color
(), | 142 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(args.fColorPOI.color
(), |
143 args.fColorPOI.valid
Flags(), | 143 args.fColorPOI.valid
Flags(), |
144 args.fColorPOI.isOpa
que(), | 144 args.fColorPOI.isOpa
que(), |
145 &blendedColor); | 145 &blendedColor); |
146 } | 146 } |
147 if (blendedColor.fWillBlendWithDst) { | 147 if (blendedColor.fWillBlendWithDst) { |
148 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; | 148 overrides->fFlags |= GrXPOverridesForBatch::kWillColorBlendWithDst_Flag; |
149 } | 149 } |
150 | 150 |
151 return pipeline; | 151 return pipeline; |
152 } | 152 } |
153 | 153 |
154 static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRe
nderTarget* rt) { | 154 static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRe
nderTarget* rt) { |
155 for (int i = 0; i < proc->numChildProcessors(); ++i) { | 155 for (int i = 0; i < proc->numChildProcessors(); ++i) { |
156 // need to recurse | 156 // need to recurse |
157 add_dependencies_for_processor(&proc->childProcessor(i), rt); | 157 add_dependencies_for_processor(&proc->childProcessor(i), rt); |
158 } | 158 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 227 } |
228 | 228 |
229 for (int i = 0; i < a.numFragmentProcessors(); i++) { | 229 for (int i = 0; i < a.numFragmentProcessors(); i++) { |
230 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { | 230 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { |
231 return false; | 231 return false; |
232 } | 232 } |
233 } | 233 } |
234 return true; | 234 return true; |
235 } | 235 } |
236 | 236 |
OLD | NEW |