From 3c8cf2178444f0d77751a94d3fdb2166e0dabb7b Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2019 10:08:03 -0500 Subject: [PATCH 1/5] Remove unused ClipNodeIndex --- webrender/doc/CLIPPING_AND_POSITIONING.md | 2 +- webrender/src/clip.rs | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/webrender/doc/CLIPPING_AND_POSITIONING.md b/webrender/doc/CLIPPING_AND_POSITIONING.md index cac264dffb..b6fd527fba 100644 --- a/webrender/doc/CLIPPING_AND_POSITIONING.md +++ b/webrender/doc/CLIPPING_AND_POSITIONING.md @@ -140,7 +140,7 @@ also are pushed and popped like stacking contexts. WebRender must access `ClipNodes` and `SpatialNodes` quite a bit when building scenes and frames, so it tries to convert `ClipIds`, which are already per-pipeline indices, to global scene-wide indices. Internally this is a -conversion from `ClipId` into `SpatialNodeIndex`, `ClipNodeIndex` or +conversion from `ClipId` into `SpatialNodeIndex` or `ClipChainIndex`. In order to make this conversion cheaper, the `DisplayListFlattner` assigns offsets for each pipeline and node type in the scene-wide `ClipScrollTree`. diff --git a/webrender/src/clip.rs b/webrender/src/clip.rs index 22ded5e2a8..2bbab4c5fe 100644 --- a/webrender/src/clip.rs +++ b/webrender/src/clip.rs @@ -89,7 +89,6 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | +------------------+------------------+------------------+------------------+------------------+ | flags | flags | flags | flags | flags | - | ClipNodeIndex | ClipNodeIndex | ClipNodeIndex | ClipNodeIndex | ClipNodeIndex | +------------------+------------------+------------------+------------------+------------------+ */ @@ -206,12 +205,6 @@ pub struct ClipChainNode { pub parent_clip_chain_id: ClipChainId, } -// An index into the clip_nodes array. -#[derive(Clone, Copy, Debug, PartialEq, Hash, Eq)] -#[cfg_attr(feature = "capture", derive(Serialize))] -#[cfg_attr(feature = "replay", derive(Deserialize))] -pub struct ClipNodeIndex(pub u32); - // When a clip node is found to be valid for a // clip chain instance, it's stored in an index // buffer style structure. This struct contains From 0ad359354704e609470e493a1b51dc316d3edfba Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2019 10:13:39 -0500 Subject: [PATCH 2/5] Fix ClipNode documentation --- webrender/src/clip.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webrender/src/clip.rs b/webrender/src/clip.rs index 2bbab4c5fe..d314c026db 100644 --- a/webrender/src/clip.rs +++ b/webrender/src/clip.rs @@ -36,13 +36,21 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; ClipItem - A single clip item (e.g. a rounded rect, or a box shadow). These are an exposed API type, stored inline in a ClipNode. - ClipNode - A ClipItem with attached positioning information (a spatial node index). - Stored as a contiguous array of nodes within the ClipStore. + ClipNode - A ClipItem with an attached GPU handle. The GPU handle is populated + when a ClipNodeInstance is built from this node (which happens while + preparing primitives for render). + ClipNodeInstance - A ClipNode with attached positioning information (a spatial + node index). This is stored as a contiguous array of nodes + within the ClipStore. + + +-----------------------+-----------------------+-----------------------+ + | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | +-----------------------+-----------------------+-----------------------+ | ClipItem | ClipItem | ClipItem | | Spatial Node Index | Spatial Node Index | Spatial Node Index | | GPU cache handle | GPU cache handle | GPU cache handle | + | ... | ... | ... | +-----------------------+-----------------------+-----------------------+ 0 1 2 From d1bd1b602736871c31f8fc640dbbc129146361b7 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2019 10:14:22 -0500 Subject: [PATCH 3/5] ClipItemRange isn't a thing anymore, ClipNodeRange is the new hotness. --- webrender/src/clip.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webrender/src/clip.rs b/webrender/src/clip.rs index d314c026db..6cce0ad3d3 100644 --- a/webrender/src/clip.rs +++ b/webrender/src/clip.rs @@ -55,15 +55,15 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; 0 1 2 +----------------+ | | - | ClipItemRange |____| | + | ClipNodeRange |____| | | index: 1 | | | count: 2 |___________________________________________________| +----------------+ - ClipItemRange - A clip item range identifies a range of clip nodes. It is stored - as an (index, count). + ClipNodeRange - A clip item range identifies a range of clip nodes instances. + It is stored as an (index, count). - ClipChain - A clip chain node contains a range of ClipNodes (a ClipItemRange) + ClipChain - A clip chain node contains a range of ClipNodes (a ClipNodeRange) and a parent link to an optional ClipChain. Both legacy hierchical clip chains and user defined API clip chains use the same data structure. ClipChainId is an index into an array, or ClipChainId::NONE for no parent. @@ -71,7 +71,7 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; +----------------+ ____+----------------+ ____+----------------+ ____+----------------+ | ClipChain | | | ClipChain | | | ClipChain | | | ClipChain | +----------------+ | +----------------+ | +----------------+ | +----------------+ - | ClipItemRange | | | ClipItemRange | | | ClipItemRange | | | ClipItemRange | + | ClipNodeRange | | | ClipNodeRange | | | ClipNodeRange | | | ClipNodeRange | | Parent Id |___| | Parent Id |___| | Parent Id |___| | Parent Id | +----------------+ +----------------+ +----------------+ +----------------+ From 6868ce3d4f754d073dde80f54298e3e1fb0f74cf Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2019 10:28:20 -0500 Subject: [PATCH 4/5] ClipChain isn't a thing, but there's a ClipChainNode --- webrender/src/clip.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/webrender/src/clip.rs b/webrender/src/clip.rs index 6cce0ad3d3..dfad604737 100644 --- a/webrender/src/clip.rs +++ b/webrender/src/clip.rs @@ -63,17 +63,19 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; ClipNodeRange - A clip item range identifies a range of clip nodes instances. It is stored as an (index, count). - ClipChain - A clip chain node contains a range of ClipNodes (a ClipNodeRange) - and a parent link to an optional ClipChain. Both legacy hierchical clip - chains and user defined API clip chains use the same data structure. - ClipChainId is an index into an array, or ClipChainId::NONE for no parent. - - +----------------+ ____+----------------+ ____+----------------+ ____+----------------+ - | ClipChain | | | ClipChain | | | ClipChain | | | ClipChain | - +----------------+ | +----------------+ | +----------------+ | +----------------+ - | ClipNodeRange | | | ClipNodeRange | | | ClipNodeRange | | | ClipNodeRange | - | Parent Id |___| | Parent Id |___| | Parent Id |___| | Parent Id | - +----------------+ +----------------+ +----------------+ +----------------+ + ClipChainNode - A clip chain node contains a handle to an interned clip item, + positioning information (from where the clip was defined), and + an optional parent link to another ClipChainNode. ClipChainId + is an index into an array, or ClipChainId::NONE for no parent. + + +----------------+ ____+----------------+ ____+----------------+ /---> ClipChainId::NONE + | ClipChainNode | | | ClipChainNode | | | ClipChainNode | | + +----------------+ | +----------------+ | +----------------+ | + | ClipDataHandle | | | ClipDataHandle | | | ClipDataHandle | | + | Spatial index | | | Spatial index | | | Spatial index | | + | Parent Id |___| | Parent Id |___| | Parent Id |___| + | ... | | ... | | ... | + +----------------+ +----------------+ +----------------+ ClipChainInstance - A ClipChain that has been built for a specific primitive + positioning node. From 8b16400f9fec9e0cd9ce73813668abbe369c1439 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2019 11:57:00 -0500 Subject: [PATCH 5/5] Update ClipChainInstance docs --- webrender/src/clip.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webrender/src/clip.rs b/webrender/src/clip.rs index dfad604737..8870ec184f 100644 --- a/webrender/src/clip.rs +++ b/webrender/src/clip.rs @@ -79,10 +79,10 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; ClipChainInstance - A ClipChain that has been built for a specific primitive + positioning node. - When given a clip chain ID, and a local primitive rect + spatial node, the clip module + When given a clip chain ID, and a local primitive rect and its spatial node, the clip module creates a clip chain instance. This is a struct with various pieces of useful information - (such as a local clip rect and affected local bounding rect). It also contains a (index, count) - range specifier into an index buffer of the ClipNode structures that are actually relevant + (such as a local clip rect). It also contains a (index, count) + range specifier into an index buffer of the ClipNodeInstance structures that are actually relevant for this clip chain instance. The index buffer structure allows a single array to be used for all of the clip-chain instances built in a single frame. Each entry in the index buffer also stores some flags relevant to the clip node in this positioning context. @@ -90,8 +90,8 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; +----------------------+ | ClipChainInstance | +----------------------+ - | local_clip_rect | - | local_bounding_rect |________________________________________________________________________ + | ... | + | local_clip_rect |________________________________________________________________________ | clips_range |_______________ | +----------------------+ | | | | @@ -99,6 +99,7 @@ use util::{extract_inner_rect_safe, project_rect, ScaleOffset}; | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | ClipNodeInstance | +------------------+------------------+------------------+------------------+------------------+ | flags | flags | flags | flags | flags | + | ... | ... | ... | ... | ... | +------------------+------------------+------------------+------------------+------------------+ */