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

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

Issue 702083003: Add mock context and use in ResourceCacheTest. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: restore removed null check Created 6 years, 1 month 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 | « include/gpu/GrContext.h ('k') | src/gpu/GrTest.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 2011 Google Inc. 3 * Copyright 2011 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 "GrContext.h" 9 #include "GrContext.h"
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 fMaxTextureSizeOverride = 1 << 20; 114 fMaxTextureSizeOverride = 1 << 20;
115 } 115 }
116 116
117 bool GrContext::init(GrBackend backend, GrBackendContext backendContext) { 117 bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
118 SkASSERT(NULL == fGpu); 118 SkASSERT(NULL == fGpu);
119 119
120 fGpu = GrGpu::Create(backend, backendContext, this); 120 fGpu = GrGpu::Create(backend, backendContext, this);
121 if (NULL == fGpu) { 121 if (NULL == fGpu) {
122 return false; 122 return false;
123 } 123 }
124 this->initCommon();
125 return true;
126 }
124 127
128 void GrContext::initCommon() {
125 fDrawState = SkNEW(GrDrawState); 129 fDrawState = SkNEW(GrDrawState);
126 fGpu->setDrawState(fDrawState); 130 fGpu->setDrawState(fDrawState);
127 131
128 fResourceCache = SkNEW_ARGS(GrResourceCache, (fGpu->caps(), 132 fResourceCache = SkNEW_ARGS(GrResourceCache, (fGpu->caps(),
129 MAX_RESOURCE_CACHE_COUNT, 133 MAX_RESOURCE_CACHE_COUNT,
130 MAX_RESOURCE_CACHE_BYTES)); 134 MAX_RESOURCE_CACHE_BYTES));
131 fResourceCache->setOverbudgetCallback(OverbudgetCB, this); 135 fResourceCache->setOverbudgetCallback(OverbudgetCB, this);
132 fResourceCache2 = SkNEW(GrResourceCache2); 136 fResourceCache2 = SkNEW(GrResourceCache2);
133 137
134 fFontCache = SkNEW_ARGS(GrFontCache, (fGpu)); 138 fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
135 139
136 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this))); 140 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this)));
137 141
138 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu)); 142 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu));
139 fOvalRenderer = SkNEW(GrOvalRenderer); 143 fOvalRenderer = SkNEW(GrOvalRenderer);
140 144
141 fDidTestPMConversions = false; 145 fDidTestPMConversions = false;
142 146
143 this->setupDrawBuffer(); 147 this->setupDrawBuffer();
144
145 return true;
146 } 148 }
147 149
148 GrContext::~GrContext() { 150 GrContext::~GrContext() {
149 if (NULL == fGpu) { 151 if (NULL == fGpu) {
150 return; 152 return;
151 } 153 }
152 154
153 this->flush(); 155 this->flush();
154 156
155 for (int i = 0; i < fCleanUpData.count(); ++i) { 157 for (int i = 0; i < fCleanUpData.count(); ++i) {
156 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo); 158 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
157 } 159 }
158 160
159 delete fResourceCache2; 161 SkDELETE(fResourceCache2);
160 fResourceCache2 = NULL; 162 fResourceCache2 = NULL;
161 delete fResourceCache; 163 SkDELETE(fResourceCache);
162 fResourceCache = NULL; 164 fResourceCache = NULL;
163 delete fFontCache; 165 SkDELETE(fFontCache);
164 delete fDrawBuffer; 166 SkDELETE(fDrawBuffer);
165 delete fDrawBufferVBAllocPool; 167 SkDELETE(fDrawBufferVBAllocPool);
166 delete fDrawBufferIBAllocPool; 168 SkDELETE(fDrawBufferIBAllocPool);
167 169
168 fAARectRenderer->unref(); 170 fAARectRenderer->unref();
169 fOvalRenderer->unref(); 171 fOvalRenderer->unref();
170 172
171 fGpu->unref(); 173 fGpu->unref();
172 SkSafeUnref(fPathRendererChain); 174 SkSafeUnref(fPathRendererChain);
173 SkSafeUnref(fSoftwarePathRenderer); 175 SkSafeUnref(fSoftwarePathRenderer);
174 fDrawState->unref(); 176 fDrawState->unref();
175 } 177 }
176 178
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 fResourceCache->printStats(); 1781 fResourceCache->printStats();
1780 } 1782 }
1781 #endif 1783 #endif
1782 1784
1783 #if GR_GPU_STATS 1785 #if GR_GPU_STATS
1784 const GrContext::GPUStats* GrContext::gpuStats() const { 1786 const GrContext::GPUStats* GrContext::gpuStats() const {
1785 return fGpu->gpuStats(); 1787 return fGpu->gpuStats();
1786 } 1788 }
1787 #endif 1789 #endif
1788 1790
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698