Allow choosing freetype or fontations in FontDataManager
This change splits out Freetype and Fontations codepaths, previously combined under the Internal experimental param, into their own params. This will allow varying between the 3 typeface types in an A/B performance experiment. Bug: 395924057 Change-Id: I5acfcca5691b0aaf93d26895da2fa1da702b0b85 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6279725 Reviewed-by: Etienne Bergeron <etienneb@chromium.org> Commit-Queue: Anthony Vallée-Dubois <anthonyvd@chromium.org> Reviewed-by: Nasko Oskov <nasko@chromium.org> Cr-Commit-Position: refs/heads/main@{#1422139}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
329d98edac
commit
40abd7f4f4
content
testing/variations
@ -1053,7 +1053,8 @@ BASE_FEATURE(kFontDataServiceAllWebContents,
|
||||
const base::FeatureParam<FontDataServiceTypefaceType>::Option
|
||||
font_data_service_typeface[] = {
|
||||
{FontDataServiceTypefaceType::kDwrite, "DWrite"},
|
||||
{FontDataServiceTypefaceType::kInternal, "Internal"}};
|
||||
{FontDataServiceTypefaceType::kFreetype, "Freetype"},
|
||||
{FontDataServiceTypefaceType::kFontations, "Fontations"}};
|
||||
const base::FeatureParam<FontDataServiceTypefaceType>
|
||||
kFontDataServiceTypefaceType{&kFontDataServiceAllWebContents, "typeface",
|
||||
FontDataServiceTypefaceType::kDwrite,
|
||||
|
@ -233,7 +233,8 @@ CONTENT_EXPORT extern const base::FeatureParam<base::TimeDelta>
|
||||
CONTENT_EXPORT BASE_DECLARE_FEATURE(kFontDataServiceAllWebContents);
|
||||
enum class FontDataServiceTypefaceType {
|
||||
kDwrite,
|
||||
kInternal,
|
||||
kFreetype,
|
||||
kFontations,
|
||||
};
|
||||
extern const base::FeatureParam<FontDataServiceTypefaceType>
|
||||
kFontDataServiceTypefaceType;
|
||||
|
@ -22,9 +22,8 @@
|
||||
#include "third_party/skia/src/ports/SkTypeface_win_dw.h" // nogncheck
|
||||
#if BUILDFLAG(ENABLE_FREETYPE)
|
||||
#include "third_party/skia/include/ports/SkFontMgr_empty.h"
|
||||
#else
|
||||
#include "third_party/skia/include/ports/SkTypeface_fontations.h"
|
||||
#endif
|
||||
#include "third_party/skia/include/ports/SkTypeface_fontations.h"
|
||||
|
||||
namespace font_data_service {
|
||||
|
||||
@ -223,15 +222,20 @@ sk_sp<SkTypeface> FontDataManager::onMakeFromStreamArgs(
|
||||
// Experiment will test the performance of different SkTypefaces.
|
||||
// 'custom_fnt_mgr_' is a wrapper to create an SkFreeType typeface.
|
||||
|
||||
return features::kFontDataServiceTypefaceType.Get() ==
|
||||
features::FontDataServiceTypefaceType::kInternal
|
||||
?
|
||||
if (features::kFontDataServiceTypefaceType.Get() ==
|
||||
features::FontDataServiceTypefaceType::kDwrite) {
|
||||
return DWriteFontTypeface::MakeFromStream(std::move(stream), args);
|
||||
} else if (features::kFontDataServiceTypefaceType.Get() ==
|
||||
features::FontDataServiceTypefaceType::kFreetype) {
|
||||
// Chromium currently always sets ENABLE_FREETYPE, but nonetheless allow
|
||||
// falling back to fontations if the param is set to freetype but freetype
|
||||
// isn't enabled.
|
||||
#if BUILDFLAG(ENABLE_FREETYPE)
|
||||
custom_fnt_mgr_->makeFromStream(std::move(stream), args)
|
||||
#else
|
||||
SkTypeface_Make_Fontations(std::move(stream), args)
|
||||
return custom_fnt_mgr_->makeFromStream(std::move(stream), args);
|
||||
#endif
|
||||
: DWriteFontTypeface::MakeFromStream(std::move(stream), args);
|
||||
}
|
||||
|
||||
return SkTypeface_Make_Fontations(std::move(stream), args);
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> FontDataManager::onMakeFromFile(const char path[],
|
||||
|
@ -10113,9 +10113,18 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Internal_Enabled",
|
||||
"name": "Freetype_Enabled",
|
||||
"params": {
|
||||
"typeface": "Internal"
|
||||
"typeface": "Freetype"
|
||||
},
|
||||
"enable_features": [
|
||||
"FontDataServiceAllWebContents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Fontations_Enabled",
|
||||
"params": {
|
||||
"typeface": "Fontations"
|
||||
},
|
||||
"enable_features": [
|
||||
"FontDataServiceAllWebContents"
|
||||
|
Reference in New Issue
Block a user