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 #3872

Merged
merged 33 commits into from Mar 6, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
240b8ed
Bug 1510030 - Don't return the current opacity value from update_opac…
hiikezoe Feb 27, 2020
0809ea1
Bug 1510030 - Fix the comment for OpacityBinding::update(). r=gw
hiikezoe Feb 27, 2020
8aa347d
Bug 1510030 - Make prepare_prim_for_render private. r=gw
hiikezoe Feb 27, 2020
b2bc0a8
Bug 1510030 - Implement WebRender backend to run background color ani…
hiikezoe Feb 27, 2020
b0e0510
Backed out 6 changesets (bug 1510030) for webrender bustages CLOSED TREE
bogdantara Feb 27, 2020
8353c5a
Bug 1510030 - Don't return the current opacity value from update_opac…
hiikezoe Feb 27, 2020
6f45b76
Bug 1510030 - Fix the comment for OpacityBinding::update(). r=gw
hiikezoe Feb 27, 2020
d422aab
Bug 1510030 - Make prepare_prim_for_render private. r=gw
hiikezoe Feb 27, 2020
692bc61
Bug 1510030 - Implement WebRender backend to run background color ani…
hiikezoe Feb 27, 2020
1fc3512
Backed out 6 changesets (bug 1510030) for test_running_on_compositor.…
bogdantara Feb 27, 2020
13e86e2
Bug 1510030 - Don't return the current opacity value from update_opac…
hiikezoe Feb 27, 2020
ecd8232
Bug 1510030 - Fix the comment for OpacityBinding::update(). r=gw
hiikezoe Feb 27, 2020
b152ac5
Bug 1510030 - Make prepare_prim_for_render private. r=gw
hiikezoe Feb 27, 2020
7b1f4fa
Bug 1510030 - Implement WebRender backend to run background color ani…
hiikezoe Feb 27, 2020
1ee6c0f
Bug 1616995 - patch 2 - Support vertical skew for upright-vertical fo…
jfkthame Feb 29, 2020
85ccbbf
Bug 1596513: Part 1: Take scale factors into account when rendering d…
cbrewster Feb 29, 2020
142de92
Bug 1596513: Part 3: Ensure drop shadow blur radius does not exceed M…
cbrewster Feb 29, 2020
6cffb1b
Bug 1579235 - Part 6 - Support an opaque/alpha native surface per sli…
gw3583 Mar 2, 2020
54d5fe8
Bug 1579235 - Part 7 - Fix UV rect calculation for external textures.…
gw3583 Mar 2, 2020
ab7ca3e
Bug 1579235 - Part 8 - Remove overlay tiles, they can be alpha tiles …
gw3583 Mar 2, 2020
49df0ec
Bug 1619265 - Bump rust versions for github CI. r=jrmuizel
staktrace Mar 2, 2020
ad0cd12
Bug 1579235 - Part 9 - Optimize compositor surface overlays. r=Bert
gw3583 Mar 3, 2020
4d776c9
Bug 1613260 - Support per-task scale for local space rasterization r=…
bpeersmoz Mar 3, 2020
517a4b6
Bug 1619293 - Re-enable rust flags in github CI. r=jrmuizel
staktrace Mar 3, 2020
7ed1505
Bug 1613260 - Increase allowed fuzz on new tests so they pass in AppV…
staktrace Mar 4, 2020
bf01196
Bug 1618319: Segregate intern::UpdateList insertions and removals. r=gw
Mar 4, 2020
a1991bc
Bug 1579235 - Part 10 - Fix incorrect skipping of composites. r=Bert
gw3583 Mar 4, 2020
dab8afd
Bug 1619393 - Reftest improvements for fuzzy tests r=gw
bpeersmoz Mar 5, 2020
8d121d8
Bug 1616255 - Handle start and end offsets in conic-gradient WR shade…
nt1m Mar 5, 2020
256215e
Bug 1619393 - Increase fuzz by one to allow reftest to pass on AppVey…
staktrace Mar 6, 2020
5aad73f
Bug 1579235 - Part 11 - Refactor how external surfaces are composited…
gw3583 Mar 6, 2020
4236b41
Bug 1579235 - Part 12 - Support native compositor surfaces. r=Bert,so…
gw3583 Mar 6, 2020
51b4045
Bug 1618939 - Hit MOZ_CRASH(explicit panic) at gfx/wr/webrender/src/r…
bpeersmoz Mar 6, 2020
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Bug 1613260 - Support per-task scale for local space rasterization r=…

  • Loading branch information
bpeersmoz authored and moz-gfx committed Mar 3, 2020
commit 4d776c9d6d65ef2f8bc112d6316ca8b20998fb79
@@ -38,16 +38,18 @@ void mix_blend_brush_vs(
V_OP = prim_user_data.x;

PictureTask src_task = fetch_picture_task(prim_user_data.z);
vec2 src_uv = device_pos +
vec2 src_device_pos = vi.world_pos.xy * (src_task.device_pixel_scale / max(0.0, vi.world_pos.w));
vec2 src_uv = src_device_pos +
src_task.common_data.task_rect.p0 -
src_task.content_origin;
V_SRC_UV = src_uv / texture_size;
V_SRC_LAYER = src_task.common_data.texture_layer_index;

RenderTaskCommonData backdrop_task = fetch_render_task_common_data(prim_user_data.y);
float src_to_backdrop_scale = pic_task.device_pixel_scale / src_task.device_pixel_scale;
vec2 backdrop_uv = device_pos +
backdrop_task.task_rect.p0 -
src_task.content_origin;
src_task.content_origin * src_to_backdrop_scale;
V_BACKDROP_UV = backdrop_uv / texture_size;
V_BACKDROP_LAYER = backdrop_task.texture_layer_index;
}
@@ -3602,6 +3602,13 @@ pub struct RasterConfig {
pub surface_index: SurfaceIndex,
/// Whether this picture establishes a rasterization root.
pub establishes_raster_root: bool,
/// Scaling factor applied to fit within MAX_SURFACE_SIZE when
/// establishing a raster root.
/// Most code doesn't need to know about it, since it is folded
/// into device_pixel_scale when the rendertask is set up.
/// However e.g. text rasterization uses it to ensure consistent
/// on-screen font size.
pub root_scaling_factor: f32,
}

bitflags! {
@@ -4316,14 +4323,14 @@ impl PicturePrimitive {
};

match self.raster_config {
Some(ref raster_config) => {
Some(ref mut raster_config) => {
let pic_rect = PictureRect::from_untyped(&self.precise_local_rect.to_untyped());

let device_pixel_scale = frame_state
let mut device_pixel_scale = frame_state
.surfaces[raster_config.surface_index.0]
.device_pixel_scale;

let (clipped, unclipped) = match get_raster_rects(
let (mut clipped, mut unclipped) = match get_raster_rects(
pic_rect,
&map_pic_to_raster,
&map_raster_to_world,
@@ -4337,11 +4344,68 @@ impl PicturePrimitive {
};
let transform = map_pic_to_raster.get_transform();

/// If the picture (raster_config) establishes a raster root,
/// its requested resolution won't be clipped by the parent or
/// viewport; so we need to make sure the requested resolution is
/// "reasonable", ie. <= MAX_SURFACE_SIZE. If not, scale the
/// picture down until it fits that limit. This results in a new
/// device_rect, a new unclipped rect, and a new device_pixel_scale.
///
/// Since the adjusted device_pixel_scale is passed into the
/// RenderTask (and then the shader via RenderTaskData) this mostly
/// works transparently, reusing existing support for variable DPI
/// support. The on-the-fly scaling can be seen as on-the-fly,
/// per-task DPI adjustment. Logical pixels are unaffected.
///
/// The scaling factor is returned to the caller; blur radius,
/// font size, etc. need to be scaled accordingly.
fn adjust_scale_for_max_surface_size(
raster_config: &RasterConfig,
pic_rect: PictureRect,
map_pic_to_raster: &SpaceMapper<PicturePixel, RasterPixel>,
map_raster_to_world: &SpaceMapper<RasterPixel, WorldPixel>,
clipped_prim_bounding_rect: WorldRect,
device_pixel_scale : &mut DevicePixelScale,
device_rect: &mut DeviceIntRect,
unclipped: &mut DeviceRect) -> Option<f32>
{
if raster_config.establishes_raster_root &&
(device_rect.size.width > (MAX_SURFACE_SIZE as i32) ||
device_rect.size.height > (MAX_SURFACE_SIZE as i32))
{
// round_out will grow by 1 integer pixel if origin is on a
// fractional position, so keep that margin for error with -1:
let scale = (MAX_SURFACE_SIZE as f32 - 1.0) /
(i32::max(device_rect.size.width, device_rect.size.height) as f32);
*device_pixel_scale = *device_pixel_scale * Scale::new(scale);
let new_device_rect = device_rect.to_f32() * Scale::new(scale);
*device_rect = new_device_rect.round_out().try_cast::<i32>().unwrap();

*unclipped = match get_raster_rects(
pic_rect,
&map_pic_to_raster,
&map_raster_to_world,
clipped_prim_bounding_rect,
*device_pixel_scale
) {
Some(info) => info.1,
None => {
return None
}
};
Some(scale)
}
else
{
None
}
}

let dep_info = match raster_config.composite_mode {
PictureCompositeMode::Filter(Filter::Blur(blur_radius)) => {
let blur_std_deviation = blur_radius * device_pixel_scale.0;
let scale_factors = scale_factors(&transform);
let blur_std_deviation = DeviceSize::new(
let mut blur_std_deviation = DeviceSize::new(
blur_std_deviation * scale_factors.0,
blur_std_deviation * scale_factors.1
);
@@ -4374,7 +4438,7 @@ impl PicturePrimitive {
clipped
};

let original_size = device_rect.size;
let mut original_size = device_rect.size;

// Adjust the size to avoid introducing sampling errors during the down-scaling passes.
// what would be even better is to rasterize the picture at the down-scaled size
@@ -4384,6 +4448,16 @@ impl PicturePrimitive {
blur_std_deviation,
);

if let Some(scale) = adjust_scale_for_max_surface_size(
raster_config, pic_rect, &map_pic_to_raster, &map_raster_to_world,
clipped_prim_bounding_rect,
&mut device_pixel_scale, &mut device_rect, &mut unclipped)
{
blur_std_deviation = blur_std_deviation * scale;
original_size = (original_size.to_f32() * scale).try_cast::<i32>().unwrap();
raster_config.root_scaling_factor = scale;
}

let uv_rect_kind = calculate_uv_rect_kind(
&pic_rect,
&transform,
@@ -4446,6 +4520,15 @@ impl PicturePrimitive {
DeviceSize::new(max_std_deviation, max_std_deviation),
);

if let Some(scale) = adjust_scale_for_max_surface_size(
raster_config, pic_rect, &map_pic_to_raster, &map_raster_to_world,
clipped_prim_bounding_rect,
&mut device_pixel_scale, &mut device_rect, &mut unclipped)
{
// std_dev adjusts automatically from using device_pixel_scale
raster_config.root_scaling_factor = scale;
}

let uv_rect_kind = calculate_uv_rect_kind(
&pic_rect,
&transform,
@@ -4536,6 +4619,15 @@ impl PicturePrimitive {
Some((render_task_id, render_task_id))
}
PictureCompositeMode::Filter(..) => {

if let Some(scale) = adjust_scale_for_max_surface_size(
raster_config, pic_rect, &map_pic_to_raster, &map_raster_to_world,
clipped_prim_bounding_rect,
&mut device_pixel_scale, &mut clipped, &mut unclipped)
{
raster_config.root_scaling_factor = scale;
}

let uv_rect_kind = calculate_uv_rect_kind(
&pic_rect,
&transform,
@@ -4561,6 +4653,14 @@ impl PicturePrimitive {
Some((render_task_id, render_task_id))
}
PictureCompositeMode::ComponentTransferFilter(..) => {
if let Some(scale) = adjust_scale_for_max_surface_size(
raster_config, pic_rect, &map_pic_to_raster, &map_raster_to_world,
clipped_prim_bounding_rect,
&mut device_pixel_scale, &mut clipped, &mut unclipped)
{
raster_config.root_scaling_factor = scale;
}

let uv_rect_kind = calculate_uv_rect_kind(
&pic_rect,
&transform,
@@ -4856,6 +4956,14 @@ impl PicturePrimitive {
}
PictureCompositeMode::MixBlend(..) |
PictureCompositeMode::Blit(_) => {
if let Some(scale) = adjust_scale_for_max_surface_size(
raster_config, pic_rect, &map_pic_to_raster, &map_raster_to_world,
clipped_prim_bounding_rect,
&mut device_pixel_scale, &mut clipped, &mut unclipped)
{
raster_config.root_scaling_factor = scale;
}

let uv_rect_kind = calculate_uv_rect_kind(
&pic_rect,
&transform,
@@ -4881,6 +4989,15 @@ impl PicturePrimitive {
Some((render_task_id, render_task_id))
}
PictureCompositeMode::SvgFilter(ref primitives, ref filter_datas) => {

if let Some(scale) = adjust_scale_for_max_surface_size(
raster_config, pic_rect, &map_pic_to_raster, &map_raster_to_world,
clipped_prim_bounding_rect,
&mut device_pixel_scale, &mut clipped, &mut unclipped)
{
raster_config.root_scaling_factor = scale;
}

let uv_rect_kind = calculate_uv_rect_kind(
&pic_rect,
&transform,
@@ -5325,6 +5442,7 @@ impl PicturePrimitive {
composite_mode,
establishes_raster_root,
surface_index: state.push_surface(surface),
root_scaling_factor: 1.0,
});
}

@@ -5477,7 +5595,9 @@ impl PicturePrimitive {
// Check if any of the surfaces can't be rasterized in local space but want to.
if raster_config.establishes_raster_root
&& (surface_rect.size.width > MAX_SURFACE_SIZE
|| surface_rect.size.height > MAX_SURFACE_SIZE) {
|| surface_rect.size.height > MAX_SURFACE_SIZE)
&& frame_context.debug_flags.contains(DebugFlags::DISABLE_RASTER_ROOT_SCALING)
{
raster_config.establishes_raster_root = false;
state.are_raster_roots_assigned = false;
}
@@ -2968,6 +2968,10 @@ impl PrimitiveStore {
let raster_space = pic.get_raster_space(frame_context.spatial_tree);
let surface = &frame_state.surfaces[pic_context.surface_index.0];
let prim_info = &scratch.prim_info[prim_instance.visibility_info.0 as usize];
let root_scaling_factor = match pic.raster_config {
Some(ref raster_config) => raster_config.root_scaling_factor,
None => 1.0
};

run.request_resources(
prim_offset,
@@ -2978,6 +2982,7 @@ impl PrimitiveStore {
surface,
prim_spatial_node_index,
raster_space,
root_scaling_factor,
&pic_context.subpixel_mode,
frame_state.resource_cache,
frame_state.gpu_cache,
@@ -229,6 +229,7 @@ impl TextRunPrimitive {
subpixel_mode: &SubpixelMode,
raster_space: RasterSpace,
prim_rect: PictureRect,
root_scaling_factor: f32,
spatial_tree: &SpatialTree,
) -> bool {
// If local raster space is specified, include that in the scale
@@ -239,7 +240,10 @@ impl TextRunPrimitive {
// will no longer be required.

let raster_scale = raster_space.local_scale().unwrap_or(1.0).max(0.001);
let dps = surface.device_pixel_scale.0;
// root_scaling_factor is used to scale very large pictures that establish
// a raster root back to something sane, thus scale the device size accordingly.
// to the shader it looks like a change in DPI which it already supports.
let dps = surface.device_pixel_scale.0 * root_scaling_factor;
let glyph_raster_scale = dps * raster_scale;
let font_size = specified_font.size.to_f32_px();
let device_font_size = font_size * glyph_raster_scale;
@@ -365,6 +369,7 @@ impl TextRunPrimitive {
surface: &SurfaceInfo,
spatial_node_index: SpatialNodeIndex,
raster_space: RasterSpace,
root_scaling_factor: f32,
subpixel_mode: &SubpixelMode,
resource_cache: &mut ResourceCache,
gpu_cache: &mut GpuCache,
@@ -380,6 +385,7 @@ impl TextRunPrimitive {
subpixel_mode,
raster_space,
prim_rect,
root_scaling_factor,
spatial_tree,
);

@@ -142,7 +142,7 @@ pub struct PictureTask {
pub uv_rect_handle: GpuCacheHandle,
pub surface_spatial_node_index: SpatialNodeIndex,
uv_rect_kind: UvRectKind,
device_pixel_scale: DevicePixelScale,
pub device_pixel_scale: DevicePixelScale,
/// A bitfield that describes which dirty regions should be included
/// in batches built for this picture task.
pub vis_mask: PrimitiveVisibilityMask,
@@ -3799,8 +3799,8 @@ impl Renderer {
// composite operation in this batch.
let (readback_rect, readback_layer) = readback.get_target_rect();
let (backdrop_rect, _) = backdrop.get_target_rect();
let backdrop_screen_origin = match backdrop.kind {
RenderTaskKind::Picture(ref task_info) => task_info.content_origin,
let (backdrop_screen_origin, backdrop_scale) = match backdrop.kind {
RenderTaskKind::Picture(ref task_info) => (task_info.content_origin, task_info.device_pixel_scale),
_ => panic!("bug: composite on non-picture?"),
};
let source_screen_origin = match source.kind {
@@ -3818,8 +3818,10 @@ impl Renderer {
false,
);

let source_in_backdrop_space = source_screen_origin.to_f32() * backdrop_scale.0;

let mut src = DeviceIntRect::new(
source_screen_origin + (backdrop_rect.origin - backdrop_screen_origin),
(source_in_backdrop_space + (backdrop_rect.origin - backdrop_screen_origin).to_f32()).to_i32(),
readback_rect.size,
);
let mut dest = readback_rect.to_i32();
@@ -1427,6 +1427,10 @@ bitflags! {
const INVALIDATION_DBG = 1 << 28;
/// Log tile cache to memory for later saving as part of wr-capture
const TILE_CACHE_LOGGING_DBG = 1 << 29;
/// For debugging, force-disable automatic scaling of establishes_raster_root
/// pictures that are too large (ie go back to old behavior that prevents those
/// large pictures from establishing a raster root).
const DISABLE_RASTER_ROOT_SCALING = 1 << 30;
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.