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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/fonts/skia/FontPlatformDataSkia.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/FontPlatformData.cpp
diff --git a/Source/platform/fonts/FontPlatformData.cpp b/Source/platform/fonts/FontPlatformData.cpp
index c96b9c4879e55425915ba16d8794bbb10bdf2412..aae969f95946597f224ccc7f270efa754925c032 100644
--- a/Source/platform/fonts/FontPlatformData.cpp
+++ b/Source/platform/fonts/FontPlatformData.cpp
@@ -21,7 +21,9 @@
#include "config.h"
#include "platform/fonts/FontPlatformData.h"
+#include "SkEndian.h"
#include "SkTypeface.h"
+#include "platform/fonts/FontCache.h"
#include "platform/fonts/harfbuzz/HarfBuzzFace.h"
#include "wtf/HashMap.h"
#include "wtf/text/StringHash.h"
@@ -345,4 +347,54 @@ HarfBuzzFace* FontPlatformData::harfBuzzFace() const
return m_harfBuzzFace.get();
}
+#if !OS(MACOSX)
+unsigned FontPlatformData::hash() const
+{
+ unsigned h = SkTypeface::UniqueID(m_typeface.get());
+ h ^= 0x01010101 * ((static_cast<int>(m_isHashTableDeletedValue) << 3) | (static_cast<int>(m_orientation) << 2) | (static_cast<int>(m_syntheticBold) << 1) | static_cast<int>(m_syntheticItalic));
+
+ // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
+ // rules. Memcpy is generally optimized enough so that performance doesn't
+ // matter here.
+ uint32_t textSizeBytes;
+ memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t));
+ h ^= textSizeBytes;
+
+ return h;
+}
+
+bool FontPlatformData::fontContainsCharacter(UChar32 character)
+{
+ SkPaint paint;
+ setupPaint(&paint);
+ paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
+
+ uint16_t glyph;
+ paint.textToGlyphs(&character, sizeof(character), &glyph);
+ return glyph;
+}
+
+#endif
+
+#if ENABLE(OPENTYPE_VERTICAL)
+PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const
+{
+ return FontCache::fontCache()->getVerticalData(typeface()->uniqueID(), *this);
+}
+
+PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
+{
+ RefPtr<SharedBuffer> buffer;
+
+ SkFontTableTag tag = SkEndianSwap32(table);
+ const size_t tableSize = m_typeface->getTableSize(tag);
+ if (tableSize) {
+ Vector<char> tableBuffer(tableSize);
+ m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]);
+ buffer = SharedBuffer::adoptVector(tableBuffer);
+ }
+ return buffer.release();
+}
+#endif
+
} // namespace blink
« 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