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

Side by Side Diff: src/gpu/GrDrawTarget.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/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
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 GrPipelineBuilder::AutoRestoreStencil ars; 134 GrPipelineBuilder::AutoRestoreStencil ars;
135 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b ounds())) { 135 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b ounds())) {
136 return; 136 return;
137 } 137 }
138 138
139 // Batch bounds are tight, so for dev copies 139 // Batch bounds are tight, so for dev copies
140 // TODO move this into setupDstReadIfNecessary when paths are in batch 140 // TODO move this into setupDstReadIfNecessary when paths are in batch
141 SkRect bounds = batch->bounds(); 141 SkRect bounds = batch->bounds();
142 bounds.outset(0.5f, 0.5f); 142 bounds.outset(0.5f, 0.5f);
143 143
144 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batc h, &bounds, 144 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, bat ch, &bounds,
145 this); 145 this);
146 if (pipelineInfo.mustSkipDraw()) { 146 if (!pipelineInfo.valid()) {
147 return; 147 return;
148 } 148 }
149 149 if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) {
150 this->onDrawBatch(batch, pipelineInfo); 150 return;
151 }
152 this->onDrawBatch(batch);
151 } 153 }
152 154
153 static const GrStencilSettings& winding_path_stencil_settings() { 155 static const GrStencilSettings& winding_path_stencil_settings() {
154 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, 156 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
155 kIncClamp_StencilOp, 157 kIncClamp_StencilOp,
156 kIncClamp_StencilOp, 158 kIncClamp_StencilOp,
157 kAlwaysIfInClip_StencilFunc, 159 kAlwaysIfInClip_StencilFunc,
158 0xFFFF, 0xFFFF, 0xFFFF); 160 0xFFFF, 0xFFFF, 0xFFFF);
159 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); 161 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
160 } 162 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &devBound s)) { 230 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &devBound s)) {
229 return; 231 return;
230 } 232 }
231 233
232 // set stencil settings for path 234 // set stencil settings for path
233 GrStencilSettings stencilSettings; 235 GrStencilSettings stencilSettings;
234 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); 236 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
235 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); 237 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
236 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); 238 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
237 239
238 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, &devBounds, 240 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pat hProc, &devBounds,
239 this); 241 this);
240 if (pipelineInfo.mustSkipDraw()) { 242 if (!pipelineInfo.valid()) {
241 return; 243 return;
242 } 244 }
243 245
244 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo); 246 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
245 } 247 }
246 248
247 void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder, 249 void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder,
248 const GrPathProcessor* pathProc, 250 const GrPathProcessor* pathProc,
249 const GrPathRange* pathRange, 251 const GrPathRange* pathRange,
250 const void* indices, 252 const void* indices,
(...skipping 20 matching lines...) Expand all
271 // set stencil settings for path 273 // set stencil settings for path
272 GrStencilSettings stencilSettings; 274 GrStencilSettings stencilSettings;
273 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); 275 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
274 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); 276 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
275 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); 277 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
276 278
277 // Don't compute a bounding box for dst copy texture, we'll opt 279 // Don't compute a bounding box for dst copy texture, we'll opt
278 // instead for it to just copy the entire dst. Realistically this is a moot 280 // instead for it to just copy the entire dst. Realistically this is a moot
279 // point, because any context that supports NV_path_rendering will also 281 // point, because any context that supports NV_path_rendering will also
280 // support NV_blend_equation_advanced. 282 // support NV_blend_equation_advanced.
281 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, NULL, this); 283 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pat hProc, NULL, this);
282 if (pipelineInfo.mustSkipDraw()) { 284 if (!pipelineInfo.valid()) {
283 return; 285 return;
284 } 286 }
285 287
286 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues, 288 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues,
287 transformType, count, stencilSettings, pipelineInfo); 289 transformType, count, stencilSettings, pipelineInfo);
288 } 290 }
289 291
290 void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder, 292 void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
291 GrColor color, 293 GrColor color,
292 const SkMatrix& viewMatrix, 294 const SkMatrix& viewMatrix,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 srcRect, 453 srcRect,
452 dstPoint, 454 dstPoint,
453 &clippedSrcRect, 455 &clippedSrcRect,
454 &clippedDstPoint)) { 456 &clippedDstPoint)) {
455 return; 457 return;
456 } 458 }
457 459
458 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint); 460 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
459 } 461 }
460 462
461 const GrPipeline* GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo,
462 void* pipelineAddr,
463 GrPipelineOptimizations* optimizat ions) {
464 return GrPipeline::CreateAt(pipelineAddr, *pipelineInfo.fPipelineBuilder,
465 pipelineInfo.fColorPOI,
466 pipelineInfo.fCoveragePOI,
467 *this->caps(),
468 *pipelineInfo.fScissor,
469 &pipelineInfo.fDstTexture,
470 optimizations);
471 }
472
473 /////////////////////////////////////////////////////////////////////////////// 463 ///////////////////////////////////////////////////////////////////////////////
474 464
475 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilde r, 465 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilde r,
476 GrScissorState* scissor, 466 const GrScissorState* scissor,
477 const GrPrimitiveProcessor* primProc, 467 const GrPrimitiveProcessor* primProc,
478 const SkRect* devBounds, 468 const SkRect* devBounds,
479 GrDrawTarget* target) 469 GrDrawTarget* target) {
480 : fPipelineBuilder(&pipelineBuilder) 470 fArgs.fPipelineBuilder = pipelineBuilder;
481 , fScissor(scissor) { 471 fArgs.fCaps = target->caps();
482 fColorPOI = fPipelineBuilder->colorProcInfo(primProc); 472 fArgs.fScissor = scissor;
483 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc); 473 fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(primProc);
484 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI, 474 fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(primProc);
485 &fDstTexture, devBounds)) { 475 if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPO I,
486 fPipelineBuilder = NULL; 476 fArgs.fCoveragePOI, &fArgs.fDstTexture, devBounds)) {
477 fArgs.fPipelineBuilder = NULL;
487 } 478 }
488 } 479 }
489 480
490 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilde r, 481 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilde r,
491 GrScissorState* scissor, 482 const GrScissorState* scissor,
492 const GrBatch* batch, 483 const GrBatch* batch,
493 const SkRect* devBounds, 484 const SkRect* devBounds,
494 GrDrawTarget* target) 485 GrDrawTarget* target) {
495 : fPipelineBuilder(&pipelineBuilder) 486 fArgs.fPipelineBuilder = pipelineBuilder;
496 , fScissor(scissor) { 487 fArgs.fCaps = target->caps();
497 fColorPOI = fPipelineBuilder->colorProcInfo(batch); 488 fArgs.fScissor = scissor;
498 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); 489 fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(batch);
499 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI, 490 fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(batch);
500 &fDstTexture, devBounds)) { 491 if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPO I,
501 fPipelineBuilder = NULL; 492 fArgs.fCoveragePOI, &fArgs.fDstTexture, devBounds)) {
493 fArgs.fPipelineBuilder = NULL;
502 } 494 }
503 } 495 }
504 496
505 /////////////////////////////////////////////////////////////////////////////// 497 ///////////////////////////////////////////////////////////////////////////////
506 GrClipTarget::GrClipTarget(GrContext* context) 498 GrClipTarget::GrClipTarget(GrContext* context)
507 : INHERITED(context->getGpu(), context->resourceProvider()) 499 : INHERITED(context->getGpu(), context->resourceProvider())
508 , fContext(context) { 500 , fContext(context) {
509 fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this))); 501 fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this)));
510 } 502 }
511 503
512 504
513 bool GrClipTarget::setupClip(const GrPipelineBuilder& pipelineBuilder, 505 bool GrClipTarget::setupClip(const GrPipelineBuilder& pipelineBuilder,
514 GrPipelineBuilder::AutoRestoreFragmentProcessorStat e* arfps, 506 GrPipelineBuilder::AutoRestoreFragmentProcessorStat e* arfps,
515 GrPipelineBuilder::AutoRestoreStencil* ars, 507 GrPipelineBuilder::AutoRestoreStencil* ars,
516 GrScissorState* scissorState, 508 GrScissorState* scissorState,
517 const SkRect* devBounds) { 509 const SkRect* devBounds) {
518 return fClipMaskManager->setupClipping(pipelineBuilder, 510 return fClipMaskManager->setupClipping(pipelineBuilder,
519 arfps, 511 arfps,
520 ars, 512 ars,
521 scissorState, 513 scissorState,
522 devBounds); 514 devBounds);
523 } 515 }
524 516
525 void GrClipTarget::purgeResources() { 517 void GrClipTarget::purgeResources() {
526 // The clip mask manager can rebuild all its clip masks so just 518 // The clip mask manager can rebuild all its clip masks so just
527 // get rid of them all. 519 // get rid of them all.
528 fClipMaskManager->purgeResources(); 520 fClipMaskManager->purgeResources();
529 }; 521 };
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