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