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

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

Issue 704563004: Revert of Add mock context and use in ResourceCacheTest. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 }
127 124
128 void GrContext::initCommon() {
129 fDrawState = SkNEW(GrDrawState); 125 fDrawState = SkNEW(GrDrawState);
130 fGpu->setDrawState(fDrawState); 126 fGpu->setDrawState(fDrawState);
131 127
132 fResourceCache = SkNEW_ARGS(GrResourceCache, (fGpu->caps(), 128 fResourceCache = SkNEW_ARGS(GrResourceCache, (fGpu->caps(),
133 MAX_RESOURCE_CACHE_COUNT, 129 MAX_RESOURCE_CACHE_COUNT,
134 MAX_RESOURCE_CACHE_BYTES)); 130 MAX_RESOURCE_CACHE_BYTES));
135 fResourceCache->setOverbudgetCallback(OverbudgetCB, this); 131 fResourceCache->setOverbudgetCallback(OverbudgetCB, this);
136 fResourceCache2 = SkNEW(GrResourceCache2); 132 fResourceCache2 = SkNEW(GrResourceCache2);
137 133
138 fFontCache = SkNEW_ARGS(GrFontCache, (fGpu)); 134 fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
139 135
140 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this))); 136 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this)));
141 137
142 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu)); 138 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu));
143 fOvalRenderer = SkNEW(GrOvalRenderer); 139 fOvalRenderer = SkNEW(GrOvalRenderer);
144 140
145 fDidTestPMConversions = false; 141 fDidTestPMConversions = false;
146 142
147 this->setupDrawBuffer(); 143 this->setupDrawBuffer();
144
145 return true;
148 } 146 }
149 147
150 GrContext::~GrContext() { 148 GrContext::~GrContext() {
151 if (NULL == fGpu) { 149 if (NULL == fGpu) {
152 return; 150 return;
153 } 151 }
154 152
155 this->flush(); 153 this->flush();
156 154
157 for (int i = 0; i < fCleanUpData.count(); ++i) { 155 for (int i = 0; i < fCleanUpData.count(); ++i) {
158 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo); 156 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
159 } 157 }
160 158
161 SkDELETE(fResourceCache2); 159 delete fResourceCache2;
162 fResourceCache2 = NULL; 160 fResourceCache2 = NULL;
163 SkDELETE(fResourceCache); 161 delete fResourceCache;
164 fResourceCache = NULL; 162 fResourceCache = NULL;
165 SkDELETE(fFontCache); 163 delete fFontCache;
166 SkDELETE(fDrawBuffer); 164 delete fDrawBuffer;
167 SkDELETE(fDrawBufferVBAllocPool); 165 delete fDrawBufferVBAllocPool;
168 SkDELETE(fDrawBufferIBAllocPool); 166 delete fDrawBufferIBAllocPool;
169 167
170 fAARectRenderer->unref(); 168 fAARectRenderer->unref();
171 fOvalRenderer->unref(); 169 fOvalRenderer->unref();
172 170
173 fGpu->unref(); 171 fGpu->unref();
174 SkSafeUnref(fPathRendererChain); 172 SkSafeUnref(fPathRendererChain);
175 SkSafeUnref(fSoftwarePathRenderer); 173 SkSafeUnref(fSoftwarePathRenderer);
176 fDrawState->unref(); 174 fDrawState->unref();
177 } 175 }
178 176
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 fResourceCache->printStats(); 1779 fResourceCache->printStats();
1782 } 1780 }
1783 #endif 1781 #endif
1784 1782
1785 #if GR_GPU_STATS 1783 #if GR_GPU_STATS
1786 const GrContext::GPUStats* GrContext::gpuStats() const { 1784 const GrContext::GPUStats* GrContext::gpuStats() const {
1787 return fGpu->gpuStats(); 1785 return fGpu->gpuStats();
1788 } 1786 }
1789 #endif 1787 #endif
1790 1788
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