зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 77d7f22c81c4 (bug 1605283) for wrench build bustages on a CLOSED TREE
This commit is contained in:
Родитель
44fdc88d8f
Коммит
f0fa29abdf
|
@ -3,15 +3,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use webrender::{TileNode, TileNodeKind, InvalidationReason, TileOffset};
|
use webrender::{TileNode, TileNodeKind, InvalidationReason, TileOffset};
|
||||||
use webrender::{TileSerializer, TileCacheInstanceSerializer, TileCacheLoggerUpdateLists};
|
use webrender::{TileSerializer, TileCacheInstanceSerializer};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
//use ron::de::from_reader;
|
//use ron::de::from_reader;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use webrender::api::enumerate_interners;
|
|
||||||
use webrender::UpdateKind;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Slice {
|
pub struct Slice {
|
||||||
|
@ -234,7 +232,7 @@ fn slices_to_svg(slices: &[Slice], prev_slices: Option<Vec<Slice>>,
|
||||||
+ "\n</svg>\n"
|
+ "\n</svg>\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_html(output_dir: &Path, svg_files: &[String], intern_files: &[String]) {
|
fn write_html(output_dir: &Path, svg_files: &[String]) {
|
||||||
let html_head = "<!DOCTYPE html>\n\
|
let html_head = "<!DOCTYPE html>\n\
|
||||||
<html>\n\
|
<html>\n\
|
||||||
<head>\n\
|
<head>\n\
|
||||||
|
@ -253,14 +251,7 @@ fn write_html(output_dir: &Path, svg_files: &[String], intern_files: &[String])
|
||||||
for svg_file in svg_files {
|
for svg_file in svg_files {
|
||||||
script = format!("{} \"{}\",\n", script, svg_file);
|
script = format!("{} \"{}\",\n", script, svg_file);
|
||||||
}
|
}
|
||||||
script = format!("{}];\n\n", script);
|
|
||||||
|
|
||||||
script = format!("{}var intern_files = [\n", script);
|
|
||||||
for intern_file in intern_files {
|
|
||||||
script = format!("{} \"{}\",\n", script, intern_file);
|
|
||||||
}
|
|
||||||
script = format!("{}];\n</script>\n\n", script);
|
script = format!("{}];\n</script>\n\n", script);
|
||||||
|
|
||||||
//TODO this requires copying the js file from somewhere?
|
//TODO this requires copying the js file from somewhere?
|
||||||
script = format!("{}<script src=\"tilecache.js\" type=\"text/javascript\"></script>\n\n", script);
|
script = format!("{}<script src=\"tilecache.js\" type=\"text/javascript\"></script>\n\n", script);
|
||||||
|
|
||||||
|
@ -271,17 +262,8 @@ fn write_html(output_dir: &Path, svg_files: &[String], intern_files: &[String])
|
||||||
|
|
||||||
let html_body = format!(
|
let html_body = format!(
|
||||||
"{}\n\
|
"{}\n\
|
||||||
<div class=\"split left\">\n\
|
<object id=\"svg_container0\" type=\"image/svg+xml\" data=\"{}\" class=\"tile_svg\" ></object>\n\
|
||||||
<div>\n\
|
<object id=\"svg_container1\" type=\"image/svg+xml\" data=\"{}\" class=\"tile_svg\" ></object>\n\
|
||||||
<object id=\"svg_container0\" type=\"image/svg+xml\" data=\"{}\" class=\"tile_svg\" ></object>\n\
|
|
||||||
<object id=\"svg_container1\" type=\"image/svg+xml\" data=\"{}\" class=\"tile_svg\" ></object>\n\
|
|
||||||
</div>\n\
|
|
||||||
</div>\n\
|
|
||||||
\n\
|
|
||||||
<div class=\"split right\">\n\
|
|
||||||
<iframe width=\"100%\" id=\"intern\" src=\"{}\"></iframe>\n\
|
|
||||||
</div>\n\
|
|
||||||
\n\
|
|
||||||
<div id=\"svg_ui_overlay\">\n\
|
<div id=\"svg_ui_overlay\">\n\
|
||||||
<div id=\"text_frame_counter\">{}</div>\n\
|
<div id=\"text_frame_counter\">{}</div>\n\
|
||||||
<div id=\"text_spacebar\">Spacebar to Play</div>\n\
|
<div id=\"text_spacebar\">Spacebar to Play</div>\n\
|
||||||
|
@ -291,7 +273,6 @@ fn write_html(output_dir: &Path, svg_files: &[String], intern_files: &[String])
|
||||||
html_body,
|
html_body,
|
||||||
svg_files[0],
|
svg_files[0],
|
||||||
svg_files[0],
|
svg_files[0],
|
||||||
intern_files[0],
|
|
||||||
svg_files[0],
|
svg_files[0],
|
||||||
svg_files.len() );
|
svg_files.len() );
|
||||||
|
|
||||||
|
@ -304,59 +285,32 @@ fn write_html(output_dir: &Path, svg_files: &[String], intern_files: &[String])
|
||||||
|
|
||||||
fn write_css(output_dir: &Path, max_slice_index: usize) {
|
fn write_css(output_dir: &Path, max_slice_index: usize) {
|
||||||
let mut css = ".tile_svg {\n\
|
let mut css = ".tile_svg {\n\
|
||||||
float: left;\n\
|
position: fixed;\n\
|
||||||
}\n\
|
}\n\n\n\
|
||||||
\n\
|
|
||||||
.split {\n\
|
|
||||||
position: fixed;\n\
|
|
||||||
z-index: 1;\n\
|
|
||||||
top: 0;\n\
|
|
||||||
padding-top: 20px;\n\
|
|
||||||
}\n\
|
|
||||||
\n\
|
|
||||||
.left {\n\
|
|
||||||
left: 0;\n\
|
|
||||||
}\n\
|
|
||||||
\n\
|
|
||||||
.right {\n\
|
|
||||||
right: 0;\n\
|
|
||||||
width: 20%;\n\
|
|
||||||
height: 100%;\n\
|
|
||||||
opacity: 90%;\n\
|
|
||||||
}\n\
|
|
||||||
\n\
|
|
||||||
#intern {\n\
|
|
||||||
position:relative;\n\
|
|
||||||
top:60px;\n\
|
|
||||||
width: 100%;\n\
|
|
||||||
height: 100%;\n\
|
|
||||||
color: orange;\n\
|
|
||||||
background-color:white;\n\
|
|
||||||
}\n\
|
|
||||||
.svg_invalidated {\n\
|
.svg_invalidated {\n\
|
||||||
fill: white;\n\
|
fill: white;\n\
|
||||||
font-family:monospace;\n\
|
font-family:monospace;\n\
|
||||||
}\n\n\n\
|
}\n\n\n\
|
||||||
#svg_ui_overlay {\n\
|
#svg_ui_overlay {\n\
|
||||||
position:absolute;\n\
|
position:absolute;\n\
|
||||||
right:0; \n\
|
right:0; \n\
|
||||||
top:0; \n\
|
top:0; \n\
|
||||||
z-index:70; \n\
|
z-index:70; \n\
|
||||||
color: rgb(255,255,100);\n\
|
color: rgb(255,255,100);\n\
|
||||||
font-family:monospace;\n\
|
font-family:monospace;\n\
|
||||||
background-color: #404040a0;\n\
|
background-color: #404040a0;\n\
|
||||||
}\n\n\n\
|
}\n\n\n\
|
||||||
.svg_quadtree {\n\
|
.svg_quadtree {\n\
|
||||||
fill: none;\n\
|
fill: none;\n\
|
||||||
stroke-width: 1;\n\
|
stroke-width: 1;\n\
|
||||||
stroke: orange;\n\
|
stroke: orange;\n\
|
||||||
}\n\n\n\
|
}\n\n\n\
|
||||||
.svg_changed_prim {\n\
|
.svg_changed_prim {\n\
|
||||||
stroke: red;\n\
|
stroke: red;\n\
|
||||||
stroke-width: 2.0;\n\
|
stroke-width: 2.0;\n\
|
||||||
}\n\n\n\
|
}\n\n\n\
|
||||||
#svg_ui_slider {\n\
|
#svg_ui_slider {\n\
|
||||||
width:90%;\n\
|
width:90%;\n\
|
||||||
}\n\n".to_string();
|
}\n\n".to_string();
|
||||||
|
|
||||||
for ix in 0..max_slice_index + 1 {
|
for ix in 0..max_slice_index + 1 {
|
||||||
|
@ -387,64 +341,6 @@ fn write_css(output_dir: &Path, max_slice_index: usize) {
|
||||||
css_output.write_all(css.as_bytes()).unwrap();
|
css_output.write_all(css.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! updatelist_to_html_macro {
|
|
||||||
( $( $name:ident: $ty:ty, )+ ) => {
|
|
||||||
fn updatelist_to_html(update_lists: &TileCacheLoggerUpdateLists) -> String {
|
|
||||||
let mut html = String::new();
|
|
||||||
$(
|
|
||||||
html += &format!("<h4 style=\"margin:5px;\">{}</h4>\n<font color=\"green\">\n", stringify!($name));
|
|
||||||
let mut was_insert = true;
|
|
||||||
for update in &update_lists.$name.1 {
|
|
||||||
let is_insert = match update.kind {
|
|
||||||
UpdateKind::Insert => true,
|
|
||||||
_ => false
|
|
||||||
};
|
|
||||||
if was_insert != is_insert {
|
|
||||||
html += &format!("</font><font color=\"{}\">", if is_insert { "green" } else { "red" });
|
|
||||||
}
|
|
||||||
html += &format!("{}, \n", update.index);
|
|
||||||
was_insert = is_insert;
|
|
||||||
}
|
|
||||||
html += &"</font><hr/>\n";
|
|
||||||
)+
|
|
||||||
html
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enumerate_interners!(updatelist_to_html_macro);
|
|
||||||
|
|
||||||
fn write_tile_cache_visualizer_svg(entry: &std::fs::DirEntry, output_dir: &Path,
|
|
||||||
slices: &[Slice], prev_slices: Option<Vec<Slice>>,
|
|
||||||
svg_width: &mut i32, svg_height: &mut i32,
|
|
||||||
max_slice_index: &mut usize,
|
|
||||||
svg_files: &mut Vec::<String>)
|
|
||||||
{
|
|
||||||
let svg = slices_to_svg(&slices, prev_slices, svg_width, svg_height, max_slice_index);
|
|
||||||
|
|
||||||
let mut output_filename = OsString::from(entry.path().file_name().unwrap());
|
|
||||||
output_filename.push(".svg");
|
|
||||||
svg_files.push(output_filename.to_string_lossy().to_string());
|
|
||||||
|
|
||||||
output_filename = output_dir.join(output_filename).into_os_string();
|
|
||||||
let mut svg_output = File::create(output_filename).unwrap();
|
|
||||||
svg_output.write_all(svg.as_bytes()).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_update_list_html(entry: &std::fs::DirEntry, output_dir: &Path,
|
|
||||||
update_lists: &TileCacheLoggerUpdateLists,
|
|
||||||
html_files: &mut Vec::<String>)
|
|
||||||
{
|
|
||||||
let html = updatelist_to_html(update_lists);
|
|
||||||
|
|
||||||
let mut output_filename = OsString::from(entry.path().file_name().unwrap());
|
|
||||||
output_filename.push(".html");
|
|
||||||
html_files.push(output_filename.to_string_lossy().to_string());
|
|
||||||
|
|
||||||
output_filename = output_dir.join(output_filename).into_os_string();
|
|
||||||
let mut html_output = File::create(output_filename).unwrap();
|
|
||||||
html_output.write_all(html.as_bytes()).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
|
@ -470,7 +366,6 @@ fn main() {
|
||||||
entries.sort_by_key(|dir| dir.path());
|
entries.sort_by_key(|dir| dir.path());
|
||||||
|
|
||||||
let mut svg_files: Vec::<String> = Vec::new();
|
let mut svg_files: Vec::<String> = Vec::new();
|
||||||
let mut intern_files: Vec::<String> = Vec::new();
|
|
||||||
let mut prev_slices = None;
|
let mut prev_slices = None;
|
||||||
|
|
||||||
for entry in &entries {
|
for entry in &entries {
|
||||||
|
@ -478,33 +373,31 @@ fn main() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
print!("processing {:?}\t", entry.path());
|
print!("processing {:?}\t", entry.path());
|
||||||
let file_data = std::fs::read_to_string(entry.path()).unwrap();
|
let f = File::open(entry.path()).unwrap();
|
||||||
let chunks: Vec<_> = file_data.split("// @@@ chunk @@@").collect();
|
let slices: Vec<Slice> = match ron::de::from_reader(f) {
|
||||||
let slices: Vec<Slice> = match ron::de::from_str(&chunks[0]) {
|
|
||||||
Ok(data) => { data }
|
Ok(data) => { data }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("ERROR: failed to deserialize slicesg {:?}\n{:?}", entry.path(), e);
|
println!("ERROR: failed to deserialize {:?}\n{:?}", entry.path(), e);
|
||||||
prev_slices = None;
|
prev_slices = None;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut update_lists = TileCacheLoggerUpdateLists::new();
|
|
||||||
update_lists.from_ron(&chunks[1]);
|
|
||||||
|
|
||||||
write_tile_cache_visualizer_svg(&entry, &output_dir,
|
let svg = slices_to_svg(&slices, prev_slices, &mut svg_width, &mut svg_height, &mut max_slice_index);
|
||||||
&slices, prev_slices,
|
|
||||||
&mut svg_width, &mut svg_height,
|
|
||||||
&mut max_slice_index,
|
|
||||||
&mut svg_files);
|
|
||||||
|
|
||||||
write_update_list_html(&entry, &output_dir, &update_lists,
|
let mut output_filename = OsString::from(entry.path().file_name().unwrap());
|
||||||
&mut intern_files);
|
output_filename.push(".svg");
|
||||||
|
svg_files.push(output_filename.to_string_lossy().to_string());
|
||||||
|
|
||||||
|
output_filename = output_dir.join(output_filename).into_os_string();
|
||||||
|
let mut svg_output = File::create(output_filename).unwrap();
|
||||||
|
svg_output.write_all(svg.as_bytes()).unwrap();
|
||||||
|
|
||||||
print!("\r");
|
print!("\r");
|
||||||
prev_slices = Some(slices);
|
prev_slices = Some(slices);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_html(output_dir, &svg_files, &intern_files);
|
write_html(output_dir, &svg_files);
|
||||||
write_css(output_dir, max_slice_index);
|
write_css(output_dir, max_slice_index);
|
||||||
|
|
||||||
println!("OK. For now, manually copy tilecache.js to the output folder please. ");
|
println!("OK. For now, manually copy tilecache.js to the output folder please. ");
|
||||||
|
|
|
@ -75,7 +75,6 @@ function go_to_svg(index) {
|
||||||
is_loading = false;
|
is_loading = false;
|
||||||
}
|
}
|
||||||
backbuffer.setAttribute('data', svg_files[svg_index]);
|
backbuffer.setAttribute('data', svg_files[svg_index]);
|
||||||
document.getElementById('intern').src = intern_files[svg_index];
|
|
||||||
|
|
||||||
// also see https://stackoverflow.com/a/29915275
|
// also see https://stackoverflow.com/a/29915275
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct Epoch(u64);
|
||||||
/// provided by the interning structure.
|
/// provided by the interning structure.
|
||||||
pub struct UpdateList<S> {
|
pub struct UpdateList<S> {
|
||||||
/// The additions and removals to apply.
|
/// The additions and removals to apply.
|
||||||
pub updates: Vec<Update>,
|
updates: Vec<Update>,
|
||||||
/// Actual new data to insert.
|
/// Actual new data to insert.
|
||||||
data: Vec<S>,
|
data: Vec<S>,
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ pub enum UpdateKind {
|
||||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||||
#[derive(MallocSizeOf)]
|
#[derive(MallocSizeOf)]
|
||||||
pub struct Update {
|
pub struct Update {
|
||||||
pub index: usize,
|
index: usize,
|
||||||
pub kind: UpdateKind,
|
kind: UpdateKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait InternDebug {
|
pub trait InternDebug {
|
||||||
|
|
|
@ -222,5 +222,4 @@ pub use crate::shade::{Shaders, WrShaders};
|
||||||
pub use api as webrender_api;
|
pub use api as webrender_api;
|
||||||
pub use webrender_build::shader::ProgramSourceDigest;
|
pub use webrender_build::shader::ProgramSourceDigest;
|
||||||
pub use crate::picture::{TileDescriptor, TileId, InvalidationReason, PrimitiveCompareResult};
|
pub use crate::picture::{TileDescriptor, TileId, InvalidationReason, PrimitiveCompareResult};
|
||||||
pub use crate::picture::{TileNode, TileNodeKind, TileSerializer, TileCacheInstanceSerializer, TileOffset, TileCacheLoggerUpdateLists};
|
pub use crate::picture::{TileNode, TileNodeKind, TileSerializer, TileCacheInstanceSerializer, TileOffset};
|
||||||
pub use crate::intern::{Update,UpdateKind};
|
|
||||||
|
|
|
@ -109,11 +109,6 @@ use crate::util::{TransformedRectKind, MatrixHelpers, MaxRect, scale_factors, Ve
|
||||||
use crate::filterdata::{FilterDataHandle};
|
use crate::filterdata::{FilterDataHandle};
|
||||||
#[cfg(feature = "capture")]
|
#[cfg(feature = "capture")]
|
||||||
use ron;
|
use ron;
|
||||||
#[cfg(feature = "capture")]
|
|
||||||
use crate::scene_builder_thread::InternerUpdates;
|
|
||||||
#[cfg(feature = "capture")]
|
|
||||||
use crate::intern::Update;
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "capture")]
|
#[cfg(feature = "capture")]
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -1498,134 +1493,13 @@ pub struct TileCacheLoggerSlice {
|
||||||
pub local_to_world_transform: DeviceRect
|
pub local_to_world_transform: DeviceRect
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "capture", feature = "replay"))]
|
|
||||||
macro_rules! declare_tile_cache_logger_updatelists {
|
|
||||||
( $( $name:ident : $ty:ty, )+ ) => {
|
|
||||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
|
||||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
|
||||||
struct TileCacheLoggerUpdateListsSerializer {
|
|
||||||
pub ron_string: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TileCacheLoggerUpdateLists {
|
|
||||||
$(
|
|
||||||
/// Generate storage, one per interner.
|
|
||||||
/// the tuple is a workaround to avoid the need for multiple
|
|
||||||
/// fields that start with $name (macro concatenation).
|
|
||||||
/// the string is .ron serialized updatelist at capture time;
|
|
||||||
/// the updates is the list of DataStore updates (avoid UpdateList
|
|
||||||
/// due to Default() requirements on the Keys) reconstructed at
|
|
||||||
/// load time.
|
|
||||||
pub $name: (String, Vec<Update>),
|
|
||||||
)+
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TileCacheLoggerUpdateLists {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
TileCacheLoggerUpdateLists {
|
|
||||||
$(
|
|
||||||
$name : ( String::new(), Vec::<Update>::new() ),
|
|
||||||
)+
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// serialize all interners in updates to .ron
|
|
||||||
fn serialize_updates(
|
|
||||||
&mut self,
|
|
||||||
updates: &InternerUpdates
|
|
||||||
) {
|
|
||||||
$(
|
|
||||||
self.$name.0 = ron::ser::to_string_pretty(&updates.$name.updates, Default::default()).unwrap();
|
|
||||||
)+
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_empty(&self) -> bool {
|
|
||||||
$(
|
|
||||||
if !self.$name.0.is_empty() { return false; }
|
|
||||||
)+
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "capture")]
|
|
||||||
fn to_ron(&self) -> String {
|
|
||||||
let mut serializer =
|
|
||||||
TileCacheLoggerUpdateListsSerializer { ron_string: Vec::new() };
|
|
||||||
$(
|
|
||||||
serializer.ron_string.push(
|
|
||||||
if self.$name.0.is_empty() {
|
|
||||||
"[]".to_string()
|
|
||||||
} else {
|
|
||||||
self.$name.0.clone()
|
|
||||||
});
|
|
||||||
)+
|
|
||||||
ron::ser::to_string_pretty(&serializer, Default::default()).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "replay")]
|
|
||||||
pub fn from_ron(&mut self, text: &str) {
|
|
||||||
let serializer : TileCacheLoggerUpdateListsSerializer =
|
|
||||||
match ron::de::from_str(&text) {
|
|
||||||
Ok(data) => { data }
|
|
||||||
Err(e) => {
|
|
||||||
println!("ERROR: failed to deserialize updatelist: {:?}\n{:?}", &text, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let mut index = 0;
|
|
||||||
$(
|
|
||||||
self.$name.1 = ron::de::from_str(&serializer.ron_string[index]).unwrap();
|
|
||||||
index = index + 1;
|
|
||||||
)+
|
|
||||||
// error: value assigned to `index` is never read
|
|
||||||
let _ = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "capture", feature = "replay"))]
|
|
||||||
enumerate_interners!(declare_tile_cache_logger_updatelists);
|
|
||||||
|
|
||||||
#[cfg(not(any(feature = "capture", feature = "replay")))]
|
|
||||||
pub struct TileCacheLoggerUpdateLists {
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(any(feature = "capture", feature = "replay")))]
|
|
||||||
impl TileCacheLoggerUpdateLists {
|
|
||||||
pub fn new() -> Self { TileCacheLoggerUpdateLists {} }
|
|
||||||
fn is_empty(&self) -> bool { true }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Log tile cache activity for one single frame.
|
|
||||||
/// Also stores the commands sent to the interning data_stores
|
|
||||||
/// so we can see which items were created or destroyed this frame,
|
|
||||||
/// and correlate that with tile invalidation activity.
|
|
||||||
pub struct TileCacheLoggerFrame {
|
|
||||||
/// slices in the frame, one per take_context call
|
|
||||||
pub slices: Vec<TileCacheLoggerSlice>,
|
|
||||||
/// interning activity
|
|
||||||
pub update_lists: TileCacheLoggerUpdateLists
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TileCacheLoggerFrame {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
TileCacheLoggerFrame {
|
|
||||||
slices: Vec::new(),
|
|
||||||
update_lists: TileCacheLoggerUpdateLists::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.slices.is_empty() && self.update_lists.is_empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Log tile cache activity whenever anything happens in take_context.
|
/// Log tile cache activity whenever anything happens in take_context.
|
||||||
pub struct TileCacheLogger {
|
pub struct TileCacheLogger {
|
||||||
/// next write pointer
|
/// next write pointer
|
||||||
pub write_index : usize,
|
pub write_index : usize,
|
||||||
/// ron serialization of tile caches;
|
/// ron serialization of tile caches;
|
||||||
pub frames: Vec<TileCacheLoggerFrame>
|
/// each frame consists of slices, one per take_context call
|
||||||
|
pub frames: Vec<Vec<TileCacheLoggerSlice>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TileCacheLogger {
|
impl TileCacheLogger {
|
||||||
|
@ -1633,9 +1507,8 @@ impl TileCacheLogger {
|
||||||
num_frames: usize
|
num_frames: usize
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut frames = Vec::with_capacity(num_frames);
|
let mut frames = Vec::with_capacity(num_frames);
|
||||||
for _i in 0..num_frames { // no Clone so no resize
|
let empty_element = Vec::new();
|
||||||
frames.push(TileCacheLoggerFrame::new());
|
frames.resize(num_frames, empty_element);
|
||||||
}
|
|
||||||
TileCacheLogger {
|
TileCacheLogger {
|
||||||
write_index: 0,
|
write_index: 0,
|
||||||
frames
|
frames
|
||||||
|
@ -1651,20 +1524,12 @@ impl TileCacheLogger {
|
||||||
if !self.is_enabled() {
|
if !self.is_enabled() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.frames[self.write_index].slices.push(
|
self.frames[self.write_index].push(
|
||||||
TileCacheLoggerSlice {
|
TileCacheLoggerSlice {
|
||||||
serialized_slice,
|
serialized_slice,
|
||||||
local_to_world_transform });
|
local_to_world_transform });
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "capture")]
|
|
||||||
pub fn serialize_updates(&mut self, updates: &InternerUpdates) {
|
|
||||||
if !self.is_enabled() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.frames[self.write_index].update_lists.serialize_updates(updates);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see if anything was written in this frame, and if so,
|
/// see if anything was written in this frame, and if so,
|
||||||
/// advance the write index in a circular way and clear the
|
/// advance the write index in a circular way and clear the
|
||||||
/// recorded string.
|
/// recorded string.
|
||||||
|
@ -1676,7 +1541,7 @@ impl TileCacheLogger {
|
||||||
if self.write_index >= self.frames.len() {
|
if self.write_index >= self.frames.len() {
|
||||||
self.write_index = 0;
|
self.write_index = 0;
|
||||||
}
|
}
|
||||||
self.frames[self.write_index] = TileCacheLoggerFrame::new();
|
self.frames[self.write_index] = Vec::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "capture")]
|
#[cfg(feature = "capture")]
|
||||||
|
@ -1706,10 +1571,10 @@ impl TileCacheLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = path_tile_cache.join(format!("frame{:05}.ron", files_written));
|
let filename = path_tile_cache.join(format!("frame{:05}.ron", files_written));
|
||||||
|
files_written = files_written + 1;
|
||||||
let mut output = File::create(filename).unwrap();
|
let mut output = File::create(filename).unwrap();
|
||||||
output.write_all(b"// slice data\n").unwrap();
|
|
||||||
output.write_all(b"[\n").unwrap();
|
output.write_all(b"[\n").unwrap();
|
||||||
for item in &self.frames[index].slices {
|
for item in &self.frames[index] {
|
||||||
output.write_all(format!("( x: {}, y: {},\n",
|
output.write_all(format!("( x: {}, y: {},\n",
|
||||||
item.local_to_world_transform.origin.x,
|
item.local_to_world_transform.origin.x,
|
||||||
item.local_to_world_transform.origin.y)
|
item.local_to_world_transform.origin.y)
|
||||||
|
@ -1718,14 +1583,7 @@ impl TileCacheLogger {
|
||||||
output.write_all(item.serialized_slice.as_bytes()).unwrap();
|
output.write_all(item.serialized_slice.as_bytes()).unwrap();
|
||||||
output.write_all(b"\n),\n").unwrap();
|
output.write_all(b"\n),\n").unwrap();
|
||||||
}
|
}
|
||||||
output.write_all(b"]\n\n").unwrap();
|
output.write_all(b"]\n").unwrap();
|
||||||
|
|
||||||
output.write_all(b"// @@@ chunk @@@\n\n").unwrap();
|
|
||||||
|
|
||||||
output.write_all(b"// interning data\n").unwrap();
|
|
||||||
output.write_all(self.frames[index].update_lists.to_ron().as_bytes()).unwrap();
|
|
||||||
|
|
||||||
files_written = files_written + 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1466,12 +1466,6 @@ impl RenderBackend {
|
||||||
// If there are any additions or removals of clip modes
|
// If there are any additions or removals of clip modes
|
||||||
// during the scene build, apply them to the data store now.
|
// during the scene build, apply them to the data store now.
|
||||||
if let Some(updates) = interner_updates {
|
if let Some(updates) = interner_updates {
|
||||||
#[cfg(feature = "capture")]
|
|
||||||
{
|
|
||||||
if self.debug_flags.contains(DebugFlags::TILE_CACHE_LOGGING_DBG) {
|
|
||||||
self.tile_cache_logger.serialize_updates(&updates);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
doc.data_stores.apply_updates(updates, profile_counters);
|
doc.data_stores.apply_updates(updates, profile_counters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче