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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 fLayerHash.rewind(); | 119 fLayerHash.rewind(); |
120 | 120 |
121 // The atlas only lets go of its texture when the atlas is deleted. | 121 // The atlas only lets go of its texture when the atlas is deleted. |
122 fAtlas.free(); | 122 fAtlas.free(); |
123 } | 123 } |
124 | 124 |
125 GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, | 125 GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, |
126 int start, int stop, | 126 int start, int stop, |
127 const SkIRect& bounds, | 127 const SkIRect& bounds, |
128 const SkMatrix& ctm, | 128 const SkMatrix& ctm, |
| 129 const int* key, |
| 130 int keySize, |
129 const SkPaint* paint) { | 131 const SkPaint* paint) { |
130 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); | 132 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); |
131 | 133 |
132 GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, bo
unds, ctm, paint)); | 134 GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, bo
unds, ctm, key, keySize, paint)); |
133 fLayerHash.add(layer); | 135 fLayerHash.add(layer); |
134 return layer; | 136 return layer; |
135 } | 137 } |
136 | 138 |
137 GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID, | 139 GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID, |
138 int start, | 140 int start, |
139 const SkIRect& bounds, | 141 const SkIRect& bounds, |
140 const SkMatrix& ctm) { | 142 const SkMatrix& ctm, |
| 143 const int* key, |
| 144 int keySize) { |
141 SkASSERT(pictureID != SK_InvalidGenID && start > 0); | 145 SkASSERT(pictureID != SK_InvalidGenID && start > 0); |
142 return fLayerHash.find(GrCachedLayer::Key(pictureID, start, bounds, ctm)); | 146 return fLayerHash.find(GrCachedLayer::Key(pictureID, start, bounds, ctm, key
, keySize)); |
143 } | 147 } |
144 | 148 |
145 GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID, | 149 GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID, |
146 int start, int stop, | 150 int start, int stop, |
147 const SkIRect& bounds, | 151 const SkIRect& bounds, |
148 const SkMatrix& ctm, | 152 const SkMatrix& ctm, |
| 153 const int* key, |
| 154 int keySize, |
149 const SkPaint* paint) { | 155 const SkPaint* paint) { |
150 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); | 156 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); |
151 GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start,
bounds, ctm)); | 157 GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start,
bounds, ctm, key, keySize)); |
152 if (NULL == layer) { | 158 if (NULL == layer) { |
153 layer = this->createLayer(pictureID, start, stop, bounds, ctm, paint); | 159 layer = this->createLayer(pictureID, start, stop, bounds, ctm, key, keyS
ize, paint); |
154 } | 160 } |
155 | 161 |
156 return layer; | 162 return layer; |
157 } | 163 } |
158 | 164 |
159 bool GrLayerCache::tryToAtlas(GrCachedLayer* layer, | 165 bool GrLayerCache::tryToAtlas(GrCachedLayer* layer, |
160 const GrSurfaceDesc& desc, | 166 const GrSurfaceDesc& desc, |
161 bool* needsRendering) { | 167 bool* needsRendering) { |
162 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas ? fAtlas->getTexture() : NULL, la
yer);) | 168 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas ? fAtlas->getTexture() : NULL, la
yer);) |
163 | 169 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 continue; | 490 continue; |
485 } | 491 } |
486 | 492 |
487 SkString fileName(dirName); | 493 SkString fileName(dirName); |
488 fileName.appendf("\\%d-%d.png", layer->fKey.pictureID(), layer->fKey.sta
rt()); | 494 fileName.appendf("\\%d-%d.png", layer->fKey.pictureID(), layer->fKey.sta
rt()); |
489 | 495 |
490 layer->texture()->surfacePriv().savePixels(fileName.c_str()); | 496 layer->texture()->surfacePriv().savePixels(fileName.c_str()); |
491 } | 497 } |
492 } | 498 } |
493 #endif | 499 #endif |
OLD | NEW |