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

Separate interning text run #3369

Merged
merged 10 commits into from Dec 6, 2018

Extract TextRun data out of PrimitiveKeyKind.

  • Loading branch information
djg committed Dec 5, 2018
commit 6591e0aa126b4d7b6173dfee364d1a1403d2b841

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -275,7 +275,7 @@ impl FrameBuilder {
&frame_context,
resource_cache,
gpu_cache,
&resources.prim_data_store,
resources,
&self.clip_store,
&mut retained_tiles,
);
@@ -134,16 +134,19 @@ pub struct DataStore<S, T, M> {
_marker: PhantomData<M>,
}

impl<S, T, M> DataStore<S, T, M> where S: Debug, T: From<S>, M: Debug {
/// Construct a new data store
pub fn new() -> Self {
impl<S, T, M> ::std::default::Default for DataStore<S, T, M> where S: Debug, T: From<S>, M: Debug
{
fn default() -> Self {
DataStore {
items: Vec::new(),
_source: PhantomData,
_marker: PhantomData,
}
}
}

impl<S, T, M> DataStore<S, T, M> where S: Debug, T: From<S>, M: Debug
{
/// Apply any updates from the scene builder thread to
/// this data store.
pub fn apply_updates(
@@ -64,9 +64,6 @@ extern crate serde;
#[macro_use]
extern crate thread_profiler;

#[macro_use]
mod storage;

mod batch;
mod border;
mod box_shadow;
@@ -112,6 +109,7 @@ mod scene_builder;
mod segment;
mod shade;
mod spatial_node;
mod storage;
mod surface;
mod texture_allocator;
mod texture_cache;
@@ -20,12 +20,14 @@ use gpu_types::{TransformPalette, TransformPaletteId, UvRectKind};
use internal_types::FastHashSet;
use plane_split::{Clipper, Polygon, Splitter};
use prim_store::{PictureIndex, PrimitiveInstance, SpaceMapper, VisibleFace, PrimitiveInstanceKind};
use prim_store::{get_raster_rects, PrimitiveDataInterner, PrimitiveDataStore, CoordinateSpaceMapping};
use prim_store::{get_raster_rects, CoordinateSpaceMapping};
use prim_store::{OpacityBindingStorage, PrimitiveTemplateKind, ImageInstanceStorage, OpacityBindingIndex, SizeKey};
use render_backend::FrameResources;
use render_task::{ClearMode, RenderTask, RenderTaskCacheEntryHandle, TileBlit};
use render_task::{RenderTaskCacheKey, RenderTaskCacheKeyKind, RenderTaskId, RenderTaskLocation};
use resource_cache::ResourceCache;
use scene::{FilterOpHelpers, SceneProperties};
use scene_builder::DocumentResources;
use smallvec::SmallVec;
use surface::{SurfaceDescriptor, TransformKey};
use std::{mem, ops};
@@ -601,7 +603,7 @@ impl TileCache {
prim_instance: &PrimitiveInstance,
surface_spatial_node_index: SpatialNodeIndex,
clip_scroll_tree: &ClipScrollTree,
prim_data_store: &PrimitiveDataStore,
resources: &FrameResources,
clip_chain_nodes: &[ClipChainNode],
pictures: &[PicturePrimitive],
resource_cache: &ResourceCache,
@@ -613,13 +615,31 @@ impl TileCache {
clip_scroll_tree,
);

let prim_data = &prim_data_store[prim_instance.prim_data_handle];
let (prim_rect, clip_rect) = match prim_instance.kind {
PrimitiveInstanceKind::Picture { data_handle, .. } |
PrimitiveInstanceKind::LineDecoration { data_handle, .. } |
PrimitiveInstanceKind::NormalBorder { data_handle, .. } |
PrimitiveInstanceKind::ImageBorder { data_handle, .. } |
PrimitiveInstanceKind::Rectangle { data_handle, .. } |
PrimitiveInstanceKind::YuvImage { data_handle, .. } |
PrimitiveInstanceKind::Image { data_handle, .. } |
PrimitiveInstanceKind::LinearGradient { data_handle, .. } |
PrimitiveInstanceKind::RadialGradient { data_handle, .. } |
PrimitiveInstanceKind::Clear { data_handle, .. } => {
let prim_data = &resources.prim_data_store[data_handle];
(&prim_data.prim_rect, &prim_data.clip_rect)
}
PrimitiveInstanceKind::TextRun { data_handle, .. } => {
let prim_data = &resources.text_run_data_store[data_handle];
(&prim_data.prim_rect, &prim_data.clip_rect)
}
};

// Map the primitive local rect into the picture space.
// TODO(gw): We should maybe store this in the primitive template
// during interning so that we never have to calculate
// it during frame building.
let culling_rect = match prim_data.prim_rect.intersection(&prim_data.clip_rect) {
let culling_rect = match prim_rect.intersection(&clip_rect) {
Some(rect) => rect,
None => return,
};
@@ -655,12 +675,12 @@ impl TileCache {

// Some primitives can not be cached (e.g. external video images)
let is_cacheable = prim_instance.is_cacheable(
prim_data_store,
&resources.prim_data_store,
resource_cache,
);

match prim_instance.kind {
PrimitiveInstanceKind::Picture { pic_index } => {
PrimitiveInstanceKind::Picture { pic_index,.. } => {
// Pictures can depend on animated opacity bindings.
let pic = &pictures[pic_index.0];
if let Some(PictureCompositeMode::Filter(FilterOp::Opacity(binding, _))) = pic.requested_composite_mode {
@@ -679,7 +699,8 @@ impl TileCache {
}
}
}
PrimitiveInstanceKind::Image { image_instance_index, .. } => {
PrimitiveInstanceKind::Image { data_handle, image_instance_index, .. } => {
let prim_data = &resources.prim_data_store[data_handle];
let image_instance = &image_instances[image_instance_index];
let opacity_binding_index = image_instance.opacity_binding_index;

@@ -701,7 +722,8 @@ impl TileCache {
}
}
}
PrimitiveInstanceKind::YuvImage { .. } => {
PrimitiveInstanceKind::YuvImage { data_handle, .. } => {
let prim_data = &resources.prim_data_store[data_handle];
match prim_data.kind {
PrimitiveTemplateKind::YuvImage { ref yuv_key, .. } => {
image_keys.extend_from_slice(yuv_key);
@@ -713,7 +735,7 @@ impl TileCache {
}
PrimitiveInstanceKind::TextRun { .. } |
PrimitiveInstanceKind::LineDecoration { .. } |
PrimitiveInstanceKind::Clear |
PrimitiveInstanceKind::Clear { .. } |
PrimitiveInstanceKind::NormalBorder { .. } |
PrimitiveInstanceKind::LinearGradient { .. } |
PrimitiveInstanceKind::RadialGradient { .. } |
@@ -778,7 +800,7 @@ impl TileCache {
}

// Update the tile descriptor, used for tile comparison during scene swaps.
tile.descriptor.prim_uids.push(prim_instance.prim_data_handle.uid());
tile.descriptor.prim_uids.push(prim_instance.uid());
tile.descriptor.clip_uids.extend_from_slice(&clip_chain_uids);
}
}
@@ -1259,7 +1281,7 @@ impl PrimitiveList {
/// significantly faster.
pub fn new(
mut prim_instances: Vec<PrimitiveInstance>,
prim_interner: &PrimitiveDataInterner,
resources: &DocumentResources
) -> Self {
let mut pictures = SmallVec::new();
let mut clusters_map = FastHashMap::default();
@@ -1272,7 +1294,7 @@ impl PrimitiveList {
// Check if this primitive is a picture. In future we should
// remove this match and embed this info directly in the primitive instance.
let is_pic = match prim_instance.kind {
PrimitiveInstanceKind::Picture { pic_index } => {
PrimitiveInstanceKind::Picture { pic_index, .. } => {
pictures.push(pic_index);
true
}
@@ -1281,9 +1303,26 @@ impl PrimitiveList {
}
};

let prim_data = match prim_instance.kind {
PrimitiveInstanceKind::Picture { data_handle, .. } |
PrimitiveInstanceKind::LineDecoration { data_handle, .. } |
PrimitiveInstanceKind::NormalBorder { data_handle, .. } |
PrimitiveInstanceKind::ImageBorder { data_handle, .. } |
PrimitiveInstanceKind::Rectangle { data_handle, .. } |
PrimitiveInstanceKind::YuvImage { data_handle, .. } |
PrimitiveInstanceKind::Image { data_handle, .. } |
PrimitiveInstanceKind::LinearGradient { data_handle, .. } |
PrimitiveInstanceKind::RadialGradient { data_handle, ..} |
PrimitiveInstanceKind::Clear { data_handle, .. } => {
&resources.prim_interner[data_handle]
}
PrimitiveInstanceKind::TextRun { data_handle, .. } => {
&resources.text_run_interner[data_handle]
}
};

// Get the key for the cluster that this primitive should
// belong to.
let prim_data = &prim_interner[prim_instance.prim_data_handle];
let key = PrimitiveClusterKey {
spatial_node_index: prim_instance.spatial_node_index,
is_backface_visible: prim_data.is_backface_visible,
@@ -1909,7 +1948,7 @@ impl PicturePrimitive {
state: &mut PictureUpdateState,
frame_context: &FrameBuildingContext,
resource_cache: &mut ResourceCache,
prim_data_store: &PrimitiveDataStore,
resources: &FrameResources,
pictures: &[PicturePrimitive],
clip_store: &ClipStore,
opacity_binding_store: &OpacityBindingStorage,
@@ -1927,7 +1966,7 @@ impl PicturePrimitive {
prim_instance,
surface_spatial_node_index,
&frame_context.clip_scroll_tree,
prim_data_store,
resources,
&clip_store.clip_chain_nodes,
pictures,
resource_cache,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.