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

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

Issue 1117433002: Remove GrFlushToGpuDrawTarget and move functionality up to GrDrawTarget. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 7 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/GrFlushToGpuDrawTarget.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 "GrBatch.h" 11 #include "GrBatch.h"
12 #include "GrBufferAllocPool.h"
12 #include "GrContext.h" 13 #include "GrContext.h"
13 #include "GrDrawTargetCaps.h" 14 #include "GrDrawTargetCaps.h"
14 #include "GrPath.h" 15 #include "GrPath.h"
15 #include "GrPipeline.h" 16 #include "GrPipeline.h"
16 #include "GrMemoryPool.h" 17 #include "GrMemoryPool.h"
17 #include "GrRenderTarget.h" 18 #include "GrRenderTarget.h"
18 #include "GrRenderTargetPriv.h" 19 #include "GrRenderTargetPriv.h"
19 #include "GrSurfacePriv.h" 20 #include "GrSurfacePriv.h"
20 #include "GrTemplates.h" 21 #include "GrTemplates.h"
21 #include "GrTexture.h" 22 #include "GrTexture.h"
(...skipping 26 matching lines...) Expand all
48 this->setIndexBuffer(di.indexBuffer()); 49 this->setIndexBuffer(di.indexBuffer());
49 50
50 return *this; 51 return *this;
51 } 52 }
52 53
53 //////////////////////////////////////////////////////////////////////////////// 54 ////////////////////////////////////////////////////////////////////////////////
54 55
55 #define DEBUG_INVAL_BUFFER 0xdeadcafe 56 #define DEBUG_INVAL_BUFFER 0xdeadcafe
56 #define DEBUG_INVAL_START_IDX -1 57 #define DEBUG_INVAL_START_IDX -1
57 58
58 GrDrawTarget::GrDrawTarget(GrContext* context) 59 GrDrawTarget::GrDrawTarget(GrContext* context,
60 GrVertexBufferAllocPool* vpool,
61 GrIndexBufferAllocPool* ipool)
59 : fContext(context) 62 : fContext(context)
60 , fGpuTraceMarkerCount(0) { 63 , fCaps(SkRef(context->getGpu()->caps()))
64 , fGpuTraceMarkerCount(0)
65 , fVertexPool(vpool)
66 , fIndexPool(ipool)
67 , fFlushing(false) {
61 SkASSERT(context); 68 SkASSERT(context);
62 } 69 }
63 70
64 //////////////////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////////////////
65 72
66 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der, 73 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der,
67 const GrProcOptInfo& colorPOI, 74 const GrProcOptInfo& colorPOI,
68 const GrProcOptInfo& coveragePOI, 75 const GrProcOptInfo& coveragePOI,
69 GrDeviceCoordTexture* dstCopy, 76 GrDeviceCoordTexture* dstCopy,
70 const SkRect* drawBounds) { 77 const SkRect* drawBounds) {
(...skipping 15 matching lines...) Expand all
86 } 93 }
87 } else { 94 } else {
88 #ifdef SK_DEBUG 95 #ifdef SK_DEBUG
89 //SkDebugf("No dev bounds when dst copy is made.\n"); 96 //SkDebugf("No dev bounds when dst copy is made.\n");
90 #endif 97 #endif
91 } 98 }
92 99
93 // MSAA consideration: When there is support for reading MSAA samples in the shader we could 100 // MSAA consideration: When there is support for reading MSAA samples in the shader we could
94 // have per-sample dst values by making the copy multisampled. 101 // have per-sample dst values by making the copy multisampled.
95 GrSurfaceDesc desc; 102 GrSurfaceDesc desc;
96 this->initCopySurfaceDstDesc(rt, &desc); 103 if (!this->getGpu()->initCopySurfaceDstDesc(rt, &desc)) {
104 desc.fOrigin = kDefault_GrSurfaceOrigin;
105 desc.fFlags = kRenderTarget_GrSurfaceFlag;
106 desc.fConfig = rt->config();
107 }
108
109
97 desc.fWidth = copyRect.width(); 110 desc.fWidth = copyRect.width();
98 desc.fHeight = copyRect.height(); 111 desc.fHeight = copyRect.height();
99 112
100 SkAutoTUnref<GrTexture> copy( 113 SkAutoTUnref<GrTexture> copy(
101 fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); 114 fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
102 115
103 if (!copy) { 116 if (!copy) {
104 SkDebugf("Failed to create temporary copy of destination texture.\n"); 117 SkDebugf("Failed to create temporary copy of destination texture.\n");
105 return false; 118 return false;
106 } 119 }
107 SkIPoint dstPoint = {0, 0}; 120 SkIPoint dstPoint = {0, 0};
108 if (this->copySurface(copy, rt, copyRect, dstPoint)) { 121 if (this->copySurface(copy, rt, copyRect, dstPoint)) {
109 dstCopy->setTexture(copy); 122 dstCopy->setTexture(copy);
110 dstCopy->setOffset(copyRect.fLeft, copyRect.fTop); 123 dstCopy->setOffset(copyRect.fLeft, copyRect.fTop);
111 return true; 124 return true;
112 } else { 125 } else {
113 return false; 126 return false;
114 } 127 }
115 } 128 }
116 129
130 void GrDrawTarget::reset() {
131 fVertexPool->reset();
132 fIndexPool->reset();
133
134 this->onReset();
135 }
136
137 void GrDrawTarget::flush() {
138 if (fFlushing) {
139 return;
140 }
141 fFlushing = true;
142
143 this->getGpu()->saveActiveTraceMarkers();
144
145 this->onFlush();
146
147 this->getGpu()->restoreActiveTraceMarkers();
148
149 fFlushing = false;
150 this->reset();
151 }
152
117 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, 153 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
118 GrBatch* batch, 154 GrBatch* batch,
119 const SkRect* devBounds) { 155 const SkRect* devBounds) {
120 SkASSERT(pipelineBuilder); 156 SkASSERT(pipelineBuilder);
121 // TODO some kind of checkdraw, but not at this level 157 // TODO some kind of checkdraw, but not at this level
122 158
123 // Setup clip 159 // Setup clip
124 GrScissorState scissorState; 160 GrScissorState scissorState;
125 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; 161 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
126 GrPipelineBuilder::AutoRestoreStencil ars; 162 GrPipelineBuilder::AutoRestoreStencil ars;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // If the rect is outside the src or dst then we've already succeeded. 442 // If the rect is outside the src or dst then we've already succeeded.
407 if (!clip_srcrect_and_dstpoint(dst, 443 if (!clip_srcrect_and_dstpoint(dst,
408 src, 444 src,
409 srcRect, 445 srcRect,
410 dstPoint, 446 dstPoint,
411 &clippedSrcRect, 447 &clippedSrcRect,
412 &clippedDstPoint)) { 448 &clippedDstPoint)) {
413 return true; 449 return true;
414 } 450 }
415 451
416 if (this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) { 452 if (this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint )) {
453 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
417 return true; 454 return true;
418 } 455 }
419 456
420 GrRenderTarget* rt = dst->asRenderTarget(); 457 GrRenderTarget* rt = dst->asRenderTarget();
421 GrTexture* tex = src->asTexture(); 458 GrTexture* tex = src->asTexture();
422 459
423 if ((dst == src) || !rt || !tex) { 460 if ((dst == src) || !rt || !tex) {
424 return false; 461 return false;
425 } 462 }
426 463
(...skipping 23 matching lines...) Expand all
450 SkIPoint clippedDstPoint; 487 SkIPoint clippedDstPoint;
451 // If the rect is outside the src or dst then we're guaranteed success 488 // If the rect is outside the src or dst then we're guaranteed success
452 if (!clip_srcrect_and_dstpoint(dst, 489 if (!clip_srcrect_and_dstpoint(dst,
453 src, 490 src,
454 srcRect, 491 srcRect,
455 dstPoint, 492 dstPoint,
456 &clippedSrcRect, 493 &clippedSrcRect,
457 &clippedDstPoint)) { 494 &clippedDstPoint)) {
458 return true; 495 return true;
459 } 496 }
460 return this->internalCanCopySurface(dst, src, clippedSrcRect, clippedDstPoin t);
461 }
462
463 bool GrDrawTarget::internalCanCopySurface(const GrSurface* dst,
464 const GrSurface* src,
465 const SkIRect& clippedSrcRect,
466 const SkIPoint& clippedDstPoint) {
467 // Check that the read/write rects are contained within the src/dst bounds.
468 SkASSERT(!clippedSrcRect.isEmpty());
469 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec t));
470 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0);
471 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() &&
472 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height());
473
474 // The base class can do it as a draw or the subclass may be able to handle it.
475 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) || 497 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
476 this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint); 498 this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPo int);
477 } 499 }
478 500
479 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo, 501 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo,
480 GrPipeline* pipeline) { 502 GrPipeline* pipeline) {
481 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder, 503 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder,
482 pipelineInfo.fColorPOI, 504 pipelineInfo.fColorPOI,
483 pipelineInfo.fCoveragePOI, 505 pipelineInfo.fCoveragePOI,
484 *this->caps(), 506 *this->caps(),
485 *pipelineInfo.fScissor, 507 *pipelineInfo.fScissor,
486 &pipelineInfo.fDstCopy)); 508 &pipelineInfo.fDstCopy));
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp, 756 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp,
735 GrPipelineBuilder::AutoRestoreStencil* ars, 757 GrPipelineBuilder::AutoRestoreStencil* ars,
736 GrScissorState* scissorState, 758 GrScissorState* scissorState,
737 const SkRect* devBounds) { 759 const SkRect* devBounds) {
738 return fClipMaskManager.setupClipping(pipelineBuilder, 760 return fClipMaskManager.setupClipping(pipelineBuilder,
739 arfp, 761 arfp,
740 ars, 762 ars,
741 scissorState, 763 scissorState,
742 devBounds); 764 devBounds);
743 } 765 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrFlushToGpuDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698