1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /// This shader renders solid colors or simple images in a color or alpha target.
10 varying highp vec2 vLocalPos;
13 #ifdef WR_VERTEX_SHADER
15 PrimitiveInfo info = ps_quad_main();
17 #ifndef SWGL_ANTIALIAS
18 RectWithEndpoint xf_bounds = RectWithEndpoint(
19 max(info.local_prim_rect.p0, info.local_clip_rect.p0),
20 min(info.local_prim_rect.p1, info.local_clip_rect.p1)
22 vTransformBounds = vec4(xf_bounds.p0, xf_bounds.p1);
24 vLocalPos = info.local_pos;
26 if (info.edge_flags == 0) {
33 if ((info.quad_flags & QF_SAMPLE_AS_MASK) != 0) {
41 #ifdef WR_FRAGMENT_SHADER
45 #ifndef SWGL_ANTIALIAS
47 float alpha = init_transform_fs(vLocalPos);
53 vec2 uv = clamp(v_uv, v_uv_sample_bounds.xy, v_uv_sample_bounds.zw);
54 vec4 texel = TEX_SAMPLE(sColor0, uv);
64 #if defined(SWGL_DRAW_SPAN)
65 void swgl_drawSpanRGBA8() {
68 // Fall back to fragment shader as we don't specialize for mask yet. Perhaps
69 // we can use an existing swgl commit or add a new one though?
71 swgl_commitTextureLinearColorRGBA8(sColor0, v_uv, v_uv_sample_bounds, v_color);
74 swgl_commitSolidRGBA8(v_color);