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

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

Issue 1521453002: Move all text stuff to its own folder (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext11textutils2
Patch Set: Created 5 years 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') | src/gpu/GrTextContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrTextBlobCache.h"
9
10 static const int kVerticesPerGlyph = 4;
11
12 GrTextBlobCache::~GrTextBlobCache() {
13 this->freeAll();
14 }
15
16 GrAtlasTextBlob* GrTextBlobCache::createBlob(int glyphCount, int runCount, size_ t maxVASize) {
17 // We allocate size for the GrAtlasTextBlob itself, plus size for the vertic es array,
18 // and size for the glyphIds array.
19 size_t verticesCount = glyphCount * kVerticesPerGlyph * maxVASize;
20 size_t size = sizeof(GrAtlasTextBlob) +
21 verticesCount +
22 glyphCount * sizeof(GrGlyph**) +
23 sizeof(GrAtlasTextBlob::Run) * runCount;
24
25 void* allocation = fPool.allocate(size);
26 #ifdef CACHE_SANITY_CHECK
27 sk_bzero(allocation, size);
28 #endif
29
30 GrAtlasTextBlob* cacheBlob = new (allocation) GrAtlasTextBlob;
31 #ifdef CACHE_SANITY_CHECK
32 cacheBlob->fSize = size;
33 #endif
34
35 // setup offsets for vertices / glyphs
36 cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned c har*>(cacheBlob);
37 cacheBlob->fGlyphs = reinterpret_cast<GrGlyph**>(cacheBlob->fVertices + vert icesCount);
38 cacheBlob->fRuns = reinterpret_cast<GrAtlasTextBlob::Run*>(cacheBlob->fGlyph s + glyphCount);
39
40 // Initialize runs
41 for (int i = 0; i < runCount; i++) {
42 new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run;
43 }
44 cacheBlob->fRunCount = runCount;
45 cacheBlob->fPool = &fPool;
46 return cacheBlob;
47 }
48
49 void GrTextBlobCache::freeAll() {
50 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key>::Iter iter(&fCache);
51 while (!iter.done()) {
52 GrAtlasTextBlob* blob = &(*iter);
53 fBlobList.remove(blob);
54 blob->unref();
55 ++iter;
56 }
57 fCache.rewind();
58 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextBlobCache.h ('k') | src/gpu/GrTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698