[Bf-blender-cvs] [5be72125bf4] master: Cleanup: Move some utilities to 'gpu_py.h'

Germano Cavalcante noreply at git.blender.org
Wed Feb 24 15:07:16 CET 2021


Commit: 5be72125bf4dfddf5dfe720caa12b3163f540faf
Author: Germano Cavalcante
Date:   Mon Feb 22 09:44:57 2021 -0300
Branches: master
https://developer.blender.org/rB5be72125bf4dfddf5dfe720caa12b3163f540faf

Cleanup: Move some utilities to 'gpu_py.h'

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

M	source/blender/python/gpu/gpu_py.c
M	source/blender/python/gpu/gpu_py.h
M	source/blender/python/gpu/gpu_py_api.c
M	source/blender/python/gpu/gpu_py_api.h
M	source/blender/python/gpu/gpu_py_batch.c
M	source/blender/python/gpu/gpu_py_element.c
M	source/blender/python/gpu/gpu_py_framebuffer.c
M	source/blender/python/gpu/gpu_py_offscreen.c
M	source/blender/python/gpu/gpu_py_shader.c
M	source/blender/python/gpu/gpu_py_texture.c
M	source/blender/python/gpu/gpu_py_uniformbuffer.c

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

diff --git a/source/blender/python/gpu/gpu_py.c b/source/blender/python/gpu/gpu_py.c
index 2c5daaf1962..7aea940da94 100644
--- a/source/blender/python/gpu/gpu_py.c
+++ b/source/blender/python/gpu/gpu_py.c
@@ -23,6 +23,7 @@
 
 #include <Python.h>
 
+#include "GPU_init_exit.h"
 #include "GPU_primitive.h"
 #include "GPU_texture.h"
 
@@ -58,3 +59,21 @@ struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
     {0, NULL},
 };
 /** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Utilities
+ * \{ */
+
+bool bpygpu_is_init_or_error(void)
+{
+  if (!GPU_is_init()) {
+    PyErr_SetString(PyExc_SystemError,
+                    "GPU functions for drawing are not available in background mode");
+
+    return false;
+  }
+
+  return true;
+}
+
+/** \} */
diff --git a/source/blender/python/gpu/gpu_py.h b/source/blender/python/gpu/gpu_py.h
index 28b3e41a08f..39e5997f866 100644
--- a/source/blender/python/gpu/gpu_py.h
+++ b/source/blender/python/gpu/gpu_py.h
@@ -22,3 +22,16 @@
 
 extern struct PyC_StringEnumItems bpygpu_primtype_items[];
 extern struct PyC_StringEnumItems bpygpu_dataformat_items[];
+
+bool bpygpu_is_init_or_error(void);
+
+#define BPYGPU_IS_INIT_OR_ERROR_OBJ \
+  if (UNLIKELY(!bpygpu_is_init_or_error())) { \
+    return NULL; \
+  } \
+  ((void)0)
+#define BPYGPU_IS_INIT_OR_ERROR_INT \
+  if (UNLIKELY(!bpygpu_is_init_or_error())) { \
+    return -1; \
+  } \
+  ((void)0)
diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index 7213dc59886..68f7eb9816c 100644
--- a/source/blender/python/gpu/gpu_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -30,8 +30,6 @@
 
 #include "../generic/python_utildefines.h"
 
-#include "GPU_init_exit.h"
-
 #include "gpu_py_matrix.h"
 #include "gpu_py_select.h"
 #include "gpu_py_state.h"
@@ -39,24 +37,6 @@
 
 #include "gpu_py_api.h" /* own include */
 
-/* -------------------------------------------------------------------- */
-/** \name Utils to invalidate functions
- * \{ */
-
-bool bpygpu_is_init_or_error(void)
-{
-  if (!GPU_is_init()) {
-    PyErr_SetString(PyExc_SystemError,
-                    "GPU functions for drawing are not available in background mode");
-
-    return false;
-  }
-
-  return true;
-}
-
-/** \} */
-
 /* -------------------------------------------------------------------- */
 /** \name GPU Module
  * \{ */
diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h
index 5e399a233aa..38452ad67c1 100644
--- a/source/blender/python/gpu/gpu_py_api.h
+++ b/source/blender/python/gpu/gpu_py_api.h
@@ -25,15 +25,3 @@
 // #define BPYGPU_USE_GPUOBJ_FREE_METHOD
 
 PyObject *BPyInit_gpu(void);
-
-bool bpygpu_is_init_or_error(void);
-#define BPYGPU_IS_INIT_OR_ERROR_OBJ \
-  if (UNLIKELY(!bpygpu_is_init_or_error())) { \
-    return NULL; \
-  } \
-  ((void)0)
-#define BPYGPU_IS_INIT_OR_ERROR_INT \
-  if (UNLIKELY(!bpygpu_is_init_or_error())) { \
-    return -1; \
-  } \
-  ((void)0)
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 9989077670b..ef795268158 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -39,7 +39,6 @@
 #include "../generic/py_capi_utils.h"
 
 #include "gpu_py.h"
-#include "gpu_py_api.h"
 #include "gpu_py_element.h"
 #include "gpu_py_shader.h"
 #include "gpu_py_vertex_buffer.h"
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c
index 0e5094cbbc0..2beabe6a93d 100644
--- a/source/blender/python/gpu/gpu_py_element.c
+++ b/source/blender/python/gpu/gpu_py_element.c
@@ -33,7 +33,6 @@
 #include "../generic/python_utildefines.h"
 
 #include "gpu_py.h"
-#include "gpu_py_api.h"
 #include "gpu_py_element.h" /* own include */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c
index 04d49a9f15d..5bf577f3b96 100644
--- a/source/blender/python/gpu/gpu_py_framebuffer.c
+++ b/source/blender/python/gpu/gpu_py_framebuffer.c
@@ -34,7 +34,7 @@
 #include "../generic/python_utildefines.h"
 #include "../mathutils/mathutils.h"
 
-#include "gpu_py_api.h"
+#include "gpu_py.h"
 #include "gpu_py_texture.h"
 
 #include "gpu_py_framebuffer.h" /* own include */
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index a98d9649f6f..9d5671ff702 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -52,7 +52,7 @@
 
 #include "../generic/py_capi_utils.h"
 
-#include "gpu_py_api.h"
+#include "gpu_py.h"
 #include "gpu_py_offscreen.h" /* own include */
 
 /* Define the free method to avoid breakage. */
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 2f9b67bdb6a..4237e2d4b2d 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -33,7 +33,7 @@
 #include "../generic/python_utildefines.h"
 #include "../mathutils/mathutils.h"
 
-#include "gpu_py_api.h"
+#include "gpu_py.h"
 #include "gpu_py_texture.h"
 #include "gpu_py_uniformbuffer.h"
 #include "gpu_py_vertex_format.h"
diff --git a/source/blender/python/gpu/gpu_py_texture.c b/source/blender/python/gpu/gpu_py_texture.c
index 85246bffac7..12855b8dbcc 100644
--- a/source/blender/python/gpu/gpu_py_texture.c
+++ b/source/blender/python/gpu/gpu_py_texture.c
@@ -33,7 +33,6 @@
 #include "../generic/py_capi_utils.h"
 
 #include "gpu_py.h"
-#include "gpu_py_api.h"
 #include "gpu_py_buffer.h"
 
 #include "gpu_py_texture.h" /* own include */
diff --git a/source/blender/python/gpu/gpu_py_uniformbuffer.c b/source/blender/python/gpu/gpu_py_uniformbuffer.c
index d1b86455918..c60d6216834 100644
--- a/source/blender/python/gpu/gpu_py_uniformbuffer.c
+++ b/source/blender/python/gpu/gpu_py_uniformbuffer.c
@@ -34,7 +34,6 @@
 #include "../generic/py_capi_utils.h"
 
 #include "gpu_py.h"
-#include "gpu_py_api.h"
 #include "gpu_py_buffer.h"
 
 #include "gpu_py_uniformbuffer.h" /* own include */



More information about the Bf-blender-cvs mailing list