Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: Source/platform/fonts/FontPlatformData.cpp

Issue 622883002: Merge FontPlatformDataSkia with FontPlatformData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase w/HEAD Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 * 18 *
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "platform/fonts/FontPlatformData.h" 22 #include "platform/fonts/FontPlatformData.h"
23 23
24 #include "SkEndian.h"
24 #include "SkTypeface.h" 25 #include "SkTypeface.h"
26 #include "platform/fonts/FontCache.h"
25 #include "platform/fonts/harfbuzz/HarfBuzzFace.h" 27 #include "platform/fonts/harfbuzz/HarfBuzzFace.h"
26 #include "wtf/HashMap.h" 28 #include "wtf/HashMap.h"
27 #include "wtf/text/StringHash.h" 29 #include "wtf/text/StringHash.h"
28 #include "wtf/text/WTFString.h" 30 #include "wtf/text/WTFString.h"
29 31
30 #if OS(MACOSX) 32 #if OS(MACOSX)
31 #include "third_party/skia/include/ports/SkTypeface_mac.h" 33 #include "third_party/skia/include/ports/SkTypeface_mac.h"
32 #endif 34 #endif
33 35
34 using namespace std; 36 using namespace std;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 340 }
339 341
340 HarfBuzzFace* FontPlatformData::harfBuzzFace() const 342 HarfBuzzFace* FontPlatformData::harfBuzzFace() const
341 { 343 {
342 if (!m_harfBuzzFace) 344 if (!m_harfBuzzFace)
343 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this ), uniqueID()); 345 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this ), uniqueID());
344 346
345 return m_harfBuzzFace.get(); 347 return m_harfBuzzFace.get();
346 } 348 }
347 349
350 #if !OS(MACOSX)
351 unsigned FontPlatformData::hash() const
352 {
353 unsigned h = SkTypeface::UniqueID(m_typeface.get());
354 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));
355
356 // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
357 // rules. Memcpy is generally optimized enough so that performance doesn't
358 // matter here.
359 uint32_t textSizeBytes;
360 memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t));
361 h ^= textSizeBytes;
362
363 return h;
364 }
365
366 bool FontPlatformData::fontContainsCharacter(UChar32 character)
367 {
368 SkPaint paint;
369 setupPaint(&paint);
370 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
371
372 uint16_t glyph;
373 paint.textToGlyphs(&character, sizeof(character), &glyph);
374 return glyph;
375 }
376
377 #endif
378
379 #if ENABLE(OPENTYPE_VERTICAL)
380 PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const
381 {
382 return FontCache::fontCache()->getVerticalData(typeface()->uniqueID(), *this );
383 }
384
385 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
386 {
387 RefPtr<SharedBuffer> buffer;
388
389 SkFontTableTag tag = SkEndianSwap32(table);
390 const size_t tableSize = m_typeface->getTableSize(tag);
391 if (tableSize) {
392 Vector<char> tableBuffer(tableSize);
393 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]);
394 buffer = SharedBuffer::adoptVector(tableBuffer);
395 }
396 return buffer.release();
397 }
398 #endif
399
348 } // namespace blink 400 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/fonts/skia/FontPlatformDataSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698