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
This commit is contained in:
Nicolas Silva 2019-05-15 13:15:55 +00:00
Родитель 0068db5320
Коммит 3d005bdb41
2 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -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<FilterOp> 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,

Просмотреть файл

@ -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());
}