| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Brent Fulgham | 2 * Copyright (C) 2011 Brent Fulgham |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } | 322 } |
| 323 | 323 |
| 324 HarfBuzzFace* FontPlatformData::harfBuzzFace() const | 324 HarfBuzzFace* FontPlatformData::harfBuzzFace() const |
| 325 { | 325 { |
| 326 if (!m_harfBuzzFace) | 326 if (!m_harfBuzzFace) |
| 327 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this
), uniqueID()); | 327 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this
), uniqueID()); |
| 328 | 328 |
| 329 return m_harfBuzzFace.get(); | 329 return m_harfBuzzFace.get(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 #if !OS(MACOSX) | |
| 333 unsigned FontPlatformData::hash() const | 332 unsigned FontPlatformData::hash() const |
| 334 { | 333 { |
| 335 unsigned h = SkTypeface::UniqueID(m_typeface.get()); | 334 unsigned h = SkTypeface::UniqueID(typeface()); |
| 336 h ^= 0x01010101 * ((static_cast<int>(m_isHashTableDeletedValue) << 3) | (sta
tic_cast<int>(m_orientation) << 2) | (static_cast<int>(m_syntheticBold) << 1) |
static_cast<int>(m_syntheticItalic)); | 335 h ^= 0x01010101 * ((static_cast<int>(m_isHashTableDeletedValue) << 3) | (sta
tic_cast<int>(m_orientation) << 2) | (static_cast<int>(m_syntheticBold) << 1) |
static_cast<int>(m_syntheticItalic)); |
| 337 | 336 |
| 338 // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing | 337 // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing |
| 339 // rules. Memcpy is generally optimized enough so that performance doesn't | 338 // rules. Memcpy is generally optimized enough so that performance doesn't |
| 340 // matter here. | 339 // matter here. |
| 341 uint32_t textSizeBytes; | 340 uint32_t textSizeBytes; |
| 342 memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t)); | 341 memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t)); |
| 343 h ^= textSizeBytes; | 342 h ^= textSizeBytes; |
| 344 | 343 |
| 345 return h; | 344 return h; |
| 346 } | 345 } |
| 347 | 346 |
| 347 #if !OS(MACOSX) |
| 348 bool FontPlatformData::fontContainsCharacter(UChar32 character) | 348 bool FontPlatformData::fontContainsCharacter(UChar32 character) |
| 349 { | 349 { |
| 350 SkPaint paint; | 350 SkPaint paint; |
| 351 setupPaint(&paint); | 351 setupPaint(&paint); |
| 352 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); | 352 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); |
| 353 | 353 |
| 354 uint16_t glyph; | 354 uint16_t glyph; |
| 355 paint.textToGlyphs(&character, sizeof(character), &glyph); | 355 paint.textToGlyphs(&character, sizeof(character), &glyph); |
| 356 return glyph; | 356 return glyph; |
| 357 } | 357 } |
| 358 | 358 |
| 359 #endif | 359 #endif |
| 360 | 360 |
| 361 #if ENABLE(OPENTYPE_VERTICAL) | |
| 362 PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const | 361 PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const |
| 363 { | 362 { |
| 364 return FontCache::fontCache()->getVerticalData(typeface()->uniqueID(), *this
); | 363 return FontCache::fontCache()->getVerticalData(typeface()->uniqueID(), *this
); |
| 365 } | 364 } |
| 366 | 365 |
| 367 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const | 366 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const |
| 368 { | 367 { |
| 369 RefPtr<SharedBuffer> buffer; | 368 RefPtr<SharedBuffer> buffer; |
| 370 | 369 |
| 371 SkFontTableTag tag = SkEndianSwap32(table); | 370 SkFontTableTag tag = SkEndianSwap32(table); |
| 372 const size_t tableSize = m_typeface->getTableSize(tag); | 371 const size_t tableSize = m_typeface->getTableSize(tag); |
| 373 if (tableSize) { | 372 if (tableSize) { |
| 374 Vector<char> tableBuffer(tableSize); | 373 Vector<char> tableBuffer(tableSize); |
| 375 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]); | 374 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]); |
| 376 buffer = SharedBuffer::adoptVector(tableBuffer); | 375 buffer = SharedBuffer::adoptVector(tableBuffer); |
| 377 } | 376 } |
| 378 return buffer.release(); | 377 return buffer.release(); |
| 379 } | 378 } |
| 380 #endif | |
| 381 | 379 |
| 382 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |