Bug 1505871. Implement the necessary things for interning of filter data. r=gw
authorTimothy Nikkel <tnikkel@gmail.com>
Tue, 26 Feb 2019 00:16:36 -0600
changeset 461127 30cb5423d03f4375ab7ba9e08906295d8864c17b
parent 461126 bc60982f282807b43fe8e1d4f200433e3352cba4
child 461128 e1f278d901a765d0951f156a73a8dd3fad01a101
push id35618
push usershindli@mozilla.com
push dateTue, 26 Feb 2019 16:54:44 +0000
treeherdermozilla-central@d326a9d5f77b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1505871
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505871. Implement the necessary things for interning of filter data. r=gw
gfx/webrender_bindings/webrender_ffi.h
gfx/wr/webrender/src/filterdata.rs
gfx/wr/webrender/src/intern_types.rs
gfx/wr/webrender/src/lib.rs
gfx/wr/webrender/src/profiler.rs
gfx/wr/webrender_api/src/api.rs
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -42,17 +42,19 @@ void gecko_profiler_end_marker(const cha
   macro(normal_border);                    \
   macro(image_border);                     \
   macro(image);                            \
   macro(yuv_image);                        \
   macro(line_decoration);                  \
   macro(linear_grad);                      \
   macro(radial_grad);                      \
   macro(picture);                          \
-  macro(text_run);
+  macro(text_run);                         \
+  macro(filterdata);
+
 
 // Prelude of types necessary before including webrender_ffi_generated.h
 namespace mozilla {
 namespace wr {
 
 // Because this struct is macro-generated on the Rust side, cbindgen can't see
 // it. Work around that by re-declaring it here.
 #define DECLARE_MEMBER(id) uintptr_t id;
new file mode 100644
--- /dev/null
+++ b/gfx/wr/webrender/src/filterdata.rs
@@ -0,0 +1,98 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use std::{hash};
+use gpu_cache::{GpuCacheHandle};
+use frame_builder::FrameBuildingState;
+use gpu_cache::GpuDataRequest;
+use intern;
+use api::{ComponentTransferFuncType};
+
+
+pub use intern_types::filterdata::Handle as FilterDataHandle;
+
+#[derive(Debug, Clone, MallocSizeOf, PartialEq)]
+#[cfg_attr(feature = "capture", derive(Serialize))]
+#[cfg_attr(feature = "replay", derive(Deserialize))]
+pub enum SFilterDataComponent {
+    Identity,
+    Table(Vec<f32>),
+    Discrete(Vec<f32>),
+    Linear(f32, f32),
+    Gamma(f32, f32, f32),
+}
+
+impl Eq for SFilterDataComponent {}
+
+impl hash::Hash for SFilterDataComponent {
+    fn hash<H: hash::Hasher>(&self, state: &mut H) {
+        match self {
+            SFilterDataComponent::Identity => {
+                0.hash(state);
+            }
+            SFilterDataComponent::Table(values) => {
+                1.hash(state);
+                values.len().hash(state);
+                for val in values {
+                    val.to_bits().hash(state);
+                }
+            }
+            SFilterDataComponent::Discrete(values) => {
+                2.hash(state);
+                values.len().hash(state);
+                for val in values {
+                    val.to_bits().hash(state);
+                }
+            }
+            SFilterDataComponent::Linear(a, b) => {
+                3.hash(state);
+                a.to_bits().hash(state);
+                b.to_bits().hash(state);
+            }
+            SFilterDataComponent::Gamma(a, b, c) => {
+                4.hash(state);
+                a.to_bits().hash(state);
+                b.to_bits().hash(state);
+                c.to_bits().hash(state);
+            }
+        }
+    }
+}
+
+#[derive(Debug, Clone, MallocSizeOf, PartialEq, Eq, Hash)]
+#[cfg_attr(feature = "capture", derive(Serialize))]
+#[cfg_attr(feature = "replay", derive(Deserialize))]
+pub struct SFilterData {
+    pub r_func: SFilterDataComponent,
+    pub g_func: SFilterDataComponent,
+    pub b_func: SFilterDataComponent,
+    pub a_func: SFilterDataComponent,
+}
+
+#[derive(Debug, Clone, MallocSizeOf, PartialEq, Eq, Hash)]
+#[cfg_attr(feature = "capture", derive(Serialize))]
+#[cfg_attr(feature = "replay", derive(Deserialize))]
+pub struct SFilterDataKey {
+    pub data: SFilterData,
+}
+
+impl intern::InternDebug for SFilterDataKey {}
+
+#[derive(Debug)]
+#[cfg_attr(feature = "capture", derive(Serialize))]
+#[cfg_attr(feature = "replay", derive(Deserialize))]
+#[derive(MallocSizeOf)]
+pub struct SFilterDataTemplate {
+    pub data: SFilterData,
+    pub gpu_cache_handle: GpuCacheHandle,
+}
+
+impl From<SFilterDataKey> for SFilterDataTemplate {
+    fn from(item: SFilterDataKey) -> Self {
+        SFilterDataTemplate {
+            data: item.data,
+            gpu_cache_handle: GpuCacheHandle::new(),
+        }
+    }
+}
--- a/gfx/wr/webrender/src/intern_types.rs
+++ b/gfx/wr/webrender/src/intern_types.rs
@@ -98,10 +98,17 @@ pub type Interner = intern::Interner<Pic
 pub mod text_run {
 common!();
 use ::prim_store::text_run::{TextRunKey, TextRunTemplate};
 pub type Store = intern::DataStore<TextRunKey, TextRunTemplate, Marker>;
 pub type UpdateList = intern::UpdateList<TextRunKey>;
 pub type Interner = intern::Interner<TextRunKey, PrimitiveSceneData, Marker>;
 }
 
+pub mod filterdata {
+common!();
+use ::filterdata::{SFilterDataKey, SFilterDataTemplate};
+pub type Store = intern::DataStore<SFilterDataKey, SFilterDataTemplate, Marker>;
+pub type UpdateList = intern::UpdateList<SFilterDataKey>;
+pub type Interner = intern::Interner<SFilterDataKey, (), Marker>;
+}
 
 
--- a/gfx/wr/webrender/src/lib.rs
+++ b/gfx/wr/webrender/src/lib.rs
@@ -85,16 +85,17 @@ mod clip_scroll_tree;
 mod debug_colors;
 mod debug_font_data;
 mod debug_render;
 #[cfg(feature = "debugger")]
 mod debug_server;
 mod device;
 mod display_list_flattener;
 mod ellipse;
+mod filterdata;
 mod frame_builder;
 mod freelist;
 #[cfg(any(target_os = "macos", target_os = "windows"))]
 mod gamma_lut;
 mod glyph_cache;
 mod glyph_rasterizer;
 mod gpu_cache;
 #[cfg(feature = "pathfinder")]
--- a/gfx/wr/webrender/src/profiler.rs
+++ b/gfx/wr/webrender/src/profiler.rs
@@ -529,16 +529,17 @@ impl BackendProfileCounters {
                 line_decoration: ResourceProfileCounter::new("Interned line decorations"),
                 linear_grad: ResourceProfileCounter::new("Interned linear gradients"),
                 normal_border: ResourceProfileCounter::new("Interned normal borders"),
                 picture: ResourceProfileCounter::new("Interned pictures"),
                 radial_grad: ResourceProfileCounter::new("Interned radial gradients"),
                 text_run: ResourceProfileCounter::new("Interned text runs"),
                 yuv_image: ResourceProfileCounter::new("Interned YUV images"),
                 clip: ResourceProfileCounter::new("Interned clips"),
+                filterdata: ResourceProfileCounter::new("Interned filterdata"),
             },
         }
     }
 
     pub fn reset(&mut self) {
         self.total_time.reset();
         self.ipc.total_time.reset();
         self.ipc.build_time.reset();
--- a/gfx/wr/webrender_api/src/api.rs
+++ b/gfx/wr/webrender_api/src/api.rs
@@ -832,16 +832,17 @@ macro_rules! enumerate_interners {
             image_border,
             image,
             yuv_image,
             line_decoration,
             linear_grad,
             radial_grad,
             picture,
             text_run,
+            filterdata,
         }
     }
 }
 
 macro_rules! declare_interning_memory_report {
     ( $( $name: ident, )+ ) => {
         #[repr(C)]
         #[derive(AddAssign, Clone, Debug, Default, Deserialize, Serialize)]