mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1909019 - Use ParamTraits_TiedFields/_IsEnumCase in WebRenderMessageUtils instead of PlainOldDataSerializer. (complete) r=gw,mccr8,ahale
Differential Revision: https://phabricator.services.mozilla.com/D217509
This commit is contained in:
parent
6662218aa3
commit
3a3aeacc4e
@ -468,7 +468,7 @@ bool ScaledFontDWrite::GetWRFontInstanceOptions(
|
||||
Maybe<wr::FontInstanceOptions>* aOutOptions,
|
||||
Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
|
||||
std::vector<FontVariation>* aOutVariations) {
|
||||
wr::FontInstanceOptions options;
|
||||
wr::FontInstanceOptions options = {};
|
||||
options.render_mode = wr::ToFontRenderMode(GetDefaultAAMode());
|
||||
options.flags = wr::FontInstanceFlags{0};
|
||||
if (HasBoldSimulation()) {
|
||||
|
@ -396,7 +396,7 @@ bool ScaledFontFontconfig::GetWRFontInstanceOptions(
|
||||
Maybe<wr::FontInstanceOptions>* aOutOptions,
|
||||
Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
|
||||
std::vector<FontVariation>* aOutVariations) {
|
||||
wr::FontInstanceOptions options;
|
||||
wr::FontInstanceOptions options = {};
|
||||
options.render_mode = wr::FontRenderMode::Alpha;
|
||||
options.flags = wr::FontInstanceFlags{0};
|
||||
if (UseSubpixelPosition()) {
|
||||
|
@ -86,7 +86,7 @@ bool ScaledFontFreeType::GetWRFontInstanceOptions(
|
||||
Maybe<wr::FontInstanceOptions>* aOutOptions,
|
||||
Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
|
||||
std::vector<FontVariation>* aOutVariations) {
|
||||
wr::FontInstanceOptions options;
|
||||
wr::FontInstanceOptions options = {};
|
||||
options.render_mode = wr::FontRenderMode::Alpha;
|
||||
options.flags = wr::FontInstanceFlags{0};
|
||||
if (UseSubpixelPosition()) {
|
||||
|
@ -468,7 +468,7 @@ bool ScaledFontMac::GetWRFontInstanceOptions(
|
||||
std::vector<FontVariation>* aOutVariations) {
|
||||
GetVariationsForCTFont(mCTFont, aOutVariations);
|
||||
|
||||
wr::FontInstanceOptions options;
|
||||
wr::FontInstanceOptions options = {};
|
||||
options.render_mode = wr::FontRenderMode::Subpixel;
|
||||
options.flags = wr::FontInstanceFlags::SUBPIXEL_POSITION;
|
||||
if (mUseFontSmoothing) {
|
||||
|
@ -151,6 +151,72 @@ inline auto TiedFields<mozilla::wr::FontInstanceKey>(
|
||||
return std::tie(a.mNamespace, a.mHandle);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::FontInstanceFlags>(
|
||||
mozilla::wr::FontInstanceFlags& a) {
|
||||
return std::tie(a._0);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::SyntheticItalics>(
|
||||
mozilla::wr::SyntheticItalics& a) {
|
||||
return std::tie(a.angle);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::FontInstanceOptions>(
|
||||
mozilla::wr::FontInstanceOptions& a) {
|
||||
return std::tie(a.flags, a.synthetic_italics, a.render_mode, a._padding);
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
#if !(defined(XP_MACOSX) || defined(XP_WIN))
|
||||
|
||||
template <>
|
||||
inline constexpr bool IsEnumCase<wr::FontLCDFilter>(
|
||||
const wr::FontLCDFilter raw) {
|
||||
switch (raw) {
|
||||
case wr::FontLCDFilter::None:
|
||||
case wr::FontLCDFilter::Default:
|
||||
case wr::FontLCDFilter::Light:
|
||||
case wr::FontLCDFilter::Legacy:
|
||||
case wr::FontLCDFilter::Sentinel:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline constexpr bool IsEnumCase<wr::FontHinting>(const wr::FontHinting raw) {
|
||||
switch (raw) {
|
||||
case wr::FontHinting::None:
|
||||
case wr::FontHinting::Mono:
|
||||
case wr::FontHinting::Light:
|
||||
case wr::FontHinting::Normal:
|
||||
case wr::FontHinting::LCD:
|
||||
case wr::FontHinting::Sentinel:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // !(defined(XP_MACOSX) || defined(XP_WIN))
|
||||
|
||||
// -
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::FontInstancePlatformOptions>(
|
||||
mozilla::wr::FontInstancePlatformOptions& a) {
|
||||
#if defined(XP_WIN)
|
||||
return std::tie(a.gamma, a.contrast, a.cleartype_level);
|
||||
#elif defined(XP_MACOSX)
|
||||
return std::tie(a.unused);
|
||||
#else
|
||||
return std::tie(a.lcd_filter, a.hinting);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::ExternalImageId>(
|
||||
mozilla::wr::ExternalImageId& a) {
|
||||
@ -162,6 +228,19 @@ inline auto TiedFields<mozilla::wr::PipelineId>(mozilla::wr::PipelineId& a) {
|
||||
return std::tie(a.mNamespace, a.mHandle);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::LayoutSize>(mozilla::wr::LayoutSize& a) {
|
||||
return std::tie(a.width, a.height);
|
||||
}
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::LayoutRect>(mozilla::wr::LayoutRect& a) {
|
||||
return std::tie(a.min, a.max);
|
||||
}
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::LayoutPoint>(mozilla::wr::LayoutPoint& a) {
|
||||
return std::tie(a.x, a.y);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline constexpr bool IsEnumCase<wr::OpacityType>(const wr::OpacityType raw) {
|
||||
switch (raw) {
|
||||
@ -173,6 +252,70 @@ inline constexpr bool IsEnumCase<wr::OpacityType>(const wr::OpacityType raw) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline constexpr bool IsEnumCase<wr::FontRenderMode>(
|
||||
const wr::FontRenderMode raw) {
|
||||
switch (raw) {
|
||||
case wr::FontRenderMode::Mono:
|
||||
case wr::FontRenderMode::Alpha:
|
||||
case wr::FontRenderMode::Subpixel:
|
||||
case wr::FontRenderMode::Sentinel:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::InternerSubReport>(
|
||||
mozilla::wr::InternerSubReport& a) {
|
||||
#define _COMMA ,
|
||||
#define _(X) a.X
|
||||
return std::tie(WEBRENDER_FOR_EACH_INTERNER(_, _COMMA));
|
||||
#undef _
|
||||
#undef _COMMA
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::InterningMemoryReport>(
|
||||
mozilla::wr::InterningMemoryReport& a) {
|
||||
return std::tie(a.interners, a.data_stores);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::MemoryReport>(
|
||||
mozilla::wr::MemoryReport& a) {
|
||||
// clang-format off
|
||||
return std::tie(
|
||||
a.clip_stores,
|
||||
a.gpu_cache_metadata,
|
||||
a.gpu_cache_cpu_mirror,
|
||||
a.render_tasks,
|
||||
a.hit_testers,
|
||||
a.fonts,
|
||||
a.weak_fonts,
|
||||
a.images,
|
||||
a.rasterized_blobs,
|
||||
a.shader_cache,
|
||||
a.interning,
|
||||
a.display_list,
|
||||
a.upload_staging_memory,
|
||||
a.swgl,
|
||||
a.gpu_cache_textures,
|
||||
a.vertex_data_textures,
|
||||
a.render_target_textures,
|
||||
a.picture_tile_textures,
|
||||
a.atlas_textures,
|
||||
a.standalone_textures,
|
||||
a.texture_cache_structures,
|
||||
a.depth_target_textures,
|
||||
a.texture_upload_pbos,
|
||||
a.swap_chain,
|
||||
a.render_texture_hosts,
|
||||
a.upload_staging_textures
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
template <>
|
||||
inline auto TiedFields<mozilla::wr::RenderReasons>(
|
||||
mozilla::wr::RenderReasons& a) {
|
||||
@ -201,13 +344,33 @@ template <>
|
||||
struct ParamTraits<mozilla::wr::FontInstanceKey>
|
||||
: public ParamTraits_TiedFields<mozilla::wr::FontInstanceKey> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::FontInstanceFlags>
|
||||
: public ParamTraits_TiedFields<mozilla::wr::FontInstanceFlags> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::SyntheticItalics>
|
||||
: public ParamTraits_TiedFields<mozilla::wr::SyntheticItalics> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::FontInstanceOptions>
|
||||
: public PlainOldDataSerializer<mozilla::wr::FontInstanceOptions> {};
|
||||
: public ParamTraits_TiedFields<mozilla::wr::FontInstanceOptions> {};
|
||||
|
||||
#if !(defined(XP_MACOSX) || defined(XP_WIN))
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::FontLCDFilter>
|
||||
: public ParamTraits_IsEnumCase<mozilla::wr::FontLCDFilter> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::FontHinting>
|
||||
: public ParamTraits_IsEnumCase<mozilla::wr::FontHinting> {};
|
||||
|
||||
#endif // !(defined(XP_MACOSX) || defined(XP_WIN))
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::FontInstancePlatformOptions>
|
||||
: public PlainOldDataSerializer<mozilla::wr::FontInstancePlatformOptions> {
|
||||
: public ParamTraits_TiedFields<mozilla::wr::FontInstancePlatformOptions> {
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -226,15 +389,15 @@ struct ParamTraits<mozilla::wr::ImageFormat>
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::LayoutSize>
|
||||
: public PlainOldDataSerializer<mozilla::wr::LayoutSize> {};
|
||||
: public ParamTraits_TiedFields<mozilla::wr::LayoutSize> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::LayoutRect>
|
||||
: public PlainOldDataSerializer<mozilla::wr::LayoutRect> {};
|
||||
: public ParamTraits_TiedFields<mozilla::wr::LayoutRect> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::LayoutPoint>
|
||||
: public PlainOldDataSerializer<mozilla::wr::LayoutPoint> {};
|
||||
: public ParamTraits_TiedFields<mozilla::wr::LayoutPoint> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::ImageRendering>
|
||||
@ -260,14 +423,26 @@ struct ParamTraits<mozilla::wr::WrRotation>
|
||||
mozilla::wr::WrRotation::Degree0,
|
||||
mozilla::wr::WrRotation::Sentinel> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::InternerSubReport>
|
||||
: public ParamTraits_TiedFields<mozilla::wr::InternerSubReport> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::InterningMemoryReport>
|
||||
: public ParamTraits_TiedFields<mozilla::wr::InterningMemoryReport> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::MemoryReport>
|
||||
: public PlainOldDataSerializer<mozilla::wr::MemoryReport> {};
|
||||
: public ParamTraits_TiedFields<mozilla::wr::MemoryReport> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::OpacityType>
|
||||
: public ParamTraits_IsEnumCase<mozilla::wr::OpacityType> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::FontRenderMode>
|
||||
: public ParamTraits_IsEnumCase<mozilla::wr::FontRenderMode> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::wr::ExternalImageKeyPair>
|
||||
: public ParamTraits_TiedFields<mozilla::wr::ExternalImageKeyPair> {};
|
||||
|
@ -752,8 +752,8 @@ WebRenderMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
helper.Report(aReport.swgl, "swgl");
|
||||
helper.Report(aReport.upload_staging_memory, "upload-stagin-memory");
|
||||
|
||||
WEBRENDER_FOR_EACH_INTERNER(REPORT_INTERNER);
|
||||
WEBRENDER_FOR_EACH_INTERNER(REPORT_DATA_STORE);
|
||||
WEBRENDER_FOR_EACH_INTERNER(REPORT_INTERNER, );
|
||||
WEBRENDER_FOR_EACH_INTERNER(REPORT_DATA_STORE, );
|
||||
|
||||
// GPU Memory.
|
||||
helper.ReportTexture(aReport.gpu_cache_textures, "gpu-cache");
|
||||
|
@ -34,24 +34,23 @@ bool gecko_profiler_thread_is_being_profiled();
|
||||
|
||||
// IMPORTANT: Keep this synchronized with enumerate_interners in
|
||||
// gfx/wr/webrender_api
|
||||
#define WEBRENDER_FOR_EACH_INTERNER(macro) \
|
||||
macro(clip); \
|
||||
macro(prim); \
|
||||
macro(normal_border); \
|
||||
macro(image_border); \
|
||||
macro(image); \
|
||||
macro(yuv_image); \
|
||||
macro(line_decoration); \
|
||||
macro(linear_grad); \
|
||||
macro(radial_grad); \
|
||||
macro(conic_grad); \
|
||||
macro(picture); \
|
||||
macro(text_run); \
|
||||
macro(filterdata); \
|
||||
macro(backdrop_capture); \
|
||||
macro(backdrop_render); \
|
||||
macro(polyon); \
|
||||
macro(box_shadow);
|
||||
#define WEBRENDER_FOR_EACH_INTERNER(macro, comma_like_delim) \
|
||||
macro(clip) comma_like_delim macro(prim) \
|
||||
comma_like_delim macro(normal_border) \
|
||||
comma_like_delim macro(image_border) \
|
||||
comma_like_delim macro(image) \
|
||||
comma_like_delim macro(yuv_image) \
|
||||
comma_like_delim macro(line_decoration) \
|
||||
comma_like_delim macro(linear_grad) \
|
||||
comma_like_delim macro(radial_grad) \
|
||||
comma_like_delim macro(conic_grad) \
|
||||
comma_like_delim macro(picture) \
|
||||
comma_like_delim macro(text_run) \
|
||||
comma_like_delim macro(filterdata) \
|
||||
comma_like_delim macro(backdrop_capture) \
|
||||
comma_like_delim macro(backdrop_render) \
|
||||
comma_like_delim macro(polyon) \
|
||||
comma_like_delim macro(box_shadow)
|
||||
|
||||
// Prelude of types necessary before including webrender_ffi_generated.h
|
||||
namespace mozilla {
|
||||
@ -61,7 +60,7 @@ namespace wr {
|
||||
// it. Work around that by re-declaring it here.
|
||||
#define DECLARE_MEMBER(id) uintptr_t id;
|
||||
struct InternerSubReport {
|
||||
WEBRENDER_FOR_EACH_INTERNER(DECLARE_MEMBER)
|
||||
WEBRENDER_FOR_EACH_INTERNER(DECLARE_MEMBER, )
|
||||
};
|
||||
|
||||
#undef DECLARE_MEMBER
|
||||
|
@ -297,9 +297,14 @@ impl Default for SyntheticItalics {
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Hash, Eq, MallocSizeOf, PartialEq, PartialOrd, Ord, Serialize)]
|
||||
pub struct FontInstanceOptions {
|
||||
pub render_mode: FontRenderMode,
|
||||
pub flags: FontInstanceFlags,
|
||||
pub synthetic_italics: SyntheticItalics,
|
||||
pub render_mode: FontRenderMode,
|
||||
// We need to pad this struct out so that all bytes are part of fields, in
|
||||
// order to satisfy the robustness requirements (and static_asserts) of
|
||||
// ParamTraits_TiedFields.
|
||||
// The sizeof(T) must be equal to the sum of the sizeof each field in T.
|
||||
pub _padding: u8,
|
||||
}
|
||||
|
||||
impl Default for FontInstanceOptions {
|
||||
@ -308,6 +313,7 @@ impl Default for FontInstanceOptions {
|
||||
render_mode: FontRenderMode::Subpixel,
|
||||
flags: Default::default(),
|
||||
synthetic_italics: SyntheticItalics::disabled(),
|
||||
_padding: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -787,6 +787,7 @@ impl FontInstanceMap {
|
||||
render_mode: instance.render_mode,
|
||||
flags: instance.flags,
|
||||
synthetic_italics: instance.synthetic_italics,
|
||||
_padding: 0,
|
||||
}),
|
||||
platform_options: instance.platform_options,
|
||||
variations: instance.variations.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user