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

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

Issue 1301823002: Put drawPath in GrBatch. (Closed) Base URL: https://skia.googlesource.com/skia.git@nvprbatch
Patch Set: update 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/GrDrawTarget.h ('k') | src/gpu/GrImmediateDrawTarget.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrDrawTarget.h" 9 #include "GrDrawTarget.h"
10 10
11 #include "GrCaps.h" 11 #include "GrCaps.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrPath.h" 13 #include "GrPath.h"
14 #include "GrPipeline.h" 14 #include "GrPipeline.h"
15 #include "GrMemoryPool.h" 15 #include "GrMemoryPool.h"
16 #include "GrRenderTarget.h" 16 #include "GrRenderTarget.h"
17 #include "GrResourceProvider.h" 17 #include "GrResourceProvider.h"
18 #include "GrRenderTargetPriv.h" 18 #include "GrRenderTargetPriv.h"
19 #include "GrSurfacePriv.h" 19 #include "GrSurfacePriv.h"
20 #include "GrTexture.h" 20 #include "GrTexture.h"
21 #include "GrVertexBuffer.h" 21 #include "GrVertexBuffer.h"
22 22
23 #include "batches/GrClearBatch.h" 23 #include "batches/GrClearBatch.h"
24 #include "batches/GrCopySurfaceBatch.h" 24 #include "batches/GrCopySurfaceBatch.h"
25 #include "batches/GrDiscardBatch.h" 25 #include "batches/GrDiscardBatch.h"
26 #include "batches/GrDrawBatch.h" 26 #include "batches/GrDrawBatch.h"
27 #include "batches/GrDrawPathBatch.h"
27 #include "batches/GrRectBatchFactory.h" 28 #include "batches/GrRectBatchFactory.h"
28 #include "batches/GrStencilPathBatch.h" 29 #include "batches/GrStencilPathBatch.h"
29 30
30 #include "SkStrokeRec.h" 31 #include "SkStrokeRec.h"
31 32
32 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
33 34
34 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) 35 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
35 : fGpu(SkRef(gpu)) 36 : fGpu(SkRef(gpu))
36 , fCaps(SkRef(gpu->caps())) 37 , fCaps(SkRef(gpu->caps()))
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 this->onFlush(); 125 this->onFlush();
125 126
126 this->getGpu()->restoreActiveTraceMarkers(); 127 this->getGpu()->restoreActiveTraceMarkers();
127 128
128 fFlushing = false; 129 fFlushing = false;
129 this->reset(); 130 this->reset();
130 } 131 }
131 132
132 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat ch* batch) { 133 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat ch* batch) {
133 // TODO some kind of checkdraw, but not at this level
134
135 // Setup clip 134 // Setup clip
136 GrScissorState scissorState; 135 GrScissorState scissorState;
137 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; 136 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
138 GrPipelineBuilder::AutoRestoreStencil ars; 137 GrPipelineBuilder::AutoRestoreStencil ars;
139 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b ounds())) { 138 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b ounds())) {
140 return; 139 return;
141 } 140 }
142 141
143 // Batch bounds are tight, so for dev copies 142 // Batch bounds are tight, so for dev copies
144 // TODO move this into setupDstReadIfNecessary when paths are in batch 143 // TODO move this into setupDstReadIfNecessary when paths are in batch
145 SkRect bounds = batch->bounds(); 144 SkRect bounds = batch->bounds();
146 bounds.outset(0.5f, 0.5f); 145 bounds.outset(0.5f, 0.5f);
147 146
148 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, bat ch, &bounds, 147 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, bat ch, &bounds,
149 this); 148 this);
149
150 if (!pipelineInfo.valid()) { 150 if (!pipelineInfo.valid()) {
151 return; 151 return;
152 } 152 }
153 if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { 153 if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) {
154 return; 154 return;
155 } 155 }
156 this->onDrawBatch(batch); 156 this->onDrawBatch(batch);
157 } 157 }
158 158
159 static const GrStencilSettings& winding_path_stencil_settings() { 159 static const GrStencilSettings& winding_path_stencil_settings() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 pipelineBuilder.getRenderTarget( ), 219 pipelineBuilder.getRenderTarget( ),
220 path); 220 path);
221 this->onDrawBatch(batch); 221 this->onDrawBatch(batch);
222 batch->unref(); 222 batch->unref();
223 } 223 }
224 224
225 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, 225 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder,
226 const GrPathProcessor* pathProc, 226 const GrPathProcessor* pathProc,
227 const GrPath* path, 227 const GrPath* path,
228 GrPathRendering::FillType fill) { 228 GrPathRendering::FillType fill) {
229 // TODO: extract portions of checkDraw that are relevant to path rendering.
230 SkASSERT(path); 229 SkASSERT(path);
231 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); 230 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
232 231
233 SkRect devBounds = path->getBounds(); 232 GrDrawPathBatch* batch = GrDrawPathBatch::Create(pathProc, path);
234 pathProc->viewMatrix().mapRect(&devBounds);
235 233
236 // Setup clip 234 // This looks like drawBatch() but there is an added wrinkle that stencil se ttings get inserted
235 // after setupClip() but before onDrawBatch(). TODO: Figure out a better mod el for handling
236 // stencil settings WRT interactions between pipeline(builder), clipmaskmana ger, and batches.
237
237 GrScissorState scissorState; 238 GrScissorState scissorState;
238 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; 239 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
239 GrPipelineBuilder::AutoRestoreStencil ars; 240 GrPipelineBuilder::AutoRestoreStencil ars;
240 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &devBound s)) { 241 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b ounds())) {
241 return; 242 return;
242 } 243 }
243 244
244 // set stencil settings for path 245 // Ensure the render target has a stencil buffer and get the stencil setting s.
245 GrStencilSettings stencilSettings; 246 GrStencilSettings stencilSettings;
246 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); 247 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
247 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); 248 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
248 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); 249 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
250 batch->setStencilSettings(stencilSettings);
249 251
250 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pat hProc, &devBounds, 252 // Don't compute a bounding box for dst copy texture, we'll opt
251 this); 253 // instead for it to just copy the entire dst. Realistically this is a moot
254 // point, because any context that supports NV_path_rendering will also
255 // support NV_blend_equation_advanced.
256 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, bat ch, NULL, this);
257
252 if (!pipelineInfo.valid()) { 258 if (!pipelineInfo.valid()) {
253 return; 259 return;
254 } 260 }
261 if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) {
262 return;
263 }
255 264
256 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo); 265 this->onDrawBatch(batch);
266 batch->unref();
257 } 267 }
258 268
259 void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder, 269 void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder,
260 const GrPathProcessor* pathProc, 270 const GrPathProcessor* pathProc,
261 const GrPathRange* pathRange, 271 const GrPathRange* pathRange,
262 const void* indices, 272 const void* indices,
263 PathIndexType indexType, 273 PathIndexType indexType,
264 const float transformValues[], 274 const float transformValues[],
265 PathTransformType transformType, 275 PathTransformType transformType,
266 int count, 276 int count,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // The clip mask manager can rebuild all its clip masks so just 485 // The clip mask manager can rebuild all its clip masks so just
476 // get rid of them all. 486 // get rid of them all.
477 fClipMaskManager->purgeResources(); 487 fClipMaskManager->purgeResources();
478 }; 488 };
479 489
480 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 490 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
481 GrBatch* batch = SkNEW_ARGS(GrClearStencilClipBatch, (rect, insideClip, rt)) ; 491 GrBatch* batch = SkNEW_ARGS(GrClearStencilClipBatch, (rect, insideClip, rt)) ;
482 this->onDrawBatch(batch); 492 this->onDrawBatch(batch);
483 batch->unref(); 493 batch->unref();
484 } 494 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrImmediateDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698