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

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

Issue 1249663002: rename BitmapTextBlob and move it to its own file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years, 5 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/GrTextBlobCache.h ('k') | no next file » | 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 * 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 "GrTextBlobCache.h" 8 #include "GrTextBlobCache.h"
9 9
10 static const int kVerticesPerGlyph = 4; 10 static const int kVerticesPerGlyph = 4;
11 11
12 GrTextBlobCache::~GrTextBlobCache() { 12 GrTextBlobCache::~GrTextBlobCache() {
13 this->freeAll(); 13 this->freeAll();
14 } 14 }
15 15
16 GrAtlasTextContext::BitmapTextBlob* GrTextBlobCache::createBlob(int glyphCount, int runCount, 16 GrAtlasTextBlob* GrTextBlobCache::createBlob(int glyphCount, int runCount,
17 size_t maxVASize ) { 17 size_t maxVASize ) {
18 // We allocate size for the BitmapTextBlob itself, plus size for the vertice s array, 18 // We allocate size for the GrAtlasTextBlob itself, plus size for the vertic es array,
19 // and size for the glyphIds array. 19 // and size for the glyphIds array.
20 size_t verticesCount = glyphCount * kVerticesPerGlyph * maxVASize; 20 size_t verticesCount = glyphCount * kVerticesPerGlyph * maxVASize;
21 size_t size = sizeof(BitmapTextBlob) + 21 size_t size = sizeof(GrAtlasTextBlob) +
22 verticesCount + 22 verticesCount +
23 glyphCount * sizeof(GrGlyph**) + 23 glyphCount * sizeof(GrGlyph**) +
24 sizeof(BitmapTextBlob::Run) * runCount; 24 sizeof(GrAtlasTextBlob::Run) * runCount;
25 25
26 BitmapTextBlob* cacheBlob = SkNEW_PLACEMENT(fPool.allocate(size), BitmapText Blob); 26 GrAtlasTextBlob* cacheBlob = SkNEW_PLACEMENT(fPool.allocate(size), GrAtlasTe xtBlob);
27 27
28 // setup offsets for vertices / glyphs 28 // setup offsets for vertices / glyphs
29 cacheBlob->fVertices = sizeof(BitmapTextBlob) + reinterpret_cast<unsigned ch ar*>(cacheBlob); 29 cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned c har*>(cacheBlob);
30 cacheBlob->fGlyphs = reinterpret_cast<GrGlyph**>(cacheBlob->fVertices + vert icesCount); 30 cacheBlob->fGlyphs = reinterpret_cast<GrGlyph**>(cacheBlob->fVertices + vert icesCount);
31 cacheBlob->fRuns = reinterpret_cast<BitmapTextBlob::Run*>(cacheBlob->fGlyphs + glyphCount); 31 cacheBlob->fRuns = reinterpret_cast<GrAtlasTextBlob::Run*>(cacheBlob->fGlyph s + glyphCount);
32 32
33 // Initialize runs 33 // Initialize runs
34 for (int i = 0; i < runCount; i++) { 34 for (int i = 0; i < runCount; i++) {
35 SkNEW_PLACEMENT(&cacheBlob->fRuns[i], BitmapTextBlob::Run); 35 SkNEW_PLACEMENT(&cacheBlob->fRuns[i], GrAtlasTextBlob::Run);
36 } 36 }
37 cacheBlob->fRunCount = runCount; 37 cacheBlob->fRunCount = runCount;
38 cacheBlob->fPool = &fPool; 38 cacheBlob->fPool = &fPool;
39 return cacheBlob; 39 return cacheBlob;
40 } 40 }
41 41
42 void GrTextBlobCache::freeAll() { 42 void GrTextBlobCache::freeAll() {
43 SkTDynamicHash<BitmapTextBlob, BitmapTextBlob::Key>::Iter iter(&fCache); 43 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key>::Iter iter(&fCache);
44 while (!iter.done()) { 44 while (!iter.done()) {
45 BitmapTextBlob* blob = &(*iter); 45 GrAtlasTextBlob* blob = &(*iter);
46 fBlobList.remove(blob); 46 fBlobList.remove(blob);
47 blob->unref(); 47 blob->unref();
48 ++iter; 48 ++iter;
49 } 49 }
50 fCache.rewind(); 50 fCache.rewind();
51 } 51 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextBlobCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698