[Bf-blender-cvs] [ca359461a80] master: Cycles: Cleanup, move functions outside of class methods

Sergey Sharybin noreply at git.blender.org
Fri Jul 27 10:47:13 CEST 2018


Commit: ca359461a803808a832ff603e2d01468a252c90f
Author: Sergey Sharybin
Date:   Fri Jul 27 10:24:03 2018 +0200
Branches: master
https://developer.blender.org/rBca359461a803808a832ff603e2d01468a252c90f

Cycles: Cleanup, move functions outside of class methods

There is no reason or justification to have helper functions as
class methods: they do not depend on anything in the class itself.

There are probably more cases like that.

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

M	intern/cycles/render/image.cpp
M	intern/cycles/render/image.h

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

diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index b8892a5329d..78451658764 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -30,20 +30,58 @@
 
 CCL_NAMESPACE_BEGIN
 
+namespace {
+
 /* Some helpers to silence warning in templated function. */
-static bool isfinite(uchar /*value*/)
+bool isfinite(uchar /*value*/)
 {
 	return true;
 }
-static bool isfinite(half /*value*/)
+bool isfinite(half /*value*/)
 {
 	return true;
 }
-static bool isfinite(uint16_t  /*value*/)
+bool isfinite(uint16_t  /*value*/)
 {
 	return true;
 }
 
+/* The lower three bits of a device texture slot number indicate its type.
+ * These functions convert the slot ids from ImageManager "images" ones
+ * to device ones and vice verse.
+ */
+int type_index_to_flattened_slot(int slot, ImageDataType type)
+{
+	return (slot << IMAGE_DATA_TYPE_SHIFT) | (type);
+}
+
+int flattened_slot_to_type_index(int flat_slot, ImageDataType *type)
+{
+	*type = (ImageDataType)(flat_slot & IMAGE_DATA_TYPE_MASK);
+	return flat_slot >> IMAGE_DATA_TYPE_SHIFT;
+}
+
+const char* name_from_type(ImageDataType type)
+{
+	switch(type) {
+		case IMAGE_DATA_TYPE_FLOAT4: return "float4";
+		case IMAGE_DATA_TYPE_BYTE4: return "byte4";
+		case IMAGE_DATA_TYPE_HALF4: return "half4";
+		case IMAGE_DATA_TYPE_FLOAT: return "float";
+		case IMAGE_DATA_TYPE_BYTE: return "byte";
+		case IMAGE_DATA_TYPE_HALF: return "half";
+		case IMAGE_DATA_TYPE_USHORT4: return "ushort4";
+		case IMAGE_DATA_TYPE_USHORT: return "ushort";
+		case IMAGE_DATA_NUM_TYPES:
+			assert(!"System enumerator type, should never be used");
+			return "";
+	}
+	assert(!"Unhandled image data type");
+	return "";
+}
+
+}  // namespace
+
 ImageManager::ImageManager(const DeviceInfo& info)
 {
 	need_update = true;
@@ -229,40 +267,6 @@ bool ImageManager::get_image_metadata(const string& filename,
 	return true;
 }
 
-/* The lower three bits of a device texture slot number indicate its type.
- * These functions convert the slot ids from ImageManager "images" ones
- * to device ones and vice verse.
- */
-int ImageManager::type_index_to_flattened_slot(int slot, ImageDataType type)
-{
-	return (slot << IMAGE_DATA_TYPE_SHIFT) | (type);
-}
-
-int ImageManager::flattened_slot_to_type_index(int flat_slot, ImageDataType *type)
-{
-	*type = (ImageDataType)(flat_slot & IMAGE_DATA_TYPE_MASK);
-	return flat_slot >> IMAGE_DATA_TYPE_SHIFT;
-}
-
-const char* ImageManager::name_from_type(ImageDataType type)
-{
-	switch(type) {
-		case IMAGE_DATA_TYPE_FLOAT4: return "float4";
-		case IMAGE_DATA_TYPE_BYTE4: return "byte4";
-		case IMAGE_DATA_TYPE_HALF4: return "half4";
-		case IMAGE_DATA_TYPE_FLOAT: return "float";
-		case IMAGE_DATA_TYPE_BYTE: return "byte";
-		case IMAGE_DATA_TYPE_HALF: return "half";
-		case IMAGE_DATA_TYPE_USHORT4: return "ushort4";
-		case IMAGE_DATA_TYPE_USHORT: return "ushort";
-		case IMAGE_DATA_NUM_TYPES:
-			assert(!"System enumerator type, should never be used");
-			return "";
-	}
-	assert(!"Unhandled image data type");
-	return "";
-}
-
 static bool image_equals(ImageManager::Image *image,
                          const string& filename,
                          void *builtin_data,
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 40b8629d549..67af4ba886c 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -149,10 +149,6 @@ private:
 	                     int texture_limit,
 	                     device_vector<DeviceType>& tex_img);
 
-	int type_index_to_flattened_slot(int slot, ImageDataType type);
-	int flattened_slot_to_type_index(int flat_slot, ImageDataType *type);
-	const char* name_from_type(ImageDataType type);
-
 	void device_load_image(Device *device,
 	                       Scene *scene,
 	                       ImageDataType type,



More information about the Bf-blender-cvs mailing list