Bug 1548092 - Fix improper alpha value in yaml reftest. r=kvark
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 30 Apr 2019 21:00:57 +0000
changeset 530836 122ff931d88359b92d695aa26a60839e244e66f0
parent 530835 e587cf00dc672e07c00b7a423afb35419d6f8095
child 530837 a6f52fa08b8a788d149f3e2604dffada83190241
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1548092
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 1548092 - Fix improper alpha value in yaml reftest. r=kvark Differential Revision: https://phabricator.services.mozilla.com/D29402
gfx/wr/webrender_api/src/color.rs
gfx/wr/wrench/reftests/text/shadow-huge-ref.yaml
gfx/wr/wrench/reftests/text/shadow-huge.yaml
gfx/wr/wrench/src/yaml_helper.rs
--- a/gfx/wr/webrender_api/src/color.rs
+++ b/gfx/wr/webrender_api/src/color.rs
@@ -119,17 +119,17 @@ pub struct ColorU {
 impl ColorU {
     /// Constructs a new additive `ColorU` from its components.
     pub fn new(r: u8, g: u8, b: u8, a: u8) -> Self {
         ColorU { r, g, b, a }
     }
 }
 
 fn round_to_int(x: f32) -> u8 {
-    debug_assert!((0.0 <= x) && (x <= 1.0));
+    debug_assert!((0.0 <= x) && (x <= 1.0), "{} should be between 0 and 1", x);
     let f = (255.0 * x) + 0.5;
     let val = f.floor();
     debug_assert!(val <= 255.0);
     val as u8
 }
 
 // TODO: We shouldn't really convert back to `ColorU` ever,
 // since it's lossy. One of the blockers is that all of our debug colors
--- a/gfx/wr/wrench/reftests/text/shadow-huge-ref.yaml
+++ b/gfx/wr/wrench/reftests/text/shadow-huge-ref.yaml
@@ -7,12 +7,12 @@ root:
           blur-radius: 600
           offset: [10, 10]
           color: black
         -
           bounds: [14, 18, 205, 35]
           glyphs: [55, 75, 76, 86, 3, 76, 86, 3, 87, 75, 72, 3, 69, 72, 86, 87]
           offsets: [16, 43, 35.533333, 43, 51.533333, 43, 60.4, 43, 72.833336, 43, 80.833336, 43, 89.7, 43, 102.13333, 43, 110.13333, 43, 119, 43, 135, 43, 149.2, 43, 157.2, 43, 173.2, 43, 187.4, 43, 196.26666, 43]
           size: 18
-          color: [0, 0, 0, 255]
+          color: [0, 0, 0, 1]
           font: "VeraBd.ttf"
         -
           type: "pop-all-shadows"
--- a/gfx/wr/wrench/reftests/text/shadow-huge.yaml
+++ b/gfx/wr/wrench/reftests/text/shadow-huge.yaml
@@ -7,12 +7,12 @@ root:
           blur-radius: 100000000
           offset: [10, 10]
           color: black
         -
           bounds: [14, 18, 205, 35]
           glyphs: [55, 75, 76, 86, 3, 76, 86, 3, 87, 75, 72, 3, 69, 72, 86, 87]
           offsets: [16, 43, 35.533333, 43, 51.533333, 43, 60.4, 43, 72.833336, 43, 80.833336, 43, 89.7, 43, 102.13333, 43, 110.13333, 43, 119, 43, 135, 43, 149.2, 43, 157.2, 43, 173.2, 43, 187.4, 43, 196.26666, 43]
           size: 18
-          color: [0, 0, 0, 255]
+          color: [0, 0, 0, 1]
           font: "VeraBd.ttf"
         -
           type: "pop-all-shadows"
--- a/gfx/wr/wrench/src/yaml_helper.rs
+++ b/gfx/wr/wrench/src/yaml_helper.rs
@@ -438,16 +438,19 @@ impl YamlHelper for Yaml {
                 nums.len() == 3 || nums.len() == 4,
                 "color expected a color name, or 3-4 floats; got '{:?}'",
                 self
             );
 
             if nums.len() == 3 {
                 nums.push(1.0);
             }
+            assert!(nums[3] >= 0.0 && nums[3] <= 1.0,
+                    "alpha value should be in the 0-1 range, got {:?}",
+                    nums[3]);
             return Some(ColorF::new(
                 nums[0] / 255.0,
                 nums[1] / 255.0,
                 nums[2] / 255.0,
                 nums[3],
             ));
         }