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" | |
12 #include "GrGpu.h" | 11 #include "GrGpu.h" |
13 #include "GrPipelineBuilder.h" | 12 #include "GrPipelineBuilder.h" |
14 #include "GrProcOptInfo.h" | 13 #include "GrProcOptInfo.h" |
15 #include "GrXferProcessor.h" | 14 #include "GrXferProcessor.h" |
16 | 15 |
17 #include "batches/GrBatch.h" | 16 #include "batches/GrBatch.h" |
18 | 17 |
19 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, | 18 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, |
20 GrPipelineOptimizations* opts) { | 19 GrPipelineOptimizations* opts) { |
21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; | 20 const GrPipelineBuilder& builder = *args.fPipelineBuilder; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 123 |
125 GrXPFactory::InvariantBlendedColor blendedColor; | 124 GrXPFactory::InvariantBlendedColor blendedColor; |
126 builder.fXPFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); | 125 builder.fXPFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); |
127 if (blendedColor.fWillBlendWithDst) { | 126 if (blendedColor.fWillBlendWithDst) { |
128 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; | 127 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; |
129 } | 128 } |
130 | 129 |
131 return pipeline; | 130 return pipeline; |
132 } | 131 } |
133 | 132 |
134 static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRe
nderTarget* rt) { | |
135 for (int i = 0; i < proc->numChildProcessors(); ++i) { | |
136 // need to recurse | |
137 add_dependencies_for_processor(&proc->childProcessor(i), rt); | |
138 } | |
139 | |
140 for (int i = 0; i < proc->numTextures(); ++i) { | |
141 GrTexture* texture = proc->textureAccess(i).getTexture(); | |
142 SkASSERT(rt->getLastDrawTarget()); | |
143 rt->getLastDrawTarget()->addDependency(texture); | |
144 } | |
145 } | |
146 | |
147 void GrPipeline::addDependenciesTo(GrRenderTarget* rt) const { | |
148 for (int i = 0; i < fFragmentProcessors.count(); ++i) { | |
149 add_dependencies_for_processor(fFragmentProcessors[i].get(), rt); | |
150 } | |
151 | |
152 if (fXferProcessor.get()) { | |
153 const GrXferProcessor* xfer = fXferProcessor.get(); | |
154 | |
155 for (int i = 0; i < xfer->numTextures(); ++i) { | |
156 GrTexture* texture = xfer->textureAccess(i).getTexture(); | |
157 SkASSERT(rt->getLastDrawTarget()); | |
158 rt->getLastDrawTarget()->addDependency(texture); | |
159 } | |
160 } | |
161 } | |
162 | |
163 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, | 133 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin
eBuilder, |
164 GrXferProcessor::OptFlags flags, | 134 GrXferProcessor::OptFlags flags, |
165 const GrProcOptInfo& colorPOI, | 135 const GrProcOptInfo& colorPOI, |
166 const GrProcOptInfo& coveragePOI
, | 136 const GrProcOptInfo& coveragePOI
, |
167 int* firstColorProcessorIdx, | 137 int* firstColorProcessorIdx, |
168 int* firstCoverageProcessorIdx)
{ | 138 int* firstCoverageProcessorIdx)
{ |
169 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); | 139 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); |
170 | 140 |
171 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || | 141 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || |
172 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { | 142 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 177 } |
208 | 178 |
209 for (int i = 0; i < a.numFragmentProcessors(); i++) { | 179 for (int i = 0; i < a.numFragmentProcessors(); i++) { |
210 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { | 180 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { |
211 return false; | 181 return false; |
212 } | 182 } |
213 } | 183 } |
214 return true; | 184 return true; |
215 } | 185 } |
216 | 186 |
OLD | NEW |