Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-03-16 14:26:37 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-03-16 14:26:37 +0300
commit36e7de9eb329e122605e3fe1ba80585d3aff1b26 (patch)
tree25bddeff8cb491d7518f060faffdf2709dea4913 /source/blender/blenlib
parent5baf0de6e74a4df43dea91e177aeece5468648c4 (diff)
parentda4efaeb87b74f73bd5b640eb70132521a1db5cb (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_console.h42
-rw-r--r--source/blender/blenlib/BLI_hash.h12
-rw-r--r--source/blender/blenlib/CMakeLists.txt1
3 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_console.h b/source/blender/blenlib/BLI_console.h
new file mode 100644
index 00000000000..bf433f78f70
--- /dev/null
+++ b/source/blender/blenlib/BLI_console.h
@@ -0,0 +1,42 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Srrgey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_CONSOLE_H__
+#define __BLI_CONSOLE_H__
+
+/** \file BLI_console.h
+ * \ingroup bli
+ * \brief Set of utility functions and constants to work with consoles.
+ */
+
+/* Format string where one could BLI_snprintf() R, G and B values
+ * and get proper marker to start colored output in the console.
+ */
+#define TRUECOLOR_ANSI_COLOR_FORMAT "\x1b[38;2;%d;%d;%dm"
+
+/* Marker which indicates that colored output is finished. */
+#define TRUECOLOR_ANSI_COLOR_FINISH "\x1b[0m"
+
+#endif /* __BLI_CONSOLE_H__ */
diff --git a/source/blender/blenlib/BLI_hash.h b/source/blender/blenlib/BLI_hash.h
index fa79481e25c..9ca7898d6b8 100644
--- a/source/blender/blenlib/BLI_hash.h
+++ b/source/blender/blenlib/BLI_hash.h
@@ -68,4 +68,16 @@ BLI_INLINE float BLI_hash_int_01(unsigned int k)
return (float)BLI_hash_int(k) * (1.0f / (float)0xFFFFFFFF);
}
+BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *b)
+{
+ size_t val = (size_t)ptr;
+ const size_t hash_a = BLI_hash_int(val & 0x0000ffff);
+ const size_t hash_b = BLI_hash_int((val & 0xffff0000) >> 32);
+ const size_t hash =
+ hash_a ^ (hash_b + 0x9e3779b9 + (hash_a << 6) + (hash_a >> 2));
+ *r = (hash & 0xff0000) >> 16;
+ *g = (hash & 0x00ff00) >> 8;
+ *b = hash & 0x0000ff;
+}
+
#endif // __BLI_HASH_H__
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index ef36b5ac6bd..5bcf4303a84 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -139,6 +139,7 @@ set(SRC
BLI_compiler_attrs.h
BLI_compiler_compat.h
BLI_compiler_typecheck.h
+ BLI_console.h
BLI_convexhull_2d.h
BLI_dial_2d.h
BLI_dlrbTree.h