| 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 cache_.Set(&new_value.first->PlatformData(), new_value); | 73 cache_.Set(&new_value.first->PlatformData(), new_value); |
| 74 if (should_retain == kDoNotRetain) | 74 if (should_retain == kDoNotRetain) |
| 75 inactive_font_data_.insert(new_value.first); | 75 inactive_font_data_.insert(new_value.first); |
| 76 return new_value.first.Release(); | 76 return new_value.first.Release(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 if (!result.Get()->value.second) { | 79 if (!result.Get()->value.second) { |
| 80 ASSERT(inactive_font_data_.Contains(result.Get()->value.first)); | 80 DCHECK(inactive_font_data_.Contains(result.Get()->value.first)); |
| 81 inactive_font_data_.erase(result.Get()->value.first); | 81 inactive_font_data_.erase(result.Get()->value.first); |
| 82 } | 82 } |
| 83 | 83 |
| 84 if (should_retain == kRetain) { | 84 if (should_retain == kRetain) { |
| 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 inactive_font_data_.insert(result.Get()->value.first); | 90 inactive_font_data_.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* font_platform_data) const { | 96 bool FontDataCache::Contains(const FontPlatformData* font_platform_data) const { |
| 97 return cache_.Contains(font_platform_data); | 97 return cache_.Contains(font_platform_data); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void FontDataCache::Release(const SimpleFontData* font_data) { | 100 void FontDataCache::Release(const SimpleFontData* font_data) { |
| 101 ASSERT(!font_data->IsCustomFont()); | 101 DCHECK(!font_data->IsCustomFont()); |
| 102 | 102 |
| 103 Cache::iterator it = cache_.Find(&(font_data->PlatformData())); | 103 Cache::iterator it = cache_.Find(&(font_data->PlatformData())); |
| 104 ASSERT(it != cache_.end()); | 104 DCHECK_NE(it, cache_.end()); |
| 105 if (it == cache_.end()) | 105 if (it == 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 inactive_font_data_.insert(it->value.first); | 110 inactive_font_data_.insert(it->value.first); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void FontDataCache::MarkAllVerticalData() { | 113 void FontDataCache::MarkAllVerticalData() { |
| 114 Cache::iterator end = cache_.end(); | 114 Cache::iterator end = cache_.end(); |
| 115 for (Cache::iterator font_data = cache_.begin(); font_data != end; | 115 for (Cache::iterator font_data = cache_.begin(); font_data != end; |
| 116 ++font_data) { | 116 ++font_data) { |
| 117 OpenTypeVerticalData* vertical_data = const_cast<OpenTypeVerticalData*>( | 117 OpenTypeVerticalData* vertical_data = const_cast<OpenTypeVerticalData*>( |
| 118 font_data->value.first->VerticalData()); | 118 font_data->value.first->VerticalData()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 bool did_work = font_data_to_delete.size(); | 164 bool did_work = font_data_to_delete.size(); |
| 165 | 165 |
| 166 font_data_to_delete.Clear(); | 166 font_data_to_delete.Clear(); |
| 167 | 167 |
| 168 is_purging = false; | 168 is_purging = false; |
| 169 | 169 |
| 170 return did_work; | 170 return did_work; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |