From 54b100b0f1fdbc6b4ba06ded4fbdc5991efb7d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Tue, 21 Apr 2020 12:24:58 +0200 Subject: [PATCH] webgl: Fix tidy --- components/canvas/webgl_thread.rs | 12 ++++-------- components/canvas_traits/webgl.rs | 18 +++++++++++++++--- .../webgl_extensions/ext/oestexturefloat.rs | 10 ++++++---- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 5e4bdbc4056..5361267179b 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -2855,8 +2855,7 @@ fn image_to_tex_image_data( pixels.truncate(pixel_count * 2); pixels }, - (TexFormat::RGBA, TexDataType::Float) | - (TexFormat::RGBA32f, TexDataType::Float) => { + (TexFormat::RGBA, TexDataType::Float) | (TexFormat::RGBA32f, TexDataType::Float) => { let mut rgbaf32 = Vec::::with_capacity(pixel_count * 16); for rgba8 in pixels.chunks(4) { rgbaf32.write_f32::(rgba8[0] as f32).unwrap(); @@ -2867,8 +2866,7 @@ fn image_to_tex_image_data( rgbaf32 }, - (TexFormat::RGB, TexDataType::Float) | - (TexFormat::RGB32f, TexDataType::Float) => { + (TexFormat::RGB, TexDataType::Float) | (TexFormat::RGB32f, TexDataType::Float) => { let mut rgbf32 = Vec::::with_capacity(pixel_count * 12); for rgba8 in pixels.chunks(4) { rgbf32.write_f32::(rgba8[0] as f32).unwrap(); @@ -2878,8 +2876,7 @@ fn image_to_tex_image_data( rgbf32 }, - (TexFormat::Alpha, TexDataType::Float) | - (TexFormat::Alpha32f, TexDataType::Float) => { + (TexFormat::Alpha, TexDataType::Float) | (TexFormat::Alpha32f, TexDataType::Float) => { for rgba8 in pixels.chunks_mut(4) { let p = rgba8[3] as f32; NativeEndian::write_f32(rgba8, p); @@ -2926,8 +2923,7 @@ fn image_to_tex_image_data( rgbaf16 }, - (TexFormat::RGB, TexDataType::HalfFloat) | - (TexFormat::RGB16f, TexDataType::HalfFloat) => { + (TexFormat::RGB, TexDataType::HalfFloat) | (TexFormat::RGB16f, TexDataType::HalfFloat) => { let mut rgbf16 = Vec::::with_capacity(pixel_count * 6); for rgba8 in pixels.chunks(4) { rgbf16 diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 698dee8e143..b063db966b6 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -1181,9 +1181,21 @@ impl TexFormat { TexDataType::Float, TexDataType::HalfFloat, ][..], - TexFormat::LuminanceAlpha => &[TexDataType::UnsignedByte, TexDataType::Float, TexDataType::HalfFloat][..], - TexFormat::Luminance => &[TexDataType::UnsignedByte, TexDataType::Float, TexDataType::HalfFloat][..], - TexFormat::Alpha => &[TexDataType::UnsignedByte, TexDataType::Float, TexDataType::HalfFloat][..], + TexFormat::LuminanceAlpha => &[ + TexDataType::UnsignedByte, + TexDataType::Float, + TexDataType::HalfFloat, + ][..], + TexFormat::Luminance => &[ + TexDataType::UnsignedByte, + TexDataType::Float, + TexDataType::HalfFloat, + ][..], + TexFormat::Alpha => &[ + TexDataType::UnsignedByte, + TexDataType::Float, + TexDataType::HalfFloat, + ][..], TexFormat::LuminanceAlpha32f => &[TexDataType::Float][..], TexFormat::LuminanceAlpha16f => &[TexDataType::HalfFloat][..], TexFormat::Luminance32f => &[TexDataType::Float][..], diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs index c568f88039b..e286095b7c7 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use super::{ - constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions, -}; +use super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -46,7 +44,11 @@ impl WebGLExtension for OESTextureFloat { ext.enable_tex_type(webgl::FLOAT); ext.add_effective_tex_internal_format(TexFormat::RGBA, webgl::FLOAT, TexFormat::RGBA32f); ext.add_effective_tex_internal_format(TexFormat::RGB, webgl::FLOAT, TexFormat::RGB32f); - ext.add_effective_tex_internal_format(TexFormat::Luminance, webgl::FLOAT, TexFormat::Luminance32f); + ext.add_effective_tex_internal_format( + TexFormat::Luminance, + webgl::FLOAT, + TexFormat::Luminance32f, + ); ext.add_effective_tex_internal_format(TexFormat::Alpha, webgl::FLOAT, TexFormat::Alpha32f); ext.add_effective_tex_internal_format( TexFormat::LuminanceAlpha,