tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ps_quad_textured.glsl (2081B)


      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/. */
      4 
      5 /// This shader renders solid colors or simple images in a color or alpha target.
      6 
      7 #include ps_quad,sample_color0
      8 
      9 #define v_flags_textured v_flags.x
     10 
     11 #ifdef WR_VERTEX_SHADER
     12 
     13 void pattern_vertex(PrimitiveInfo info) {
     14     // Note: Since the uv rect is passed via segments, This shader cannot sample from a
     15     // texture if no segments are provided
     16     if (info.segment.uv_rect.p0 != info.segment.uv_rect.p1) {
     17         // Textured
     18         v_flags_textured = 1;
     19         // TODO: Ideally we would unconditionally modulate the texture with the provided
     20         // base color, however we are currently getting glitches on Adreno GPUs on Windows
     21         // if the base color is set to white for composite primitives. While we figure this
     22         // out, v_color is forced to white here in the textured case, which restores the
     23         // behavior from before the patch that introduced the glitches.
     24         // See comment in `add_composite_prim`.
     25         v_color = vec4(1.0);
     26 
     27         vec2 f = (info.local_pos - info.segment.rect.p0) / rect_size(info.segment.rect);
     28         vs_init_sample_color0(f, info.segment.uv_rect);
     29     } else {
     30         // Solid color
     31         v_flags_textured = 0;
     32     }
     33 }
     34 
     35 #endif
     36 
     37 #ifdef WR_FRAGMENT_SHADER
     38 
     39 vec4 pattern_fragment(vec4 color) {
     40     if (v_flags_textured != 0) {
     41         vec4 texel = fs_sample_color0();
     42         color *= texel;
     43     }
     44 
     45     return color;
     46 }
     47 
     48 #if defined(SWGL_DRAW_SPAN)
     49 void swgl_drawSpanRGBA8() {
     50     if (v_flags_textured != 0) {
     51         if (v_flags_is_mask != 0) {
     52             // Fall back to fragment shader as we don't specialize for mask yet. Perhaps
     53             // we can use an existing swgl commit or add a new one though?
     54         } else {
     55             swgl_commitTextureLinearColorRGBA8(sColor0, v_uv0, v_uv0_sample_bounds, v_color);
     56         }
     57     } else {
     58         swgl_commitSolidRGBA8(v_color);
     59     }
     60 }
     61 #endif
     62 
     63 #endif