| 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 28 matching lines...) Expand all Loading... |
| 39 #if !OS(ANDROID) | 39 #if !OS(ANDROID) |
| 40 const unsigned cMaxInactiveFontData = 250; | 40 const unsigned cMaxInactiveFontData = 250; |
| 41 const unsigned cTargetInactiveFontData = 200; | 41 const unsigned cTargetInactiveFontData = 200; |
| 42 #else | 42 #else |
| 43 const unsigned cMaxInactiveFontData = 225; | 43 const unsigned cMaxInactiveFontData = 225; |
| 44 const unsigned cTargetInactiveFontData = 200; | 44 const unsigned cTargetInactiveFontData = 200; |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 PassRefPtr<SimpleFontData> FontDataCache::get( | 47 PassRefPtr<SimpleFontData> FontDataCache::get( |
| 48 const FontPlatformData* platformData, | 48 const FontPlatformData* platformData, |
| 49 ShouldRetain shouldRetain, | 49 ShouldRetain shouldRetain) { |
| 50 bool subpixelAscentDescent) { | |
| 51 if (!platformData) | 50 if (!platformData) |
| 52 return nullptr; | 51 return nullptr; |
| 53 | 52 |
| 54 // TODO: crbug.com/446376 - This should not happen, but we currently | 53 // TODO: crbug.com/446376 - This should not happen, but we currently |
| 55 // do not have a reproduction for the crash that an empty typeface() | 54 // do not have a reproduction for the crash that an empty typeface() |
| 56 // causes downstream from here. | 55 // causes downstream from here. |
| 57 if (!platformData->typeface()) { | 56 if (!platformData->typeface()) { |
| 58 DLOG(ERROR) | 57 DLOG(ERROR) |
| 59 << "Empty typeface() in FontPlatformData when accessing FontDataCache."; | 58 << "Empty typeface() in FontPlatformData when accessing FontDataCache."; |
| 60 return nullptr; | 59 return nullptr; |
| 61 } | 60 } |
| 62 | 61 |
| 63 Cache::iterator result = m_cache.find(platformData); | 62 Cache::iterator result = m_cache.find(platformData); |
| 64 if (result == m_cache.end()) { | 63 if (result == m_cache.end()) { |
| 65 std::pair<RefPtr<SimpleFontData>, unsigned> newValue( | 64 std::pair<RefPtr<SimpleFontData>, unsigned> newValue( |
| 66 SimpleFontData::create(*platformData, nullptr, false, | 65 SimpleFontData::create(*platformData, nullptr), |
| 67 subpixelAscentDescent), | |
| 68 shouldRetain == Retain ? 1 : 0); | 66 shouldRetain == Retain ? 1 : 0); |
| 69 // The new SimpleFontData takes a copy of the incoming FontPlatformData | 67 // The new SimpleFontData takes a copy of the incoming FontPlatformData |
| 70 // object. The incoming key may be temporary. So, for cache storage, take | 68 // 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 | 69 // the address of the newly created FontPlatformData that is copied an owned |
| 72 // by SimpleFontData. | 70 // by SimpleFontData. |
| 73 m_cache.set(&newValue.first->platformData(), newValue); | 71 m_cache.set(&newValue.first->platformData(), newValue); |
| 74 if (shouldRetain == DoNotRetain) | 72 if (shouldRetain == DoNotRetain) |
| 75 m_inactiveFontData.insert(newValue.first); | 73 m_inactiveFontData.insert(newValue.first); |
| 76 return newValue.first.release(); | 74 return newValue.first.release(); |
| 77 } | 75 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 bool didWork = fontDataToDelete.size(); | 161 bool didWork = fontDataToDelete.size(); |
| 164 | 162 |
| 165 fontDataToDelete.clear(); | 163 fontDataToDelete.clear(); |
| 166 | 164 |
| 167 isPurging = false; | 165 isPurging = false; |
| 168 | 166 |
| 169 return didWork; | 167 return didWork; |
| 170 } | 168 } |
| 171 | 169 |
| 172 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |