| OLD | NEW |
| 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" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 VALIDATE; | 183 VALIDATE; |
| 184 } | 184 } |
| 185 | 185 |
| 186 GrTextureStripAtlas::AtlasRow* GrTextureStripAtlas::getLRU() { | 186 GrTextureStripAtlas::AtlasRow* GrTextureStripAtlas::getLRU() { |
| 187 // Front is least-recently-used | 187 // Front is least-recently-used |
| 188 AtlasRow* row = fLRUFront; | 188 AtlasRow* row = fLRUFront; |
| 189 return row; | 189 return row; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void GrTextureStripAtlas::lockTexture() { | 192 void GrTextureStripAtlas::lockTexture() { |
| 193 GrTextureParams params; | |
| 194 GrSurfaceDesc texDesc; | 193 GrSurfaceDesc texDesc; |
| 195 texDesc.fWidth = fDesc.fWidth; | 194 texDesc.fWidth = fDesc.fWidth; |
| 196 texDesc.fHeight = fDesc.fHeight; | 195 texDesc.fHeight = fDesc.fHeight; |
| 197 texDesc.fConfig = fDesc.fConfig; | 196 texDesc.fConfig = fDesc.fConfig; |
| 198 | 197 |
| 199 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); | 198 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); |
| 200 GrContentKey key; | 199 GrContentKey key; |
| 201 GrContentKey::Builder builder(&key, kDomain, 1); | 200 GrContentKey::Builder builder(&key, kDomain, 1); |
| 202 builder[0] = static_cast<uint32_t>(fCacheKey); | 201 builder[0] = static_cast<uint32_t>(fCacheKey); |
| 203 builder.finish(); | 202 builder.finish(); |
| 204 | 203 |
| 205 fTexture = fDesc.fContext->findAndRefTexture(texDesc, key, ¶ms); | 204 fTexture = fDesc.fContext->findAndRefCachedTexture(key); |
| 206 if (NULL == fTexture) { | 205 if (NULL == fTexture) { |
| 207 fTexture = fDesc.fContext->createTexture(¶ms, texDesc, key, NULL, 0)
; | 206 fTexture = fDesc.fContext->createTexture(texDesc, NULL, 0); |
| 207 SkAssertResult(fDesc.fContext->addResourceToCache(key, fTexture)); |
| 208 // This is a new texture, so all of our cache info is now invalid | 208 // This is a new texture, so all of our cache info is now invalid |
| 209 this->initLRU(); | 209 this->initLRU(); |
| 210 fKeyTable.rewind(); | 210 fKeyTable.rewind(); |
| 211 } | 211 } |
| 212 SkASSERT(fTexture); | 212 SkASSERT(fTexture); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void GrTextureStripAtlas::unlockTexture() { | 215 void GrTextureStripAtlas::unlockTexture() { |
| 216 SkASSERT(fTexture && 0 == fLockedRows); | 216 SkASSERT(fTexture && 0 == fLockedRows); |
| 217 fTexture->unref(); | 217 fTexture->unref(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 // If we have locked rows, we should have a locked texture, otherwise | 339 // If we have locked rows, we should have a locked texture, otherwise |
| 340 // it should be unlocked | 340 // it should be unlocked |
| 341 if (fLockedRows == 0) { | 341 if (fLockedRows == 0) { |
| 342 SkASSERT(NULL == fTexture); | 342 SkASSERT(NULL == fTexture); |
| 343 } else { | 343 } else { |
| 344 SkASSERT(fTexture); | 344 SkASSERT(fTexture); |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 #endif | 347 #endif |
| OLD | NEW |