[Bf-blender-cvs] [930b3a7401c] temp-explicit-colors: Cleanup: to_byte_encoded => encode.

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


Commit: 930b3a7401ce5d0a0c95dee063bc1c2cc37ecff7
Author: Jeroen Bakker
Date:   Tue May 25 08:08:10 2021 +0200
Branches: temp-explicit-colors
https://developer.blender.org/rB930b3a7401ce5d0a0c95dee063bc1c2cc37ecff7

Cleanup: to_byte_encoded => encode.

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

M	source/blender/blenkernel/intern/geometry_component_mesh.cc
M	source/blender/blenlib/BLI_color.hh
M	source/blender/blenlib/tests/BLI_color_test.cc

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

diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 41db5e09f56..a3ecc873341 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -794,7 +794,7 @@ static ColorGeometry4f get_loop_color(const MLoopCol &col)
 
 static void set_loop_color(MLoopCol &col, ColorGeometry4f linear_color)
 {
-  ColorGeometry4b encoded_color = linear_color.to_byte_encoded();
+  ColorGeometry4b encoded_color = linear_color.encode();
   col.r = encoded_color.r;
   col.g = encoded_color.g;
   col.b = encoded_color.b;
diff --git a/source/blender/blenlib/BLI_color.hh b/source/blender/blenlib/BLI_color.hh
index 64058659420..dd740c470a7 100644
--- a/source/blender/blenlib/BLI_color.hh
+++ b/source/blender/blenlib/BLI_color.hh
@@ -181,7 +181,7 @@ class ColorSceneLinear4f final : public ColorRGBA<float, eSpace::SceneLinear, Al
   /**
    * Convert to its byte encoded counter space.
    **/
-  ColorSceneLinearByteEncoded4b<Alpha> to_byte_encoded() const
+  ColorSceneLinearByteEncoded4b<Alpha> encode() const
   {
     ColorSceneLinearByteEncoded4b<Alpha> encoded;
     linearrgb_to_srgb_uchar4(encoded, *this);
@@ -244,12 +244,13 @@ class ColorSceneLinearByteEncoded4b final
 
 /**
  * Theme color template class.
- * 
+ *
  * Don't use directly, but use `ColorTheme4b/ColorTheme4b`.
  *
  * This has been implemented as a template to improve inlining. When implemented as concrete
- * classes (ColorTheme4b/f) the functions would be hidden in a compile unit what wouldn't be inlined.
- * An effect is that the precision conversions will fail in runtime when they aren't needed.
+ * classes (ColorTheme4b/f) the functions would be hidden in a compile unit what wouldn't be
+ * inlined. An effect is that the precision conversions will fail in runtime when they aren't
+ * needed.
  */
 template<typename ChannelStorageType>
 class ColorTheme4 final : public ColorRGBA<ChannelStorageType, eSpace::Theme, eAlpha::Straight> {
@@ -276,7 +277,7 @@ class ColorTheme4 final : public ColorRGBA<ChannelStorageType, eSpace::Theme, eA
    */
   ColorTheme4<float> to_4f() const
   {
-    BLI_assert(typeof(r) == uint8_t);
+    // BLI_assert(ChannelStorageType == uint8_t);
     return BLI_color_convert_to_theme4f(*this);
   }
 
@@ -287,7 +288,7 @@ class ColorTheme4 final : public ColorRGBA<ChannelStorageType, eSpace::Theme, eA
    */
   ColorTheme4<uint8_t> to_4b() const
   {
-    BLI_assert(typeof(r) == float);
+    // BLI_assert(ChannelStorageType == float);
     return BLI_color_convert_to_theme4b(*this);
   }
 };
diff --git a/source/blender/blenlib/tests/BLI_color_test.cc b/source/blender/blenlib/tests/BLI_color_test.cc
index fbb602e2e97..80829bcf66e 100644
--- a/source/blender/blenlib/tests/BLI_color_test.cc
+++ b/source/blender/blenlib/tests/BLI_color_test.cc
@@ -111,7 +111,7 @@ TEST(color, SceneLinearPremultipliedToSrgbByte)
 TEST(color, SceneLinearByteEncoding)
 {
   ColorSceneLinear4f<eAlpha::Premultiplied> linear(0.75f, 0.5f, 0.25f, 0.5f);
-  ColorSceneLinearByteEncoded4b<eAlpha::Premultiplied> encoded = linear.to_byte_encoded();
+  ColorSceneLinearByteEncoded4b<eAlpha::Premultiplied> encoded = linear.encode();
   EXPECT_EQ(225, encoded.r);
   EXPECT_EQ(188, encoded.g);
   EXPECT_EQ(137, encoded.b);



More information about the Bf-blender-cvs mailing list