mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Update Skia (#2704)
This commit is contained in:
parent
1b936794aa
commit
a126207c6e
2
DEPS
2
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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 <unicode/uscript.h>
|
||||
@ -128,7 +129,7 @@ private:
|
||||
FontPlatformData* createFontPlatformData(const FontDescription&, const FontFaceCreationParams&, float fontSize);
|
||||
|
||||
// Implemented on skia platforms.
|
||||
PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFaceCreationParams&, CString& name);
|
||||
sk_sp<SkTypeface> createTypeface(const FontDescription&, const FontFaceCreationParams&, CString& name);
|
||||
|
||||
PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformData*, ShouldRetain = Retain);
|
||||
PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription&, UChar32);
|
||||
|
||||
@ -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<SkTypeface>);
|
||||
RefPtr<SkTypeface> m_typeface;
|
||||
explicit FontCustomPlatformData(sk_sp<SkTypeface>);
|
||||
sk_sp<SkTypeface> m_typeface;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
@ -76,7 +76,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src)
|
||||
{
|
||||
}
|
||||
|
||||
FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, bool subpixelTextPosition)
|
||||
FontPlatformData::FontPlatformData(sk_sp<SkTypeface> tf, const char* family, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, bool subpixelTextPosition)
|
||||
: m_typeface(tf)
|
||||
, m_family(family)
|
||||
, m_textSize(textSize)
|
||||
|
||||
@ -62,7 +62,7 @@ public:
|
||||
FontPlatformData();
|
||||
FontPlatformData(float textSize, bool syntheticBold, bool syntheticItalic);
|
||||
FontPlatformData(const FontPlatformData&);
|
||||
FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subpixelTextPosition = defaultUseSubpixelPositioning());
|
||||
FontPlatformData(sk_sp<SkTypeface>, 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<SkTypeface> m_typeface;
|
||||
sk_sp<SkTypeface> m_typeface;
|
||||
CString m_family;
|
||||
float m_textSize;
|
||||
bool m_syntheticBold;
|
||||
|
||||
@ -51,7 +51,7 @@ static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription&
|
||||
fontLocale = fontDescription.locale().ascii();
|
||||
bcp47Locales[localeCount++] = fontLocale.data();
|
||||
}
|
||||
RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFontStyle(), bcp47Locales, localeCount, c));
|
||||
sk_sp<SkTypeface> typeface(fm->matchFamilyStyleCharacter(0, SkFontStyle(), bcp47Locales, localeCount, c));
|
||||
if (!typeface)
|
||||
return emptyAtom;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -213,22 +213,19 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
|
||||
return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
|
||||
}
|
||||
|
||||
PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name)
|
||||
sk_sp<SkTypeface> 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<SkTypeface> 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<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc
|
||||
|
||||
SkFontStyle style = toSkiaFontStyle(fontDescription);
|
||||
RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
|
||||
RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyle(name.data(), style));
|
||||
sk_sp<SkTypeface> 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<SkTypeface> 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<SkTypeface::Style>(legacyStyle)));
|
||||
return SkTypeface::MakeFromName(name.data(), static_cast<SkTypeface::Style>(legacyStyle));
|
||||
}
|
||||
|
||||
#if !OS(WIN)
|
||||
FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, float fontSize)
|
||||
{
|
||||
CString name;
|
||||
RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name));
|
||||
sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name);
|
||||
if (!tf)
|
||||
return 0;
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
namespace blink {
|
||||
|
||||
FontCustomPlatformData::FontCustomPlatformData(PassRefPtr<SkTypeface> typeface)
|
||||
FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> 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> FontCustomPlatformData::create(SharedBuffer* buffer)
|
||||
@ -62,11 +62,11 @@ PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer*
|
||||
ASSERT_ARG(buffer, buffer);
|
||||
|
||||
SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get());
|
||||
RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream));
|
||||
sk_sp<SkTypeface> 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)
|
||||
|
||||
@ -46,7 +46,7 @@ struct FlutterFontSelector::FlutterFontAttributes {
|
||||
struct FlutterFontSelector::TypefaceAsset {
|
||||
TypefaceAsset();
|
||||
~TypefaceAsset();
|
||||
RefPtr<SkTypeface> typeface;
|
||||
sk_sp<SkTypeface> typeface;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
@ -193,8 +193,8 @@ PassRefPtr<FontData> FlutterFontSelector::getFontData(
|
||||
RefPtr<SimpleFontData> font_data = font_platform_data_cache_.get(key);
|
||||
|
||||
if (font_data == nullptr) {
|
||||
SkTypeface* typeface = getTypefaceAsset(font_description, family_name);
|
||||
if (typeface == nullptr)
|
||||
sk_sp<SkTypeface> typeface = getTypefaceAsset(font_description, family_name);
|
||||
if (!typeface)
|
||||
return nullptr;
|
||||
|
||||
bool synthetic_bold =
|
||||
@ -219,7 +219,7 @@ PassRefPtr<FontData> FlutterFontSelector::getFontData(
|
||||
return font_data;
|
||||
}
|
||||
|
||||
SkTypeface* FlutterFontSelector::getTypefaceAsset(
|
||||
sk_sp<SkTypeface> 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<TypefaceAsset> typeface_asset(new TypefaceAsset);
|
||||
@ -255,14 +255,14 @@ SkTypeface* FlutterFontSelector::getTypefaceAsset(
|
||||
SkAutoTUnref<SkFontMgr> 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<SkTypeface>(
|
||||
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<SkTypeface> result = typeface_asset->typeface;
|
||||
typeface_cache_.insert(std::make_pair(
|
||||
asset_path, std::move(typeface_asset)));
|
||||
|
||||
|
||||
@ -52,8 +52,9 @@ class FlutterFontSelector : public blink::FontSelector {
|
||||
|
||||
void parseFontManifest();
|
||||
|
||||
SkTypeface* getTypefaceAsset(const blink::FontDescription& font_description,
|
||||
const AtomicString& family_name);
|
||||
sk_sp<SkTypeface> getTypefaceAsset(
|
||||
const blink::FontDescription& font_description,
|
||||
const AtomicString& family_name);
|
||||
|
||||
scoped_refptr<mojo::asset_bundle::ZipAssetBundle> zip_asset_bundle_;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user