OLD | NEW |
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" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 fAtlas.free(); | 112 fAtlas.free(); |
113 // GrLayerCache always assumes an atlas exists so recreate it. The atlas | 113 // GrLayerCache always assumes an atlas exists so recreate it. The atlas |
114 // lazily allocates a replacement texture so reallocating a new | 114 // lazily allocates a replacement texture so reallocating a new |
115 // atlas here won't disrupt a GrContext::abandonContext or freeGpuResources. | 115 // atlas here won't disrupt a GrContext::abandonContext or freeGpuResources. |
116 // TODO: Make GrLayerCache lazily allocate the atlas manager? | 116 // TODO: Make GrLayerCache lazily allocate the atlas manager? |
117 this->initAtlas(); | 117 this->initAtlas(); |
118 } | 118 } |
119 | 119 |
120 GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, | 120 GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, |
121 int start, int stop, | 121 int start, int stop, |
| 122 const SkIPoint& offset, |
122 const SkMatrix& ctm) { | 123 const SkMatrix& ctm) { |
123 SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0); | 124 SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0); |
124 | 125 |
125 GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, ct
m)); | 126 GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, of
fset, ctm)); |
126 fLayerHash.add(layer); | 127 fLayerHash.add(layer); |
127 return layer; | 128 return layer; |
128 } | 129 } |
129 | 130 |
130 GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID, | 131 GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID, |
131 int start, int stop, | 132 int start, int stop, |
| 133 const SkIPoint& offset, |
132 const SkMatrix& ctm) { | 134 const SkMatrix& ctm) { |
133 SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0); | 135 SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0); |
134 return fLayerHash.find(GrCachedLayer::Key(pictureID, start, stop, ctm)); | 136 return fLayerHash.find(GrCachedLayer::Key(pictureID, start, stop, offset, ct
m)); |
135 } | 137 } |
136 | 138 |
137 GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID, | 139 GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID, |
138 int start, int stop, | 140 int start, int stop, |
| 141 const SkIPoint& offset, |
139 const SkMatrix& ctm) { | 142 const SkMatrix& ctm) { |
140 SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0); | 143 SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0); |
141 GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start,
stop, ctm)); | 144 GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start,
stop, offset, ctm)); |
142 if (NULL == layer) { | 145 if (NULL == layer) { |
143 layer = this->createLayer(pictureID, start, stop, ctm); | 146 layer = this->createLayer(pictureID, start, stop, offset, ctm); |
144 } | 147 } |
145 | 148 |
146 return layer; | 149 return layer; |
147 } | 150 } |
148 | 151 |
149 bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do
ntAtlas) { | 152 bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do
ntAtlas) { |
150 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);) | 153 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);) |
151 | 154 |
152 if (layer->locked()) { | 155 if (layer->locked()) { |
153 // This layer is already locked | 156 // This layer is already locked |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 417 |
415 void GrLayerCache::processDeletedPictures() { | 418 void GrLayerCache::processDeletedPictures() { |
416 SkTDArray<GrPictureDeletedMessage> deletedPictures; | 419 SkTDArray<GrPictureDeletedMessage> deletedPictures; |
417 fPictDeletionInbox.poll(&deletedPictures); | 420 fPictDeletionInbox.poll(&deletedPictures); |
418 | 421 |
419 for (int i = 0; i < deletedPictures.count(); i++) { | 422 for (int i = 0; i < deletedPictures.count(); i++) { |
420 this->purge(deletedPictures[i].pictureID); | 423 this->purge(deletedPictures[i].pictureID); |
421 } | 424 } |
422 } | 425 } |
423 | 426 |
OLD | NEW |