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

pipe through a scene_id to distinguish cached pictures #2776

Merged
merged 2 commits into from Jun 4, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

pipe through a scene_id to distinguish cached pictures

  • Loading branch information
Gankra committed Jun 4, 2018
commit 7a7adc88147d44964333ce22b1b8f28042636269
@@ -204,6 +204,7 @@ impl<'a> DisplayListFlattener<'a> {
output_pipelines: &FastHashSet<PipelineId>,
frame_builder_config: &FrameBuilderConfig,
new_scene: &mut Scene,
scene_id: u64,
) -> FrameBuilder {
// We checked that the root pipeline is available on the render backend.
let root_pipeline_id = scene.root_pipeline_id.unwrap();
@@ -254,7 +255,8 @@ impl<'a> DisplayListFlattener<'a> {
view.inner_rect,
background_color,
view.window_size,
flattener
scene_id,
flattener,
)
}

@@ -2062,7 +2064,8 @@ pub fn build_scene(config: &FrameBuilderConfig, request: SceneRequest) -> BuiltS
&request.view,
&request.output_pipelines,
config,
&mut new_scene
&mut new_scene,
request.scene_id,
);

BuiltScene {
@@ -41,6 +41,7 @@ pub struct FrameBuilder {
screen_rect: DeviceUintRect,
background_color: Option<ColorF>,
window_size: DeviceUintSize,
scene_id: u64,
pub prim_store: PrimitiveStore,
pub clip_store: ClipStore,
pub hit_testing_runs: Vec<HitTestingRun>,
@@ -50,6 +51,7 @@ pub struct FrameBuilder {
}

pub struct FrameBuildingContext<'a> {
pub scene_id: u64,
pub device_pixel_scale: DevicePixelScale,
pub scene_properties: &'a SceneProperties,
pub pipelines: &'a FastHashMap<PipelineId, Arc<ScenePipeline>>,
@@ -125,6 +127,7 @@ impl FrameBuilder {
screen_rect: DeviceUintRect::zero(),
window_size: DeviceUintSize::zero(),
background_color: None,
scene_id: 0,
config: FrameBuilderConfig {
enable_scrollbars: false,
default_font_render_mode: FontRenderMode::Mono,
@@ -138,6 +141,7 @@ impl FrameBuilder {
screen_rect: DeviceUintRect,
background_color: Option<ColorF>,
window_size: DeviceUintSize,
scene_id: u64,
flattener: DisplayListFlattener,
) -> Self {
FrameBuilder {
@@ -149,6 +153,7 @@ impl FrameBuilder {
screen_rect,
background_color,
window_size,
scene_id,
config: flattener.config,
}
}
@@ -185,6 +190,7 @@ impl FrameBuilder {
.display_list;

let frame_context = FrameBuildingContext {
scene_id: self.scene_id,
device_pixel_scale,
scene_properties,
pipelines,
@@ -80,7 +80,11 @@ pub struct PictureCacheKey {
// we relax that, we'll need to consider some
// extra parameters, depending on transform.

// The unique identifier for this picture.
// This is a globally unique id of the scene this picture
// is associated with, to avoid picture id collisions.
scene_id: u64,

// The unique (for the scene_id) identifier for this picture.
// TODO(gw): Currently, these will not be
// shared across new display lists,
// so will only remain valid during
@@ -374,6 +378,7 @@ impl PicturePrimitive {
RenderTaskCacheKey {
size: device_rect.size,
kind: RenderTaskCacheKeyKind::Picture(PictureCacheKey {
scene_id: frame_context.scene_id,
picture_id: self.id,
unclipped_size: prim_screen_rect.unclipped.size,
pic_relative_render_rect,
@@ -176,7 +176,7 @@ impl Document {
}

// TODO: We will probably get rid of this soon and always forward to the scene building thread.
fn build_scene(&mut self, resource_cache: &mut ResourceCache) {
fn build_scene(&mut self, resource_cache: &mut ResourceCache, scene_id: u64) {
let max_texture_size = resource_cache.max_texture_size();

if self.view.window_size.width > max_texture_size ||
@@ -199,7 +199,7 @@ impl Document {
return;
}

// The DisplayListFlattener will re-create the up-to-date current scene's pipeline epoch
// The DisplayListFlattener re-create the up-to-date current scene's pipeline epoch
// map and clip scroll tree from the information in the pending scene.
self.current.scene.pipeline_epochs.clear();
let old_scrolling_states = self.clip_scroll_tree.drain();
@@ -213,6 +213,7 @@ impl Document {
&self.output_pipelines,
&self.frame_builder_config,
&mut self.current.scene,
scene_id,
);

self.clip_scroll_tree.finalize_and_apply_pending_scroll_offsets(old_scrolling_states);
@@ -233,6 +234,7 @@ impl Document {
transaction_msg: TransactionMsg,
document_ops: &DocumentOps,
document_id: DocumentId,
scene_id: u64,
resource_cache: &ResourceCache,
scene_tx: &Sender<SceneBuilderRequest>,
) {
@@ -250,6 +252,7 @@ impl Document {
view: self.view.clone(),
font_instances: resource_cache.get_font_instances(),
output_pipelines: self.output_pipelines.clone(),
scene_id,
})
} else {
None
@@ -397,6 +400,7 @@ struct PlainRenderBackend {
frame_config: FrameBuilderConfig,
documents: FastHashMap<DocumentId, DocumentView>,
resources: PlainResources,
last_scene_id: u64,
}

/// The render backend is responsible for transforming high level display lists into
@@ -424,6 +428,7 @@ pub struct RenderBackend {
recorder: Option<Box<ApiRecordingReceiver>>,
sampler: Option<Box<AsyncPropertySampler + Send>>,

last_scene_id: u64,

This comment has been minimized.

@kvark

kvark May 28, 2018

Member

nit: any specific reason for not using usize?

This comment has been minimized.

@Gankra

Gankra May 28, 2018

Author Contributor

because all our other ids are 64-bit unconditionally (less platform-specificness)

enable_render_on_scroll: bool,
}

@@ -460,6 +465,7 @@ impl RenderBackend {
notifier,
recorder,
sampler,
last_scene_id: 0,
enable_render_on_scroll,
}
}
@@ -688,6 +694,12 @@ impl RenderBackend {
IdNamespace(NEXT_NAMESPACE_ID.fetch_add(1, Ordering::Relaxed) as u32)
}

pub fn make_unique_scene_id(&mut self) -> u64 {
// 2^64 scenes ought to be enough for anybody!
self.last_scene_id += 1;
self.last_scene_id
}

pub fn run(&mut self, mut profile_counters: BackendProfileCounters) {
let mut frame_counter: u32 = 0;
let mut keep_going = true;
@@ -746,7 +758,7 @@ impl RenderBackend {
document_id,
transaction_msg,
&mut frame_counter,
&mut profile_counters
&mut profile_counters,
);
}
},
@@ -945,7 +957,7 @@ impl RenderBackend {
document_id,
doc_msgs,
frame_counter,
profile_counters
profile_counters,
)
}
}
@@ -975,11 +987,14 @@ impl RenderBackend {
}

if transaction_msg.use_scene_builder_thread {
let scene_id = self.make_unique_scene_id();
let doc = self.documents.get_mut(&document_id).unwrap();

doc.forward_transaction_to_scene_builder(
transaction_msg,
&op,
document_id,
scene_id,
&self.resource_cache,
&self.scene_tx,
);
@@ -993,11 +1008,12 @@ impl RenderBackend {
);

if op.build {
let scene_id = self.make_unique_scene_id();
let doc = self.documents.get_mut(&document_id).unwrap();
let _timer = profile_counters.total_time.timer();
profile_scope!("build scene");

doc.build_scene(&mut self.resource_cache);
doc.build_scene(&mut self.resource_cache, scene_id);
doc.render_on_hittest = true;
}

@@ -1269,6 +1285,7 @@ impl RenderBackend {
.map(|(id, doc)| (*id, doc.view.clone()))
.collect(),
resources,
last_scene_id: self.last_scene_id,
};

config.serialize(&backend, "backend");
@@ -1328,6 +1345,7 @@ impl RenderBackend {
self.frame_config = backend.frame_config;
self.enable_render_on_scroll = backend.enable_render_on_scroll;

let mut last_scene_id = backend.last_scene_id;
for (id, view) in backend.documents {
debug!("\tdocument {:?}", id);
let scene_name = format!("scene-{}-{}", (id.0).0, id.1);
@@ -1362,7 +1380,8 @@ impl RenderBackend {
RenderedDocument::new(frame)
}
None => {
doc.build_scene(&mut self.resource_cache);
last_scene_id += 1;
doc.build_scene(&mut self.resource_cache, last_scene_id);
doc.render(
&mut self.resource_cache,
&mut self.gpu_cache,
@@ -57,6 +57,7 @@ pub struct SceneRequest {
pub font_instances: FontInstanceMap,
pub output_pipelines: FastHashSet<PipelineId>,
pub removed_pipelines: Vec<PipelineId>,
pub scene_id: u64,
}

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