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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp

Issue 2032943002: Avoid one temporary copy on web fonts decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp b/third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp
index 714fc0496bd0077427bdbb4cbcc42412526b51fa..5b80c62a6e485f9da6aee3476525e39a3e06428c 100644
--- a/third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp
+++ b/third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp
@@ -36,7 +36,7 @@
#include "platform/SharedBuffer.h"
#include "platform/fonts/FontCache.h"
#include "platform/fonts/FontPlatformData.h"
-#include "platform/fonts/opentype/OpenTypeSanitizer.h"
+#include "platform/fonts/WebFontDecoder.h"
#include "third_party/skia/include/core/SkStream.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "wtf/PassOwnPtr.h"
@@ -59,31 +59,18 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold,
PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer, String& otsParseMessage)
{
DCHECK(buffer);
-
- OpenTypeSanitizer sanitizer(buffer);
- RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
-
- if (!transcodeBuffer) {
- otsParseMessage = sanitizer.getErrorString();
- return nullptr; // validation failed.
- }
- buffer = transcodeBuffer.get();
-
- SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get());
-#if OS(WIN)
- RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager()->createFromStream(stream));
-#else
- RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream));
-#endif
- if (!typeface)
+ WebFontDecoder decoder;
+ RefPtr<SkTypeface> typeface = decoder.decode(buffer);
+ if (!typeface) {
+ otsParseMessage = decoder.getErrorString();
return nullptr;
-
+ }
return adoptPtr(new FontCustomPlatformData(typeface.release()));
}
bool FontCustomPlatformData::supportsFormat(const String& format)
{
- return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || OpenTypeSanitizer::supportsFormat(format);
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || WebFontDecoder::supportsFormat(format);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698