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

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

Issue 1229143007: Start to propagate constness of GrPipelineBuilder up the stack (Closed) Base URL: https://skia.googlesource.com/skia.git@const-fix
Patch Set: rebase Created 5 years, 5 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/GrGpu.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
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 this->getGpu()->saveActiveTraceMarkers(); 119 this->getGpu()->saveActiveTraceMarkers();
120 120
121 this->onFlush(); 121 this->onFlush();
122 122
123 this->getGpu()->restoreActiveTraceMarkers(); 123 this->getGpu()->restoreActiveTraceMarkers();
124 124
125 fFlushing = false; 125 fFlushing = false;
126 this->reset(); 126 this->reset();
127 } 127 }
128 128
129 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, 129 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrBatch* batch) {
130 GrBatch* batch) {
131 SkASSERT(pipelineBuilder);
132 // TODO some kind of checkdraw, but not at this level 130 // TODO some kind of checkdraw, but not at this level
133 131
134 // Setup clip 132 // Setup clip
135 GrScissorState scissorState; 133 GrScissorState scissorState;
136 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; 134 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
137 GrPipelineBuilder::AutoRestoreStencil ars; 135 GrPipelineBuilder::AutoRestoreStencil ars;
138 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm; 136 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm;
139 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, &b atch->bounds())) { 137 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, &b atch->bounds())) {
140 return; 138 return;
141 } 139 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 case GrPathRendering::kWinding_FillType: 180 case GrPathRendering::kWinding_FillType:
183 *outStencilSettings = winding_path_stencil_settings(); 181 *outStencilSettings = winding_path_stencil_settings();
184 break; 182 break;
185 case GrPathRendering::kEvenOdd_FillType: 183 case GrPathRendering::kEvenOdd_FillType:
186 *outStencilSettings = even_odd_path_stencil_settings(); 184 *outStencilSettings = even_odd_path_stencil_settings();
187 break; 185 break;
188 } 186 }
189 this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings); 187 this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings);
190 } 188 }
191 189
192 void GrDrawTarget::stencilPath(GrPipelineBuilder* pipelineBuilder, 190 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
193 const GrPathProcessor* pathProc, 191 const GrPathProcessor* pathProc,
194 const GrPath* path, 192 const GrPath* path,
195 GrPathRendering::FillType fill) { 193 GrPathRendering::FillType fill) {
196 // TODO: extract portions of checkDraw that are relevant to path stenciling. 194 // TODO: extract portions of checkDraw that are relevant to path stenciling.
197 SkASSERT(path); 195 SkASSERT(path);
198 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); 196 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
199 SkASSERT(pipelineBuilder);
200 197
201 // Setup clip 198 // Setup clip
202 GrScissorState scissorState; 199 GrScissorState scissorState;
203 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; 200 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
204 GrPipelineBuilder::AutoRestoreStencil ars; 201 GrPipelineBuilder::AutoRestoreStencil ars;
205 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm; 202 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm;
206 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, NU LL)) { 203 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, NU LL)) {
207 return; 204 return;
208 } 205 }
209 206
210 // set stencil settings for path 207 // set stencil settings for path
211 GrStencilSettings stencilSettings; 208 GrStencilSettings stencilSettings;
212 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); 209 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
213 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); 210 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
214 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); 211 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
215 212
216 this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilS ettings); 213 this->onStencilPath(pipelineBuilder, pathProc, path, scissorState, stencilSe ttings);
217 } 214 }
218 215
219 void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder, 216 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder,
220 const GrPathProcessor* pathProc, 217 const GrPathProcessor* pathProc,
221 const GrPath* path, 218 const GrPath* path,
222 GrPathRendering::FillType fill) { 219 GrPathRendering::FillType fill) {
223 // TODO: extract portions of checkDraw that are relevant to path rendering. 220 // TODO: extract portions of checkDraw that are relevant to path rendering.
224 SkASSERT(path); 221 SkASSERT(path);
225 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); 222 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
226 SkASSERT(pipelineBuilder);
227 223
228 SkRect devBounds = path->getBounds(); 224 SkRect devBounds = path->getBounds();
229 pathProc->viewMatrix().mapRect(&devBounds); 225 pathProc->viewMatrix().mapRect(&devBounds);
230 226
231 // Setup clip 227 // Setup clip
232 GrScissorState scissorState; 228 GrScissorState scissorState;
233 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; 229 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
234 GrPipelineBuilder::AutoRestoreStencil ars; 230 GrPipelineBuilder::AutoRestoreStencil ars;
235 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm; 231 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm;
236 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, &d evBounds)) { 232 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, &d evBounds)) {
237 return; 233 return;
238 } 234 }
239 235
240 // set stencil settings for path 236 // set stencil settings for path
241 GrStencilSettings stencilSettings; 237 GrStencilSettings stencilSettings;
242 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); 238 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
243 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); 239 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
244 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); 240 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
245 241
246 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, &devBounds, 242 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, &devBounds,
247 this); 243 this);
248 if (pipelineInfo.mustSkipDraw()) { 244 if (pipelineInfo.mustSkipDraw()) {
249 return; 245 return;
250 } 246 }
251 247
252 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo); 248 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
253 } 249 }
254 250
255 void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder, 251 void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder,
256 const GrPathProcessor* pathProc, 252 const GrPathProcessor* pathProc,
257 const GrPathRange* pathRange, 253 const GrPathRange* pathRange,
258 const void* indices, 254 const void* indices,
259 PathIndexType indexType, 255 PathIndexType indexType,
260 const float transformValues[], 256 const float transformValues[],
261 PathTransformType transformType, 257 PathTransformType transformType,
262 int count, 258 int count,
263 GrPathRendering::FillType fill) { 259 GrPathRendering::FillType fill) {
264 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); 260 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
265 SkASSERT(pathRange); 261 SkASSERT(pathRange);
266 SkASSERT(indices); 262 SkASSERT(indices);
267 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeIn Bytes(indexType)); 263 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeIn Bytes(indexType));
268 SkASSERT(transformValues); 264 SkASSERT(transformValues);
269 SkASSERT(pipelineBuilder);
270 265
271 // Setup clip 266 // Setup clip
272 GrScissorState scissorState; 267 GrScissorState scissorState;
273 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; 268 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
274 GrPipelineBuilder::AutoRestoreStencil ars; 269 GrPipelineBuilder::AutoRestoreStencil ars;
275 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm; 270 GrPipelineBuilder::AutoRestoreProcessorDataManager arpdm;
276 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, NU LL)) { 271 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &arpdm, &scissorState, NU LL)) {
277 return; 272 return;
278 } 273 }
279 274
280 // set stencil settings for path 275 // set stencil settings for path
281 GrStencilSettings stencilSettings; 276 GrStencilSettings stencilSettings;
282 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); 277 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
283 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); 278 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
284 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); 279 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
285 280
286 // Don't compute a bounding box for dst copy texture, we'll opt 281 // Don't compute a bounding box for dst copy texture, we'll opt
287 // instead for it to just copy the entire dst. Realistically this is a moot 282 // instead for it to just copy the entire dst. Realistically this is a moot
288 // point, because any context that supports NV_path_rendering will also 283 // point, because any context that supports NV_path_rendering will also
289 // support NV_blend_equation_advanced. 284 // support NV_blend_equation_advanced.
290 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, NULL, this); 285 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, NULL, this);
291 if (pipelineInfo.mustSkipDraw()) { 286 if (pipelineInfo.mustSkipDraw()) {
292 return; 287 return;
293 } 288 }
294 289
295 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues, 290 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues,
296 transformType, count, stencilSettings, pipelineInfo); 291 transformType, count, stencilSettings, pipelineInfo);
297 } 292 }
298 293
299 void GrDrawTarget::drawBWRect(GrPipelineBuilder* pipelineBuilder, 294 void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
300 GrColor color, 295 GrColor color,
301 const SkMatrix& viewMatrix, 296 const SkMatrix& viewMatrix,
302 const SkRect& rect, 297 const SkRect& rect,
303 const SkRect* localRect, 298 const SkRect* localRect,
304 const SkMatrix* localMatrix) { 299 const SkMatrix* localMatrix) {
305 SkAutoTUnref<GrBatch> batch(GrRectBatch::Create(color, viewMatrix, rect, loca lRect, 300 SkAutoTUnref<GrBatch> batch(GrRectBatch::Create(color, viewMatrix, rect, loca lRect,
306 localMatrix)); 301 localMatrix));
307 this->drawBatch(pipelineBuilder, batch); 302 this->drawBatch(pipelineBuilder, batch);
308 } 303 }
309 304
310 void GrDrawTarget::drawAARect(GrPipelineBuilder* pipelineBuilder, 305 void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder,
311 GrColor color, 306 GrColor color,
312 const SkMatrix& viewMatrix, 307 const SkMatrix& viewMatrix,
313 const SkRect& rect, 308 const SkRect& rect,
314 const SkRect& devRect) { 309 const SkRect& devRect) {
315 GrAARectRenderer::FillAARect(this, pipelineBuilder, color, viewMatrix, rect, devRect); 310 GrAARectRenderer::FillAARect(this, pipelineBuilder, color, viewMatrix, rect, devRect);
316 } 311 }
317 312
318 void GrDrawTarget::clear(const SkIRect* rect, 313 void GrDrawTarget::clear(const SkIRect* rect,
319 GrColor color, 314 GrColor color,
320 bool canIgnoreRect, 315 bool canIgnoreRect,
321 GrRenderTarget* renderTarget) { 316 GrRenderTarget* renderTarget) {
322 if (fCaps->useDrawInsteadOfClear()) { 317 if (fCaps->useDrawInsteadOfClear()) {
323 // This works around a driver bug with clear by drawing a rect instead. 318 // This works around a driver bug with clear by drawing a rect instead.
324 // The driver will ignore a clear if it is the only thing rendered to a 319 // The driver will ignore a clear if it is the only thing rendered to a
325 // target before the target is read. 320 // target before the target is read.
326 SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->he ight()); 321 SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->he ight());
327 if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) { 322 if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) {
328 rect = &rtRect; 323 rect = &rtRect;
329 // We first issue a discard() since that may help tilers. 324 // We first issue a discard() since that may help tilers.
330 this->discard(renderTarget); 325 this->discard(renderTarget);
331 } 326 }
332 327
333 GrPipelineBuilder pipelineBuilder; 328 GrPipelineBuilder pipelineBuilder;
334 pipelineBuilder.setRenderTarget(renderTarget); 329 pipelineBuilder.setRenderTarget(renderTarget);
335 330
336 this->drawSimpleRect(&pipelineBuilder, color, SkMatrix::I(), *rect); 331 this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect);
337 } else { 332 } else {
338 this->onClear(rect, color, canIgnoreRect, renderTarget); 333 this->onClear(rect, color, canIgnoreRect, renderTarget);
339 } 334 }
340 } 335 }
341 336
342 typedef GrTraceMarkerSet::Iter TMIter; 337 typedef GrTraceMarkerSet::Iter TMIter;
343 void GrDrawTarget::saveActiveTraceMarkers() { 338 void GrDrawTarget::saveActiveTraceMarkers() {
344 if (this->caps()->gpuTracingSupport()) { 339 if (this->caps()->gpuTracingSupport()) {
345 SkASSERT(0 == fStoredTraceMarkers.count()); 340 SkASSERT(0 == fStoredTraceMarkers.count());
346 fStoredTraceMarkers.addSet(fActiveTraceMarkers); 341 fStoredTraceMarkers.addSet(fActiveTraceMarkers);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 GrPipeline* pipeline) { 454 GrPipeline* pipeline) {
460 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder, 455 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder,
461 pipelineInfo.fColorPOI, 456 pipelineInfo.fColorPOI,
462 pipelineInfo.fCoveragePOI, 457 pipelineInfo.fCoveragePOI,
463 *this->caps(), 458 *this->caps(),
464 *pipelineInfo.fScissor, 459 *pipelineInfo.fScissor,
465 &pipelineInfo.fDstTexture)); 460 &pipelineInfo.fDstTexture));
466 } 461 }
467 /////////////////////////////////////////////////////////////////////////////// 462 ///////////////////////////////////////////////////////////////////////////////
468 463
469 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder, 464 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilde r,
470 GrScissorState* scissor, 465 GrScissorState* scissor,
471 const GrPrimitiveProcessor* primProc, 466 const GrPrimitiveProcessor* primProc,
472 const SkRect* devBounds, 467 const SkRect* devBounds,
473 GrDrawTarget* target) 468 GrDrawTarget* target)
474 : fPipelineBuilder(pipelineBuilder) 469 : fPipelineBuilder(&pipelineBuilder)
475 , fScissor(scissor) { 470 , fScissor(scissor) {
476 fColorPOI = fPipelineBuilder->colorProcInfo(primProc); 471 fColorPOI = fPipelineBuilder->colorProcInfo(primProc);
477 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc); 472 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc);
478 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI, 473 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI,
479 &fDstTexture, devBounds)) { 474 &fDstTexture, devBounds)) {
480 fPipelineBuilder = NULL; 475 fPipelineBuilder = NULL;
481 } 476 }
482 } 477 }
483 478
484 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder, 479 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilde r,
485 GrScissorState* scissor, 480 GrScissorState* scissor,
486 const GrBatch* batch, 481 const GrBatch* batch,
487 const SkRect* devBounds, 482 const SkRect* devBounds,
488 GrDrawTarget* target) 483 GrDrawTarget* target)
489 : fPipelineBuilder(pipelineBuilder) 484 : fPipelineBuilder(&pipelineBuilder)
490 , fScissor(scissor) { 485 , fScissor(scissor) {
491 fColorPOI = fPipelineBuilder->colorProcInfo(batch); 486 fColorPOI = fPipelineBuilder->colorProcInfo(batch);
492 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); 487 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
493 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI, 488 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI,
494 &fDstTexture, devBounds)) { 489 &fDstTexture, devBounds)) {
495 fPipelineBuilder = NULL; 490 fPipelineBuilder = NULL;
496 } 491 }
497 } 492 }
498 493
499 /////////////////////////////////////////////////////////////////////////////// 494 ///////////////////////////////////////////////////////////////////////////////
500 GrClipTarget::GrClipTarget(GrContext* context) 495 GrClipTarget::GrClipTarget(GrContext* context)
501 : INHERITED(context->getGpu(), context->resourceProvider()) 496 : INHERITED(context->getGpu(), context->resourceProvider())
502 , fContext(context) { 497 , fContext(context) {
503 fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this))); 498 fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this)));
504 } 499 }
505 500
506 501
507 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, 502 bool GrClipTarget::setupClip(const GrPipelineBuilder& pipelineBuilder,
508 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp, 503 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp,
509 GrPipelineBuilder::AutoRestoreStencil* ars, 504 GrPipelineBuilder::AutoRestoreStencil* ars,
510 GrPipelineBuilder::AutoRestoreProcessorDataManager* arpdm, 505 GrPipelineBuilder::AutoRestoreProcessorDataManager* arpdm,
511 GrScissorState* scissorState, 506 GrScissorState* scissorState,
512 const SkRect* devBounds) { 507 const SkRect* devBounds) {
513 return fClipMaskManager->setupClipping(*pipelineBuilder, 508 return fClipMaskManager->setupClipping(pipelineBuilder,
514 arfp, 509 arfp,
515 ars, 510 ars,
516 arpdm, 511 arpdm,
517 scissorState, 512 scissorState,
518 devBounds); 513 devBounds);
519 } 514 }
520 515
521 void GrClipTarget::purgeResources() { 516 void GrClipTarget::purgeResources() {
522 // The clip mask manager can rebuild all its clip masks so just 517 // The clip mask manager can rebuild all its clip masks so just
523 // get rid of them all. 518 // get rid of them all.
524 fClipMaskManager->purgeResources(); 519 fClipMaskManager->purgeResources();
525 }; 520 };
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698