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

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

Issue 1261643004: Some cleanup in GrTextureProvider and GrResourceProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@pathargs
Patch Set: fix Created 5 years, 4 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrBatchFontCache.h" 8 #include "GrBatchFontCache.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrFontAtlasSizes.h" 10 #include "GrFontAtlasSizes.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrRectanizer.h" 12 #include "GrRectanizer.h"
13 #include "GrResourceProvider.h"
13 #include "GrSurfacePriv.h" 14 #include "GrSurfacePriv.h"
14 #include "SkString.h" 15 #include "SkString.h"
15 16
16 #include "SkDistanceFieldGen.h" 17 #include "SkDistanceFieldGen.h"
17 18
18 /////////////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////////////
19 20
20 static GrBatchAtlas* make_atlas(GrContext* context, GrPixelConfig config, 21 static GrBatchAtlas* make_atlas(GrContext* context, GrPixelConfig config,
21 int textureWidth, int textureHeight, 22 int textureWidth, int textureHeight,
22 int numPlotsX, int numPlotsY) { 23 int numPlotsX, int numPlotsY) {
23 GrSurfaceDesc desc; 24 GrSurfaceDesc desc;
24 desc.fFlags = kNone_GrSurfaceFlags; 25 desc.fFlags = kNone_GrSurfaceFlags;
25 desc.fWidth = textureWidth; 26 desc.fWidth = textureWidth;
26 desc.fHeight = textureHeight; 27 desc.fHeight = textureHeight;
27 desc.fConfig = config; 28 desc.fConfig = config;
28 29
29 // We don't want to flush the context so we claim we're in the middle of flu shing so as to 30 // We don't want to flush the context so we claim we're in the middle of flu shing so as to
30 // guarantee we do not recieve a texture with pending IO 31 // guarantee we do not recieve a texture with pending IO
31 GrTexture* texture = context->textureProvider()->refScratchTexture( 32 // TODO: Determine how to avoid having to do this. (http://skbug.com/4156)
32 desc, GrTextureProvider::kApprox_ScratchTexMatch, true); 33 static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag;
34 GrTexture* texture = context->resourceProvider()->createApproxTexture(desc, kFlags);
33 if (!texture) { 35 if (!texture) {
34 return NULL; 36 return NULL;
35 } 37 }
36 return SkNEW_ARGS(GrBatchAtlas, (texture, numPlotsX, numPlotsY)); 38 return SkNEW_ARGS(GrBatchAtlas, (texture, numPlotsX, numPlotsY));
37 } 39 }
38 40
39 bool GrBatchFontCache::initAtlas(GrMaskFormat format) { 41 bool GrBatchFontCache::initAtlas(GrMaskFormat format) {
40 int index = MaskFormatToAtlasIndex(format); 42 int index = MaskFormatToAtlasIndex(format);
41 if (!fAtlases[index]) { 43 if (!fAtlases[index]) {
42 GrPixelConfig config = MaskFormatToPixelConfig(format); 44 GrPixelConfig config = MaskFormatToPixelConfig(format);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 226
225 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, e xpectedMaskFormat, 227 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, e xpectedMaskFormat,
226 glyph->width(), glyph->height(), 228 glyph->width(), glyph->height(),
227 storage.get(), &glyph->fAtlasLoca tion); 229 storage.get(), &glyph->fAtlasLoca tion);
228 if (success) { 230 if (success) {
229 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); 231 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID);
230 fAtlasedGlyphs++; 232 fAtlasedGlyphs++;
231 } 233 }
232 return success; 234 return success;
233 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698