Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync changes from mozilla-central gfx/wr #3833

Merged
merged 32 commits into from Jan 15, 2020
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1d95e5d
Bug 1606827 - A corner is not rounded when the radius is zero in eith…
SimonSapin Jan 15, 2020
8e3220d
Bug 1595767 - Don't use rayon for glyph rasterization unless there is…
bpeersmoz Jan 15, 2020
4a2f3cf
Bug 1607352 - Support DirectComposition virtual surface API. r=sotaro
Jan 15, 2020
8b55532
Bug 1606685 - Support empty tiles within compositor surfaces. r=sotaro
Jan 15, 2020
2a5c1b3
Bug 1607419 - Avoid option.expect(&format in hot code. r=jrmuizel
nical Jan 15, 2020
c5a8d9a
Bug 1607697 - Address some clippy lints in WebRender API. r=Gankro
nical Jan 15, 2020
6e0321a
Bug 1607697 - Remove leading zeros in dither matrix litterals. r=Gankro
nical Jan 15, 2020
2958cde
Bug 1607697 - Allow excessive precision in debug color constants. r=G…
nical Jan 15, 2020
4509d8f
Bug 1607697 - Address unwrap_or_else(callback) and functions in callb…
nical Jan 15, 2020
3597f88
Bug 1607697 - Address clippy lints about nested branches. r=Gankro
nical Jan 15, 2020
f4171db
Bug 1607697 - Pass-by-value clippy lints for some small structures. r…
nical Jan 15, 2020
f8796d8
Bug 1607697 - Box the memory reports in enums. r=Gankro
nical Jan 15, 2020
c76840d
Bug 1607697 - Miscellaneous clippy lint fixes. r=Gankro
nical Jan 15, 2020
a74df4e
Backed out 8 changesets (bug 1607697) for Build bustages. CLOSED TREE
dgluca Jan 15, 2020
d3458da
Bug 1607697 - Address some clippy lints in WebRender API. r=Gankro
nical Jan 15, 2020
f7e0447
Bug 1607697 - Remove leading zeros in dither matrix litterals. r=Gankro
nical Jan 15, 2020
8e23cfc
Bug 1607697 - Allow excessive precision in debug color constants. r=G…
nical Jan 15, 2020
4510da2
Bug 1607697 - Address unwrap_or_else(callback) and functions in callb…
nical Jan 15, 2020
d2dab4f
Bug 1607697 - Address clippy lints about nested branches. r=Gankro
nical Jan 15, 2020
4fe4faa
Bug 1607697 - Pass-by-value clippy lints for some small structures. r…
nical Jan 15, 2020
4a21991
Bug 1607697 - Box the memory reports in enums. r=Gankro
nical Jan 15, 2020
7b98dfb
Bug 1607697 - Miscellaneous clippy lint fixes. r=Gankro
nical Jan 15, 2020
b383cb6
Bug 1607697 - Address servo-tidy complaint.
nical Jan 15, 2020
b25c1f8
Bug 1608280 - Support a per-tile clip (valid) region for compositor t…
gw3583 Jan 15, 2020
67f9d48
Bug 1607746 - Part 1: Move opacity to its own shader in WebRender r=n…
cbrewster Jan 15, 2020
b549115
Bug 1607746 - Part 2: Clean up passing filter mode to shader r=nical
cbrewster Jan 15, 2020
3ddb13b
Backed out changeset 7295ca89e880 (bug 1608280) for causing bug 16089…
AndreeaPavel Jan 15, 2020
3b18bde
Merge mozilla-central to autoland on a CLOSED TREE
AndreeaPavel Jan 15, 2020
c9fe1c3
Bug 1609049 - WebRender version bump. r=jrmuizel
nical Jan 15, 2020
3167089
Bug 1609049 - Add required fileds in peek-poke Cargo.toml. r=jrmuizel
nical Jan 15, 2020
2b9f40d
Bug 1609136 - Fix cs_border_solid attribute names r=jrmuizel
kvark Jan 15, 2020
93c7a2b
Bug 1605171 - Replace wrupdater with github-sync r=tomprince
kvark Jan 15, 2020
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Bug 1607746 - Part 2: Clean up passing filter mode to shader r=nical

I removed the old opacity filter path in the brush_blend shader and cleaned up the filter mode
constants in the shader so there are less magic numbers. This should help if/when we move more
filters to their own shaders.

Depends on D59610

Differential Revision: https://phabricator.services.mozilla.com/D59611

[ghsync] From https://hg.mozilla.org/mozilla-central/rev/5cd63d35010f9bf9538a37fb330127d459b7ccc0
  • Loading branch information
cbrewster authored and moz-gfx committed Jan 15, 2020
commit b5491151be5efc4c33f8f6437be92c2d707e52e4
@@ -14,6 +14,21 @@
#define COMPONENT_TRANSFER_LINEAR 3
#define COMPONENT_TRANSFER_GAMMA 4

// Must be kept in sync with `Filter::as_int` in internal_types.rs
// Not all filters are defined here because some filter use different shaders.
#define FILTER_CONTRAST 0
#define FILTER_GRAYSCALE 1
#define FILTER_HUE_ROTATE 2
#define FILTER_INVERT 3
#define FILTER_SATURATE 4
#define FILTER_SEPIA 5
#define FILTER_BRIGHTNESS 6
#define FILTER_COLOR_MATRIX 7
#define FILTER_SRGB_TO_LINEAR 8
#define FILTER_LINEAR_TO_SRGB 9
#define FILTER_FLOOD 10
#define FILTER_COMPONENT_TRANSFER 11

#include shared,prim_shared,brush

// Interpolated UV coordinates to sample.
@@ -100,8 +115,7 @@ void blend_brush_vs(
vFuncs[3] = (prim_user_data.y >> 16) & 0xf; // A

switch (V_OP) {
case 2: {
// Grayscale
case FILTER_GRAYSCALE: {
vColorMat = mat4(
vec4(lumR + oneMinusLumR * invAmount, lumR - lumR * invAmount, lumR - lumR * invAmount, 0.0),
vec4(lumG - lumG * invAmount, lumG + oneMinusLumG * invAmount, lumG - lumG * invAmount, 0.0),
@@ -111,8 +125,7 @@ void blend_brush_vs(
V_COLOR_OFFSET = vec4(0.0);
break;
}
case 3: {
// HueRotate
case FILTER_HUE_ROTATE: {
float c = cos(amount);
float s = sin(amount);
vColorMat = mat4(
@@ -124,8 +137,7 @@ void blend_brush_vs(
V_COLOR_OFFSET = vec4(0.0);
break;
}
case 5: {
// Saturate
case FILTER_SATURATE: {
vColorMat = mat4(
vec4(invAmount * lumR + amount, invAmount * lumR, invAmount * lumR, 0.0),
vec4(invAmount * lumG, invAmount * lumG + amount, invAmount * lumG, 0.0),
@@ -135,8 +147,7 @@ void blend_brush_vs(
V_COLOR_OFFSET = vec4(0.0);
break;
}
case 6: {
// Sepia
case FILTER_SEPIA: {
vColorMat = mat4(
vec4(0.393 + 0.607 * invAmount, 0.349 - 0.349 * invAmount, 0.272 - 0.272 * invAmount, 0.0),
vec4(0.769 - 0.769 * invAmount, 0.686 + 0.314 * invAmount, 0.534 - 0.534 * invAmount, 0.0),
@@ -146,21 +157,18 @@ void blend_brush_vs(
V_COLOR_OFFSET = vec4(0.0);
break;
}
case 10: {
// Color Matrix
case FILTER_COLOR_MATRIX: {
vec4 mat_data[4] = fetch_from_gpu_cache_4(prim_user_data.z);
vec4 offset_data = fetch_from_gpu_cache_1(prim_user_data.z + 4);
vColorMat = mat4(mat_data[0], mat_data[1], mat_data[2], mat_data[3]);
V_COLOR_OFFSET = offset_data;
break;
}
case 13: {
// Component Transfer
case FILTER_COMPONENT_TRANSFER: {
V_TABLE_ADDRESS = prim_user_data.z;
break;
}
case 14: {
// Flood
case FILTER_FLOOD: {
V_FLOOD_COLOR = fetch_from_gpu_cache_1(prim_user_data.z);
break;
}
@@ -269,40 +277,35 @@ Fragment blend_brush_fs() {
vec3 color = alpha != 0.0 ? Cs.rgb / alpha : Cs.rgb;

switch (V_OP) {
case 0:
break;
case 1:
case FILTER_CONTRAST:
color = Contrast(color, V_AMOUNT);
break;
case 4:
case FILTER_INVERT:
color = Invert(color, V_AMOUNT);
break;
case 7:
case FILTER_BRIGHTNESS:
color = Brightness(color, V_AMOUNT);
break;
case 8: // Opacity
alpha *= V_AMOUNT;
break;
case 11:
case FILTER_SRGB_TO_LINEAR:
color = SrgbToLinear(color);
break;
case 12:
case FILTER_LINEAR_TO_SRGB:
color = LinearToSrgb(color);
break;
case 13: {
// Component Transfer
case FILTER_COMPONENT_TRANSFER: {
// Get the unpremultiplied color with alpha.
vec4 colora = vec4(color, alpha);
colora = ComponentTransfer(colora);
color = colora.rgb;
alpha = colora.a;
break;
}
case 14: // Flood
case FILTER_FLOOD:
color = V_FLOOD_COLOR.rgb;
alpha = V_FLOOD_COLOR.a;
break;
default:
// Color matrix type filters (sepia, hue-rotate, etc...)
vec4 result = vColorMat * vec4(color, alpha) + V_COLOR_OFFSET;
result = clamp(result, vec4(0.0), vec4(1.0));
color = result.rgb;
@@ -1404,24 +1404,8 @@ impl BatchBuilder {
);
}
_ => {
let filter_mode = match filter {
Filter::Identity => 1, // matches `Contrast(1)`
Filter::Blur(..) => 0,
Filter::Contrast(..) => 1,
Filter::Grayscale(..) => 2,
Filter::HueRotate(..) => 3,
Filter::Invert(..) => 4,
Filter::Saturate(..) => 5,
Filter::Sepia(..) => 6,
Filter::Brightness(..) => 7,
Filter::Opacity(..) => 8,
Filter::DropShadows(..) => 9,
Filter::ColorMatrix(..) => 10,
Filter::SrgbToLinear => 11,
Filter::LinearToSrgb => 12,
Filter::ComponentTransfer => unreachable!(),
Filter::Flood(..) => 14,
};
// Must be kept in sync with brush_blend.glsl
let filter_mode = filter.as_int();

let user_data = match filter {
Filter::Identity => 0x10000i32, // matches `Contrast(1)`
@@ -1430,26 +1414,25 @@ impl BatchBuilder {
Filter::Invert(amount) |
Filter::Saturate(amount) |
Filter::Sepia(amount) |
Filter::Brightness(amount) |
Filter::Opacity(_, amount) => {
Filter::Brightness(amount) => {
(amount * 65536.0) as i32
}
Filter::SrgbToLinear | Filter::LinearToSrgb => 0,
Filter::HueRotate(angle) => {
(0.01745329251 * angle * 65536.0) as i32
}
// Go through different paths
Filter::Blur(..) |
Filter::DropShadows(..) => {
unreachable!();
}
Filter::ColorMatrix(_) => {
picture.extra_gpu_data_handles[0].as_int(gpu_cache)
}
Filter::ComponentTransfer => unreachable!(),
Filter::Flood(_) => {
picture.extra_gpu_data_handles[0].as_int(gpu_cache)
}

// These filters are handled via different paths.
Filter::ComponentTransfer |
Filter::Blur(..) |
Filter::DropShadows(..) |
Filter::Opacity(..) => unreachable!(),
};

let (uv_rect_address, textures) = render_tasks.resolve_surface(
@@ -1491,7 +1474,7 @@ impl BatchBuilder {
// except we store a little more data in the filter mode and
// a gpu cache handle in the user data.
let filter_data = &ctx.data_stores.filter_data[handle];
let filter_mode : i32 = 13 |
let filter_mode : i32 = Filter::ComponentTransfer.as_int() |
((filter_data.data.r_func.to_int() << 28 |
filter_data.data.g_func.to_int() << 24 |
filter_data.data.b_func.to_int() << 20 |
@@ -163,6 +163,29 @@ impl Filter {
Filter::Flood(..) => false,
}
}


pub fn as_int(&self) -> i32 {
// Must be kept in sync with brush_blend.glsl
match *self {
Filter::Identity => 0, // matches `Contrast(1)`
Filter::Contrast(..) => 0,
Filter::Grayscale(..) => 1,
Filter::HueRotate(..) => 2,
Filter::Invert(..) => 3,
Filter::Saturate(..) => 4,
Filter::Sepia(..) => 5,
Filter::Brightness(..) => 6,
Filter::ColorMatrix(..) => 7,
Filter::SrgbToLinear => 8,
Filter::LinearToSrgb => 9,
Filter::Flood(..) => 10,
Filter::ComponentTransfer => 11,
Filter::Blur(..) => 12,
Filter::DropShadows(..) => 13,
Filter::Opacity(..) => 14,
}
}
}

impl From<FilterOp> for Filter {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.