From 3d005bdb41ead61a8552051f2ed7f46154fc8701 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 15 May 2019 13:15:55 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- gfx/wr/webrender/src/internal_types.rs | 18 ++++++++++-------- gfx/wr/webrender/src/picture.rs | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gfx/wr/webrender/src/internal_types.rs b/gfx/wr/webrender/src/internal_types.rs index 68fb8afbe6a1..6cb2fccfcda0 100644 --- a/gfx/wr/webrender/src/internal_types.rs +++ b/gfx/wr/webrender/src/internal_types.rs @@ -51,7 +51,7 @@ pub enum Filter { Saturate(f32), Sepia(f32), DropShadowStack(SmallVec<[Shadow; 1]>), - ColorMatrix([f32; 20]), + ColorMatrix(Box<[f32; 20]>), SrgbToLinear, LinearToSrgb, ComponentTransfer, @@ -117,12 +117,14 @@ impl Filter { 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 | @@ -144,7 +146,7 @@ impl From for Filter { 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, diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs index 3f1f877f0239..414a0b7ec4c7 100644 --- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -3258,7 +3258,7 @@ impl PicturePrimitive { } 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()); }