Skip to content

Pass AsyncImageBlobRasterizer through the stack explicitly #3382

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions webrender/src/frame_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use api::{AsyncBlobImageRasterizer};
use api::{ColorF, DeviceIntPoint, DevicePixelScale, LayoutPixel, PicturePixel, RasterPixel};
use api::{DeviceIntRect, DeviceIntSize, DocumentLayer, FontRenderMode};
use api::{LayoutPoint, LayoutRect, LayoutSize, PipelineId, RasterSpace, WorldPoint, WorldRect, WorldPixel};
Expand Down Expand Up @@ -372,6 +373,7 @@ impl FrameBuilder {
scene_properties: &SceneProperties,
resources: &mut FrameResources,
scratch: &mut PrimitiveScratchBuffer,
blob_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
) -> Frame {
profile_scope!("build");
debug_assert!(
Expand Down Expand Up @@ -416,9 +418,12 @@ impl FrameBuilder {
scratch,
);

resource_cache.block_until_all_resources_added(gpu_cache,
&mut render_tasks,
texture_cache_profile);
resource_cache.block_until_all_resources_added(
gpu_cache,
&mut render_tasks,
blob_rasterizer,
texture_cache_profile,
);

let mut passes = vec![
special_render_passes.alpha_glyph_pass,
Expand Down
15 changes: 8 additions & 7 deletions webrender/src/render_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! See the comment at the top of the `renderer` module for a description of
//! how these two pieces interact.

use api::{ApiMsg, BuiltDisplayList, ClearCache, DebugCommand};
use api::{ApiMsg, AsyncBlobImageRasterizer, BuiltDisplayList, ClearCache, DebugCommand};
#[cfg(feature = "debugger")]
use api::{BuiltDisplayListIter, SpecificDisplayItem};
use api::{DevicePixelScale, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
Expand Down Expand Up @@ -405,6 +405,7 @@ impl Document {
&mut self,
resource_cache: &mut ResourceCache,
gpu_cache: &mut GpuCache,
blob_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
resource_profile: &mut ResourceProfileCounters,
) -> RenderedDocument {
let accumulated_scale_factor = self.view.accumulated_scale_factor();
Expand Down Expand Up @@ -432,6 +433,7 @@ impl Document {
&self.dynamic_properties,
&mut self.resources,
&mut self.scratch,
blob_rasterizer,
);
self.hit_tester = Some(frame_builder.create_hit_tester(
&self.clip_scroll_tree,
Expand Down Expand Up @@ -786,9 +788,6 @@ impl RenderBackend {
self.resource_cache.add_rasterized_blob_images(
replace(&mut txn.rasterized_blobs, Vec::new())
);
if let Some(rasterizer) = txn.blob_rasterizer.take() {
self.resource_cache.set_blob_rasterizer(rasterizer);
}

self.update_document(
txn.document_id,
Expand All @@ -798,6 +797,7 @@ impl RenderBackend {
replace(&mut txn.notifications, Vec::new()),
txn.render_frame,
txn.invalidate_rendered_frame,
txn.blob_rasterizer.take(),
&mut frame_counter,
&mut profile_counters,
has_built_scene,
Expand Down Expand Up @@ -1111,9 +1111,6 @@ impl RenderBackend {
}

if !transaction_msg.use_scene_builder_thread && txn.can_skip_scene_builder() {
if let Some(rasterizer) = txn.blob_rasterizer.take() {
self.resource_cache.set_blob_rasterizer(rasterizer);
}
self.update_document(
txn.document_id,
replace(&mut txn.resource_updates, Vec::new()),
Expand All @@ -1122,6 +1119,7 @@ impl RenderBackend {
replace(&mut txn.notifications, Vec::new()),
txn.render_frame,
txn.invalidate_rendered_frame,
txn.blob_rasterizer.take(),
frame_counter,
profile_counters,
false
Expand Down Expand Up @@ -1158,6 +1156,7 @@ impl RenderBackend {
mut notifications: Vec<NotificationRequest>,
mut render_frame: bool,
invalidate_rendered_frame: bool,
blob_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
frame_counter: &mut u32,
profile_counters: &mut BackendProfileCounters,
has_built_scene: bool,
Expand Down Expand Up @@ -1242,6 +1241,7 @@ impl RenderBackend {
let rendered_document = doc.build_frame(
&mut self.resource_cache,
&mut self.gpu_cache,
blob_rasterizer,
&mut profile_counters.resources,
);

Expand Down Expand Up @@ -1492,6 +1492,7 @@ impl RenderBackend {
let rendered_document = doc.build_frame(
&mut self.resource_cache,
&mut self.gpu_cache,
None,
&mut profile_counters.resources,
);
//TODO: write down doc's pipeline info?
Expand Down
22 changes: 6 additions & 16 deletions webrender/src/resource_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ pub struct ResourceCache {
// If while building a frame we encounter blobs that we didn't already
// rasterize, add them to this list and rasterize them synchronously.
missing_blob_images: Vec<BlobImageParams>,
// The rasterizer associated with the current scene.
blob_image_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
// A log of the last three frames worth of deleted image keys kept
// for debugging purposes.
deleted_blob_keys: VecDeque<Vec<BlobImageKey>>
Expand All @@ -463,7 +461,6 @@ impl ResourceCache {
rasterized_blob_images: FastHashMap::default(),
blob_image_templates: FastHashMap::default(),
missing_blob_images: Vec::new(),
blob_image_rasterizer: None,
// We want to keep three frames worth of delete blob keys
deleted_blob_keys: vec![Vec::new(), Vec::new(), Vec::new()].into(),
}
Expand Down Expand Up @@ -640,10 +637,6 @@ impl ResourceCache {
);
}

pub fn set_blob_rasterizer(&mut self, rasterizer: Box<AsyncBlobImageRasterizer>) {
self.blob_image_rasterizer = Some(rasterizer);
}

pub fn add_rasterized_blob_images(&mut self, images: Vec<(BlobImageRequest, BlobImageResult)>) {
for (request, result) in images {
let data = match result {
Expand Down Expand Up @@ -1478,6 +1471,7 @@ impl ResourceCache {
&mut self,
gpu_cache: &mut GpuCache,
render_tasks: &mut RenderTaskTree,
blob_image_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
texture_cache_profile: &mut TextureCacheProfileCounters,
) {
profile_scope!("block_until_all_resources_added");
Expand All @@ -1494,7 +1488,9 @@ impl ResourceCache {
texture_cache_profile,
);

self.rasterize_missing_blob_images();
if !self.missing_blob_images.is_empty() {
self.rasterize_missing_blob_images(&mut *blob_image_rasterizer.unwrap());
}

// Apply any updates of new / updated images (incl. blobs) to the texture cache.
self.update_texture_cache(gpu_cache);
Expand All @@ -1507,11 +1503,7 @@ impl ResourceCache {
self.texture_cache.end_frame(texture_cache_profile);
}

fn rasterize_missing_blob_images(&mut self) {
if self.missing_blob_images.is_empty() {
return;
}

fn rasterize_missing_blob_images(&mut self, blob_image_rasterizer: &mut AsyncBlobImageRasterizer) {
self.blob_image_handler
.as_mut()
.unwrap()
Expand All @@ -1524,9 +1516,7 @@ impl ResourceCache {
}
}
let is_low_priority = false;
let rasterized_blobs = self.blob_image_rasterizer
.as_mut()
.unwrap()
let rasterized_blobs = blob_image_rasterizer
.rasterize(&self.missing_blob_images, is_low_priority);

self.add_rasterized_blob_images(rasterized_blobs);
Expand Down