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

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

Issue 1166553002: Remove GrContext from GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove comment Created 5 years, 6 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') | tests/GLProgramsTest.cpp » ('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 "GrAARectRenderer.h" 11 #include "GrAARectRenderer.h"
12 #include "GrBatch.h" 12 #include "GrBatch.h"
13 #include "GrCaps.h" 13 #include "GrCaps.h"
14 #include "GrContext.h" 14 #include "GrGpu.h"
15 #include "GrPath.h" 15 #include "GrPath.h"
16 #include "GrPipeline.h" 16 #include "GrPipeline.h"
17 #include "GrMemoryPool.h" 17 #include "GrMemoryPool.h"
18 #include "GrRectBatch.h" 18 #include "GrRectBatch.h"
19 #include "GrRenderTarget.h" 19 #include "GrRenderTarget.h"
20 #include "GrResourceProvider.h"
20 #include "GrRenderTargetPriv.h" 21 #include "GrRenderTargetPriv.h"
21 #include "GrSurfacePriv.h" 22 #include "GrSurfacePriv.h"
22 #include "GrTemplates.h" 23 #include "GrTemplates.h"
23 #include "GrTexture.h" 24 #include "GrTexture.h"
24 #include "GrVertexBuffer.h" 25 #include "GrVertexBuffer.h"
25 26
26 #include "SkStrokeRec.h" 27 #include "SkStrokeRec.h"
27 28
28 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
29 30
30 #define DEBUG_INVAL_BUFFER 0xdeadcafe 31 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
31 #define DEBUG_INVAL_START_IDX -1 32 : fGpu(SkRef(gpu))
32 33 , fCaps(SkRef(gpu->caps()))
33 GrDrawTarget::GrDrawTarget(GrContext* context) 34 , fResourceProvider(resourceProvider)
34 : fContext(context)
35 , fCaps(SkRef(context->caps()))
36 , fGpuTraceMarkerCount(0) 35 , fGpuTraceMarkerCount(0)
37 , fFlushing(false) { 36 , fFlushing(false) {
38 SkASSERT(context); 37 }
38
39 GrDrawTarget::~GrDrawTarget() {
40 fGpu->unref();
41 fCaps->unref();
39 } 42 }
40 43
41 //////////////////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////////////////
42 45
43 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der, 46 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der,
44 const GrProcOptInfo& colorPOI, 47 const GrProcOptInfo& colorPOI,
45 const GrProcOptInfo& coveragePOI, 48 const GrProcOptInfo& coveragePOI,
46 GrXferProcessor::DstTexture* dstTextu re, 49 GrXferProcessor::DstTexture* dstTextu re,
47 const SkRect* drawBounds) { 50 const SkRect* drawBounds) {
48 if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coverageP OI)) { 51 if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coverageP OI)) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (!this->getGpu()->initCopySurfaceDstDesc(rt, &desc)) { 89 if (!this->getGpu()->initCopySurfaceDstDesc(rt, &desc)) {
87 desc.fOrigin = kDefault_GrSurfaceOrigin; 90 desc.fOrigin = kDefault_GrSurfaceOrigin;
88 desc.fFlags = kRenderTarget_GrSurfaceFlag; 91 desc.fFlags = kRenderTarget_GrSurfaceFlag;
89 desc.fConfig = rt->config(); 92 desc.fConfig = rt->config();
90 } 93 }
91 94
92 95
93 desc.fWidth = copyRect.width(); 96 desc.fWidth = copyRect.width();
94 desc.fHeight = copyRect.height(); 97 desc.fHeight = copyRect.height();
95 98
96 SkAutoTUnref<GrTexture> copy(fContext->textureProvider()->refScratchTexture( desc, 99 SkAutoTUnref<GrTexture> copy(
97 GrTextureProvider::kApprox_ScratchTexMatch)); 100 fResourceProvider->refScratchTexture(desc, GrTextureProvider::kApprox_Sc ratchTexMatch));
98 101
99 if (!copy) { 102 if (!copy) {
100 SkDebugf("Failed to create temporary copy of destination texture.\n"); 103 SkDebugf("Failed to create temporary copy of destination texture.\n");
101 return false; 104 return false;
102 } 105 }
103 SkIPoint dstPoint = {0, 0}; 106 SkIPoint dstPoint = {0, 0};
104 if (this->copySurface(copy, rt, copyRect, dstPoint)) { 107 if (this->copySurface(copy, rt, copyRect, dstPoint)) {
105 dstTexture->setTexture(copy); 108 dstTexture->setTexture(copy);
106 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); 109 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop);
107 return true; 110 return true;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 , fScissor(scissor) { 536 , fScissor(scissor) {
534 fColorPOI = fPipelineBuilder->colorProcInfo(batch); 537 fColorPOI = fPipelineBuilder->colorProcInfo(batch);
535 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); 538 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
536 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI, 539 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI,
537 &fDstTexture, devBounds)) { 540 &fDstTexture, devBounds)) {
538 fPipelineBuilder = NULL; 541 fPipelineBuilder = NULL;
539 } 542 }
540 } 543 }
541 544
542 /////////////////////////////////////////////////////////////////////////////// 545 ///////////////////////////////////////////////////////////////////////////////
543 GrClipTarget::GrClipTarget(GrContext* context) : INHERITED(context) { 546 GrClipTarget::GrClipTarget(GrContext* context)
547 : INHERITED(context->getGpu(), context->resourceProvider())
548 , fContext(context) {
544 fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this))); 549 fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this)));
545 } 550 }
546 551
547 552
548 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, 553 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder,
549 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp, 554 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp,
550 GrPipelineBuilder::AutoRestoreStencil* ars, 555 GrPipelineBuilder::AutoRestoreStencil* ars,
551 GrScissorState* scissorState, 556 GrScissorState* scissorState,
552 const SkRect* devBounds) { 557 const SkRect* devBounds) {
553 return fClipMaskManager->setupClipping(pipelineBuilder, 558 return fClipMaskManager->setupClipping(pipelineBuilder,
554 arfp, 559 arfp,
555 ars, 560 ars,
556 scissorState, 561 scissorState,
557 devBounds); 562 devBounds);
558 } 563 }
559 564
560 void GrClipTarget::purgeResources() { 565 void GrClipTarget::purgeResources() {
561 // The clip mask manager can rebuild all its clip masks so just 566 // The clip mask manager can rebuild all its clip masks so just
562 // get rid of them all. 567 // get rid of them all.
563 fClipMaskManager->purgeResources(); 568 fClipMaskManager->purgeResources();
564 }; 569 };
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698