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 "GrRenderTargetPriv.h" |
15 #include "GrXferProcessor.h" | 16 #include "GrXferProcessor.h" |
16 | 17 |
17 #include "batches/GrBatch.h" | 18 #include "batches/GrBatch.h" |
18 | 19 |
19 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, | 20 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, |
20 GrXPOverridesForBatch* overrides) { | 21 GrXPOverridesForBatch* overrides) { |
21 const GrPipelineBuilder& builder = *args.fPipelineBuilder; | 22 const GrPipelineBuilder& builder = *args.fPipelineBuilder; |
22 | 23 |
23 GrPipeline* pipeline = new (memory) GrPipeline; | 24 GrPipeline* pipeline = new (memory) GrPipeline; |
24 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); | 25 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); |
25 SkASSERT(pipeline->fRenderTarget); | 26 SkASSERT(pipeline->fRenderTarget); |
26 pipeline->fScissorState = *args.fScissor; | 27 pipeline->fScissorState = *args.fScissor; |
27 if (builder.hasUserStencilSettings() || args.fHasStencilClip) { | 28 if (builder.hasUserStencilSettings() || args.fHasStencilClip) { |
28 SkASSERT(args.fNumStencilBits); | 29 const GrRenderTargetPriv& rtPriv = builder.getRenderTarget()->renderTarg
etPriv(); |
29 pipeline->fStencilSettings.reset(*builder.getUserStencil(), args.fHasSte
ncilClip, | 30 pipeline->fStencilSettings.reset(*builder.getUserStencil(), args.fHasSte
ncilClip, |
30 args.fNumStencilBits); | 31 rtPriv.numStencilBits()); |
31 SkASSERT(!pipeline->fStencilSettings.usesWrapOp() || args.fCaps->stencil
WrapOpsSupport()); | 32 SkASSERT(!pipeline->fStencilSettings.usesWrapOp() || args.fCaps->stencil
WrapOpsSupport()); |
32 } | 33 } |
33 pipeline->fDrawFace = builder.getDrawFace(); | 34 pipeline->fDrawFace = builder.getDrawFace(); |
34 | 35 |
35 pipeline->fFlags = 0; | 36 pipeline->fFlags = 0; |
36 if (builder.isHWAntialias()) { | 37 if (builder.isHWAntialias()) { |
37 pipeline->fFlags |= kHWAA_Flag; | 38 pipeline->fFlags |= kHWAA_Flag; |
38 } | 39 } |
39 if (builder.snapVerticesToPixelCenters()) { | 40 if (builder.snapVerticesToPixelCenters()) { |
40 pipeline->fFlags |= kSnapVertices_Flag; | 41 pipeline->fFlags |= kSnapVertices_Flag; |
41 } | 42 } |
42 if (builder.getDisableOutputConversionToSRGB()) { | 43 if (builder.getDisableOutputConversionToSRGB()) { |
43 pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag; | 44 pipeline->fFlags |= kDisableOutputConversionToSRGB_Flag; |
44 } | 45 } |
45 if (builder.getAllowSRGBInputs()) { | 46 if (builder.getAllowSRGBInputs()) { |
46 pipeline->fFlags |= kAllowSRGBInputs_Flag; | 47 pipeline->fFlags |= kAllowSRGBInputs_Flag; |
47 } | 48 } |
| 49 if (args.fHasStencilClip) { |
| 50 pipeline->fFlags |= kHasStencilClip_Flag; |
| 51 } |
48 | 52 |
49 // Create XferProcessor from DS's XPFactory | 53 // Create XferProcessor from DS's XPFactory |
50 bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() && | 54 bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() && |
51 (builder.isHWAntialias() || !pipeline->fStencilSettin
gs.isDisabled()); | 55 (builder.isHWAntialias() || !pipeline->fStencilSettin
gs.isDisabled()); |
52 const GrXPFactory* xpFactory = builder.getXPFactory(); | 56 const GrXPFactory* xpFactory = builder.getXPFactory(); |
53 SkAutoTUnref<GrXferProcessor> xferProcessor; | 57 SkAutoTUnref<GrXferProcessor> xferProcessor; |
54 if (xpFactory) { | 58 if (xpFactory) { |
55 xferProcessor.reset(xpFactory->createXferProcessor(args.fOpts, | 59 xferProcessor.reset(xpFactory->createXferProcessor(args.fOpts, |
56 hasMixedSamples, | 60 hasMixedSamples, |
57 &args.fDstTexture, | 61 &args.fDstTexture, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 237 } |
234 } | 238 } |
235 | 239 |
236 for (int i = 0; i < a.numFragmentProcessors(); i++) { | 240 for (int i = 0; i < a.numFragmentProcessors(); i++) { |
237 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { | 241 if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignore
CoordTransforms)) { |
238 return false; | 242 return false; |
239 } | 243 } |
240 } | 244 } |
241 return true; | 245 return true; |
242 } | 246 } |
OLD | NEW |