[Bf-blender-cvs] [3a6d2e84cf7] temp-explicit-colors: Cleanup: to_straight_alpha => unpremultiply_alpha.

Jeroen Bakker noreply at git.blender.org
Tue May 25 08:56:15 CEST 2021


Commit: 3a6d2e84cf76c0570fff20bffb4cbd87a359f1aa
Author: Jeroen Bakker
Date:   Tue May 25 08:17:13 2021 +0200
Branches: temp-explicit-colors
https://developer.blender.org/rB3a6d2e84cf76c0570fff20bffb4cbd87a359f1aa

Cleanup: to_straight_alpha => unpremultiply_alpha.

===================================================================

M	source/blender/blenlib/BLI_color.hh
M	source/blender/blenlib/tests/BLI_color_test.cc

===================================================================

diff --git a/source/blender/blenlib/BLI_color.hh b/source/blender/blenlib/BLI_color.hh
index c9f962e0398..bab2a35235a 100644
--- a/source/blender/blenlib/BLI_color.hh
+++ b/source/blender/blenlib/BLI_color.hh
@@ -48,7 +48,7 @@ namespace blender {
  * - Encoding colors (compressing to store colors inside a less precision storage)
  *   should be done by invoking the `encode` and `decode` methods.
  * - Changing alpha association should be done by invoking `to_multiplied_alpha` or
- *   `to_straight_alpha` methods.
+ *   `unpremultiply_alpha` methods.
  *
  * # Encoding.
  *
@@ -206,7 +206,7 @@ class ColorSceneLinear4f final : public ColorRGBA<float, eSpace::SceneLinear, Al
    *
    * Will assert when called on a color with straight alpha..
    */
-  ColorSceneLinear4f<eAlpha::Straight> to_straight_alpha() const
+  ColorSceneLinear4f<eAlpha::Straight> unpremultiply_alpha() const
   {
     BLI_assert(Alpha == eAlpha::Premultiplied);
     ColorSceneLinear4f<eAlpha::Straight> straighten;
diff --git a/source/blender/blenlib/tests/BLI_color_test.cc b/source/blender/blenlib/tests/BLI_color_test.cc
index 88d188cf13f..14796e6bf71 100644
--- a/source/blender/blenlib/tests/BLI_color_test.cc
+++ b/source/blender/blenlib/tests/BLI_color_test.cc
@@ -56,7 +56,7 @@ TEST(color, SceneLinearStraightToPremultiplied)
 TEST(color, SceneLinearPremultipliedToStraight)
 {
   ColorSceneLinear4f<eAlpha::Premultiplied> premultiplied(0.75f, 0.5f, 0.25f, 0.5f);
-  ColorSceneLinear4f<eAlpha::Straight> straight = premultiplied.to_straight_alpha();
+  ColorSceneLinear4f<eAlpha::Straight> straight = premultiplied.unpremultiply_alpha();
   EXPECT_NEAR(1.5f, straight.r, 0.01f);
   EXPECT_NEAR(1.0f, straight.g, 0.01f);
   EXPECT_NEAR(0.5f, straight.b, 0.01f);
@@ -78,7 +78,7 @@ TEST(color, SceneLinearPremultipliedToSrgbFloat)
 {
   BLI_init_srgb_conversion();
   ColorSceneLinear4f<eAlpha::Premultiplied> linear(0.75f, 0.5f, 0.25f, 0.5f);
-  ColorTheme4f theme = BLI_color_convert_to_theme4f(linear.to_straight_alpha());
+  ColorTheme4f theme = BLI_color_convert_to_theme4f(linear.unpremultiply_alpha());
 
   EXPECT_NEAR(1.19f, theme.r, 0.01);
   EXPECT_NEAR(1.0f, theme.g, 0.01);
@@ -101,7 +101,7 @@ TEST(color, SceneLinearPremultipliedToSrgbByte)
 {
   BLI_init_srgb_conversion();
   ColorSceneLinear4f<eAlpha::Premultiplied> linear(0.75f, 0.5f, 0.25f, 0.5f);
-  ColorTheme4b theme = BLI_color_convert_to_theme4b(linear.to_straight_alpha());
+  ColorTheme4b theme = BLI_color_convert_to_theme4b(linear.unpremultiply_alpha());
   EXPECT_EQ(255, theme.r);
   EXPECT_EQ(255, theme.g);
   EXPECT_EQ(188, theme.b);



More information about the Bf-blender-cvs mailing list