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" | 8 #include "SkBitmapCache.h" |
9 #include "SkResourceCache.h" | 9 #include "SkResourceCache.h" |
10 #include "SkYUVPlanesCache.h" | 10 #include "SkYUVPlanesCache.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 ~YUVPlanesRec() { | 42 ~YUVPlanesRec() { |
43 fValue.fData->detachFromCacheAndUnref(); | 43 fValue.fData->detachFromCacheAndUnref(); |
44 } | 44 } |
45 | 45 |
46 YUVPlanesKey fKey; | 46 YUVPlanesKey fKey; |
47 YUVValue fValue; | 47 YUVValue fValue; |
48 | 48 |
49 const Key& getKey() const override { return fKey; } | 49 const Key& getKey() const override { return fKey; } |
50 size_t bytesUsed() const override { return sizeof(*this) + fValue.fData->siz
e(); } | 50 size_t bytesUsed() const override { return sizeof(*this) + fValue.fData->siz
e(); } |
| 51 const char* getCategory() const override { return "yuv-planes"; } |
| 52 SkDiscardableMemory* diagnostic_only_getDiscardable() const override { |
| 53 return fValue.fData->diagnostic_only_getDiscardable(); |
| 54 } |
51 | 55 |
52 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData)
{ | 56 static bool Visitor(const SkResourceCache::Rec& baseRec, void* contextData)
{ |
53 const YUVPlanesRec& rec = static_cast<const YUVPlanesRec&>(baseRec); | 57 const YUVPlanesRec& rec = static_cast<const YUVPlanesRec&>(baseRec); |
54 YUVValue* result = static_cast<YUVValue*>(contextData); | 58 YUVValue* result = static_cast<YUVValue*>(contextData); |
55 | 59 |
56 SkCachedData* tmpData = rec.fValue.fData; | 60 SkCachedData* tmpData = rec.fValue.fData; |
57 tmpData->ref(); | 61 tmpData->ref(); |
58 if (NULL == tmpData->data()) { | 62 if (NULL == tmpData->data()) { |
59 tmpData->unref(); | 63 tmpData->unref(); |
60 return false; | 64 return false; |
(...skipping 15 matching lines...) Expand all Loading... |
76 | 80 |
77 *info = result.fInfo; | 81 *info = result.fInfo; |
78 return result.fData; | 82 return result.fData; |
79 } | 83 } |
80 | 84 |
81 void SkYUVPlanesCache::Add(uint32_t genID, SkCachedData* data, Info* info, | 85 void SkYUVPlanesCache::Add(uint32_t genID, SkCachedData* data, Info* info, |
82 SkResourceCache* localCache) { | 86 SkResourceCache* localCache) { |
83 YUVPlanesKey key(genID); | 87 YUVPlanesKey key(genID); |
84 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(YUVPlanesRec, (key, data
, info))); | 88 return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(YUVPlanesRec, (key, data
, info))); |
85 } | 89 } |
OLD | NEW |