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

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

Issue 1011403004: BitmapTextBatch and BitmapTextBlob (Closed) Base URL: https://skia.googlesource.com/skia.git@dfpr_take_2
Patch Set: feedback inc Created 5 years, 9 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
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
11 #include "GrAARectRenderer.h" 11 #include "GrAARectRenderer.h"
12 #include "GrBatch.h" 12 #include "GrBatch.h"
13 #include "GrBatchFontCache.h"
13 #include "GrBatchTarget.h" 14 #include "GrBatchTarget.h"
14 #include "GrBufferAllocPool.h" 15 #include "GrBufferAllocPool.h"
15 #include "GrDefaultGeoProcFactory.h" 16 #include "GrDefaultGeoProcFactory.h"
16 #include "GrFontCache.h" 17 #include "GrFontCache.h"
17 #include "GrGpuResource.h" 18 #include "GrGpuResource.h"
18 #include "GrGpuResourcePriv.h" 19 #include "GrGpuResourcePriv.h"
19 #include "GrDistanceFieldTextContext.h" 20 #include "GrDistanceFieldTextContext.h"
20 #include "GrDrawTargetCaps.h" 21 #include "GrDrawTargetCaps.h"
21 #include "GrGpu.h" 22 #include "GrGpu.h"
22 #include "GrIndexBuffer.h" 23 #include "GrIndexBuffer.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 context->unref(); 88 context->unref();
88 return NULL; 89 return NULL;
89 } 90 }
90 } 91 }
91 92
92 GrContext::GrContext(const Options& opts) : fOptions(opts) { 93 GrContext::GrContext(const Options& opts) : fOptions(opts) {
93 fGpu = NULL; 94 fGpu = NULL;
94 fPathRendererChain = NULL; 95 fPathRendererChain = NULL;
95 fSoftwarePathRenderer = NULL; 96 fSoftwarePathRenderer = NULL;
96 fResourceCache = NULL; 97 fResourceCache = NULL;
98 fBatchFontCache = NULL;
97 fFontCache = NULL; 99 fFontCache = NULL;
98 fDrawBuffer = NULL; 100 fDrawBuffer = NULL;
99 fDrawBufferVBAllocPool = NULL; 101 fDrawBufferVBAllocPool = NULL;
100 fDrawBufferIBAllocPool = NULL; 102 fDrawBufferIBAllocPool = NULL;
101 fFlushToReduceCacheSize = false; 103 fFlushToReduceCacheSize = false;
102 fAARectRenderer = NULL; 104 fAARectRenderer = NULL;
103 fOvalRenderer = NULL; 105 fOvalRenderer = NULL;
104 fMaxTextureSizeOverride = 1 << 20; 106 fMaxTextureSizeOverride = 1 << 20;
105 } 107 }
106 108
(...skipping 15 matching lines...) Expand all
122 fFontCache = SkNEW_ARGS(GrFontCache, (fGpu)); 124 fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
123 125
124 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this))); 126 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this)));
125 127
126 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu)); 128 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu));
127 fOvalRenderer = SkNEW_ARGS(GrOvalRenderer, (fGpu)); 129 fOvalRenderer = SkNEW_ARGS(GrOvalRenderer, (fGpu));
128 130
129 fDidTestPMConversions = false; 131 fDidTestPMConversions = false;
130 132
131 this->setupDrawBuffer(); 133 this->setupDrawBuffer();
134
135 // GrBatchFontCache creates resources on context in its constructor
136 fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this));
Jvsquare 2015/03/27 15:07:29 This will eventually replace fFontCache, right? A
joshualitt 2015/03/30 14:56:43 Acknowledged.
132 } 137 }
133 138
134 GrContext::~GrContext() { 139 GrContext::~GrContext() {
135 if (NULL == fGpu) { 140 if (NULL == fGpu) {
136 return; 141 return;
137 } 142 }
138 143
139 this->flush(); 144 this->flush();
140 145
141 for (int i = 0; i < fCleanUpData.count(); ++i) { 146 for (int i = 0; i < fCleanUpData.count(); ++i) {
142 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo); 147 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
143 } 148 }
144 149
145 SkDELETE(fResourceCache); 150 SkDELETE(fResourceCache);
151 SkDELETE(fBatchFontCache);
146 SkDELETE(fFontCache); 152 SkDELETE(fFontCache);
147 SkDELETE(fDrawBuffer); 153 SkDELETE(fDrawBuffer);
148 SkDELETE(fDrawBufferVBAllocPool); 154 SkDELETE(fDrawBufferVBAllocPool);
149 SkDELETE(fDrawBufferIBAllocPool); 155 SkDELETE(fDrawBufferIBAllocPool);
150 156
151 fAARectRenderer->unref(); 157 fAARectRenderer->unref();
152 fOvalRenderer->unref(); 158 fOvalRenderer->unref();
153 159
154 fGpu->unref(); 160 fGpu->unref();
155 SkSafeUnref(fPathRendererChain); 161 SkSafeUnref(fPathRendererChain);
(...skipping 17 matching lines...) Expand all
173 179
174 delete fDrawBufferVBAllocPool; 180 delete fDrawBufferVBAllocPool;
175 fDrawBufferVBAllocPool = NULL; 181 fDrawBufferVBAllocPool = NULL;
176 182
177 delete fDrawBufferIBAllocPool; 183 delete fDrawBufferIBAllocPool;
178 fDrawBufferIBAllocPool = NULL; 184 fDrawBufferIBAllocPool = NULL;
179 185
180 fAARectRenderer->reset(); 186 fAARectRenderer->reset();
181 fOvalRenderer->reset(); 187 fOvalRenderer->reset();
182 188
189 fBatchFontCache->freeAll();
183 fFontCache->freeAll(); 190 fFontCache->freeAll();
184 fLayerCache->freeAll(); 191 fLayerCache->freeAll();
185 } 192 }
186 193
187 void GrContext::resetContext(uint32_t state) { 194 void GrContext::resetContext(uint32_t state) {
188 fGpu->markContextDirty(state); 195 fGpu->markContextDirty(state);
189 } 196 }
190 197
191 void GrContext::freeGpuResources() { 198 void GrContext::freeGpuResources() {
192 this->flush(); 199 this->flush();
193 200
194 if (fDrawBuffer) { 201 if (fDrawBuffer) {
195 fDrawBuffer->purgeResources(); 202 fDrawBuffer->purgeResources();
196 } 203 }
197 204
198 fAARectRenderer->reset(); 205 fAARectRenderer->reset();
199 fOvalRenderer->reset(); 206 fOvalRenderer->reset();
200 207
208 fBatchFontCache->freeAll();
201 fFontCache->freeAll(); 209 fFontCache->freeAll();
202 fLayerCache->freeAll(); 210 fLayerCache->freeAll();
203 // a path renderer may be holding onto resources 211 // a path renderer may be holding onto resources
204 SkSafeSetNull(fPathRendererChain); 212 SkSafeSetNull(fPathRendererChain);
205 SkSafeSetNull(fSoftwarePathRenderer); 213 SkSafeSetNull(fSoftwarePathRenderer);
206 } 214 }
207 215
208 void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const { 216 void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
209 if (resourceCount) { 217 if (resourceCount) {
210 *resourceCount = fResourceCache->getBudgetedResourceCount(); 218 *resourceCount = fResourceCache->getBudgetedResourceCount();
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 } 2007 }
2000 } 2008 }
2001 2009
2002 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { 2010 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
2003 fGpu->removeGpuTraceMarker(marker); 2011 fGpu->removeGpuTraceMarker(marker);
2004 if (fDrawBuffer) { 2012 if (fDrawBuffer) {
2005 fDrawBuffer->removeGpuTraceMarker(marker); 2013 fDrawBuffer->removeGpuTraceMarker(marker);
2006 } 2014 }
2007 } 2015 }
2008 2016
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698