Bug 1505871. Implement the necessary things for interning of filter data. r=gw
☠☠ backed out by c14904748ffb ☠ ☠
authorTimothy Nikkel <tnikkel@gmail.com>
Mon, 25 Feb 2019 22:45:16 -0600
changeset 518999 11c9d5a64a30a5b1c25056412162fe68a63fb83d
parent 518998 def812790f5c1d6d98bd4f0efab8ace51c7ff89e
child 519000 1206e1a32e5fe2e4a329be1aef9330f7e632c91a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [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)]