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 GrXPOverridesForBatch* overrides) { | 20 GrXPOverridesForBatch* overrides) { |
21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; | 21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; |
22 | 22 |
| 23 GrPipeline* pipeline = new (memory) GrPipeline; |
| 24 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); |
| 25 SkASSERT(pipeline->fRenderTarget); |
| 26 pipeline->fScissorState = *args.fScissor; |
| 27 if (builder.hasUserStencilSettings() || args.fHasStencilClip) { |
| 28 SkASSERT(args.fNumStencilBits); |
| 29 pipeline->fStencilSettings.reset(*builder.getUserStencil(), args.fHasSte
ncilClip, |
| 30 args.fNumStencilBits); |
| 31 } |
| 32 pipeline->fDrawFace = builder.getDrawFace(); |
| 33 |
| 34 pipeline->fFlags = 0; |
| 35 if (builder.isHWAntialias()) { |
| 36 pipeline->fFlags |= kHWAA_Flag; |
| 37 } |
| 38 if (builder.snapVerticesToPixelCenters()) { |
| 39 pipeline->fFlags |= kSnapVertices_Flag; |
| 40 } |
| 41 if (builder.getDisableOutputConversionToSRGB()) { |
| 42 pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag; |
| 43 } |
| 44 if (builder.getAllowSRGBInputs()) { |
| 45 pipeline->fFlags |= kAllowSRGBInputs_Flag; |
| 46 } |
| 47 |
23 // Create XferProcessor from DS's XPFactory | 48 // Create XferProcessor from DS's XPFactory |
24 bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() && | 49 bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() && |
25 (builder.isHWAntialias() || !builder.getStencil().isD
isabled()); | 50 (builder.isHWAntialias() || !pipeline->fStencilSettin
gs.isDisabled()); |
26 const GrXPFactory* xpFactory = builder.getXPFactory(); | 51 const GrXPFactory* xpFactory = builder.getXPFactory(); |
27 SkAutoTUnref<GrXferProcessor> xferProcessor; | 52 SkAutoTUnref<GrXferProcessor> xferProcessor; |
28 if (xpFactory) { | 53 if (xpFactory) { |
29 xferProcessor.reset(xpFactory->createXferProcessor(args.fOpts, | 54 xferProcessor.reset(xpFactory->createXferProcessor(args.fOpts, |
30 hasMixedSamples, | 55 hasMixedSamples, |
31 &args.fDstTexture, | 56 &args.fDstTexture, |
32 *args.fCaps)); | 57 *args.fCaps)); |
33 if (!xferProcessor) { | 58 if (!xferProcessor) { |
| 59 pipeline->~GrPipeline(); |
34 return nullptr; | 60 return nullptr; |
35 } | 61 } |
36 } else { | 62 } else { |
37 // This may return nullptr in the common case of src-over implemented us
ing hw blending. | 63 // This may return nullptr in the common case of src-over implemented us
ing hw blending. |
38 xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor( | 64 xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor( |
39 *args.fC
aps, | 65 *args.fC
aps, |
40 args.fOp
ts, | 66 args.fOp
ts, |
41 hasMixed
Samples, | 67 hasMixed
Samples, |
42 &args.fD
stTexture)); | 68 &args.fD
stTexture)); |
43 } | 69 } |
44 GrColor overrideColor = GrColor_ILLEGAL; | 70 GrColor overrideColor = GrColor_ILLEGAL; |
45 if (args.fOpts.fColorPOI.firstEffectiveProcessorIndex() != 0) { | 71 if (args.fOpts.fColorPOI.firstEffectiveProcessorIndex() != 0) { |
46 overrideColor = args.fOpts.fColorPOI.inputColorToFirstEffectiveProccesor
(); | 72 overrideColor = args.fOpts.fColorPOI.inputColorToFirstEffectiveProccesor
(); |
47 } | 73 } |
48 | 74 |
49 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; | 75 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; |
50 | 76 |
51 const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() : | 77 const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() : |
52 &GrPorterDuffXPFactory::S
impleSrcOverXP(); | 78 &GrPorterDuffXPFactory::S
impleSrcOverXP(); |
53 optFlags = xpForOpts->getOptimizations(args.fOpts, | 79 optFlags = xpForOpts->getOptimizations(args.fOpts, |
54 builder.getStencil().doesWrite(), | 80 pipeline->fStencilSettings.doesWrite(
), |
55 &overrideColor, | 81 &overrideColor, |
56 *args.fCaps); | 82 *args.fCaps); |
57 | 83 |
58 // When path rendering the stencil settings are not always set on the GrPipe
lineBuilder | 84 // When path rendering the stencil settings are not always set on the GrPipe
lineBuilder |
59 // so we must check the draw type. In cases where we will skip drawing we si
mply return a | 85 // so we must check the draw type. In cases where we will skip drawing we si
mply return a |
60 // null GrPipeline. | 86 // null GrPipeline. |
61 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { | 87 if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) { |
| 88 pipeline->~GrPipeline(); |
62 return nullptr; | 89 return nullptr; |
63 } | 90 } |
64 | 91 |
65 // No need to have an override color if it isn't even going to be used. | 92 // No need to have an override color if it isn't even going to be used. |
66 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { | 93 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { |
67 overrideColor = GrColor_ILLEGAL; | 94 overrideColor = GrColor_ILLEGAL; |
68 } | 95 } |
69 | 96 |
70 GrPipeline* pipeline = new (memory) GrPipeline; | |
71 pipeline->fXferProcessor.reset(xferProcessor); | 97 pipeline->fXferProcessor.reset(xferProcessor); |
72 | 98 |
73 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); | |
74 SkASSERT(pipeline->fRenderTarget); | |
75 pipeline->fScissorState = *args.fScissor; | |
76 pipeline->fStencilSettings = builder.getStencil(); | |
77 pipeline->fDrawFace = builder.getDrawFace(); | |
78 | |
79 pipeline->fFlags = 0; | |
80 if (builder.isHWAntialias()) { | |
81 pipeline->fFlags |= kHWAA_Flag; | |
82 } | |
83 if (builder.snapVerticesToPixelCenters()) { | |
84 pipeline->fFlags |= kSnapVertices_Flag; | |
85 } | |
86 if (builder.getDisableOutputConversionToSRGB()) { | |
87 pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag; | |
88 } | |
89 if (builder.getAllowSRGBInputs()) { | |
90 pipeline->fFlags |= kAllowSRGBInputs_Flag; | |
91 } | |
92 | |
93 int firstColorProcessorIdx = args.fOpts.fColorPOI.firstEffectiveProcessorInd
ex(); | 99 int firstColorProcessorIdx = args.fOpts.fColorPOI.firstEffectiveProcessorInd
ex(); |
94 | 100 |
95 // TODO: Once we can handle single or four channel input into coverage GrFra
gmentProcessors | 101 // TODO: Once we can handle single or four channel input into coverage GrFra
gmentProcessors |
96 // then we can use GrPipelineBuilder's coverageProcInfo (like color above) t
o set this initial | 102 // then we can use GrPipelineBuilder's coverageProcInfo (like color above) t
o set this initial |
97 // information. | 103 // information. |
98 int firstCoverageProcessorIdx = 0; | 104 int firstCoverageProcessorIdx = 0; |
99 | 105 |
100 pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fOpts.fColo
rPOI, | 106 pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fOpts.fColo
rPOI, |
101 args.fOpts.fCoveragePOI, &firstColo
rProcessorIdx, | 107 args.fOpts.fCoveragePOI, &firstColo
rProcessorIdx, |
102 &firstCoverageProcessorIdx); | 108 &firstCoverageProcessorIdx); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 232 } |
227 } | 233 } |
228 | 234 |
229 for (int i = 0; i < a.numFragmentProcessors(); i++) { | 235 for (int i = 0; i < a.numFragmentProcessors(); i++) { |
230 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { | 236 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { |
231 return false; | 237 return false; |
232 } | 238 } |
233 } | 239 } |
234 return true; | 240 return true; |
235 } | 241 } |
OLD | NEW |