Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/gpu/GrPipeline.cpp

Issue 1278643006: Make GrBatch carry its own GrPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrPipeline.h ('k') | src/gpu/GrReorderCommandBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrPipelineBuilder.h" 12 #include "GrPipelineBuilder.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrXferProcessor.h" 14 #include "GrXferProcessor.h"
15 15
16 #include "batches/GrBatch.h" 16 #include "batches/GrBatch.h"
17 17
18 GrPipeline* GrPipeline::CreateAt(void* memory, 18 GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args,
19 const GrPipelineBuilder& builder,
20 const GrProcOptInfo& colorPOI,
21 const GrProcOptInfo& coveragePOI,
22 const GrCaps& caps,
23 const GrScissorState& scissor,
24 const GrXferProcessor::DstTexture* dst,
25 GrPipelineOptimizations* opts) { 19 GrPipelineOptimizations* opts) {
26 GrPipeline* pipeline = SkNEW_PLACEMENT(memory, GrPipeline); 20 GrPipeline* pipeline = SkNEW_PLACEMENT(memory, GrPipeline);
21 const GrPipelineBuilder& builder = *args.fPipelineBuilder;
27 22
28 // Create XferProcessor from DS's XPFactory 23 // Create XferProcessor from DS's XPFactory
29 SkAutoTUnref<GrXferProcessor> xferProcessor( 24 SkAutoTUnref<GrXferProcessor> xferProcessor(
30 builder.getXPFactory()->createXferProcessor( 25 builder.getXPFactory()->createXferProcessor(args.fColorPOI, args.fCovera gePOI,
31 colorPOI, coveragePOI, builder.hasMixedSamples(), dst, caps)); 26 builder.hasMixedSamples(), & args.fDstTexture,
27 *args.fCaps));
32 28
33 GrColor overrideColor = GrColor_ILLEGAL; 29 GrColor overrideColor = GrColor_ILLEGAL;
34 if (colorPOI.firstEffectiveStageIndex() != 0) { 30 if (args.fColorPOI.firstEffectiveStageIndex() != 0) {
35 overrideColor = colorPOI.inputColorToEffectiveStage(); 31 overrideColor = args.fColorPOI.inputColorToEffectiveStage();
36 } 32 }
37 33
38 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; 34 GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
39 if (xferProcessor) { 35 if (xferProcessor) {
40 pipeline->fXferProcessor.reset(xferProcessor.get()); 36 pipeline->fXferProcessor.reset(xferProcessor.get());
41 37
42 optFlags = xferProcessor->getOptimizations(colorPOI, 38 optFlags = xferProcessor->getOptimizations(args.fColorPOI,
43 coveragePOI, 39 args.fCoveragePOI,
44 builder.getStencil().doesWrit e(), 40 builder.getStencil().doesWrit e(),
45 &overrideColor, 41 &overrideColor,
46 caps); 42 *args.fCaps);
47 } 43 }
48 44
49 // No need to have an override color if it isn't even going to be used. 45 // No need to have an override color if it isn't even going to be used.
50 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { 46 if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) {
51 overrideColor = GrColor_ILLEGAL; 47 overrideColor = GrColor_ILLEGAL;
52 } 48 }
53 49
54 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder 50 // When path rendering the stencil settings are not always set on the GrPipe lineBuilder
55 // so we must check the draw type. In cases where we will skip drawing we si mply return a 51 // so we must check the draw type. In cases where we will skip drawing we si mply return a
56 // null GrPipeline. 52 // null GrPipeline.
57 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) { 53 if (!xferProcessor || (GrXferProcessor::kSkipDraw_OptFlag & optFlags)) {
58 // Set the fields that don't default init and return. The lack of a rend er target will 54 pipeline->~GrPipeline();
59 // indicate that this can be skipped. 55 return nullptr;
60 pipeline->fFlags = 0;
61 pipeline->fDrawFace = GrPipelineBuilder::kInvalid_DrawFace;
62 return pipeline;
63 } 56 }
64 57
65 pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); 58 pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
66 SkASSERT(pipeline->fRenderTarget); 59 SkASSERT(pipeline->fRenderTarget);
67 pipeline->fScissorState = scissor; 60 pipeline->fScissorState = *args.fScissor;
68 pipeline->fStencilSettings = builder.getStencil(); 61 pipeline->fStencilSettings = builder.getStencil();
69 pipeline->fDrawFace = builder.getDrawFace(); 62 pipeline->fDrawFace = builder.getDrawFace();
70 63
71 pipeline->fFlags = 0; 64 pipeline->fFlags = 0;
72 if (builder.isHWAntialias()) { 65 if (builder.isHWAntialias()) {
73 pipeline->fFlags |= kHWAA_Flag; 66 pipeline->fFlags |= kHWAA_Flag;
74 } 67 }
75 if (builder.isDither()) { 68 if (builder.isDither()) {
76 pipeline->fFlags |= kDither_Flag; 69 pipeline->fFlags |= kDither_Flag;
77 } 70 }
78 if (builder.snapVerticesToPixelCenters()) { 71 if (builder.snapVerticesToPixelCenters()) {
79 pipeline->fFlags |= kSnapVertices_Flag; 72 pipeline->fFlags |= kSnapVertices_Flag;
80 } 73 }
81 74
82 int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); 75 int firstColorStageIdx = args.fColorPOI.firstEffectiveStageIndex();
83 76
84 // TODO: Once we can handle single or four channel input into coverage stage s then we can use 77 // TODO: Once we can handle single or four channel input into coverage stage s then we can use
85 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi al information. 78 // GrPipelineBuilder's coverageProcInfo (like color above) to set this initi al information.
86 int firstCoverageStageIdx = 0; 79 int firstCoverageStageIdx = 0;
87 80
88 pipeline->adjustProgramFromOptimizations(builder, optFlags, colorPOI, covera gePOI, 81 pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fColorPOI, args.fCoveragePOI,
89 &firstColorStageIdx, &firstCoverage StageIdx); 82 &firstColorStageIdx, &firstCoverage StageIdx);
90 83
91 bool usesLocalCoords = false; 84 bool usesLocalCoords = false;
92 85
93 // Copy Stages from PipelineBuilder to Pipeline 86 // Copy Stages from PipelineBuilder to Pipeline
94 for (int i = firstColorStageIdx; i < builder.numColorFragmentStages(); ++i) { 87 for (int i = firstColorStageIdx; i < builder.numColorFragmentStages(); ++i) {
95 const GrFragmentStage& fps = builder.fColorStages[i]; 88 const GrFragmentStage& fps = builder.fColorStages[i];
96 const GrFragmentProcessor* fp = fps.processor(); 89 const GrFragmentProcessor* fp = fps.processor();
97 SkNEW_APPEND_TO_TARRAY(&pipeline->fFragmentStages, GrPendingFragmentStag e, (fps)); 90 SkNEW_APPEND_TO_TARRAY(&pipeline->fFragmentStages, GrPendingFragmentStag e, (fps));
98 usesLocalCoords = usesLocalCoords || fp->usesLocalCoords(); 91 usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 172
180 for (int i = 0; i < this->numFragmentStages(); i++) { 173 for (int i = 0; i < this->numFragmentStages(); i++) {
181 if (!this->getFragmentStage(i).processor()->isEqual(*that.getFragmentSta ge(i).processor(), 174 if (!this->getFragmentStage(i).processor()->isEqual(*that.getFragmentSta ge(i).processor(),
182 ignoreCoordTransform s)) { 175 ignoreCoordTransform s)) {
183 return false; 176 return false;
184 } 177 }
185 } 178 }
186 return true; 179 return true;
187 } 180 }
188 181
OLDNEW
« no previous file with comments | « src/gpu/GrPipeline.h ('k') | src/gpu/GrReorderCommandBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698