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

Merged
merged 1 commit into from Jan 20, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -65,6 +65,7 @@ pub struct FrameBuilderConfig {
pub batch_lookback_count: usize,
pub background_color: Option<ColorF>,
pub compositor_kind: CompositorKind,
pub tile_size_override: Option<DeviceIntSize>,
}

/// A set of common / global resources that are retained between
@@ -117,7 +118,7 @@ pub struct FrameVisibilityContext<'a> {
pub surfaces: &'a [SurfaceInfo],
pub debug_flags: DebugFlags,
pub scene_properties: &'a SceneProperties,
pub config: &'a FrameBuilderConfig,
pub config: FrameBuilderConfig,
}

pub struct FrameVisibilityState<'a> {
@@ -242,6 +243,7 @@ impl FrameBuilder {
texture_cache_profile: &mut TextureCacheProfileCounters,
composite_state: &mut CompositeState,
tile_cache_logger: &mut TileCacheLogger,
config: FrameBuilderConfig,
) -> Option<RenderTaskId> {
profile_scope!("cull");

@@ -327,7 +329,7 @@ impl FrameBuilder {
surfaces,
debug_flags,
scene_properties,
config: &scene.config,
config,
};

let mut visibility_state = FrameVisibilityState {
@@ -472,6 +474,7 @@ impl FrameBuilder {
render_task_counters: &mut RenderTaskGraphCounters,
debug_flags: DebugFlags,
tile_cache_logger: &mut TileCacheLogger,
config: FrameBuilderConfig,
) -> Frame {
profile_scope!("build");
profile_marker!("BuildFrame");
@@ -542,6 +545,7 @@ impl FrameBuilder {
&mut resource_profile.texture_cache,
&mut composite_state,
tile_cache_logger,
config,
);

let mut passes;
@@ -278,13 +278,38 @@ pub const TILE_SIZE_SCROLLBAR_VERTICAL: DeviceIntSize = DeviceIntSize {
_unit: marker::PhantomData,
};

const TILE_SIZE_FOR_TESTS: [DeviceIntSize; 6] = [
DeviceIntSize {
width: 128,
height: 128,
_unit: marker::PhantomData,
},
DeviceIntSize {
width: 256,
height: 256,
_unit: marker::PhantomData,
},
DeviceIntSize {
width: 512,
height: 512,
_unit: marker::PhantomData,
},
TILE_SIZE_DEFAULT,
TILE_SIZE_SCROLLBAR_VERTICAL,
TILE_SIZE_SCROLLBAR_HORIZONTAL,
];

// Return the list of tile sizes for the renderer to allocate texture arrays for.
pub fn tile_cache_sizes() -> &'static [DeviceIntSize] {
&[
TILE_SIZE_DEFAULT,
TILE_SIZE_SCROLLBAR_HORIZONTAL,
TILE_SIZE_SCROLLBAR_VERTICAL,
]
pub fn tile_cache_sizes(testing: bool) -> &'static [DeviceIntSize] {
if testing {
&TILE_SIZE_FOR_TESTS
} else {
&[
TILE_SIZE_DEFAULT,
TILE_SIZE_SCROLLBAR_HORIZONTAL,
TILE_SIZE_SCROLLBAR_VERTICAL,
]
}
}

/// The maximum size per axis of a surface,
@@ -1654,6 +1679,9 @@ pub struct TileCacheInstance {
pub device_position: DevicePoint,
/// True if the entire picture cache surface is opaque.
is_opaque: bool,
/// The currently considered tile size override. Used to check if we should
/// re-evaluate tile size, even if the frame timer hasn't expired.
tile_size_override: Option<DeviceIntSize>,
}

impl TileCacheInstance {
@@ -1704,6 +1732,7 @@ impl TileCacheInstance {
native_surface_id: None,
device_position: DevicePoint::zero(),
is_opaque: true,
tile_size_override: None,
}
}

@@ -1861,22 +1890,28 @@ impl TileCacheInstance {
// Only evaluate what tile size to use fairly infrequently, so that we don't end
// up constantly invalidating and reallocating tiles if the picture rect size is
// changing near a threshold value.
if self.frames_until_size_eval == 0 {
if self.frames_until_size_eval == 0 ||
self.tile_size_override != frame_context.config.tile_size_override {
const TILE_SIZE_TINY: f32 = 32.0;

// Work out what size tile is appropriate for this picture cache.
let desired_tile_size;

// There's no need to check the other dimension. If we encounter a picture
// that is small on one dimension, it's a reasonable choice to use a scrollbar
// sized tile configuration regardless of the other dimension.
if pic_rect.size.width <= TILE_SIZE_TINY {
desired_tile_size = TILE_SIZE_SCROLLBAR_VERTICAL;
} else if pic_rect.size.height <= TILE_SIZE_TINY {
desired_tile_size = TILE_SIZE_SCROLLBAR_HORIZONTAL;
} else {
desired_tile_size = TILE_SIZE_DEFAULT;
}
let desired_tile_size = match frame_context.config.tile_size_override {
Some(tile_size_override) => {
tile_size_override
}
None => {
// There's no need to check the other dimension. If we encounter a picture
// that is small on one dimension, it's a reasonable choice to use a scrollbar
// sized tile configuration regardless of the other dimension.
if pic_rect.size.width <= TILE_SIZE_TINY {
TILE_SIZE_SCROLLBAR_VERTICAL
} else if pic_rect.size.height <= TILE_SIZE_TINY {
TILE_SIZE_SCROLLBAR_HORIZONTAL
} else {
TILE_SIZE_DEFAULT
}
}
};

// If the desired tile size has changed, then invalidate and drop any
// existing tiles.
@@ -1893,6 +1928,7 @@ impl TileCacheInstance {
// Reset counter until next evaluating the desired tile size. This is an
// arbitrary value.
self.frames_until_size_eval = 120;
self.tile_size_override = frame_context.config.tile_size_override;
}

// Map an arbitrary point in picture space to world space, to work out
@@ -541,6 +541,7 @@ impl Document {
resource_profile: &mut ResourceProfileCounters,
debug_flags: DebugFlags,
tile_cache_logger: &mut TileCacheLogger,
config: FrameBuilderConfig,
) -> RenderedDocument {
let accumulated_scale_factor = self.view.accumulated_scale_factor();
let pan = self.view.pan.to_f32() / accumulated_scale_factor;
@@ -568,6 +569,7 @@ impl Document {
&mut self.render_task_counters,
debug_flags,
tile_cache_logger,
config,
);
self.hit_tester = Some(self.scene.create_hit_tester(&self.data_stores.clip));
frame
@@ -1142,6 +1144,11 @@ impl RenderBackend {
// We don't want to forward this message to the renderer.
return RenderBackendStatus::Continue;
}
DebugCommand::SetPictureTileSize(tile_size) => {
self.frame_config.tile_size_override = tile_size;

return RenderBackendStatus::Continue;
}
DebugCommand::FetchDocuments => {
// Ask SceneBuilderThread to send JSON presentation of the documents,
// that will be forwarded to Renderer.
@@ -1534,6 +1541,7 @@ impl RenderBackend {
&mut profile_counters.resources,
self.debug_flags,
&mut self.tile_cache_logger,
self.frame_config,
);

debug!("generated frame for document {:?} with {} passes",
@@ -1712,6 +1720,7 @@ impl RenderBackend {
&mut profile_counters.resources,
self.debug_flags,
&mut self.tile_cache_logger,
self.frame_config,
);
// After we rendered the frames, there are pending updates to both
// GPU cache and resources. Instead of serializing them, we are going to make sure
@@ -2185,6 +2185,7 @@ impl Renderer {
batch_lookback_count: options.batch_lookback_count,
background_color: options.clear_color,
compositor_kind,
tile_size_override: None,
};
info!("WR {:?}", config);

@@ -2292,7 +2293,7 @@ impl Renderer {
max_texture_size,
max_texture_layers,
if config.global_enable_picture_caching {
tile_cache_sizes()
tile_cache_sizes(config.testing)
} else {
&[]
},
@@ -2845,7 +2846,8 @@ impl Renderer {
fn handle_debug_command(&mut self, command: DebugCommand) {
match command {
DebugCommand::EnableDualSourceBlending(_) |
DebugCommand::SetTransactionLogging(_) => {
DebugCommand::SetTransactionLogging(_) |
DebugCommand::SetPictureTileSize(_) => {
panic!("Should be handled by render backend");
}
DebugCommand::FetchDocuments |
@@ -258,6 +258,7 @@ impl BuiltScene {
batch_lookback_count: 0,
background_color: None,
compositor_kind: CompositorKind::default(),
tile_size_override: None,
},
}
}
@@ -977,6 +977,8 @@ pub enum DebugCommand {
SimulateLongLowPrioritySceneBuild(u32),
/// Logs transactions to a file for debugging purposes
SetTransactionLogging(bool),
/// Set an override tile size to use for picture caches
SetPictureTileSize(Option<DeviceIntSize>),
}

/// Message sent by the `RenderApi` to the render backend thread.
@@ -28,5 +28,5 @@ platform(linux,mac) == small-dotted-border.yaml small-dotted-border.png
platform(linux,mac) == border-dashed-dotted-caching.yaml border-dashed-dotted-caching.png
!= small-inset-outset.yaml small-inset-outset-notref.yaml
fuzzy(1,16) == no-aa.yaml green-square.yaml
skip_on(android,device) border-double-1px.yaml border-double-1px-ref.yaml # Fails on Pixel2
skip_on(android,device) == border-double-1px.yaml border-double-1px-ref.yaml # Fails on Pixel2
== max-scale.yaml max-scale-ref.yaml
@@ -15,3 +15,4 @@ include snap/reftest.list
include split/reftest.list
include text/reftest.list
include transforms/reftest.list
include tiles/reftest.list
@@ -73,5 +73,5 @@ options(disable-aa) == snap-clip.yaml snap-clip-ref.yaml
platform(linux) == perspective-clip.yaml perspective-clip.png
fuzzy(1,39) options(disable-subpixel) == raster-space-snap.yaml raster-space-snap-ref.yaml
# == intermediate-transform.yaml intermediate-transform-ref.yaml # fails because of AA inavailable with an intermediate surface
platform(linux) allow_sacrificing_subpixel_aa(false) text-fixed-slice.yaml text-fixed-slice-slow.png
platform(linux) allow_sacrificing_subpixel_aa(true) text-fixed-slice.yaml text-fixed-slice-fast.png
platform(linux) allow_sacrificing_subpixel_aa(false) == text-fixed-slice.yaml text-fixed-slice-slow.png
platform(linux) allow_sacrificing_subpixel_aa(true) == text-fixed-slice.yaml text-fixed-slice-fast.png
@@ -0,0 +1,45 @@
---
root:
items:
- type: stacking-context
bounds: [50, 50, 100, 100]
transform: rotate(30)
items:
- type: rect
bounds: [ 10, 10, 80, 80 ]
color: [0, 255, 0]
- type: box-shadow
bounds: [ 10, 10, 80, 80 ]
blur-radius: 25
clip-mode: inset

- type: rect
bounds: [ 140, 10, 80, 80 ]
color: [0, 255, 0]
- type: box-shadow
bounds: [ 140, 10, 80, 80 ]
blur-radius: 25
clip-mode: outset

- type: border
bounds: [ 250, 10, 100, 100 ]
width: [ 10, 10, 10, 10 ]
border-type: normal
style: solid
color: [ red, green, blue, black ]
radius: {
top-left: [20, 20],
top-right: [10, 10],
bottom-left: [25, 25],
bottom-right: [0, 0],
}

- bounds: [150, 150, 128, 128]
image: checkerboard(4, 15, 8)
stretch-size: 128 128

- type: radial-gradient
bounds: 300 150 100 100
center: 50 50
radius: 50 50
stops: [0, red, 1, blue]
@@ -0,0 +1,6 @@
---
root:
items:
- type: rect
bounds: 50 50 200 200
color: red
@@ -0,0 +1,4 @@
** rect.yaml
** simple-gradient.yaml
# TODO: Fix rasterizer inaccuracies so this is the same regardless of tile size!
!* prim-suite.yaml
@@ -0,0 +1,9 @@
---
root:
items:
- type: gradient
bounds: [ 0, 0, 1980, 1080]
start: [ 0, -2000 ]
end: [ 0, 4000 ]
stops: [ 0.0, red, 1.0, green ]
repeat: false
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.