mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1514179
- Update webrender to commit b8096a76030818c960a6111666c8b1213b5da25a (WR PR #3412). r=kats
https://github.com/servo/webrender/pull/3412 Differential Revision: https://phabricator.services.mozilla.com/D14536 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
372979b6e0
commit
f5809bd2c3
@ -23,7 +23,7 @@ default-features = false
|
|||||||
features = ["capture", "serialize_program"]
|
features = ["capture", "serialize_program"]
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
dwrote = "0.6.2"
|
dwrote = "0.6.3"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-foundation = "0.6"
|
core-foundation = "0.6"
|
||||||
|
@ -1 +1 @@
|
|||||||
22f3f356ea1a9fe2760cd4a609cba78614e428c4
|
b8096a76030818c960a6111666c8b1213b5da25a
|
||||||
|
10
gfx/wr/Cargo.lock
generated
10
gfx/wr/Cargo.lock
generated
@ -362,7 +362,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dwrote"
|
name = "dwrote"
|
||||||
version = "0.6.2"
|
version = "0.6.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1541,7 +1541,7 @@ dependencies = [
|
|||||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dwrote 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1593,7 +1593,7 @@ dependencies = [
|
|||||||
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dwrote 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1672,7 +1672,7 @@ dependencies = [
|
|||||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dwrote 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"font-loader 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"font-loader 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1800,7 +1800,7 @@ dependencies = [
|
|||||||
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
|
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
|
||||||
"checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c"
|
"checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c"
|
||||||
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
|
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
|
||||||
"checksum dwrote 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b46afd0d0bbbea88fc083ea293e40865e26a75ec9d38cf5d05a23ac3e2ffe02"
|
"checksum dwrote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f0beca78470f26189a662e72afe7a54c625b4feb06b2d36c207ac15319bd57c5"
|
||||||
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
|
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
|
||||||
"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a"
|
"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a"
|
||||||
"checksum euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"
|
"checksum euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"
|
||||||
|
@ -74,7 +74,7 @@ rand = "0.4"
|
|||||||
freetype = { version = "0.4", default-features = false }
|
freetype = { version = "0.4", default-features = false }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
dwrote = "0.6.2"
|
dwrote = "0.6.3"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-foundation = "0.6"
|
core-foundation = "0.6"
|
||||||
|
@ -160,7 +160,9 @@ impl<'a> From<&'a LayoutToWorldTransform> for FontTransform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const FONT_SIZE_LIMIT: f64 = 1024.0;
|
// Some platforms (i.e. Windows) may have trouble rasterizing glyphs above this size.
|
||||||
|
// Ensure glyph sizes are reasonably limited to avoid that scenario.
|
||||||
|
pub const FONT_SIZE_LIMIT: f64 = 512.0;
|
||||||
|
|
||||||
#[derive(Clone, Hash, PartialEq, Eq, Debug, Ord, PartialOrd)]
|
#[derive(Clone, Hash, PartialEq, Eq, Debug, Ord, PartialOrd)]
|
||||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||||
|
@ -253,7 +253,7 @@ impl FontContext {
|
|||||||
size: f32,
|
size: f32,
|
||||||
transform: Option<dwrote::DWRITE_MATRIX>,
|
transform: Option<dwrote::DWRITE_MATRIX>,
|
||||||
bitmaps: bool,
|
bitmaps: bool,
|
||||||
) -> dwrote::GlyphRunAnalysis {
|
) -> (dwrote::GlyphRunAnalysis, dwrote::DWRITE_TEXTURE_TYPE, dwrote::RECT) {
|
||||||
let face = self.get_font_face(font);
|
let face = self.get_font_face(font);
|
||||||
let glyph = key.index() as u16;
|
let glyph = key.index() as u16;
|
||||||
let advance = 0.0f32;
|
let advance = 0.0f32;
|
||||||
@ -282,7 +282,7 @@ impl FontContext {
|
|||||||
bitmaps,
|
bitmaps,
|
||||||
);
|
);
|
||||||
|
|
||||||
dwrote::GlyphRunAnalysis::create(
|
let analysis = dwrote::GlyphRunAnalysis::create(
|
||||||
&glyph_run,
|
&glyph_run,
|
||||||
1.0,
|
1.0,
|
||||||
transform,
|
transform,
|
||||||
@ -290,7 +290,28 @@ impl FontContext {
|
|||||||
dwrite_measure_mode,
|
dwrite_measure_mode,
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
)
|
);
|
||||||
|
let texture_type = dwrite_texture_type(font.render_mode);
|
||||||
|
let bounds = analysis.get_alpha_texture_bounds(texture_type);
|
||||||
|
// If the bounds are empty, then we might not be able to render the glyph with cleartype.
|
||||||
|
// Try again with aliased rendering to check if that works instead.
|
||||||
|
if font.render_mode != FontRenderMode::Mono &&
|
||||||
|
(bounds.left == bounds.right || bounds.top == bounds.bottom) {
|
||||||
|
let analysis2 = dwrote::GlyphRunAnalysis::create(
|
||||||
|
&glyph_run,
|
||||||
|
1.0,
|
||||||
|
transform,
|
||||||
|
dwrote::DWRITE_RENDERING_MODE_ALIASED,
|
||||||
|
dwrite_measure_mode,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
);
|
||||||
|
let bounds2 = analysis2.get_alpha_texture_bounds(dwrote::DWRITE_TEXTURE_ALIASED_1x1);
|
||||||
|
if bounds2.left != bounds2.right && bounds2.top != bounds2.bottom {
|
||||||
|
return (analysis2, dwrote::DWRITE_TEXTURE_ALIASED_1x1, bounds2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(analysis, texture_type, bounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_glyph_index(&mut self, font_key: FontKey, ch: char) -> Option<u32> {
|
pub fn get_glyph_index(&mut self, font_key: FontKey, ch: char) -> Option<u32> {
|
||||||
@ -334,11 +355,7 @@ impl FontContext {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let analysis = self.create_glyph_analysis(font, key, size, transform, bitmaps);
|
let (_, _, bounds) = self.create_glyph_analysis(font, key, size, transform, bitmaps);
|
||||||
|
|
||||||
let texture_type = dwrite_texture_type(font.render_mode);
|
|
||||||
|
|
||||||
let bounds = analysis.get_alpha_texture_bounds(texture_type);
|
|
||||||
|
|
||||||
let width = (bounds.right - bounds.left) as i32;
|
let width = (bounds.right - bounds.left) as i32;
|
||||||
let height = (bounds.bottom - bounds.top) as i32;
|
let height = (bounds.bottom - bounds.top) as i32;
|
||||||
@ -373,11 +390,12 @@ impl FontContext {
|
|||||||
fn convert_to_bgra(
|
fn convert_to_bgra(
|
||||||
&self,
|
&self,
|
||||||
pixels: &[u8],
|
pixels: &[u8],
|
||||||
|
texture_type: dwrote::DWRITE_TEXTURE_TYPE,
|
||||||
render_mode: FontRenderMode,
|
render_mode: FontRenderMode,
|
||||||
bitmaps: bool,
|
bitmaps: bool,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
match (render_mode, bitmaps) {
|
match (texture_type, render_mode, bitmaps) {
|
||||||
(FontRenderMode::Mono, _) => {
|
(dwrote::DWRITE_TEXTURE_ALIASED_1x1, _, _) => {
|
||||||
let mut bgra_pixels: Vec<u8> = vec![0; pixels.len() * 4];
|
let mut bgra_pixels: Vec<u8> = vec![0; pixels.len() * 4];
|
||||||
for i in 0 .. pixels.len() {
|
for i in 0 .. pixels.len() {
|
||||||
let alpha = pixels[i];
|
let alpha = pixels[i];
|
||||||
@ -388,7 +406,18 @@ impl FontContext {
|
|||||||
}
|
}
|
||||||
bgra_pixels
|
bgra_pixels
|
||||||
}
|
}
|
||||||
(FontRenderMode::Alpha, _) | (_, true) => {
|
(_, FontRenderMode::Subpixel, false) => {
|
||||||
|
let length = pixels.len() / 3;
|
||||||
|
let mut bgra_pixels: Vec<u8> = vec![0; length * 4];
|
||||||
|
for i in 0 .. length {
|
||||||
|
bgra_pixels[i * 4 + 0] = pixels[i * 3 + 2];
|
||||||
|
bgra_pixels[i * 4 + 1] = pixels[i * 3 + 1];
|
||||||
|
bgra_pixels[i * 4 + 2] = pixels[i * 3 + 0];
|
||||||
|
bgra_pixels[i * 4 + 3] = 0xff;
|
||||||
|
}
|
||||||
|
bgra_pixels
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
let length = pixels.len() / 3;
|
let length = pixels.len() / 3;
|
||||||
let mut bgra_pixels: Vec<u8> = vec![0; length * 4];
|
let mut bgra_pixels: Vec<u8> = vec![0; length * 4];
|
||||||
for i in 0 .. length {
|
for i in 0 .. length {
|
||||||
@ -401,17 +430,6 @@ impl FontContext {
|
|||||||
}
|
}
|
||||||
bgra_pixels
|
bgra_pixels
|
||||||
}
|
}
|
||||||
(FontRenderMode::Subpixel, false) => {
|
|
||||||
let length = pixels.len() / 3;
|
|
||||||
let mut bgra_pixels: Vec<u8> = vec![0; length * 4];
|
|
||||||
for i in 0 .. length {
|
|
||||||
bgra_pixels[i * 4 + 0] = pixels[i * 3 + 2];
|
|
||||||
bgra_pixels[i * 4 + 1] = pixels[i * 3 + 1];
|
|
||||||
bgra_pixels[i * 4 + 2] = pixels[i * 3 + 0];
|
|
||||||
bgra_pixels[i * 4 + 3] = 0xff;
|
|
||||||
}
|
|
||||||
bgra_pixels
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,13 +486,10 @@ impl FontContext {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let analysis = self.create_glyph_analysis(font, key, size, transform, bitmaps);
|
let (analysis, texture_type, bounds) = self.create_glyph_analysis(font, key, size, transform, bitmaps);
|
||||||
let texture_type = dwrite_texture_type(font.render_mode);
|
|
||||||
|
|
||||||
let bounds = analysis.get_alpha_texture_bounds(texture_type);
|
|
||||||
let width = (bounds.right - bounds.left) as i32;
|
let width = (bounds.right - bounds.left) as i32;
|
||||||
let height = (bounds.bottom - bounds.top) as i32;
|
let height = (bounds.bottom - bounds.top) as i32;
|
||||||
|
|
||||||
// Alpha texture bounds can sometimes return an empty rect
|
// Alpha texture bounds can sometimes return an empty rect
|
||||||
// Such as for spaces
|
// Such as for spaces
|
||||||
if width == 0 || height == 0 {
|
if width == 0 || height == 0 {
|
||||||
@ -482,7 +497,7 @@ impl FontContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let pixels = analysis.create_alpha_texture(texture_type, bounds);
|
let pixels = analysis.create_alpha_texture(texture_type, bounds);
|
||||||
let mut bgra_pixels = self.convert_to_bgra(&pixels, font.render_mode, bitmaps);
|
let mut bgra_pixels = self.convert_to_bgra(&pixels, texture_type, font.render_mode, bitmaps);
|
||||||
|
|
||||||
// These are the default values we use in Gecko.
|
// These are the default values we use in Gecko.
|
||||||
// We use a gamma value of 2.3 for gdi fonts
|
// We use a gamma value of 2.3 for gdi fonts
|
||||||
@ -509,13 +524,21 @@ impl FontContext {
|
|||||||
));
|
));
|
||||||
gamma_lut.preblend(&mut bgra_pixels, font.color);
|
gamma_lut.preblend(&mut bgra_pixels, font.color);
|
||||||
|
|
||||||
|
let format = if bitmaps {
|
||||||
|
GlyphFormat::Bitmap
|
||||||
|
} else if texture_type == dwrote::DWRITE_TEXTURE_ALIASED_1x1 {
|
||||||
|
font.get_alpha_glyph_format()
|
||||||
|
} else {
|
||||||
|
font.get_glyph_format()
|
||||||
|
};
|
||||||
|
|
||||||
GlyphRasterResult::Bitmap(RasterizedGlyph {
|
GlyphRasterResult::Bitmap(RasterizedGlyph {
|
||||||
left: bounds.left as f32,
|
left: bounds.left as f32,
|
||||||
top: -bounds.top as f32,
|
top: -bounds.top as f32,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
scale: (if bitmaps { scale / y_scale } else { scale }) as f32,
|
scale: (if bitmaps { scale / y_scale } else { scale }) as f32,
|
||||||
format: if bitmaps { GlyphFormat::Bitmap } else { font.get_glyph_format() },
|
format,
|
||||||
bytes: bgra_pixels,
|
bytes: bgra_pixels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,4 @@ core-foundation = "0.6"
|
|||||||
core-graphics = "0.17.1"
|
core-graphics = "0.17.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
dwrote = "0.6.2"
|
dwrote = "0.6.3"
|
||||||
|
@ -39,7 +39,7 @@ headless = [ "osmesa-sys", "osmesa-src" ]
|
|||||||
pathfinder = [ "webrender/pathfinder" ]
|
pathfinder = [ "webrender/pathfinder" ]
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
dwrote = "0.6.2"
|
dwrote = "0.6.3"
|
||||||
mozangle = {version = "0.1.5", features = ["egl"]}
|
mozangle = {version = "0.1.5", features = ["egl"]}
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(target_os = "android")))'.dependencies]
|
[target.'cfg(all(unix, not(target_os = "android")))'.dependencies]
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
== decorations.yaml decorations-ref.yaml
|
== decorations.yaml decorations-ref.yaml
|
||||||
fuzzy(1,173) == decorations-suite.yaml decorations-suite.png
|
fuzzy(1,173) == decorations-suite.yaml decorations-suite.png
|
||||||
== 1658.yaml 1658-ref.yaml
|
== 1658.yaml 1658-ref.yaml
|
||||||
== split-batch.yaml split-batch-ref.yaml
|
fuzzy(1,5) == split-batch.yaml split-batch-ref.yaml
|
||||||
== shadow-red.yaml shadow-red-ref.yaml
|
== shadow-red.yaml shadow-red-ref.yaml
|
||||||
fuzzy(1,735) == shadow-grey.yaml shadow-grey-ref.yaml
|
fuzzy(1,735) == shadow-grey.yaml shadow-grey-ref.yaml
|
||||||
fuzzy(1,663) == shadow-grey-transparent.yaml shadow-grey-ref.yaml
|
fuzzy(1,663) == shadow-grey-transparent.yaml shadow-grey-ref.yaml
|
||||||
|
Loading…
Reference in New Issue
Block a user