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 GrPipelineOptimizations* opts) { |
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 SkAutoTUnref<GrXferProcessor> xferProcessor( | 24 const GrXPFactory* xpFactory = builder.getXPFactory(); |
25 builder.getXPFactory()->createXferProcessor(args.fColorPOI, args.fCovera gePOI, | 25 GrXferProcessor* xferProcessor; |
bsalomon
2015/11/23 20:19:52
Why not
SkAutoTUnref xferProcessor;
if (xpFactory
egdaniel
2015/11/23 20:49:04
Done.
| |
26 builder.hasMixedSamples(), & args.fDstTexture, | 26 if (xpFactory) { |
27 *args.fCaps)); | 27 xferProcessor = xpFactory->createXferProcessor(args.fColorPOI, args.fCov eragePOI, |
28 builder.hasMixedSamples() , &args.fDstTexture, | |
29 *args.fCaps); | |
30 } else { | |
31 xferProcessor = GrCreateSrcOverXferProcessor(*args.fCaps, args.fColorPOI , args.fCoveragePOI, | |
32 builder.hasMixedSamples(), &args.fDstTexture); | |
33 } | |
34 | |
28 if (!xferProcessor) { | 35 if (!xferProcessor) { |
29 return nullptr; | 36 return nullptr; |
30 } | 37 } |
31 | 38 |
32 GrColor overrideColor = GrColor_ILLEGAL; | 39 GrColor overrideColor = GrColor_ILLEGAL; |
33 if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) { | 40 if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) { |
34 overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor(); | 41 overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor(); |
35 } | 42 } |
36 | 43 |
37 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; | 44 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; |
38 | 45 |
39 optFlags = xferProcessor->getOptimizations(args.fColorPOI, | 46 optFlags = xferProcessor->getOptimizations(args.fColorPOI, |
40 args.fCoveragePOI, | 47 args.fCoveragePOI, |
41 builder.getStencil().doesWrite() , | 48 builder.getStencil().doesWrite() , |
42 &overrideColor, | 49 &overrideColor, |
43 *args.fCaps); | 50 *args.fCaps); |
44 | 51 |
45 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder | 52 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder |
46 // so we must check the draw type. In cases where we will skip drawing we si mply return a | 53 // so we must check the draw type. In cases where we will skip drawing we si mply return a |
47 // null GrPipeline. | 54 // null GrPipeline. |
48 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { | 55 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { |
56 xferProcessor->unref(); | |
49 return nullptr; | 57 return nullptr; |
50 } | 58 } |
51 | 59 |
52 // No need to have an override color if it isn't even going to be used. | 60 // No need to have an override color if it isn't even going to be used. |
53 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { | 61 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { |
54 overrideColor = GrColor_ILLEGAL; | 62 overrideColor = GrColor_ILLEGAL; |
55 } | 63 } |
56 | 64 |
57 GrPipeline* pipeline = new (memory) GrPipeline; | 65 GrPipeline* pipeline = new (memory) GrPipeline; |
58 pipeline->fXferProcessor.reset(xferProcessor.get()); | 66 pipeline->fXferProcessor.reset(xferProcessor); |
59 | 67 |
60 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); | 68 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); |
61 SkASSERT(pipeline->fRenderTarget); | 69 SkASSERT(pipeline->fRenderTarget); |
62 pipeline->fScissorState = *args.fScissor; | 70 pipeline->fScissorState = *args.fScissor; |
63 pipeline->fStencilSettings = builder.getStencil(); | 71 pipeline->fStencilSettings = builder.getStencil(); |
64 pipeline->fDrawFace = builder.getDrawFace(); | 72 pipeline->fDrawFace = builder.getDrawFace(); |
65 | 73 |
66 pipeline->fFlags = 0; | 74 pipeline->fFlags = 0; |
67 if (builder.isHWAntialias()) { | 75 if (builder.isHWAntialias()) { |
68 pipeline->fFlags |= kHWAA_Flag; | 76 pipeline->fFlags |= kHWAA_Flag; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 opts->fFlags |= GrPipelineOptimizations::kReadsCoverage_Flag; | 124 opts->fFlags |= GrPipelineOptimizations::kReadsCoverage_Flag; |
117 } | 125 } |
118 if (usesLocalCoords) { | 126 if (usesLocalCoords) { |
119 opts->fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag; | 127 opts->fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag; |
120 } | 128 } |
121 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) { | 129 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) { |
122 opts->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag; | 130 opts->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag; |
123 } | 131 } |
124 | 132 |
125 GrXPFactory::InvariantBlendedColor blendedColor; | 133 GrXPFactory::InvariantBlendedColor blendedColor; |
126 builder.fXPFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); | 134 if (xpFactory) { |
135 xpFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); | |
136 } else { | |
137 GrSrcOverInvariantBlendedColor(args.fColorPOI.color(), | |
138 args.fColorPOI.validFlags(), | |
139 args.fColorPOI.isOpaque(), | |
140 &blendedColor); | |
141 } | |
127 if (blendedColor.fWillBlendWithDst) { | 142 if (blendedColor.fWillBlendWithDst) { |
128 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; | 143 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; |
129 } | 144 } |
130 | 145 |
146 xferProcessor->unref(); | |
131 return pipeline; | 147 return pipeline; |
132 } | 148 } |
133 | 149 |
134 static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRe nderTarget* rt) { | 150 static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRe nderTarget* rt) { |
135 for (int i = 0; i < proc->numChildProcessors(); ++i) { | 151 for (int i = 0; i < proc->numChildProcessors(); ++i) { |
136 // need to recurse | 152 // need to recurse |
137 add_dependencies_for_processor(&proc->childProcessor(i), rt); | 153 add_dependencies_for_processor(&proc->childProcessor(i), rt); |
138 } | 154 } |
139 | 155 |
140 for (int i = 0; i < proc->numTextures(); ++i) { | 156 for (int i = 0; i < proc->numTextures(); ++i) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 } | 223 } |
208 | 224 |
209 for (int i = 0; i < a.numFragmentProcessors(); i++) { | 225 for (int i = 0; i < a.numFragmentProcessors(); i++) { |
210 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore CoordTransforms)) { | 226 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore CoordTransforms)) { |
211 return false; | 227 return false; |
212 } | 228 } |
213 } | 229 } |
214 return true; | 230 return true; |
215 } | 231 } |
216 | 232 |
OLD | NEW |