Skip to content

Commit

Permalink
Update WR and shaders (initial subpixel AA work).
Browse files Browse the repository at this point in the history
  • Loading branch information
gw3583 committed Nov 8, 2016
1 parent 784ca17 commit e9c6ee3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
18 changes: 9 additions & 9 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/servo/lib.rs
Expand Up @@ -166,6 +166,7 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
precache_shaders: opts.precache_shaders,
enable_scrollbars: opts.output_file.is_none(),
renderer_kind: renderer_kind,
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
})
};

Expand Down
11 changes: 11 additions & 0 deletions components/util/opts.rs
Expand Up @@ -109,6 +109,11 @@ pub struct Opts {
/// font for layout tests.
pub enable_text_antialiasing: bool,

/// If set with --enable-subpixel, use subpixel antialiasing for glyphs. In the future
/// this will likely become the default, but for now it's opt-in while we work
/// out any bugs and improve the implementation.
pub enable_subpixel_text_antialiasing: bool,

/// If set with --disable-canvas-aa, disable antialiasing on the HTML canvas element.
/// Like --disable-text-aa, this is useful for reftests where pixel perfect results are required.
pub enable_canvas_antialiasing: bool,
Expand Down Expand Up @@ -241,6 +246,9 @@ pub struct DebugOptions {
/// Disable antialiasing of rendered text.
pub disable_text_aa: bool,

/// Enable subpixel antialiasing of rendered text.
pub enable_subpixel_aa: bool,

/// Disable antialiasing of rendered text on the HTML canvas element.
pub disable_canvas_aa: bool,

Expand Down Expand Up @@ -343,6 +351,7 @@ impl DebugOptions {
"help" => debug_options.help = true,
"bubble-widths" => debug_options.bubble_widths = true,
"disable-text-aa" => debug_options.disable_text_aa = true,
"enable-subpixel-aa" => debug_options.enable_subpixel_aa = true,
"disable-canvas-aa" => debug_options.disable_text_aa = true,
"dump-style-tree" => debug_options.dump_style_tree = true,
"dump-rule-tree" => debug_options.dump_rule_tree = true,
Expand Down Expand Up @@ -516,6 +525,7 @@ pub fn default_opts() -> Opts {
show_debug_parallel_layout: false,
paint_flashing: false,
enable_text_antialiasing: false,
enable_subpixel_text_antialiasing: false,
enable_canvas_antialiasing: false,
trace_layout: false,
debugger_port: None,
Expand Down Expand Up @@ -830,6 +840,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
show_debug_parallel_layout: debug_options.show_parallel_layout,
paint_flashing: debug_options.paint_flashing,
enable_text_antialiasing: !debug_options.disable_text_aa,
enable_subpixel_text_antialiasing: debug_options.enable_subpixel_aa,
enable_canvas_antialiasing: !debug_options.disable_canvas_aa,
dump_style_tree: debug_options.dump_style_tree,
dump_rule_tree: debug_options.dump_rule_tree,
Expand Down
18 changes: 9 additions & 9 deletions ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions resources/shaders/ps_text_run.fs.glsl
Expand Up @@ -3,11 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

void main(void) {
#ifdef WR_FEATURE_SUBPIXEL_AA
oFragColor = texture(sDiffuse, vUv);
#else
float a = texture(sDiffuse, vUv).a;
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
init_transform_fs(vLocalPos, vLocalRect, alpha);
a *= alpha;
#endif
oFragColor = vec4(vColor.rgb, vColor.a * a);
#endif
}

0 comments on commit e9c6ee3

Please sign in to comment.