| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmapCache.h" |
| 9 #include "SkResourceCache.h" |
| 8 #include "SkYUVPlanesCache.h" | 10 #include "SkYUVPlanesCache.h" |
| 9 #include "SkResourceCache.h" | |
| 10 | 11 |
| 11 #define CHECK_LOCAL(localCache, localName, globalName, ...) \ | 12 #define CHECK_LOCAL(localCache, localName, globalName, ...) \ |
| 12 ((localCache) ? localCache->localName(__VA_ARGS__) : SkResourceCache::global
Name(__VA_ARGS__)) | 13 ((localCache) ? localCache->localName(__VA_ARGS__) : SkResourceCache::global
Name(__VA_ARGS__)) |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 static unsigned gYUVPlanesKeyNamespaceLabel; | 16 static unsigned gYUVPlanesKeyNamespaceLabel; |
| 16 | 17 |
| 17 struct YUVValue { | 18 struct YUVValue { |
| 18 SkYUVPlanesCache::Info fInfo; | 19 SkYUVPlanesCache::Info fInfo; |
| 19 SkCachedData* fData; | 20 SkCachedData* fData; |
| 20 }; | 21 }; |
| 21 | 22 |
| 22 struct YUVPlanesKey : public SkResourceCache::Key { | 23 struct YUVPlanesKey : public SkResourceCache::Key { |
| 23 YUVPlanesKey(uint32_t genID) | 24 YUVPlanesKey(uint32_t genID) |
| 24 : fGenID(genID) | 25 : fGenID(genID) |
| 25 { | 26 { |
| 26 this->init(&gYUVPlanesKeyNamespaceLabel, sizeof(genID)); | 27 this->init(&gYUVPlanesKeyNamespaceLabel, SkMakeResourceCacheSharedIDForB
itmap(genID), |
| 28 sizeof(genID)); |
| 27 } | 29 } |
| 28 | 30 |
| 29 uint32_t fGenID; | 31 uint32_t fGenID; |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 struct YUVPlanesRec : public SkResourceCache::Rec { | 34 struct YUVPlanesRec : public SkResourceCache::Rec { |
| 33 YUVPlanesRec(YUVPlanesKey key, SkCachedData* data, SkYUVPlanesCache::Info* i
nfo) | 35 YUVPlanesRec(YUVPlanesKey key, SkCachedData* data, SkYUVPlanesCache::Info* i
nfo) |
| 34 : fKey(key) | 36 : fKey(key) |
| 35 { | 37 { |
| 36 fValue.fData = data; | 38 fValue.fData = data; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 76 |
| 75 *info = result.fInfo; | 77 *info = result.fInfo; |
| 76 return result.fData; | 78 return result.fData; |
| 77 } | 79 } |
| 78 | 80 |
| 79 void SkYUVPlanesCache::Add(uint32_t genID, SkCachedData* data, Info* info, | 81 void SkYUVPlanesCache::Add(uint32_t genID, SkCachedData* data, Info* info, |
| 80 SkResourceCache* localCache) { | 82 SkResourceCache* localCache) { |
| 81 YUVPlanesKey key(genID); | 83 YUVPlanesKey key(genID); |
| 82 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(YUVPlanesRec, (key, data
, info))); | 84 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(YUVPlanesRec, (key, data
, info))); |
| 83 } | 85 } |
| OLD | NEW |