| 53 | } |
| 54 | |
| 55 | void AvatarCache::SetImage(const std::string& resource, HImage* him, bool hasAlpha) |
| 56 | { |
| 57 | std::string id = MakeIdentifier(resource); |
| 58 | |
| 59 | // Remove the least recently used bitmap until the maximum amount is loaded. |
| 60 | while (m_profileToBitmap.size() > MAX_BITMAPS_KEEP_LOADED) |
| 61 | { |
| 62 | if (!TrimBitmap()) |
| 63 | break; |
| 64 | } |
| 65 | |
| 66 | AgeBitmaps(); |
| 67 | |
| 68 | auto iter = m_profileToBitmap.find(id); |
| 69 | if (iter != m_profileToBitmap.end()) |
| 70 | { |
| 71 | DeleteImageIfNeeded(iter->second.m_image); |
| 72 | iter->second.m_image = him; |
| 73 | iter->second.m_age = 0; |
| 74 | iter->second.m_bHasAlpha = hasAlpha; |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | m_profileToBitmap[id] = BitmapObject(him, 0, hasAlpha); |
| 79 | } |
| 80 | |
| 81 | ImagePlace AvatarCache::GetPlace(const std::string& resource) |
| 82 | { |
no test coverage detected