Bug 1615613 - Make the text fragment shader compatible with the brush infrastructure. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D63093

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Silva 2020-02-18 13:32:24 +00:00
Родитель 60706288cf
Коммит e4cabee633
3 изменённых файлов: 41 добавлений и 22 удалений

Просмотреть файл

@ -249,13 +249,6 @@ void main(void) {
#ifdef WR_FRAGMENT_SHADER
struct Fragment {
vec4 color;
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
vec4 blend;
#endif
};
// Foward-declare all brush entry-points.
Fragment image_brush_fs();
Fragment solid_brush_fs();
@ -266,6 +259,7 @@ Fragment radial_gradient_brush_fs();
Fragment conic_gradient_brush_fs();
Fragment yuv_brush_fs();
Fragment opacity_brush_fs();
Fragment text_brush_fs();
Fragment multi_brush_fs(int brush_kind);
void main(void) {

Просмотреть файл

@ -241,6 +241,14 @@ vec2 get_image_quad_uv(int address, vec2 f) {
#ifdef WR_FRAGMENT_SHADER
struct Fragment {
vec4 color;
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
vec4 blend;
#endif
};
float do_clip() {
// check for the dummy bounds, which are given to the opaque objects
if (vClipMaskUvBounds.xy == vClipMaskUvBounds.zw) {

Просмотреть файл

@ -273,24 +273,41 @@ void main(void) {
#endif
#ifdef WR_FRAGMENT_SHADER
void main(void) {
Fragment text_brush_fs(void) {
Fragment frag;
vec3 tc = vec3(clamp(V_UV, V_UV_BOUNDS.xy, V_UV_BOUNDS.zw), V_LAYER);
vec4 mask = texture(sColor0, tc);
mask.rgb = mask.rgb * V_MASK_SWIZZLE.x + mask.aaa * V_MASK_SWIZZLE.y;
float alpha = do_clip();
#ifdef WR_FEATURE_GLYPH_TRANSFORM
alpha *= float(all(greaterThanEqual(V_UV_CLIP, vec4(0.0))));
mask *= float(all(greaterThanEqual(V_UV_CLIP, vec4(0.0))));
#endif
frag.color = V_COLOR * mask;
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
frag.blend = V_COLOR.a * mask;
#endif
return frag;
}
void main(void) {
Fragment frag = text_brush_fs();
float clip_mask = do_clip();
frag.color *= clip_mask;
#if defined(WR_FEATURE_DEBUG_OVERDRAW)
oFragColor = WR_DEBUG_OVERDRAW_COLOR;
#elif defined(WR_FEATURE_DUAL_SOURCE_BLENDING)
vec4 alpha_mask = mask * alpha;
oFragColor = V_COLOR * alpha_mask;
oFragBlend = alpha_mask * V_COLOR.a;
oFragColor = frag.color;
oFragBlend = frag.blend * clip_mask;
#else
write_output(V_COLOR * mask * alpha);
write_output(frag.color);
#endif
}
#endif
#endif // WR_FRAGMENT_SHADER