зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1460259 - Send synthetic oblique angle to WR. r=jfkthame
This commit is contained in:
Родитель
3ca8423283
Коммит
e251ecb952
|
@ -898,13 +898,18 @@ public:
|
|||
virtual cairo_scaled_font_t* GetCairoScaledFont() { return nullptr; }
|
||||
virtual void SetCairoScaledFont(cairo_scaled_font_t* font) {}
|
||||
|
||||
Float GetSyntheticObliqueAngle() const { return mSyntheticObliqueAngle; }
|
||||
void SetSyntheticObliqueAngle(Float aAngle) { mSyntheticObliqueAngle = aAngle; }
|
||||
|
||||
protected:
|
||||
explicit ScaledFont(const RefPtr<UnscaledFont>& aUnscaledFont)
|
||||
: mUnscaledFont(aUnscaledFont)
|
||||
, mSyntheticObliqueAngle(0.0f)
|
||||
{}
|
||||
|
||||
UserData mUserData;
|
||||
RefPtr<UnscaledFont> mUnscaledFont;
|
||||
Float mSyntheticObliqueAngle;
|
||||
|
||||
private:
|
||||
static Atomic<uint32_t> sDeletionCounter;
|
||||
|
|
|
@ -474,6 +474,7 @@ ScaledFontDWrite::GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* aOutO
|
|||
options.flags |= wr::FontInstanceFlags::FORCE_GDI;
|
||||
}
|
||||
options.bg_color = wr::ToColorU(Color());
|
||||
options.synthetic_italics = wr::DegreesToSyntheticItalics(GetSyntheticObliqueAngle());
|
||||
*aOutOptions = Some(options);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -241,6 +241,7 @@ ScaledFontFontconfig::GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* a
|
|||
// options.flags = wr::FontInstanceFlags::SUBPIXEL_POSITION;
|
||||
options.flags = 0;
|
||||
options.bg_color = wr::ToColorU(Color());
|
||||
options.synthetic_italics = wr::DegreesToSyntheticItalics(GetSyntheticObliqueAngle());
|
||||
|
||||
wr::FontInstancePlatformOptions platformOptions;
|
||||
platformOptions.lcd_filter = wr::FontLCDFilter::Legacy;
|
||||
|
|
|
@ -68,6 +68,7 @@ ScaledFontFreeType::GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* aOu
|
|||
// options.flags = wr::FontInstanceFlags::SUBPIXEL_POSITION;
|
||||
options.flags = 0;
|
||||
options.bg_color = wr::ToColorU(Color());
|
||||
options.synthetic_italics = wr::DegreesToSyntheticItalics(GetSyntheticObliqueAngle());
|
||||
|
||||
wr::FontInstancePlatformOptions platformOptions;
|
||||
platformOptions.lcd_filter = wr::FontLCDFilter::None;
|
||||
|
|
|
@ -452,6 +452,7 @@ ScaledFontMac::GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* aOutOpti
|
|||
options.flags |= wr::FontInstanceFlags::SYNTHETIC_BOLD;
|
||||
}
|
||||
options.bg_color = wr::ToColorU(mFontSmoothingBackgroundColor);
|
||||
options.synthetic_italics = wr::DegreesToSyntheticItalics(GetSyntheticObliqueAngle());
|
||||
*aOutOptions = Some(options);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -697,6 +697,7 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
|||
if (!mAzureScaledFont) {
|
||||
return nullptr;
|
||||
}
|
||||
InitializeScaledFont();
|
||||
mAzureScaledFontUsedClearType = sUseClearType;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,6 +192,7 @@ gfxFT2Font::GetScaledFont(DrawTarget *aTarget)
|
|||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
InitializeScaledFont();
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
|
|
|
@ -1467,6 +1467,7 @@ gfxFontconfigFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
|||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
InitializeScaledFont();
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
|
|
|
@ -752,12 +752,8 @@ gfxShapedText::AdjustAdvancesForSyntheticBold(float aSynBoldOffset,
|
|||
}
|
||||
|
||||
float
|
||||
gfxFont::SkewForSyntheticOblique() const
|
||||
gfxFont::AngleForSyntheticOblique() const
|
||||
{
|
||||
// Precomputed value of tan(14deg), the default italic/oblique slant;
|
||||
// avoids calling tan() at runtime except for custom oblique values.
|
||||
const float kTan14deg = 0.249328f;
|
||||
|
||||
// If the style doesn't call for italic/oblique, or if the face already
|
||||
// provides it, no synthetic style should be added.
|
||||
if (mStyle.style == FontSlantStyle::Normal() ||
|
||||
|
@ -769,12 +765,29 @@ gfxFont::SkewForSyntheticOblique() const
|
|||
// If style calls for italic, and face doesn't support it, use default
|
||||
// oblique angle as a simulation.
|
||||
if (mStyle.style.IsItalic()) {
|
||||
return mFontEntry->SupportsItalic() ? 0.0f : kTan14deg;
|
||||
return mFontEntry->SupportsItalic() ? 0.0f : FontSlantStyle::kDefaultAngle;
|
||||
}
|
||||
|
||||
// Default oblique angle
|
||||
return mStyle.style == FontSlantStyle::Oblique()
|
||||
? kTan14deg : tan(mStyle.style.ObliqueAngle() * (M_PI / 180.0));
|
||||
// Default or custom oblique angle
|
||||
return mStyle.style.ObliqueAngle();
|
||||
}
|
||||
|
||||
float
|
||||
gfxFont::SkewForSyntheticOblique() const
|
||||
{
|
||||
// Precomputed value of tan(kDefaultAngle), the default italic/oblique slant;
|
||||
// avoids calling tan() at runtime except for custom oblique values.
|
||||
static const float kTanDefaultAngle =
|
||||
tan(FontSlantStyle::kDefaultAngle * (M_PI / 180.0));
|
||||
|
||||
float angle = AngleForSyntheticOblique();
|
||||
if (angle == 0.0f) {
|
||||
return 0.0f;
|
||||
} else if (angle == FontSlantStyle::kDefaultAngle) {
|
||||
return kTanDefaultAngle;
|
||||
} else {
|
||||
return tan(angle * (M_PI / 180.0));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1627,6 +1640,19 @@ gfxFont::HasFeatureSet(uint32_t aFeature, bool& aFeatureOn)
|
|||
return featureSet;
|
||||
}
|
||||
|
||||
void
|
||||
gfxFont::InitializeScaledFont()
|
||||
{
|
||||
if (!mAzureScaledFont) {
|
||||
return;
|
||||
}
|
||||
|
||||
float angle = AngleForSyntheticOblique();
|
||||
if (angle != 0.0f) {
|
||||
mAzureScaledFont->SetSyntheticObliqueAngle(angle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function in case we need to do any rounding or other
|
||||
* processing here.
|
||||
|
@ -2304,27 +2330,21 @@ gfxFont::Draw(const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
|||
}
|
||||
}
|
||||
|
||||
if (fontParams.obliqueSkew != 0.0f) {
|
||||
if (textDrawer) {
|
||||
glyphFlagsRestore.Save(textDrawer);
|
||||
textDrawer->SetWRGlyphFlags(textDrawer->GetWRGlyphFlags() |
|
||||
wr::FontInstanceFlags::SYNTHETIC_ITALICS);
|
||||
} else if (!fontParams.isVerticalFont) {
|
||||
// Adjust matrix for synthetic-oblique, except if we're doing vertical-
|
||||
// upright text, in which case this will be handled for each glyph
|
||||
// individually in DrawOneGlyph.
|
||||
if (!matrixRestore.HasMatrix()) {
|
||||
matrixRestore.SetContext(aRunParams.context);
|
||||
}
|
||||
gfx::Point p(aPt->x * aRunParams.devPerApp,
|
||||
aPt->y * aRunParams.devPerApp);
|
||||
gfx::Matrix mat =
|
||||
aRunParams.context->CurrentMatrix().
|
||||
PreTranslate(p).
|
||||
PreMultiply(gfx::Matrix(1, 0, -fontParams.obliqueSkew, 1, 0, 0)).
|
||||
PreTranslate(-p);
|
||||
aRunParams.context->SetMatrix(mat);
|
||||
if (fontParams.obliqueSkew != 0.0f && !fontParams.isVerticalFont && !textDrawer) {
|
||||
// Adjust matrix for synthetic-oblique, except if we're doing vertical-
|
||||
// upright text, in which case this will be handled for each glyph
|
||||
// individually in DrawOneGlyph.
|
||||
if (!matrixRestore.HasMatrix()) {
|
||||
matrixRestore.SetContext(aRunParams.context);
|
||||
}
|
||||
gfx::Point p(aPt->x * aRunParams.devPerApp,
|
||||
aPt->y * aRunParams.devPerApp);
|
||||
gfx::Matrix mat =
|
||||
aRunParams.context->CurrentMatrix().
|
||||
PreTranslate(p).
|
||||
PreMultiply(gfx::Matrix(1, 0, -fontParams.obliqueSkew, 1, 0, 0)).
|
||||
PreTranslate(-p);
|
||||
aRunParams.context->SetMatrix(mat);
|
||||
}
|
||||
|
||||
RefPtr<SVGContextPaint> contextPaint;
|
||||
|
|
|
@ -1830,6 +1830,7 @@ public:
|
|||
|
||||
bool IsSyntheticBold() const { return mApplySyntheticBold; }
|
||||
|
||||
float AngleForSyntheticOblique() const;
|
||||
float SkewForSyntheticOblique() const;
|
||||
|
||||
// Amount by which synthetic bold "fattens" the glyphs:
|
||||
|
@ -1950,6 +1951,8 @@ public:
|
|||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(DrawTarget* aTarget) = 0;
|
||||
|
||||
void InitializeScaledFont();
|
||||
|
||||
bool KerningDisabled() {
|
||||
return mKerningSet && !mKerningEnabled;
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ gfxGDIFont::GetScaledFont(DrawTarget *aTarget)
|
|||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
InitializeScaledFont();
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
|
|
|
@ -614,7 +614,7 @@ gfxMacFont::GetScaledFont(DrawTarget *aTarget)
|
|||
if (!mAzureScaledFont) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InitializeScaledFont();
|
||||
mAzureScaledFont->SetCairoScaledFont(mScaledFont);
|
||||
}
|
||||
|
||||
|
|
|
@ -804,6 +804,12 @@ static inline wr::WrYuvColorSpace ToWrYuvColorSpace(YUVColorSpace aYUVColorSpace
|
|||
return wr::WrYuvColorSpace::Rec601;
|
||||
}
|
||||
|
||||
static inline wr::SyntheticItalics DegreesToSyntheticItalics(float aDegrees) {
|
||||
wr::SyntheticItalics synthetic_italics;
|
||||
synthetic_italics.angle = int16_t(std::min(std::max(aDegrees, -89.0f), 89.0f) * 256.0f);
|
||||
return synthetic_italics;
|
||||
}
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ struct FontInstanceFlags {
|
|||
}
|
||||
|
||||
enum : uint32_t {
|
||||
SYNTHETIC_ITALICS = 1 << 0,
|
||||
SYNTHETIC_BOLD = 1 << 1,
|
||||
EMBEDDED_BITMAPS = 1 << 2,
|
||||
SUBPIXEL_BGR = 1 << 3,
|
||||
|
|
|
@ -575,18 +575,6 @@ struct BorderSide {
|
|||
}
|
||||
};
|
||||
|
||||
using LayoutPoint = TypedPoint2D<float, LayoutPixel>;
|
||||
|
||||
struct GradientStop {
|
||||
float offset;
|
||||
ColorF color;
|
||||
|
||||
bool operator==(const GradientStop& aOther) const {
|
||||
return offset == aOther.offset &&
|
||||
color == aOther.color;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename U>
|
||||
struct TypedSideOffsets2D {
|
||||
T top;
|
||||
|
@ -606,6 +594,18 @@ struct TypedSideOffsets2D {
|
|||
template<typename T>
|
||||
using SideOffsets2D = TypedSideOffsets2D<T, UnknownUnit>;
|
||||
|
||||
using LayoutPoint = TypedPoint2D<float, LayoutPixel>;
|
||||
|
||||
struct GradientStop {
|
||||
float offset;
|
||||
ColorF color;
|
||||
|
||||
bool operator==(const GradientStop& aOther) const {
|
||||
return offset == aOther.offset &&
|
||||
color == aOther.color;
|
||||
}
|
||||
};
|
||||
|
||||
struct Shadow {
|
||||
LayoutVector2D offset;
|
||||
ColorF color;
|
||||
|
@ -880,6 +880,14 @@ struct ColorU {
|
|||
}
|
||||
};
|
||||
|
||||
struct SyntheticItalics {
|
||||
int16_t angle;
|
||||
|
||||
bool operator==(const SyntheticItalics& aOther) const {
|
||||
return angle == aOther.angle;
|
||||
}
|
||||
};
|
||||
|
||||
struct FontInstanceOptions {
|
||||
FontRenderMode render_mode;
|
||||
FontInstanceFlags flags;
|
||||
|
@ -887,11 +895,13 @@ struct FontInstanceOptions {
|
|||
// the text will be rendered with bg_color.r/g/b as an opaque estimated
|
||||
// background color.
|
||||
ColorU bg_color;
|
||||
SyntheticItalics synthetic_italics;
|
||||
|
||||
bool operator==(const FontInstanceOptions& aOther) const {
|
||||
return render_mode == aOther.render_mode &&
|
||||
flags == aOther.flags &&
|
||||
bg_color == aOther.bg_color;
|
||||
bg_color == aOther.bg_color &&
|
||||
synthetic_italics == aOther.synthetic_italics;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ fails == stretchy-mover-2a.html stretchy-mover-2-ref.html
|
|||
== stretchy-largeop-3.html stretchy-largeop-3-ref.html
|
||||
== table-width-1.xhtml table-width-1-ref.xhtml
|
||||
== table-width-2.html table-width-2-ref.html
|
||||
fails-if(webrender&&winWidget) == table-width-3.html table-width-3-ref.html # bug 1460259
|
||||
== table-width-3.html table-width-3-ref.html
|
||||
== table-width-4.html table-width-4-ref.html
|
||||
== underbar-width-1.xhtml underbar-width-1-ref.xhtml
|
||||
== mathml-type-supported.xhtml mathml-type-supported-ref.xml
|
||||
|
|
Загрузка…
Ссылка в новой задаче