| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2015 Google Inc. All rights reserved. | 3 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 static const unsigned minimumTableSize = 16; | 130 static const unsigned minimumTableSize = 16; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 friend bool operator==(const SmallStringKey&, const SmallStringKey&); | 133 friend bool operator==(const SmallStringKey&, const SmallStringKey&); |
| 134 | 134 |
| 135 public: | 135 public: |
| 136 ShapeCache(): m_weakFactory(this), m_version(0) { } | 136 ShapeCache(): m_weakFactory(this), m_version(0) { } |
| 137 | 137 |
| 138 ShapeCacheEntry* add(const TextRun& run, ShapeCacheEntry entry) | 138 ShapeCacheEntry* add(const TextRun& run, ShapeCacheEntry entry) |
| 139 { | 139 { |
| 140 if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity()) | 140 if (run.length() > SmallStringKey::capacity()) |
| 141 return 0; | 141 return 0; |
| 142 | 142 |
| 143 return addSlowCase(run, entry); | 143 return addSlowCase(run, entry); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void clearIfVersionChanged(unsigned version) | 146 void clearIfVersionChanged(unsigned version) |
| 147 { | 147 { |
| 148 if (version != m_version) { | 148 if (version != m_version) { |
| 149 clear(); | 149 clear(); |
| 150 m_version = version; | 150 m_version = version; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 WeakPtr<ShapeCache> weakPtr() | 177 WeakPtr<ShapeCache> weakPtr() |
| 178 { | 178 { |
| 179 return m_weakFactory.createWeakPtr(); | 179 return m_weakFactory.createWeakPtr(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) | 183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) |
| 184 { | 184 { |
| 185 int length = run.length(); | 185 unsigned length = run.length(); |
| 186 bool isNewEntry; | 186 bool isNewEntry; |
| 187 ShapeCacheEntry *value; | 187 ShapeCacheEntry *value; |
| 188 if (length == 1) { | 188 if (length == 1) { |
| 189 uint32_t key = run[0]; | 189 uint32_t key = run[0]; |
| 190 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF, | 190 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF, |
| 191 // as such use bit 32 to indicate direction. | 191 // as such use bit 32 to indicate direction. |
| 192 if (run.direction() == RTL) | 192 if (run.direction() == RTL) |
| 193 key |= (1u << 31); | 193 key |= (1u << 31); |
| 194 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry)
; | 194 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry)
; |
| 195 isNewEntry = addResult.isNewEntry; | 195 isNewEntry = addResult.isNewEntry; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 inline bool operator==(const ShapeCache::SmallStringKey& a, const ShapeCache::Sm
allStringKey& b) | 240 inline bool operator==(const ShapeCache::SmallStringKey& a, const ShapeCache::Sm
allStringKey& b) |
| 241 { | 241 { |
| 242 if (a.length() != b.length() || a.direction() != b.direction()) | 242 if (a.length() != b.length() || a.direction() != b.direction()) |
| 243 return false; | 243 return false; |
| 244 return WTF::equal(a.characters(), b.characters(), a.length()); | 244 return WTF::equal(a.characters(), b.characters(), a.length()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace blink | 247 } // namespace blink |
| 248 | 248 |
| 249 #endif // ShapeCache_h | 249 #endif // ShapeCache_h |
| OLD | NEW |