Bug 1908261 - When caching a rendered image of a color-emoji glyph, use 2x scaling to get a higher-resolution rendering; and when painting the cached image, pixel-align the position to keep a sharper result. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D235840
This commit is contained in:
Jonathan Kew
2025-01-29 17:39:40 +00:00
parent dfe44c03b7
commit e60dcec5cc
3 changed files with 24 additions and 19 deletions

View File

@@ -43,7 +43,7 @@ pref(layout.css.backdrop-filter.enabled,true) == 1765862.html 1765862-ref.html
skip-if(!cocoaWidget) != 1806140.html 1806140-notref.html
fuzzy(0-1,0-240) == 1812341.html 1812341-ref.html
random-if(gtkWidget) fuzzy-if(Android,0-125,0-106) fuzzy-if(winWidget,0-255,0-44) == 1845828-1.html 1845828-1-ref.html # Result on Linux depends on font configuration/hinting/etc, affecting whether subpixel positioning is used
fuzzy-if(!winWidget,0-2,0-106) fuzzy-if(winWidget,14-14,245-314) == 1853216-1.html 1853216-1-ref.html
fuzzy-if(!winWidget,0-2,0-106) fuzzy-if(winWidget,0-14,0-314) == 1853216-1.html 1853216-1-ref.html
fuzzy-if(winWidget,0-1,0-13) == 1873708-emoji-canvas-filter.html 1873708-emoji-canvas-filter-ref.html
!= 1870240-colrv1-cycle.html 1870240-colrv1-cycle-notref.html
== 1909933.html 1909933-ref.html

View File

@@ -2726,14 +2726,18 @@ bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext,
}
}
const int kScale = 2;
if (!snapshot) {
// Create a temporary DrawTarget and render the glyph to it.
IntSize size(int(bounds.width), int(bounds.height));
SurfaceFormat format = SurfaceFormat::B8G8R8A8;
RefPtr target =
Factory::CreateDrawTarget(BackendType::SKIA, size, format);
Factory::CreateDrawTarget(BackendType::SKIA, size * kScale, format);
if (target) {
// Use OP_OVER and opaque alpha to create the glyph snapshot.
Matrix m;
m.PreScale(kScale, kScale);
target->SetTransform(m);
DrawOptions drawOptions(aFontParams.drawOptions);
drawOptions.mCompositionOp = CompositionOp::OP_OVER;
drawOptions.mAlpha = 1.0f;
@@ -2764,10 +2768,11 @@ bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext,
}
if (snapshot) {
// Paint the snapshot using the appropriate composition op.
aDrawTarget->DrawSurface(snapshot,
Rect(aPoint + bounds.TopLeft(), bounds.Size()),
Rect(Point(), bounds.Size()),
DrawSurfaceOptions(), aFontParams.drawOptions);
Point snappedPoint = Point(roundf(aPoint.x), roundf(aPoint.y));
aDrawTarget->DrawSurface(
snapshot, Rect(snappedPoint + bounds.TopLeft(), bounds.Size()),
Rect(Point(), bounds.Size() * kScale), DrawSurfaceOptions(),
aFontParams.drawOptions);
return true;
}
}

View File

@@ -154,9 +154,9 @@ HTTP(..) == font-redirect.html order-1-ref.html
== dynamic-duplicate-rule-1c.html dynamic-duplicate-rule-1-ref.html
# Test for COLR and CPAL support
fuzzy-if(cocoaWidget,154-198,172-172) == color-1a.html color-1-ref.html
fuzzy(0-198,0-172) == color-1a.html color-1-ref.html
!= color-1a.html color-1-notref.html
fuzzy-if(cocoaWidget,154-198,172-172) == color-1b.html color-1-ref.html
fuzzy(0-198,0-172) == color-1b.html color-1-ref.html
== color-2a.html color-2-ref.html
!= color-2a.html color-2-notref.html
@@ -169,18 +169,18 @@ defaults pref(gfx.font_rendering.colr_v1.enabled,true)
fuzzy(0-64,0-200) == colrv1-01.html#A colrv1-01-ref.html#A
fuzzy(0-32,0-200) == colrv1-01.html#B colrv1-01-ref.html#B
fuzzy(0-8,0-10100) == colrv1-01.html#C colrv1-01-ref.html#C
fuzzy(0-64,0-600) == colrv1-01.html#D colrv1-01-ref.html#D
fuzzy(0-64,0-398) == colrv1-01.html#E colrv1-01-ref.html#E
fuzzy(0-64,0-398) == colrv1-01.html#F colrv1-01-ref.html#F
fuzzy(0-64,0-596) == colrv1-01.html#G colrv1-01-ref.html#G
fuzzy(0-64,0-596) == colrv1-01.html#H colrv1-01-ref.html#H
fuzzy(0-64,0-7000) == colrv1-01.html#D colrv1-01-ref.html#D
fuzzy(0-64,0-3000) == colrv1-01.html#E colrv1-01-ref.html#E
fuzzy(0-64,0-3000) == colrv1-01.html#F colrv1-01-ref.html#F
fuzzy(0-64,0-3400) == colrv1-01.html#G colrv1-01-ref.html#G
fuzzy(0-64,0-3400) == colrv1-01.html#H colrv1-01-ref.html#H
fuzzy(0-64,0-10100) == colrv1-01.html#I colrv1-01-ref.html#I
fuzzy(0-64,0-6806) == colrv1-01.html#J colrv1-01-ref.html#J
fuzzy(0-1,0-748) == colrv1-01.html#K colrv1-01-ref.html#K
fuzzy(0-129,0-7448) == colrv1-01.html#K colrv1-01-ref.html#K
fuzzy(0-67,0-9494) == colrv1-01.html#L colrv1-01-ref.html#L
fuzzy(0-64,0-3578) == colrv1-01.html#M colrv1-01-ref.html#M
fuzzy(0-64,0-7636) == colrv1-01.html#M colrv1-01-ref.html#M
fuzzy(0-64,0-6116) == colrv1-01.html#N colrv1-01-ref.html#N
fuzzy(0-80,0-5491) == colrv1-01.html#O colrv1-01-ref.html#O
fuzzy(0-80,0-6626) == colrv1-01.html#O colrv1-01-ref.html#O
fuzzy(0-112,0-300) == colrv1-01.html#P colrv1-01-ref.html#P
fuzzy(0-149,0-484) == colrv1-01.html#Q colrv1-01-ref.html#Q
fuzzy(0-214,0-461) == colrv1-01.html#R colrv1-01-ref.html#R
@@ -188,9 +188,9 @@ fuzzy(0-255,0-373) == colrv1-01.html#S colrv1-01-ref.html#S
fuzzy(0-255,0-290) == colrv1-01.html#T colrv1-01-ref.html#T
fuzzy(0-1,0-1) == colrv1-03.html colrv1-03-ref.html
fuzzy(0-1,0-1800) fuzzy-if(Android,0-64,0-37100) == colrv1-04.html colrv1-04-ref.html
fuzzy-if(Android,8-8,1484-1484) == colrv1-05.html colrv1-05-ref.html
fuzzy(0-1,0-291) == colrv1-06.html colrv1-06-ref.html
fuzzy(0-1,0-38200) fuzzy-if(Android,0-64,0-37100) == colrv1-04.html colrv1-04-ref.html
fuzzy(0-65,0-6105) == colrv1-05.html colrv1-05-ref.html
fuzzy(0-1,0-318) == colrv1-06.html colrv1-06-ref.html
fuzzy(0-128,0-264) == colrv1-07.html colrv1-07-ref.html
== colrv1-08.html colrv1-08-ref.html
== colrv1-09.html colrv1-09-ref.html