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