Bug 1551187 - Box the color matrix in Filter. r=kvark
authorNicolas Silva <nsilva@mozilla.com>
Mon, 13 May 2019 14:55:57 +0200
changeset 532984 f8516287a42503baa4cce8bee1a6025fa92f6095
parent 532983 f92d432ffcc8bff708398c39548caa5898be4c03
child 532985 846d0d928675e4017254197e5eba61a6af552378
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1551187
milestone68.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 1551187 - Box the color matrix in Filter. r=kvark ColorMatrix is rarely used but takes most space in the Filter enum. This removes 44 bytes from the enum and all structs that embed it. Differential Revision: https://phabricator.services.mozilla.com/D30910
gfx/wr/webrender/src/internal_types.rs
gfx/wr/webrender/src/picture.rs
--- a/gfx/wr/webrender/src/internal_types.rs
+++ b/gfx/wr/webrender/src/internal_types.rs
@@ -46,17 +46,17 @@ pub enum Filter {
     Contrast(f32),
     Grayscale(f32),
     HueRotate(f32),
     Invert(f32),
     Opacity(api::PropertyBinding<f32>, f32),
     Saturate(f32),
     Sepia(f32),
     DropShadowStack(SmallVec<[Shadow; 1]>),
-    ColorMatrix([f32; 20]),
+    ColorMatrix(Box<[f32; 20]>),
     SrgbToLinear,
     LinearToSrgb,
     ComponentTransfer,
 }
 
 impl Filter {
     /// Ensure that the parameters for a filter operation
     /// are sensible.
@@ -112,22 +112,24 @@ impl Filter {
                 for shadow in shadows {
                     if shadow.offset.x != 0.0 || shadow.offset.y != 0.0 || shadow.blur_radius != 0.0 {
                         return false;
                     }
                 }
 
                 true
             }
-            Filter::ColorMatrix(matrix) => {
-                matrix == [1.0, 0.0, 0.0, 0.0,
-                           0.0, 1.0, 0.0, 0.0,
-                           0.0, 0.0, 1.0, 0.0,
-                           0.0, 0.0, 0.0, 1.0,
-                           0.0, 0.0, 0.0, 0.0]
+            Filter::ColorMatrix(ref matrix) => {
+                **matrix == [
+                    1.0, 0.0, 0.0, 0.0,
+                    0.0, 1.0, 0.0, 0.0,
+                    0.0, 0.0, 1.0, 0.0,
+                    0.0, 0.0, 0.0, 1.0,
+                    0.0, 0.0, 0.0, 0.0
+                ]
             }
             Filter::SrgbToLinear |
             Filter::LinearToSrgb |
             Filter::ComponentTransfer => false,
         }
     }
 }
 
@@ -139,17 +141,17 @@ impl From<FilterOp> for Filter {
             FilterOp::Brightness(b) => Filter::Brightness(b),
             FilterOp::Contrast(c) => Filter::Contrast(c),
             FilterOp::Grayscale(g) => Filter::Grayscale(g),
             FilterOp::HueRotate(h) => Filter::HueRotate(h),
             FilterOp::Invert(i) => Filter::Invert(i),
             FilterOp::Opacity(binding, opacity) => Filter::Opacity(binding, opacity),
             FilterOp::Saturate(s) => Filter::Saturate(s),
             FilterOp::Sepia(s) => Filter::Sepia(s),
-            FilterOp::ColorMatrix(mat) => Filter::ColorMatrix(mat),
+            FilterOp::ColorMatrix(mat) => Filter::ColorMatrix(Box::new(mat)),
             FilterOp::SrgbToLinear => Filter::SrgbToLinear,
             FilterOp::LinearToSrgb => Filter::LinearToSrgb,
             FilterOp::ComponentTransfer => Filter::ComponentTransfer,
             FilterOp::DropShadow(shadow) => Filter::DropShadowStack(smallvec![shadow]),
         }
     }
 }
 
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -3253,17 +3253,17 @@ impl PicturePrimitive {
                         // segment rect / extra data
                         request.push(shadow_rect);
                         request.push([0.0, 0.0, 0.0, 0.0]);
                     }
                 }
             }
             PictureCompositeMode::MixBlend(..) if !frame_context.fb_config.gpu_supports_advanced_blend => {}
             PictureCompositeMode::Filter(ref filter) => {
-                if let Filter::ColorMatrix(m) = *filter {
+                if let Filter::ColorMatrix(ref m) = *filter {
                     if self.extra_gpu_data_handles.is_empty() {
                         self.extra_gpu_data_handles.push(GpuCacheHandle::new());
                     }
                     if let Some(mut request) = frame_state.gpu_cache.request(&mut self.extra_gpu_data_handles[0]) {
                         for i in 0..5 {
                             request.push([m[i*4], m[i*4+1], m[i*4+2], m[i*4+3]]);
                         }
                     }