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 SkAutoTUnref<GrXferProcessor> xferProcessor; |
26 builder.hasMixedSamples(), &
args.fDstTexture, | 26 if (xpFactory) { |
27 *args.fCaps)); | 27 xferProcessor.reset(xpFactory->createXferProcessor(args.fColorPOI, |
| 28 args.fCoveragePOI, |
| 29 builder.hasMixedSampl
es(), |
| 30 &args.fDstTexture, |
| 31 *args.fCaps)); |
| 32 } else { |
| 33 xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor( |
| 34 *args.fC
aps, |
| 35 args.fCo
lorPOI, |
| 36 args.fCo
veragePOI, |
| 37 builder.
hasMixedSamples(), |
| 38 &args.fD
stTexture)); |
| 39 } |
| 40 |
28 if (!xferProcessor) { | 41 if (!xferProcessor) { |
29 return nullptr; | 42 return nullptr; |
30 } | 43 } |
31 | 44 |
32 GrColor overrideColor = GrColor_ILLEGAL; | 45 GrColor overrideColor = GrColor_ILLEGAL; |
33 if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) { | 46 if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) { |
34 overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor(); | 47 overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor(); |
35 } | 48 } |
36 | 49 |
37 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; | 50 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; |
(...skipping 10 matching lines...) Expand all Loading... |
48 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { | 61 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { |
49 return nullptr; | 62 return nullptr; |
50 } | 63 } |
51 | 64 |
52 // No need to have an override color if it isn't even going to be used. | 65 // No need to have an override color if it isn't even going to be used. |
53 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { | 66 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { |
54 overrideColor = GrColor_ILLEGAL; | 67 overrideColor = GrColor_ILLEGAL; |
55 } | 68 } |
56 | 69 |
57 GrPipeline* pipeline = new (memory) GrPipeline; | 70 GrPipeline* pipeline = new (memory) GrPipeline; |
58 pipeline->fXferProcessor.reset(xferProcessor.get()); | 71 pipeline->fXferProcessor.reset(xferProcessor); |
59 | 72 |
60 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); | 73 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); |
61 SkASSERT(pipeline->fRenderTarget); | 74 SkASSERT(pipeline->fRenderTarget); |
62 pipeline->fScissorState = *args.fScissor; | 75 pipeline->fScissorState = *args.fScissor; |
63 pipeline->fStencilSettings = builder.getStencil(); | 76 pipeline->fStencilSettings = builder.getStencil(); |
64 pipeline->fDrawFace = builder.getDrawFace(); | 77 pipeline->fDrawFace = builder.getDrawFace(); |
65 | 78 |
66 pipeline->fFlags = 0; | 79 pipeline->fFlags = 0; |
67 if (builder.isHWAntialias()) { | 80 if (builder.isHWAntialias()) { |
68 pipeline->fFlags |= kHWAA_Flag; | 81 pipeline->fFlags |= kHWAA_Flag; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 opts->fFlags |= GrPipelineOptimizations::kReadsCoverage_Flag; | 129 opts->fFlags |= GrPipelineOptimizations::kReadsCoverage_Flag; |
117 } | 130 } |
118 if (usesLocalCoords) { | 131 if (usesLocalCoords) { |
119 opts->fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag; | 132 opts->fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag; |
120 } | 133 } |
121 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag))
{ | 134 if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag))
{ |
122 opts->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag;
| 135 opts->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag;
|
123 } | 136 } |
124 | 137 |
125 GrXPFactory::InvariantBlendedColor blendedColor; | 138 GrXPFactory::InvariantBlendedColor blendedColor; |
126 builder.fXPFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); | 139 if (xpFactory) { |
| 140 xpFactory->getInvariantBlendedColor(args.fColorPOI, &blendedColor); |
| 141 } else { |
| 142 GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(args.fColorPOI.color
(), |
| 143 args.fColorPOI.valid
Flags(), |
| 144 args.fColorPOI.isOpa
que(), |
| 145 &blendedColor); |
| 146 } |
127 if (blendedColor.fWillBlendWithDst) { | 147 if (blendedColor.fWillBlendWithDst) { |
128 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; | 148 opts->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; |
129 } | 149 } |
130 | 150 |
131 return pipeline; | 151 return pipeline; |
132 } | 152 } |
133 | 153 |
134 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) { |
135 for (int i = 0; i < proc->numChildProcessors(); ++i) { | 155 for (int i = 0; i < proc->numChildProcessors(); ++i) { |
136 // need to recurse | 156 // need to recurse |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 227 } |
208 | 228 |
209 for (int i = 0; i < a.numFragmentProcessors(); i++) { | 229 for (int i = 0; i < a.numFragmentProcessors(); i++) { |
210 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { | 230 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { |
211 return false; | 231 return false; |
212 } | 232 } |
213 } | 233 } |
214 return true; | 234 return true; |
215 } | 235 } |
216 | 236 |
OLD | NEW |