/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{BuiltDisplayList, ColorF, DynamicProperties, Epoch, FontRenderMode}; use api::{PipelineId, PropertyBinding, PropertyBindingId, PropertyValue, MixBlendMode, StackingContext}; use api::units::*; use api::channel::Sender; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; usecrate::render_api::MemoryReport; usecrate::composite::CompositorKind; usecrate::clip::{ClipStore, ClipTree}; usecrate::spatial_tree::SpatialTree; usecrate::frame_builder::FrameBuilderConfig; usecrate::hit_test::{HitTester, HitTestingScene, HitTestingSceneStats}; usecrate::internal_types::FastHashMap; usecrate::picture::SurfaceInfo; usecrate::picture_graph::PictureGraph; usecrate::prim_store::{PrimitiveStore, PrimitiveStoreStats, PictureIndex, PrimitiveInstance}; usecrate::tile_cache::TileCacheConfig; use std::sync::Arc;
/// Stores a map of the animated property bindings for the current display list. These /// can be used to animate the transform and/or opacity of a display list without /// re-submitting the display list itself. #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] pubstruct SceneProperties {
transform_properties: FastHashMap<PropertyBindingId, LayoutTransform>,
float_properties: FastHashMap<PropertyBindingId, f32>,
color_properties: FastHashMap<PropertyBindingId, ColorF>,
current_properties: DynamicProperties,
pending_properties: Option<DynamicProperties>,
}
/// Reset the pending properties without flush. pubfn reset_properties(&mutself) { self.pending_properties = None;
}
/// Add to the current property list for this display list. pubfn add_properties(&mutself, properties: DynamicProperties) { letmut pending_properties = self.pending_properties
.take()
.unwrap_or_default();
/// Add to the current transform property list for this display list. pubfn add_transforms(&mutself, transforms: Vec<PropertyValue<LayoutTransform>>) { letmut pending_properties = self.pending_properties
.take()
.unwrap_or_default();
/// Flush any pending updates to the scene properties. Returns /// true if the properties have changed since the last flush /// was called. This code allows properties to be changed by /// multiple reset_properties, add_properties and add_transforms calls /// during a single transaction, and still correctly determine if any /// properties have changed. This can have significant power /// saving implications, allowing a frame build to be skipped /// if the properties haven't changed in many cases. pubfn flush_pending_updates(&mutself) -> bool { letmut properties_changed = false;
/// Get the current value for a color property. pubfn resolve_color(
&self,
property: &PropertyBinding<ColorF>
) -> ColorF { match *property {
PropertyBinding::Value(value) => value,
PropertyBinding::Binding(ref key, v) => { self.color_properties
.get(&key.id)
.cloned()
.unwrap_or(v)
}
}
}
/// A representation of the layout within the display port for a given document or iframe. #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] #[derive(Clone)] pubstruct ScenePipeline { pub display_list: BuiltDisplayList,
}
/// A complete representation of the layout bundling visible pipelines together. #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] #[derive(Clone)] pubstruct Scene { pub root_pipeline_id: Option<PipelineId>, pub pipelines: FastHashMap<PipelineId, ScenePipeline>, pub pipeline_epochs: FastHashMap<PipelineId, Epoch>,
}
impl Scene { pubfn new() -> Self {
Scene {
root_pipeline_id: None,
pipelines: FastHashMap::default(),
pipeline_epochs: FastHashMap::default(),
}
}
/// Deallocating memory outside of the thread that allocated it causes lock /// contention in jemalloc. To avoid this we send the built scene back to /// the scene builder thread when we don't need it anymore, and in the process, /// also reuse some allocations. pub recycler_tx: Option<Sender<BuiltScene>>,
}
/// Send the scene back to the scene builder thread so that recycling/deallocations /// can happen there. pubfn recycle(mutself) { iflet Some(tx) = self.recycler_tx.take() { let _ = tx.send(self);
}
}
/// Get the memory usage statistics to pre-allocate for the next scene. pubfn get_stats(&self) -> SceneStats {
SceneStats {
prim_store_stats: self.prim_store.get_stats(),
hit_test_stats: self.hit_testing_scene.get_stats(),
}
}
/// Stores the allocation sizes of various arrays in the built /// scene. This is retrieved from the current frame builder /// and used to reserve an approximately correct capacity of /// the arrays for the next scene that is getting built. pubstruct SceneStats { pub prim_store_stats: PrimitiveStoreStats, pub hit_test_stats: HitTestingSceneStats,
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.