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

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

Issue 233703003: Rename GrAtlasedLayer to GrCachedLayer (since not all cached layers are atlased) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | src/gpu/SkGpuDevice.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 2014 Google Inc. 2 * Copyright 2014 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 "GrAtlas.h" 8 #include "GrAtlas.h"
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 #include "GrLayerCache.h" 10 #include "GrLayerCache.h"
11 11
12 /** 12 /**
13 * PictureLayerKey just wraps a saveLayer's id in the picture for GrTHashTable. 13 * PictureLayerKey just wraps a saveLayer's id in the picture for GrTHashTable.
14 */ 14 */
15 class GrLayerCache::PictureLayerKey { 15 class GrLayerCache::PictureLayerKey {
16 public: 16 public:
17 PictureLayerKey(uint32_t pictureID, int layerID) 17 PictureLayerKey(uint32_t pictureID, int layerID)
18 : fPictureID(pictureID) 18 : fPictureID(pictureID)
19 , fLayerID(layerID) { 19 , fLayerID(layerID) {
20 } 20 }
21 21
22 uint32_t pictureID() const { return fPictureID; } 22 uint32_t pictureID() const { return fPictureID; }
23 int layerID() const { return fLayerID; } 23 int layerID() const { return fLayerID; }
24 24
25 uint32_t getHash() const { return (fPictureID << 16) | fLayerID; } 25 uint32_t getHash() const { return (fPictureID << 16) | fLayerID; }
26 26
27 static bool LessThan(const GrAtlasedLayer& layer, const PictureLayerKey& key ) { 27 static bool LessThan(const GrCachedLayer& layer, const PictureLayerKey& key) {
28 if (layer.pictureID() == key.pictureID()) { 28 if (layer.pictureID() == key.pictureID()) {
29 return layer.layerID() < key.layerID(); 29 return layer.layerID() < key.layerID();
30 } 30 }
31 31
32 return layer.pictureID() < key.pictureID(); 32 return layer.pictureID() < key.pictureID();
33 } 33 }
34 34
35 static bool Equals(const GrAtlasedLayer& layer, const PictureLayerKey& key) { 35 static bool Equals(const GrCachedLayer& layer, const PictureLayerKey& key) {
36 return layer.pictureID() == key.pictureID() && layer.layerID() == key.la yerID(); 36 return layer.pictureID() == key.pictureID() && layer.layerID() == key.la yerID();
37 } 37 }
38 38
39 private: 39 private:
40 uint32_t fPictureID; 40 uint32_t fPictureID;
41 int fLayerID; 41 int fLayerID;
42 }; 42 };
43 43
44 GrLayerCache::GrLayerCache(GrGpu* gpu) 44 GrLayerCache::GrLayerCache(GrGpu* gpu)
45 : fGpu(SkRef(gpu)) 45 : fGpu(SkRef(gpu))
(...skipping 13 matching lines...) Expand all
59 SkISize textureSize = SkISize::Make(kAtlasTextureWidth, kAtlasTextureHeight) ; 59 SkISize textureSize = SkISize::Make(kAtlasTextureWidth, kAtlasTextureHeight) ;
60 fAtlasMgr.reset(SkNEW_ARGS(GrAtlasMgr, (fGpu, kSkia8888_GrPixelConfig, 60 fAtlasMgr.reset(SkNEW_ARGS(GrAtlasMgr, (fGpu, kSkia8888_GrPixelConfig,
61 textureSize, 1, 1))); 61 textureSize, 1, 1)));
62 } 62 }
63 63
64 void GrLayerCache::freeAll() { 64 void GrLayerCache::freeAll() {
65 fLayerHash.deleteAll(); 65 fLayerHash.deleteAll();
66 fAtlasMgr.free(); 66 fAtlasMgr.free();
67 } 67 }
68 68
69 GrAtlasedLayer* GrLayerCache::createLayer(SkPicture* picture, int layerID) { 69 GrCachedLayer* GrLayerCache::createLayer(SkPicture* picture, int layerID) {
70 GrAtlasedLayer* layer = fLayerPool.alloc(); 70 GrCachedLayer* layer = fLayerPool.alloc();
71 71
72 SkASSERT(picture->uniqueID() != SK_InvalidGenID); 72 SkASSERT(picture->uniqueID() != SK_InvalidGenID);
73 layer->init(picture->uniqueID(), layerID); 73 layer->init(picture->uniqueID(), layerID);
74 fLayerHash.insert(PictureLayerKey(picture->uniqueID(), layerID), layer); 74 fLayerHash.insert(PictureLayerKey(picture->uniqueID(), layerID), layer);
75 return layer; 75 return layer;
76 } 76 }
77 77
78 78
79 const GrAtlasedLayer* GrLayerCache::findLayerOrCreate(SkPicture* picture, int la yerID) { 79 GrCachedLayer* GrLayerCache::findLayerOrCreate(SkPicture* picture, int layerID) {
80 SkASSERT(picture->uniqueID() != SK_InvalidGenID); 80 SkASSERT(picture->uniqueID() != SK_InvalidGenID);
81 GrAtlasedLayer* layer = fLayerHash.find(PictureLayerKey(picture->uniqueID(), layerID)); 81 GrCachedLayer* layer = fLayerHash.find(PictureLayerKey(picture->uniqueID(), layerID));
82 if (NULL == layer) { 82 if (NULL == layer) {
83 layer = this->createLayer(picture, layerID); 83 layer = this->createLayer(picture, layerID);
84 } 84 }
85 return layer; 85 return layer;
86 } 86 }
OLDNEW
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698