Blame SOURCES/0002-cogl-Define-autoptr-cleanup-functions-for-Cogl-types.patch

79df40
From 758ede11d0967b38eba75241fb5dadb395f29617 Mon Sep 17 00:00:00 2001
79df40
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
79df40
Date: Tue, 9 Jul 2019 14:45:48 +0200
79df40
Subject: [PATCH 02/28] cogl: Define autoptr cleanup functions for Cogl types
79df40
79df40
Make possible to use g_autoptr () with Cogl types
79df40
79df40
https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
79df40
---
79df40
 cogl/cogl/Makefile.am         |  1 +
79df40
 cogl/cogl/cogl-autocleanups.h | 67 +++++++++++++++++++++++++++++++++++
79df40
 cogl/cogl/cogl.h              |  2 ++
79df40
 3 files changed, 70 insertions(+)
79df40
 create mode 100644 cogl/cogl/cogl-autocleanups.h
79df40
79df40
diff --git a/cogl/cogl/Makefile.am b/cogl/cogl/Makefile.am
79df40
index 66accf709..ecb5e8b59 100644
79df40
--- a/cogl/cogl/Makefile.am
79df40
+++ b/cogl/cogl/Makefile.am
79df40
@@ -38,60 +38,61 @@ endif
79df40
 AM_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) $(MAINTAINER_CFLAGS)
79df40
 
79df40
 BUILT_SOURCES += cogl-defines.h cogl-egl-defines.h cogl-gl-header.h
79df40
 DISTCLEANFILES += cogl-defines.h cogl-egl-defines.h cogl-gl-header.h
79df40
 EXTRA_DIST += cogl-defines.h.in cogl-egl-defines.h.in cogl-gl-header.h.in
79df40
 
79df40
 pc_files = mutter-cogl-$(LIBMUTTER_API_VERSION).pc
79df40
 
79df40
 pkgconfigdir = $(libdir)/pkgconfig
79df40
 pkgconfig_DATA = $(pc_files)
79df40
 
79df40
 DISTCLEANFILES += $(pc_files)
79df40
 
79df40
 cogl_deprecated_h = \
79df40
 	deprecated/cogl-material-compat.h 	\
79df40
 	deprecated/cogl-vertex-buffer.h 	\
79df40
 	deprecated/cogl-shader.h 		\
79df40
 	deprecated/cogl-clutter.h       	\
79df40
 	deprecated/cogl-type-casts.h       	\
79df40
 	deprecated/cogl-auto-texture.h	\
79df40
 	$(NULL)
79df40
 
79df40
 cogl_deprecated_nonintrospected_h = \
79df40
 	deprecated/cogl-framebuffer-deprecated.h \
79df40
 	$(NULL)
79df40
 
79df40
 # public 1.x api headers
79df40
 cogl_1_public_h = \
79df40
 	$(cogl_deprecated_h)			\
79df40
 	cogl1-context.h 		\
79df40
+	cogl-autocleanups.h		\
79df40
 	cogl-bitmap.h 		\
79df40
 	cogl-color.h 			\
79df40
 	cogl-matrix.h 		\
79df40
 	cogl-offscreen.h 		\
79df40
 	cogl-primitives.h 		\
79df40
 	cogl-texture.h 		\
79df40
 	cogl-types.h 			\
79df40
 	cogl.h			\
79df40
 	$(NULL)
79df40
 
79df40
 cogl_nonintrospected_h = \
79df40
 	cogl-object.h 		\
79df40
 	cogl-renderer.h 		\
79df40
 	cogl-swap-chain.h 		\
79df40
 	cogl-onscreen-template.h 	\
79df40
 	cogl-display.h 		\
79df40
 	cogl-context.h 		\
79df40
 	cogl-pipeline.h 		\
79df40
 	cogl-pipeline-state.h 	\
79df40
 	cogl-pipeline-layer-state.h 	\
79df40
 	cogl-snippet.h		\
79df40
 	cogl-gles2.h			\
79df40
 	cogl-gles2-types.h		\
79df40
 	cogl-index-buffer.h 		\
79df40
 	cogl-attribute-buffer.h 	\
79df40
 	cogl-indices.h 		\
79df40
 	cogl-attribute.h 		\
79df40
 	cogl-primitive.h 		\
79df40
 	cogl-framebuffer.h		\
79df40
 	cogl-onscreen.h		\
79df40
diff --git a/cogl/cogl/cogl-autocleanups.h b/cogl/cogl/cogl-autocleanups.h
79df40
new file mode 100644
79df40
index 000000000..f18002418
79df40
--- /dev/null
79df40
+++ b/cogl/cogl/cogl-autocleanups.h
79df40
@@ -0,0 +1,67 @@
79df40
+/*
79df40
+ * Cogl
79df40
+ *
79df40
+ * A Low Level GPU Graphics and Utilities API
79df40
+ *
79df40
+ * Copyright (C) 2009  Intel Corporation.
79df40
+ * Copyright (C) 2019  Canonical Ltd.
79df40
+ *
79df40
+ * Permission is hereby granted, free of charge, to any person
79df40
+ * obtaining a copy of this software and associated documentation
79df40
+ * files (the "Software"), to deal in the Software without
79df40
+ * restriction, including without limitation the rights to use, copy,
79df40
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
79df40
+ * of the Software, and to permit persons to whom the Software is
79df40
+ * furnished to do so, subject to the following conditions:
79df40
+ *
79df40
+ * The above copyright notice and this permission notice shall be
79df40
+ * included in all copies or substantial portions of the Software.
79df40
+ *
79df40
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
79df40
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79df40
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
79df40
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
79df40
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
79df40
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
79df40
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
79df40
+ * SOFTWARE.
79df40
+ *
79df40
+ */
79df40
+
79df40
+#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
79df40
+#error "Only <cogl/cogl.h> can be included directly."
79df40
+#endif
79df40
+
79df40
+#ifndef __COGL_AUTOCLEANUPS_H__
79df40
+#define __COGL_AUTOCLEANUPS_H__
79df40
+
79df40
+#ifndef __GI_SCANNER__
79df40
+
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglAtlasTexture, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglAttribute, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglAttributeBuffer, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglBitmap, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglColor, cogl_color_free)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglDisplay, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglEuler, cogl_euler_free)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglFramebuffer, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglIndices, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglHandle, cogl_handle_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglMatrix, cogl_matrix_free)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglMatrixEntry, cogl_matrix_entry_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglMatrixStack, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglObject, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglOffscreen, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglOnscreenTemplate, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglPath, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglPipeline, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglQuaternion, cogl_quaternion_free)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglRenderer, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglSnippet, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglTexture, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglTexture2D, cogl_object_unref)
79df40
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglTexture2DSliced, cogl_object_unref)
79df40
+
79df40
+#endif /* __GI_SCANNER__ */
79df40
+
79df40
+#endif /* __COGL_AUTOCLEANUPS_H__ */
79df40
diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h
79df40
index 5210e3c59..c7cf7e6a8 100644
79df40
--- a/cogl/cogl/cogl.h
79df40
+++ b/cogl/cogl/cogl.h
79df40
@@ -127,51 +127,53 @@
79df40
 #include <cogl/cogl-frame-info.h>
79df40
 #include <cogl/cogl-poll.h>
79df40
 #include <cogl/cogl-fence.h>
79df40
 #include <cogl/cogl-glib-source.h>
79df40
 /* XXX: This will definitly go away once all the Clutter winsys
79df40
  * code has been migrated down into Cogl! */
79df40
 #include <cogl/deprecated/cogl-clutter.h>
79df40
 
79df40
 /*
79df40
  * API deprecations
79df40
  */
79df40
 #include <cogl/cogl-deprecated.h>
79df40
 
79df40
 /*
79df40
  * Cogl Path api compatability
79df40
  *
79df40
  * The cogl_path_ api used to be part of the core Cogl api so for
79df40
  * compatability we include cogl-path.h via cogl.h
79df40
  *
79df40
  * Note: we have to make sure not to include cogl-path.h while
79df40
  * building core cogl or generating the Cogl .gir data because
79df40
  * cogl-path now gets built after cogl and some cogl-path headers are
79df40
  * only generated at build time...
79df40
  */
79df40
 #if defined (COGL_HAS_COGL_PATH_SUPPORT) && \
79df40
   !defined (COGL_COMPILATION) && \
79df40
   !defined (COGL_GIR_SCANNING)
79df40
 #include <cogl-path/cogl-path.h>
79df40
 #endif
79df40
 
79df40
+#include <cogl/cogl-autocleanups.h>
79df40
+
79df40
 /**
79df40
  * SECTION:cogl
79df40
  * @short_description: General purpose API
79df40
  *
79df40
  * General utility functions for COGL.
79df40
  */
79df40
 
79df40
 /* The gobject introspection scanner seems to parse public headers in
79df40
  * isolation which means we need to be extra careful about how we
79df40
  * define and undefine __COGL_H_INSIDE__ used to detect when internal
79df40
  * headers are incorrectly included by developers. In the gobject
79df40
  * introspection case we have to manually define __COGL_H_INSIDE__ as
79df40
  * a commandline argument for the scanner which means we must be
79df40
  * careful not to undefine it in a header...
79df40
  */
79df40
 #ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__
79df40
 #undef __COGL_H_INSIDE__
79df40
 #undef __COGL_MUST_UNDEF_COGL_H_INSIDE__
79df40
 #endif
79df40
 
79df40
 #endif /* __COGL_H__ */
79df40
-- 
79df40
2.26.2
79df40