[Bf-blender-cvs] [f943f4f99c1] functions: move rgba_b and rgba_f to separate file

Jacques Lucke noreply at git.blender.org
Thu Feb 13 18:58:51 CET 2020


Commit: f943f4f99c196e3b05584eee24cfeba9378dff1a
Author: Jacques Lucke
Date:   Thu Feb 13 17:59:05 2020 +0100
Branches: functions
https://developer.blender.org/rBf943f4f99c196e3b05584eee24cfeba9378dff1a

move rgba_b and rgba_f to separate file

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

A	source/blender/blenlib/BLI_color.h
M	source/blender/blenlib/BLI_float3.h
M	source/blender/blenlib/BLI_float4x4.h
M	source/blender/blenlib/BLI_math_cxx.h

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

diff --git a/source/blender/blenlib/BLI_color.h b/source/blender/blenlib/BLI_color.h
new file mode 100644
index 00000000000..7c104754b76
--- /dev/null
+++ b/source/blender/blenlib/BLI_color.h
@@ -0,0 +1,66 @@
+#ifndef __BLI_COLOR_H__
+#define __BLI_COLOR_H__
+
+namespace BLI {
+
+struct rgba_f {
+  float r, g, b, a;
+
+  rgba_f() = default;
+
+  rgba_f(float r, float g, float b, float a) : r(r), g(g), b(b), a(a)
+  {
+  }
+
+  operator float *()
+  {
+    return &r;
+  }
+
+  operator std::array<float, 4>()
+  {
+    return {r, g, b, a};
+  }
+
+  friend std::ostream &operator<<(std::ostream &stream, rgba_f c)
+  {
+    stream << "(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
+    return stream;
+  }
+};
+
+struct rgba_b {
+  uint8_t r, g, b, a;
+
+  rgba_b() = default;
+
+  rgba_b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a)
+  {
+  }
+
+  rgba_b(rgba_f other)
+  {
+    rgba_float_to_uchar(*this, other);
+  }
+
+  operator rgba_f() const
+  {
+    rgba_f result;
+    rgba_uchar_to_float(result, *this);
+    return result;
+  }
+
+  operator uint8_t *()
+  {
+    return &r;
+  }
+
+  operator const uint8_t *() const
+  {
+    return &r;
+  }
+};
+
+}  // namespace BLI
+
+#endif /* __BLI_COLOR_H__ */
diff --git a/source/blender/blenlib/BLI_float3.h b/source/blender/blenlib/BLI_float3.h
index db87e81c1e1..1b085fa1b16 100644
--- a/source/blender/blenlib/BLI_float3.h
+++ b/source/blender/blenlib/BLI_float3.h
@@ -1,6 +1,11 @@
 #ifndef __BLI_FLOAT3_H__
 #define __BLI_FLOAT3_H__
 
+#include <array>
+#include <iostream>
+
+#include "BLI_math_vector.h"
+
 namespace BLI {
 struct float3 {
   float x, y, z;
diff --git a/source/blender/blenlib/BLI_float4x4.h b/source/blender/blenlib/BLI_float4x4.h
index 51d3e54d027..c1f72439eba 100644
--- a/source/blender/blenlib/BLI_float4x4.h
+++ b/source/blender/blenlib/BLI_float4x4.h
@@ -1,7 +1,9 @@
 #ifndef __BLI_FLOAT4X4_H__
 #define __BLI_FLOAT4X4_H__
 
+#include "BLI_array_ref.h"
 #include "BLI_float3.h"
+#include "BLI_math_matrix.h"
 
 namespace BLI {
 
diff --git a/source/blender/blenlib/BLI_math_cxx.h b/source/blender/blenlib/BLI_math_cxx.h
index e1dad172dfe..adb24b6aed8 100644
--- a/source/blender/blenlib/BLI_math_cxx.h
+++ b/source/blender/blenlib/BLI_math_cxx.h
@@ -23,76 +23,7 @@
 
 #pragma once
 
-#include <array>
-
-#include "BLI_array_ref.h"
-#include "BLI_math_vector.h"
-#include "BLI_math_matrix.h"
 #include "BLI_float3.h"
 #include "BLI_float2.h"
 #include "BLI_float4x4.h"
-
-namespace BLI {
-
-struct rgba_f;
-struct rgba_b;
-
-struct rgba_f {
-  float r, g, b, a;
-
-  rgba_f() = default;
-
-  rgba_f(float r, float g, float b, float a) : r(r), g(g), b(b), a(a)
-  {
-  }
-
-  operator float *()
-  {
-    return &r;
-  }
-
-  operator std::array<float, 4>()
-  {
-    return {r, g, b, a};
-  }
-
-  friend std::ostream &operator<<(std::ostream &stream, rgba_f c)
-  {
-    stream << "(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
-    return stream;
-  }
-};
-
-struct rgba_b {
-  uint8_t r, g, b, a;
-
-  rgba_b() = default;
-
-  rgba_b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a)
-  {
-  }
-
-  rgba_b(rgba_f other)
-  {
-    rgba_float_to_uchar(*this, other);
-  }
-
-  operator rgba_f() const
-  {
-    rgba_f result;
-    rgba_uchar_to_float(result, *this);
-    return result;
-  }
-
-  operator uint8_t *()
-  {
-    return &r;
-  }
-
-  operator const uint8_t *() const
-  {
-    return &r;
-  }
-};
-
-}  // namespace BLI
+#include "BLI_color.h"



More information about the Bf-blender-cvs mailing list