OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // object. The incoming key may be temporary. So, for cache storage, take | 70 // object. The incoming key may be temporary. So, for cache storage, take |
71 // the address of the newly created FontPlatformData that is copied an owned | 71 // the address of the newly created FontPlatformData that is copied an owned |
72 // by SimpleFontData. | 72 // by SimpleFontData. |
73 m_cache.set(&newValue.first->platformData(), newValue); | 73 m_cache.set(&newValue.first->platformData(), newValue); |
74 if (shouldRetain == DoNotRetain) | 74 if (shouldRetain == DoNotRetain) |
75 m_inactiveFontData.insert(newValue.first); | 75 m_inactiveFontData.insert(newValue.first); |
76 return newValue.first.release(); | 76 return newValue.first.release(); |
77 } | 77 } |
78 | 78 |
79 if (!result.get()->value.second) { | 79 if (!result.get()->value.second) { |
80 ASSERT(m_inactiveFontData.contains(result.get()->value.first)); | 80 DCHECK(m_inactiveFontData.contains(result.get()->value.first)); |
81 m_inactiveFontData.erase(result.get()->value.first); | 81 m_inactiveFontData.erase(result.get()->value.first); |
82 } | 82 } |
83 | 83 |
84 if (shouldRetain == Retain) { | 84 if (shouldRetain == Retain) { |
85 result.get()->value.second++; | 85 result.get()->value.second++; |
86 } else if (!result.get()->value.second) { | 86 } else if (!result.get()->value.second) { |
87 // If shouldRetain is DoNotRetain and count is 0, we want to remove the | 87 // If shouldRetain is DoNotRetain and count is 0, we want to remove the |
88 // fontData from m_inactiveFontData (above) and re-add here to update LRU | 88 // fontData from m_inactiveFontData (above) and re-add here to update LRU |
89 // position. | 89 // position. |
90 m_inactiveFontData.insert(result.get()->value.first); | 90 m_inactiveFontData.insert(result.get()->value.first); |
91 } | 91 } |
92 | 92 |
93 return result.get()->value.first; | 93 return result.get()->value.first; |
94 } | 94 } |
95 | 95 |
96 bool FontDataCache::contains(const FontPlatformData* fontPlatformData) const { | 96 bool FontDataCache::contains(const FontPlatformData* fontPlatformData) const { |
97 return m_cache.contains(fontPlatformData); | 97 return m_cache.contains(fontPlatformData); |
98 } | 98 } |
99 | 99 |
100 void FontDataCache::release(const SimpleFontData* fontData) { | 100 void FontDataCache::release(const SimpleFontData* fontData) { |
101 ASSERT(!fontData->isCustomFont()); | 101 DCHECK(!fontData->isCustomFont()); |
102 | 102 |
103 Cache::iterator it = m_cache.find(&(fontData->platformData())); | 103 Cache::iterator it = m_cache.find(&(fontData->platformData())); |
104 ASSERT(it != m_cache.end()); | 104 DCHECK_NE(it, m_cache.end()); |
105 if (it == m_cache.end()) | 105 if (it == m_cache.end()) |
106 return; | 106 return; |
107 | 107 |
108 ASSERT(it->value.second); | 108 DCHECK(it->value.second); |
109 if (!--it->value.second) | 109 if (!--it->value.second) |
110 m_inactiveFontData.insert(it->value.first); | 110 m_inactiveFontData.insert(it->value.first); |
111 } | 111 } |
112 | 112 |
113 void FontDataCache::markAllVerticalData() { | 113 void FontDataCache::markAllVerticalData() { |
114 Cache::iterator end = m_cache.end(); | 114 Cache::iterator end = m_cache.end(); |
115 for (Cache::iterator fontData = m_cache.begin(); fontData != end; | 115 for (Cache::iterator fontData = m_cache.begin(); fontData != end; |
116 ++fontData) { | 116 ++fontData) { |
117 OpenTypeVerticalData* verticalData = const_cast<OpenTypeVerticalData*>( | 117 OpenTypeVerticalData* verticalData = const_cast<OpenTypeVerticalData*>( |
118 fontData->value.first->verticalData()); | 118 fontData->value.first->verticalData()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool didWork = fontDataToDelete.size(); | 163 bool didWork = fontDataToDelete.size(); |
164 | 164 |
165 fontDataToDelete.clear(); | 165 fontDataToDelete.clear(); |
166 | 166 |
167 isPurging = false; | 167 isPurging = false; |
168 | 168 |
169 return didWork; | 169 return didWork; |
170 } | 170 } |
171 | 171 |
172 } // namespace blink | 172 } // namespace blink |
OLD | NEW |