Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: src/gpu/GrPipeline.cpp

Issue 1540363002: Don't ref/unref the static src-over xp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tiny Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrPipeline.h ('k') | src/gpu/batches/GrDrawBatch.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 10 matching lines...) Expand all
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.fOpts, 27 xferProcessor.reset(xpFactory->createXferProcessor(args.fOpts,
28 builder.hasMixedSampl es(), 28 builder.hasMixedSampl es(),
29 &args.fDstTexture, 29 &args.fDstTexture,
30 *args.fCaps)); 30 *args.fCaps));
31 if (!xferProcessor) {
32 return nullptr;
33 }
31 } else { 34 } else {
35 // This may return nullptr in the common case of src-over implemented us ing hw blending.
32 xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor( 36 xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
33 *args.fC aps, 37 *args.fC aps,
34 args.fOp ts, 38 args.fOp ts,
35 builder. hasMixedSamples(), 39 builder. hasMixedSamples(),
36 &args.fD stTexture)); 40 &args.fD stTexture));
37 } 41 }
38 42 GrColor overrideColor = GrColor_ILLEGAL;
39 if (!xferProcessor) {
40 return nullptr;
41 }
42
43 GrColor overrideColor = GrColor_ILLEGAL;
44 if (args.fOpts.fColorPOI.firstEffectiveProcessorIndex() != 0) { 43 if (args.fOpts.fColorPOI.firstEffectiveProcessorIndex() != 0) {
45 overrideColor = args.fOpts.fColorPOI.inputColorToFirstEffectiveProccesor (); 44 overrideColor = args.fOpts.fColorPOI.inputColorToFirstEffectiveProccesor ();
46 } 45 }
47 46
48 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; 47 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
49 48
50 optFlags = xferProcessor->getOptimizations(args.fOpts, 49 const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() :
51 builder.getStencil().doesWrite(), 50 &GrPorterDuffXPFactory::S impleSrcOverXP();
52 &overrideColor, 51 optFlags = xpForOpts->getOptimizations(args.fOpts,
53 *args.fCaps); 52 builder.getStencil().doesWrite(),
53 &overrideColor,
54 *args.fCaps);
54 55
55 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder 56 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder
56 // so we must check the draw type. In cases where we will skip drawing we si mply return a 57 // so we must check the draw type. In cases where we will skip drawing we si mply return a
57 // null GrPipeline. 58 // null GrPipeline.
58 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { 59 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) {
59 return nullptr; 60 return nullptr;
60 } 61 }
61 62
62 // No need to have an override color if it isn't even going to be used. 63 // No need to have an override color if it isn't even going to be used.
63 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { 64 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 SkASSERT(rt->getLastDrawTarget()); 161 SkASSERT(rt->getLastDrawTarget());
161 rt->getLastDrawTarget()->addDependency(texture); 162 rt->getLastDrawTarget()->addDependency(texture);
162 } 163 }
163 } 164 }
164 165
165 void GrPipeline::addDependenciesTo(GrRenderTarget* rt) const { 166 void GrPipeline::addDependenciesTo(GrRenderTarget* rt) const {
166 for (int i = 0; i < fFragmentProcessors.count(); ++i) { 167 for (int i = 0; i < fFragmentProcessors.count(); ++i) {
167 add_dependencies_for_processor(fFragmentProcessors[i].get(), rt); 168 add_dependencies_for_processor(fFragmentProcessors[i].get(), rt);
168 } 169 }
169 170
170 if (fXferProcessor.get()) { 171 const GrXferProcessor& xfer = this->getXferProcessor();
171 const GrXferProcessor* xfer = fXferProcessor.get();
172 172
173 for (int i = 0; i < xfer->numTextures(); ++i) { 173 for (int i = 0; i < xfer.numTextures(); ++i) {
174 GrTexture* texture = xfer->textureAccess(i).getTexture(); 174 GrTexture* texture = xfer.textureAccess(i).getTexture();
175 SkASSERT(rt->getLastDrawTarget()); 175 SkASSERT(rt->getLastDrawTarget());
176 rt->getLastDrawTarget()->addDependency(texture); 176 rt->getLastDrawTarget()->addDependency(texture);
177 }
178 } 177 }
179 } 178 }
180 179
181 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin eBuilder, 180 void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelin eBuilder,
182 GrXferProcessor::OptFlags flags, 181 GrXferProcessor::OptFlags flags,
183 const GrProcOptInfo& colorPOI, 182 const GrProcOptInfo& colorPOI,
184 const GrProcOptInfo& coveragePOI , 183 const GrProcOptInfo& coveragePOI ,
185 int* firstColorProcessorIdx, 184 int* firstColorProcessorIdx,
186 int* firstCoverageProcessorIdx) { 185 int* firstCoverageProcessorIdx) {
187 fIgnoresCoverage = SkToBool(flags & GrXferProcessor::kIgnoreCoverage_OptFlag ); 186 fIgnoresCoverage = SkToBool(flags & GrXferProcessor::kIgnoreCoverage_OptFlag );
188 fReadsFragPosition = fXferProcessor->willReadFragmentPosition(); 187 fReadsFragPosition = this->getXferProcessor().willReadFragmentPosition();
189 188
190 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) || 189 if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
191 (flags & GrXferProcessor::kOverrideColor_OptFlag)) { 190 (flags & GrXferProcessor::kOverrideColor_OptFlag)) {
192 *firstColorProcessorIdx = pipelineBuilder.numColorFragmentProcessors(); 191 *firstColorProcessorIdx = pipelineBuilder.numColorFragmentProcessors();
193 } else { 192 } else {
194 if (colorPOI.readsFragPosition()) { 193 if (colorPOI.readsFragPosition()) {
195 fReadsFragPosition = true; 194 fReadsFragPosition = true;
196 } 195 }
197 } 196 }
198 197
(...skipping 15 matching lines...) Expand all
214 if (a.getRenderTarget() != b.getRenderTarget() || 213 if (a.getRenderTarget() != b.getRenderTarget() ||
215 a.fFragmentProcessors.count() != b.fFragmentProcessors.count() || 214 a.fFragmentProcessors.count() != b.fFragmentProcessors.count() ||
216 a.fNumColorProcessors != b.fNumColorProcessors || 215 a.fNumColorProcessors != b.fNumColorProcessors ||
217 a.fScissorState != b.fScissorState || 216 a.fScissorState != b.fScissorState ||
218 a.fFlags != b.fFlags || 217 a.fFlags != b.fFlags ||
219 a.fStencilSettings != b.fStencilSettings || 218 a.fStencilSettings != b.fStencilSettings ||
220 a.fDrawFace != b.fDrawFace) { 219 a.fDrawFace != b.fDrawFace) {
221 return false; 220 return false;
222 } 221 }
223 222
224 if (!a.getXferProcessor()->isEqual(*b.getXferProcessor())) { 223 // Most of the time both are nullptr
225 return false; 224 if (a.fXferProcessor.get() || b.fXferProcessor.get()) {
225 if (!a.getXferProcessor().isEqual(b.getXferProcessor())) {
226 return false;
227 }
226 } 228 }
227 229
228 for (int i = 0; i < a.numFragmentProcessors(); i++) { 230 for (int i = 0; i < a.numFragmentProcessors(); i++) {
229 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore CoordTransforms)) { 231 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore CoordTransforms)) {
230 return false; 232 return false;
231 } 233 }
232 } 234 }
233 return true; 235 return true;
234 } 236 }
235 237
OLDNEW
« no previous file with comments | « src/gpu/GrPipeline.h ('k') | src/gpu/batches/GrDrawBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698