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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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/GrTestUtils.cpp ('k') | src/gpu/GrTextContext.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 * 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 GrAtlasTextBlob* GrTextBlobCache::createBlob(int glyphCount, int runCount, size_ t maxVASize) { 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, 17 // We allocate size for the GrAtlasTextBlob itself, plus size for the vertic es array,
18 // and size for the glyphIds array. 18 // and size for the glyphIds array.
19 size_t verticesCount = glyphCount * kVerticesPerGlyph * maxVASize; 19 size_t verticesCount = glyphCount * kVerticesPerGlyph * maxVASize;
20 size_t size = sizeof(GrAtlasTextBlob) + 20 size_t size = sizeof(GrAtlasTextBlob) +
21 verticesCount + 21 verticesCount +
22 glyphCount * sizeof(GrGlyph**) + 22 glyphCount * sizeof(GrGlyph**) +
23 sizeof(GrAtlasTextBlob::Run) * runCount; 23 sizeof(GrAtlasTextBlob::Run) * runCount;
24 24
25 void* allocation = fPool.allocate(size); 25 void* allocation = fPool.allocate(size);
26 #ifdef CACHE_SANITY_CHECK 26 #ifdef CACHE_SANITY_CHECK
27 sk_bzero(allocation, size); 27 sk_bzero(allocation, size);
28 #endif 28 #endif
29 29
30 GrAtlasTextBlob* cacheBlob = SkNEW_PLACEMENT(allocation, GrAtlasTextBlob); 30 GrAtlasTextBlob* cacheBlob = new (allocation) GrAtlasTextBlob;
31 #ifdef CACHE_SANITY_CHECK 31 #ifdef CACHE_SANITY_CHECK
32 cacheBlob->fSize = size; 32 cacheBlob->fSize = size;
33 #endif 33 #endif
34 34
35 // setup offsets for vertices / glyphs 35 // setup offsets for vertices / glyphs
36 cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned c har*>(cacheBlob); 36 cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned c har*>(cacheBlob);
37 cacheBlob->fGlyphs = reinterpret_cast<GrGlyph**>(cacheBlob->fVertices + vert icesCount); 37 cacheBlob->fGlyphs = reinterpret_cast<GrGlyph**>(cacheBlob->fVertices + vert icesCount);
38 cacheBlob->fRuns = reinterpret_cast<GrAtlasTextBlob::Run*>(cacheBlob->fGlyph s + glyphCount); 38 cacheBlob->fRuns = reinterpret_cast<GrAtlasTextBlob::Run*>(cacheBlob->fGlyph s + glyphCount);
39 39
40 // Initialize runs 40 // Initialize runs
41 for (int i = 0; i < runCount; i++) { 41 for (int i = 0; i < runCount; i++) {
42 SkNEW_PLACEMENT(&cacheBlob->fRuns[i], GrAtlasTextBlob::Run); 42 new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run;
43 } 43 }
44 cacheBlob->fRunCount = runCount; 44 cacheBlob->fRunCount = runCount;
45 cacheBlob->fPool = &fPool; 45 cacheBlob->fPool = &fPool;
46 return cacheBlob; 46 return cacheBlob;
47 } 47 }
48 48
49 void GrTextBlobCache::freeAll() { 49 void GrTextBlobCache::freeAll() {
50 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key>::Iter iter(&fCache); 50 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key>::Iter iter(&fCache);
51 while (!iter.done()) { 51 while (!iter.done()) {
52 GrAtlasTextBlob* blob = &(*iter); 52 GrAtlasTextBlob* blob = &(*iter);
53 fBlobList.remove(blob); 53 fBlobList.remove(blob);
54 blob->unref(); 54 blob->unref();
55 ++iter; 55 ++iter;
56 } 56 }
57 fCache.rewind(); 57 fCache.rewind();
58 } 58 }
OLDNEW
« no previous file with comments | « src/gpu/GrTestUtils.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698