OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "GrTextureStripAtlas.h" | 8 #include "GrTextureStripAtlas.h" |
10 #include "SkPixelRef.h" | 9 #include "SkPixelRef.h" |
11 #include "SkTSearch.h" | 10 #include "SkTSearch.h" |
12 #include "GrTexture.h" | 11 #include "GrTexture.h" |
13 | 12 |
14 #ifdef SK_DEBUG | 13 #ifdef SK_DEBUG |
15 #define VALIDATE this->validate() | 14 #define VALIDATE this->validate() |
16 #else | 15 #else |
17 #define VALIDATE | 16 #define VALIDATE |
18 #endif | 17 #endif |
19 | 18 |
20 class GrTextureStripAtlas::Hash : public SkTDynamicHash<GrTextureStripAtlas::Atl
asEntry, | 19 class GrTextureStripAtlas::Hash : public SkTDynamicHash<GrTextureStripAtlas::Atl
asEntry, |
21 GrTextureStripAtlas::Des
c> {}; | 20 GrTextureStripAtlas::Des
c> {}; |
22 | 21 |
23 int32_t GrTextureStripAtlas::gCacheCount = 0; | 22 int32_t GrTextureStripAtlas::gCacheCount = 0; |
24 | 23 |
25 GrTextureStripAtlas::Hash* GrTextureStripAtlas::gAtlasCache = nullptr; | 24 GrTextureStripAtlas::Hash* GrTextureStripAtlas::gAtlasCache = nullptr; |
26 | 25 |
27 GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() { | 26 GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() { |
28 | 27 |
29 if (nullptr == gAtlasCache) { | 28 if (nullptr == gAtlasCache) { |
30 gAtlasCache = new Hash; | 29 gAtlasCache = new Hash; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Front is least-recently-used | 185 // Front is least-recently-used |
187 AtlasRow* row = fLRUFront; | 186 AtlasRow* row = fLRUFront; |
188 return row; | 187 return row; |
189 } | 188 } |
190 | 189 |
191 void GrTextureStripAtlas::lockTexture() { | 190 void GrTextureStripAtlas::lockTexture() { |
192 GrSurfaceDesc texDesc; | 191 GrSurfaceDesc texDesc; |
193 texDesc.fWidth = fDesc.fWidth; | 192 texDesc.fWidth = fDesc.fWidth; |
194 texDesc.fHeight = fDesc.fHeight; | 193 texDesc.fHeight = fDesc.fHeight; |
195 texDesc.fConfig = fDesc.fConfig; | 194 texDesc.fConfig = fDesc.fConfig; |
| 195 texDesc.fIsMipMapped = false; |
196 | 196 |
197 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 197 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
198 GrUniqueKey key; | 198 GrUniqueKey key; |
199 GrUniqueKey::Builder builder(&key, kDomain, 1); | 199 GrUniqueKey::Builder builder(&key, kDomain, 1); |
200 builder[0] = static_cast<uint32_t>(fCacheKey); | 200 builder[0] = static_cast<uint32_t>(fCacheKey); |
201 builder.finish(); | 201 builder.finish(); |
202 | 202 |
203 fTexture = fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(k
ey); | 203 fTexture = fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(k
ey); |
204 if (nullptr == fTexture) { | 204 if (nullptr == fTexture) { |
205 fTexture = fDesc.fContext->textureProvider()->createTexture(texDesc, tru
e, nullptr, 0); | 205 fTexture = fDesc.fContext->textureProvider()->createTexture(texDesc, tru
e, nullptr, 0); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 340 |
341 // 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 |
342 // it should be unlocked | 342 // it should be unlocked |
343 if (fLockedRows == 0) { | 343 if (fLockedRows == 0) { |
344 SkASSERT(nullptr == fTexture); | 344 SkASSERT(nullptr == fTexture); |
345 } else { | 345 } else { |
346 SkASSERT(fTexture); | 346 SkASSERT(fTexture); |
347 } | 347 } |
348 } | 348 } |
349 #endif | 349 #endif |
OLD | NEW |