Repository: alacritty/alacritty
File: alacritty/src/renderer/text/gles2.rs (Rust)

Code before:
    // Color.
    r: u8,
    g: u8,
    b: u8,

    // Whether the glyph is colored.
    colored: RenderingGlyphFlags,

    // Background color.
    bg_r: u8,
    bg_g: u8,
    bg_b: u8,
    bg_a: u8,
}

#[derive(Debug)]
pub struct TextShaderProgram {
    /// Shader program.
    program: ShaderProgram,

    /// Projection scale and offset uniform.
    u_projection: GLint,

    /// Rendering pass.
    ///
    /// For dual source blending, there're 2 passes, one for background, another for text,
    /// similar to the GLSL3 renderer.
    ///
    /// If GL_EXT_blend_func_extended is not available, the rendering is split into 4 passes.
    /// One is used for the background and the rest to perform subpixel text rendering according to
    /// https://github.com/servo/webrender/blob/master/webrender/doc/text-rendering.md.
    ///
    /// Rendering is split into three passes.
    u_rendering_pass: GLint,
}

impl TextShaderProgram {
    pub fn new(shader_version: ShaderVersion, dual_source_blending: bool) -> Result<Self, Error> {
        let fragment_shader =
            if dual_source_blending { &glsl3::TEXT_SHADER_F } else { &TEXT_SHADER_F };

        let program = ShaderProgram::new(shader_version, TEXT_SHADER_V, fragment_shader)?;

        Ok(Self {
            u_projection: program.get_uniform_location(cstr!("projection"))?,
            u_rendering_pass: program.get_uniform_location(cstr!("renderingPass"))?,
            program,
        })
    }

    fn set_rendering_pass(&self, rendering_pass: RenderingPass) {

Review comment (bug):
I don't think it's gramatically incorrect, but "there're" is a bit awkward. So I'd suggest changing it:

```suggestion
    /// For dual source blending, there are 2 passes; one for background, another for text,
```

Code after:
    // Color.
    r: u8,
    g: u8,
    b: u8,

    // Whether the glyph is colored.
    colored: RenderingGlyphFlags,

    // Background color.
    bg_r: u8,
    bg_g: u8,
    bg_b: u8,
    bg_a: u8,
}

#[derive(Debug)]
pub struct TextShaderProgram {
    /// Shader program.
    program: ShaderProgram,

    /// Projection scale and offset uniform.
    u_projection: GLint,

    /// Rendering pass.
    ///
    /// For dual source blending, there are 2 passes; one for background, another for text,
    /// similar to the GLSL3 renderer.
    ///
    /// If GL_EXT_blend_func_extended is not available, the rendering is split into 4 passes.
    /// One is used for the background and the rest to perform subpixel text rendering according to
    /// https://github.com/servo/webrender/blob/master/webrender/doc/text-rendering.md.
    ///
    /// Rendering is split into three passes.
    u_rendering_pass: GLint,
}

impl TextShaderProgram {
    pub fn new(shader_version: ShaderVersion, dual_source_blending: bool) -> Result<Self, Error> {
        let fragment_shader =
            if dual_source_blending { &glsl3::TEXT_SHADER_F } else { &TEXT_SHADER_F };

        let program = ShaderProgram::new(shader_version, TEXT_SHADER_V, fragment_shader)?;

        Ok(Self {
            u_projection: program.get_uniform_location(cstr!("projection"))?,
            u_rendering_pass: program.get_uniform_location(cstr!("renderingPass"))?,
            program,
        })
    }

    fn set_rendering_pass(&self, rendering_pass: RenderingPass) {