From a126207c6eaa06785e6ac49eb36d90eee225abff Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 23 May 2016 13:48:18 -0700 Subject: [PATCH] Update Skia (#2704) --- DEPS | 2 +- flow/raster_cache.cc | 2 +- sky/engine/platform/fonts/FontCache.h | 3 ++- .../platform/fonts/FontCustomPlatformData.h | 5 +++-- .../platform/fonts/FontPlatformData.cpp | 2 +- sky/engine/platform/fonts/FontPlatformData.h | 4 ++-- .../fonts/android/FontCacheAndroid.cpp | 2 +- .../fonts/linux/FontPlatformDataLinux.cpp | 2 +- .../platform/fonts/skia/FontCacheSkia.cpp | 21 ++++++++----------- .../fonts/skia/FontCustomPlatformDataSkia.cpp | 8 +++---- sky/shell/ui/flutter_font_selector.cc | 14 ++++++------- sky/shell/ui/flutter_font_selector.h | 5 +++-- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/DEPS b/DEPS index 05d722aa4f6..b1a88c42da2 100644 --- a/DEPS +++ b/DEPS @@ -21,7 +21,7 @@ vars = { 'chromium_git': 'https://chromium.googlesource.com', 'mojo_sdk_revision': '55352570f8c52ca1282dcfa26a4a32adc08495d6', 'base_revision': '672b04e54b937ec899429a6bd5409c5a6300d151', - 'skia_revision': '3ccf2e75ed92adb3c2c289e0cb95901d162df394', + 'skia_revision': '8cc209111876b7c78b5ec577c9221d8ed5e21024', # Note: When updating the Dart revision, ensure that all entries that are # dependencies of dart are also updated diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index ea86d6d14cd..59dc8c4239f 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -22,7 +22,7 @@ static const int kRasterThreshold = 3; static bool isWorthRasterizing(SkPicture* picture) { // TODO(abarth): We should find a better heuristic here that lets us avoid // wasting memory on trivial layers that are easy to re-rasterize every frame. - return picture->approximateOpCount() > 10 || picture->hasText(); + return picture->approximateOpCount() > 10; } #endif diff --git a/sky/engine/platform/fonts/FontCache.h b/sky/engine/platform/fonts/FontCache.h index 385dd43f1e5..9ec38630ecc 100644 --- a/sky/engine/platform/fonts/FontCache.h +++ b/sky/engine/platform/fonts/FontCache.h @@ -40,6 +40,7 @@ #include "sky/engine/wtf/text/CString.h" #include "sky/engine/wtf/text/WTFString.h" #include "sky/engine/wtf/unicode/Unicode.h" +#include "third_party/skia/include/core/SkRefCnt.h" #if OS(ANDROID) #include @@ -128,7 +129,7 @@ private: FontPlatformData* createFontPlatformData(const FontDescription&, const FontFaceCreationParams&, float fontSize); // Implemented on skia platforms. - PassRefPtr createTypeface(const FontDescription&, const FontFaceCreationParams&, CString& name); + sk_sp createTypeface(const FontDescription&, const FontFaceCreationParams&, CString& name); PassRefPtr fontDataFromFontPlatformData(const FontPlatformData*, ShouldRetain = Retain); PassRefPtr fallbackOnStandardFontStyle(const FontDescription&, UChar32); diff --git a/sky/engine/platform/fonts/FontCustomPlatformData.h b/sky/engine/platform/fonts/FontCustomPlatformData.h index 4cdfb91ebab..4495df01dcb 100644 --- a/sky/engine/platform/fonts/FontCustomPlatformData.h +++ b/sky/engine/platform/fonts/FontCustomPlatformData.h @@ -39,6 +39,7 @@ #include "sky/engine/wtf/Noncopyable.h" #include "sky/engine/wtf/RefPtr.h" #include "sky/engine/wtf/text/WTFString.h" +#include "third_party/skia/include/core/SkRefCnt.h" class SkTypeface; @@ -58,8 +59,8 @@ public: static bool supportsFormat(const String&); private: - explicit FontCustomPlatformData(PassRefPtr); - RefPtr m_typeface; + explicit FontCustomPlatformData(sk_sp); + sk_sp m_typeface; }; } // namespace blink diff --git a/sky/engine/platform/fonts/FontPlatformData.cpp b/sky/engine/platform/fonts/FontPlatformData.cpp index a5953f6d002..799631d0ff4 100644 --- a/sky/engine/platform/fonts/FontPlatformData.cpp +++ b/sky/engine/platform/fonts/FontPlatformData.cpp @@ -76,7 +76,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src) { } -FontPlatformData::FontPlatformData(PassRefPtr tf, const char* family, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, bool subpixelTextPosition) +FontPlatformData::FontPlatformData(sk_sp tf, const char* family, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, bool subpixelTextPosition) : m_typeface(tf) , m_family(family) , m_textSize(textSize) diff --git a/sky/engine/platform/fonts/FontPlatformData.h b/sky/engine/platform/fonts/FontPlatformData.h index bb3561de2dd..b9598670249 100644 --- a/sky/engine/platform/fonts/FontPlatformData.h +++ b/sky/engine/platform/fonts/FontPlatformData.h @@ -62,7 +62,7 @@ public: FontPlatformData(); FontPlatformData(float textSize, bool syntheticBold, bool syntheticItalic); FontPlatformData(const FontPlatformData&); - FontPlatformData(PassRefPtr, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subpixelTextPosition = defaultUseSubpixelPositioning()); + FontPlatformData(sk_sp, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subpixelTextPosition = defaultUseSubpixelPositioning()); FontPlatformData(const FontPlatformData& src, float textSize); ~FontPlatformData(); @@ -107,7 +107,7 @@ private: bool static defaultUseSubpixelPositioning(); void querySystemForRenderStyle(bool useSkiaSubpixelPositioning); - RefPtr m_typeface; + sk_sp m_typeface; CString m_family; float m_textSize; bool m_syntheticBold; diff --git a/sky/engine/platform/fonts/android/FontCacheAndroid.cpp b/sky/engine/platform/fonts/android/FontCacheAndroid.cpp index 67a44e2e7d7..e21d4b4f015 100644 --- a/sky/engine/platform/fonts/android/FontCacheAndroid.cpp +++ b/sky/engine/platform/fonts/android/FontCacheAndroid.cpp @@ -51,7 +51,7 @@ static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription& fontLocale = fontDescription.locale().ascii(); bcp47Locales[localeCount++] = fontLocale.data(); } - RefPtr typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFontStyle(), bcp47Locales, localeCount, c)); + sk_sp typeface(fm->matchFamilyStyleCharacter(0, SkFontStyle(), bcp47Locales, localeCount, c)); if (!typeface) return emptyAtom; diff --git a/sky/engine/platform/fonts/linux/FontPlatformDataLinux.cpp b/sky/engine/platform/fonts/linux/FontPlatformDataLinux.cpp index 1e4d7dec003..8f93da8a314 100644 --- a/sky/engine/platform/fonts/linux/FontPlatformDataLinux.cpp +++ b/sky/engine/platform/fonts/linux/FontPlatformDataLinux.cpp @@ -92,7 +92,7 @@ void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) const float ts = m_textSize >= 0 ? m_textSize : 12; paint->setTextSize(SkFloatToScalar(ts)); - paint->setTypeface(m_typeface.get()); + paint->setTypeface(m_typeface); paint->setFakeBoldText(m_syntheticBold); paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0); } diff --git a/sky/engine/platform/fonts/skia/FontCacheSkia.cpp b/sky/engine/platform/fonts/skia/FontCacheSkia.cpp index 47b7ed3dd38..7380c4ba205 100644 --- a/sky/engine/platform/fonts/skia/FontCacheSkia.cpp +++ b/sky/engine/platform/fonts/skia/FontCacheSkia.cpp @@ -213,22 +213,19 @@ PassRefPtr FontCache::getLastResortFallbackFont(const FontDescri return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); } -PassRefPtr FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name) +sk_sp FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name) { #if !OS(WIN) && !OS(ANDROID) && !OS(IOS) && !OS(MACOSX) if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) { // TODO(dro): crbug.com/381620 Use creationParams.ttcIndex() after // https://code.google.com/p/skia/issues/detail?id=1186 gets fixed. - SkTypeface* typeface = nullptr; + sk_sp typeface; if (Platform::current()->sandboxSupport()) - typeface = SkTypeface::CreateFromStream(streamForFontconfigInterfaceId(creationParams.fontconfigInterfaceId())); + typeface = SkTypeface::MakeFromStream(streamForFontconfigInterfaceId(creationParams.fontconfigInterfaceId())); else - typeface = SkTypeface::CreateFromFile(creationParams.filename().data()); + typeface = SkTypeface::MakeFromFile(creationParams.filename().data()); - if (typeface) - return adoptRef(typeface); - else - return nullptr; + return typeface; } #endif @@ -244,9 +241,9 @@ PassRefPtr FontCache::createTypeface(const FontDescription& fontDesc SkFontStyle style = toSkiaFontStyle(fontDescription); RefPtr fm = adoptRef(SkFontMgr::RefDefault()); - RefPtr typeface = adoptRef(fm->matchFamilyStyle(name.data(), style)); + sk_sp typeface(fm->matchFamilyStyle(name.data(), style)); if (typeface) - return typeface.release(); + return typeface; int legacyStyle = SkTypeface::kNormal; if (fontDescription.weight() >= FontWeight600) @@ -257,14 +254,14 @@ PassRefPtr FontCache::createTypeface(const FontDescription& fontDesc // FIXME: Use fm, SkFontStyle and matchFamilyStyle instead of this legacy // API. To make this work, we need to understand the extra fallback behavior // in CreateFromName. - return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast(legacyStyle))); + return SkTypeface::MakeFromName(name.data(), static_cast(legacyStyle)); } #if !OS(WIN) FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, float fontSize) { CString name; - RefPtr tf(createTypeface(fontDescription, creationParams, name)); + sk_sp tf = createTypeface(fontDescription, creationParams, name); if (!tf) return 0; diff --git a/sky/engine/platform/fonts/skia/FontCustomPlatformDataSkia.cpp b/sky/engine/platform/fonts/skia/FontCustomPlatformDataSkia.cpp index 7bec75c86bc..92240be6f12 100644 --- a/sky/engine/platform/fonts/skia/FontCustomPlatformDataSkia.cpp +++ b/sky/engine/platform/fonts/skia/FontCustomPlatformDataSkia.cpp @@ -42,7 +42,7 @@ namespace blink { -FontCustomPlatformData::FontCustomPlatformData(PassRefPtr typeface) +FontCustomPlatformData::FontCustomPlatformData(sk_sp typeface) : m_typeface(typeface) { } @@ -54,7 +54,7 @@ FontCustomPlatformData::~FontCustomPlatformData() FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant) { ASSERT(m_typeface); - return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isBold(), italic && !m_typeface->isItalic(), orientation); + return FontPlatformData(m_typeface, "", size, bold && !m_typeface->isBold(), italic && !m_typeface->isItalic(), orientation); } PassOwnPtr FontCustomPlatformData::create(SharedBuffer* buffer) @@ -62,11 +62,11 @@ PassOwnPtr FontCustomPlatformData::create(SharedBuffer* ASSERT_ARG(buffer, buffer); SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get()); - RefPtr typeface = adoptRef(SkTypeface::CreateFromStream(stream)); + sk_sp typeface = SkTypeface::MakeFromStream(stream); if (!typeface) return nullptr; - return adoptPtr(new FontCustomPlatformData(typeface.release())); + return adoptPtr(new FontCustomPlatformData(typeface)); } bool FontCustomPlatformData::supportsFormat(const String& format) diff --git a/sky/shell/ui/flutter_font_selector.cc b/sky/shell/ui/flutter_font_selector.cc index 0e6a11a0abf..5f0b82b9b72 100644 --- a/sky/shell/ui/flutter_font_selector.cc +++ b/sky/shell/ui/flutter_font_selector.cc @@ -46,7 +46,7 @@ struct FlutterFontSelector::FlutterFontAttributes { struct FlutterFontSelector::TypefaceAsset { TypefaceAsset(); ~TypefaceAsset(); - RefPtr typeface; + sk_sp typeface; std::vector data; }; @@ -193,8 +193,8 @@ PassRefPtr FlutterFontSelector::getFontData( RefPtr font_data = font_platform_data_cache_.get(key); if (font_data == nullptr) { - SkTypeface* typeface = getTypefaceAsset(font_description, family_name); - if (typeface == nullptr) + sk_sp typeface = getTypefaceAsset(font_description, family_name); + if (!typeface) return nullptr; bool synthetic_bold = @@ -219,7 +219,7 @@ PassRefPtr FlutterFontSelector::getFontData( return font_data; } -SkTypeface* FlutterFontSelector::getTypefaceAsset( +sk_sp FlutterFontSelector::getTypefaceAsset( const FontDescription& font_description, const AtomicString& family_name) { auto family_iter = font_family_map_.find(family_name); @@ -242,7 +242,7 @@ SkTypeface* FlutterFontSelector::getTypefaceAsset( auto typeface_iter = typeface_cache_.find(asset_path); if (typeface_iter != typeface_cache_.end()) { const TypefaceAsset* cache_asset = typeface_iter->second.get(); - return cache_asset ? cache_asset->typeface.get() : nullptr; + return cache_asset ? cache_asset->typeface : nullptr; } std::unique_ptr typeface_asset(new TypefaceAsset); @@ -255,14 +255,14 @@ SkTypeface* FlutterFontSelector::getTypefaceAsset( SkAutoTUnref font_mgr(SkFontMgr::RefDefault()); SkMemoryStream* typeface_stream = new SkMemoryStream( typeface_asset->data.data(), typeface_asset->data.size()); - typeface_asset->typeface = adoptRef( + typeface_asset->typeface = sk_sp( font_mgr->createFromStream(typeface_stream)); if (typeface_asset->typeface == nullptr) { typeface_cache_.insert(std::make_pair(asset_path, nullptr)); return nullptr; } - SkTypeface* result = typeface_asset->typeface.get(); + sk_sp result = typeface_asset->typeface; typeface_cache_.insert(std::make_pair( asset_path, std::move(typeface_asset))); diff --git a/sky/shell/ui/flutter_font_selector.h b/sky/shell/ui/flutter_font_selector.h index a8b3c475f2f..8386d7da66b 100644 --- a/sky/shell/ui/flutter_font_selector.h +++ b/sky/shell/ui/flutter_font_selector.h @@ -52,8 +52,9 @@ class FlutterFontSelector : public blink::FontSelector { void parseFontManifest(); - SkTypeface* getTypefaceAsset(const blink::FontDescription& font_description, - const AtomicString& family_name); + sk_sp getTypefaceAsset( + const blink::FontDescription& font_description, + const AtomicString& family_name); scoped_refptr zip_asset_bundle_;