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

Side by Side Diff: src/gpu/effects/GrTextureStripAtlas.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/effects/GrTextureStripAtlas.h ('k') | src/gpu/effects/GrYUVtoRGBEffect.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 "GrTextureStripAtlas.h" 9 #include "GrTextureStripAtlas.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
11 #include "SkTSearch.h" 11 #include "SkTSearch.h"
12 #include "GrTexture.h" 12 #include "GrTexture.h"
13 13
14 #ifdef SK_DEBUG 14 #ifdef SK_DEBUG
15 #define VALIDATE this->validate() 15 #define VALIDATE this->validate()
16 #else 16 #else
17 #define VALIDATE 17 #define VALIDATE
18 #endif 18 #endif
19 19
20 class GrTextureStripAtlas::Hash : public SkTDynamicHash<GrTextureStripAtlas::Atl asEntry, 20 class GrTextureStripAtlas::Hash : public SkTDynamicHash<GrTextureStripAtlas::Atl asEntry,
21 GrTextureStripAtlas::Des c> {}; 21 GrTextureStripAtlas::Des c> {};
22 22
23 int32_t GrTextureStripAtlas::gCacheCount = 0; 23 int32_t GrTextureStripAtlas::gCacheCount = 0;
24 24
25 GrTextureStripAtlas::Hash* GrTextureStripAtlas::gAtlasCache = NULL; 25 GrTextureStripAtlas::Hash* GrTextureStripAtlas::gAtlasCache = NULL;
26 26
27 GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() { 27 GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() {
28 28
29 if (NULL == gAtlasCache) { 29 if (NULL == gAtlasCache) {
30 gAtlasCache = SkNEW(Hash); 30 gAtlasCache = new Hash;
31 } 31 }
32 32
33 return gAtlasCache; 33 return gAtlasCache;
34 } 34 }
35 35
36 // Remove the specified atlas from the cache 36 // Remove the specified atlas from the cache
37 void GrTextureStripAtlas::CleanUp(const GrContext*, void* info) { 37 void GrTextureStripAtlas::CleanUp(const GrContext*, void* info) {
38 SkASSERT(info); 38 SkASSERT(info);
39 39
40 AtlasEntry* entry = static_cast<AtlasEntry*>(info); 40 AtlasEntry* entry = static_cast<AtlasEntry*>(info);
41 41
42 // remove the cache entry 42 // remove the cache entry
43 GetCache()->remove(entry->fDesc); 43 GetCache()->remove(entry->fDesc);
44 44
45 // remove the actual entry 45 // remove the actual entry
46 SkDELETE(entry); 46 delete entry;
47 47
48 if (0 == GetCache()->count()) { 48 if (0 == GetCache()->count()) {
49 SkDELETE(gAtlasCache); 49 delete gAtlasCache;
50 gAtlasCache = NULL; 50 gAtlasCache = NULL;
51 } 51 }
52 } 52 }
53 53
54 GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::De sc& desc) { 54 GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::De sc& desc) {
55 AtlasEntry* entry = GetCache()->find(desc); 55 AtlasEntry* entry = GetCache()->find(desc);
56 if (NULL == entry) { 56 if (NULL == entry) {
57 entry = SkNEW(AtlasEntry); 57 entry = new AtlasEntry;
58 58
59 entry->fAtlas = SkNEW_ARGS(GrTextureStripAtlas, (desc)); 59 entry->fAtlas = new GrTextureStripAtlas(desc);
60 entry->fDesc = desc; 60 entry->fDesc = desc;
61 61
62 desc.fContext->addCleanUp(CleanUp, entry); 62 desc.fContext->addCleanUp(CleanUp, entry);
63 63
64 GetCache()->add(entry); 64 GetCache()->add(entry);
65 } 65 }
66 66
67 return entry->fAtlas; 67 return entry->fAtlas;
68 } 68 }
69 69
70 GrTextureStripAtlas::GrTextureStripAtlas(GrTextureStripAtlas::Desc desc) 70 GrTextureStripAtlas::GrTextureStripAtlas(GrTextureStripAtlas::Desc desc)
71 : fCacheKey(sk_atomic_inc(&gCacheCount)) 71 : fCacheKey(sk_atomic_inc(&gCacheCount))
72 , fLockedRows(0) 72 , fLockedRows(0)
73 , fDesc(desc) 73 , fDesc(desc)
74 , fNumRows(desc.fHeight / desc.fRowHeight) 74 , fNumRows(desc.fHeight / desc.fRowHeight)
75 , fTexture(NULL) 75 , fTexture(NULL)
76 , fRows(SkNEW_ARRAY(AtlasRow, fNumRows)) 76 , fRows(new AtlasRow[fNumRows])
77 , fLRUFront(NULL) 77 , fLRUFront(NULL)
78 , fLRUBack(NULL) { 78 , fLRUBack(NULL) {
79 SkASSERT(fNumRows * fDesc.fRowHeight == fDesc.fHeight); 79 SkASSERT(fNumRows * fDesc.fRowHeight == fDesc.fHeight);
80 this->initLRU(); 80 this->initLRU();
81 fNormalizedYHeight = SK_Scalar1 / fDesc.fHeight; 81 fNormalizedYHeight = SK_Scalar1 / fDesc.fHeight;
82 VALIDATE; 82 VALIDATE;
83 } 83 }
84 84
85 GrTextureStripAtlas::~GrTextureStripAtlas() { 85 GrTextureStripAtlas::~GrTextureStripAtlas() { delete[] fRows; }
86 SkDELETE_ARRAY(fRows);
87 }
88 86
89 int GrTextureStripAtlas::lockRow(const SkBitmap& data) { 87 int GrTextureStripAtlas::lockRow(const SkBitmap& data) {
90 VALIDATE; 88 VALIDATE;
91 if (0 == fLockedRows) { 89 if (0 == fLockedRows) {
92 this->lockTexture(); 90 this->lockTexture();
93 if (!fTexture) { 91 if (!fTexture) {
94 return -1; 92 return -1;
95 } 93 }
96 } 94 }
97 95
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 340
343 // If we have locked rows, we should have a locked texture, otherwise 341 // If we have locked rows, we should have a locked texture, otherwise
344 // it should be unlocked 342 // it should be unlocked
345 if (fLockedRows == 0) { 343 if (fLockedRows == 0) {
346 SkASSERT(NULL == fTexture); 344 SkASSERT(NULL == fTexture);
347 } else { 345 } else {
348 SkASSERT(fTexture); 346 SkASSERT(fTexture);
349 } 347 }
350 } 348 }
351 #endif 349 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureStripAtlas.h ('k') | src/gpu/effects/GrYUVtoRGBEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698