[gtkmm] Gdk::GLContext: Add API for version 4.6
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk::GLContext: Add API for version 4.6
- Date: Fri, 4 Feb 2022 14:24:01 +0000 (UTC)
commit ccea9955167e6872a2eadfb05c5ceb5982e53141
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Fri Feb 4 15:18:21 2022 +0100
Gdk::GLContext: Add API for version 4.6
* configure.ac:
* meson.build: Require gtk4 >= 4.5.0
* gdk/gdkmm/general.[cc|h]: Deprecate Gdk::Cairo::draw_from_gl().
* gdk/src/glcontext.[ccg|hg]: Deprecate set_use_es() and unset_use_es().
Add set/get/property_allowed_apis() and get/property_api().
* tools/m4/convert_gdk.m4: Add m4 macros for enum GdkGLAPI.
configure.ac | 2 +-
gdk/gdkmm/general.cc | 2 ++
gdk/gdkmm/general.h | 9 ++++++++-
gdk/src/glcontext.ccg | 11 ++---------
gdk/src/glcontext.hg | 44 +++++++++++++++-----------------------------
meson.build | 2 +-
tools/m4/convert_gdk.m4 | 1 +
7 files changed, 30 insertions(+), 41 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5c23b168..56229a1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,7 +95,7 @@ AS_IF([test "x$enable_static" = xyes],
# gdkmm really does need GTK, because part of Gdk::DragContext is in GTK.
# The extra gdk-pixbuf-2.0 check is because gdkmm requires a newer gdk-pixbuf than gtk4 requires.
# TODO: Remove the mention of cairomm once pangomm needs to depend on such a new version.
-AC_SUBST([GDKMM_MODULES], ['giomm-2.68 >= 2.68.0 pangomm-2.48 >= 2.48.0 cairomm-1.16 >= 1.15.4 gtk4 >= 4.4.0
gdk-pixbuf-2.0 >= 2.35.5'])
+AC_SUBST([GDKMM_MODULES], ['giomm-2.68 >= 2.68.0 pangomm-2.48 >= 2.48.0 cairomm-1.16 >= 1.15.4 gtk4 >= 4.5.0
gdk-pixbuf-2.0 >= 2.35.5'])
AS_IF([test "x$gtkmm_host_windows" = xyes],
[GTKMM_MODULES=$GDKMM_MODULES],
diff --git a/gdk/gdkmm/general.cc b/gdk/gdkmm/general.cc
index c20a97f3..ef05881c 100644
--- a/gdk/gdkmm/general.cc
+++ b/gdk/gdkmm/general.cc
@@ -52,6 +52,7 @@ void add_region_to_path(const ::Cairo::RefPtr< ::Cairo::Context >& context, cons
return Gdk::Cairo::wrap(gdk_cairo_region_create_from_surface(surface->cobj()), true);
}
+#ifndef GDKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void draw_from_gl(const ::Cairo::RefPtr< ::Cairo::Context >& context,
const Glib::RefPtr<Gdk::Surface>& surface, int source, int source_type,
@@ -61,6 +62,7 @@ void draw_from_gl(const ::Cairo::RefPtr< ::Cairo::Context >& context,
buffer_scale, x, y, width, height);
}
G_GNUC_END_IGNORE_DEPRECATIONS
+#endif // GDKMM_DISABLE_DEPRECATED
} //namespace Cairo
diff --git a/gdk/gdkmm/general.h b/gdk/gdkmm/general.h
index e5cdc8bd..87b07a1d 100644
--- a/gdk/gdkmm/general.h
+++ b/gdk/gdkmm/general.h
@@ -90,6 +90,7 @@ void add_region_to_path(const ::Cairo::RefPtr< ::Cairo::Context >& context, cons
GDKMM_API
::Cairo::RefPtr< ::Cairo::Region> create_region_from_surface(const ::Cairo::RefPtr< ::Cairo::Surface>&
surface);
+#ifndef GDKMM_DISABLE_DEPRECATED
/** This is the main way to draw GL content in gtkmm.
* It takes a render buffer ID (@a source_type == GL_RENDERBUFFER) or a texture id
* (@a source_type == GL_TEXTURE) and draws it onto @a context with an OVER operation,
@@ -108,6 +109,12 @@ GDKMM_API
*
* Calling this may change the current GL context.
*
+ * @deprecated The function is overly complex and produces broken output
+ * in various combinations of arguments. If you want to draw with GL textures
+ * in Gtkmm, use Gdk::GLTexture::create(); if you want to use that texture in
+ * %Cairo, use Gdk::Texture::download() to download the data into a %Cairo
+ * image surface.
+ *
* @param context A cairo context.
* @param surface The surface we're rendering for (not necessarily into).
* @param source The GL ID of the source buffer.
@@ -124,7 +131,7 @@ GDKMM_API
void draw_from_gl(const ::Cairo::RefPtr< ::Cairo::Context >& context,
const Glib::RefPtr<Gdk::Surface>& surface, int source, int source_type,
int buffer_scale, int x, int y, int width, int height);
-//TODO: Deprecate draw_from_gl() in master when the gtkmm-4-4 branch has been created.
+#endif // GDKMM_DISABLE_DEPRECATED
} //namespace Cairo
diff --git a/gdk/src/glcontext.ccg b/gdk/src/glcontext.ccg
index b6ede0ff..1bfe276b 100644
--- a/gdk/src/glcontext.ccg
+++ b/gdk/src/glcontext.ccg
@@ -21,20 +21,13 @@
namespace Gdk
{
-// We hand-code set_use_es() and unset_use_es().
-// gdk_gl_context_set_use_es() is deprecated in gtk 4.6.
-// We can't use the replacement gdk_gl_context_set_allowed_apis(),
-// which is new in gtk 4.6. This version of gtkmm does not require gtk 4.6.
+#ifndef GDKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-void GLContext::set_use_es(bool use_es)
-{
- gdk_gl_context_set_use_es(gobj(), static_cast<int>(use_es));
-}
-
void GLContext::unset_use_es()
{
gdk_gl_context_set_use_es(gobj(), -1);
}
G_GNUC_END_IGNORE_DEPRECATIONS
+#endif // GDKMM_DISABLE_DEPRECATED
} // namespace Gdk
diff --git a/gdk/src/glcontext.hg b/gdk/src/glcontext.hg
index d76a1162..9b58a534 100644
--- a/gdk/src/glcontext.hg
+++ b/gdk/src/glcontext.hg
@@ -26,6 +26,7 @@ _PINCLUDE(gdkmm/private/drawcontext_p.h)
namespace Gdk
{
+_WRAP_ENUM(GLAPI, GdkGLAPI, gtype_func gdk_gl_api_get_type, decl_prefix GDKMM_API)
_WRAP_GERROR(GLError, GdkGLError, GDK_GL_ERROR, newin "3,18", decl_prefix GDKMM_API)
/** A %Gdk::GLContext is an OpenGL context abstraction.
@@ -47,9 +48,10 @@ public:
_WRAP_METHOD(Glib::RefPtr<Surface> get_surface(), gdk_gl_context_get_surface, refreturn, newin "3,18")
_WRAP_METHOD(Glib::RefPtr<const Surface> get_surface() const, gdk_gl_context_get_surface, refreturn,
constversion, newin "3,18")
_WRAP_METHOD(Glib::RefPtr<GLContext> get_shared_context(), gdk_gl_context_get_shared_context, refreturn,
- newin "3,18", deprecated "Always returns an empty RefPtr.")
+ newin "3,18", deprecated "Always returns an empty RefPtr. Use is_shared() to check if contexts can be
shared.")
_WRAP_METHOD(Glib::RefPtr<const GLContext> get_shared_context() const, gdk_gl_context_get_shared_context,
- refreturn, constversion, newin "3,18", deprecated "Always returns an empty RefPtr.")
+ refreturn, constversion, newin "3,18",
+ deprecated "Always returns an empty RefPtr. Use is_shared() to check if contexts can be shared.")
_WRAP_METHOD(void get_version(int& major, int& minor) const, gdk_gl_context_get_version, newin "3,18")
_WRAP_METHOD(bool is_legacy() const, gdk_gl_context_is_legacy)
_WRAP_METHOD(bool is_shared(const Glib::RefPtr<const GLContext>& other) const, gdk_gl_context_is_shared,
newin "4,4")
@@ -59,42 +61,24 @@ public:
_WRAP_METHOD(void set_debug_enabled(bool enabled = true), gdk_gl_context_set_debug_enabled, newin "3,18")
_WRAP_METHOD(bool get_forward_compatible() const, gdk_gl_context_get_forward_compatible, newin "3,18")
_WRAP_METHOD(void set_forward_compatible(bool compatible = true), gdk_gl_context_set_forward_compatible,
newin "3,18")
+ _WRAP_METHOD(void set_allowed_apis(GLAPI apis), gdk_gl_context_set_allowed_apis)
+ _WRAP_METHOD(GLAPI get_allowed_apis() const, gdk_gl_context_get_allowed_apis)
+ _WRAP_METHOD(GLAPI get_api() const, gdk_gl_context_get_api)
+ _WRAP_METHOD(void set_use_es(bool use_es = true), gdk_gl_context_set_use_es,
+ deprecated "Use set_allowed_apis() instead.")
- // We hand-code set_use_es() and unset_use_es().
- // gdk_gl_context_set_use_es() is deprecated in gtk 4.6.
- // We can't use the replacement gdk_gl_context_set_allowed_apis(),
- // which is new in gtk 4.6. This version of gtkmm does not require gtk 4.6.
- //_WRAP_METHOD(void set_use_es(bool use_es = true), gdk_gl_context_set_use_es,
- // deprecated "Use set_allowed_apis() instead.")
-
- /** Requests that GDK create an OpenGL ES context instead of an OpenGL one,
- * if the platform and windowing system allows it.
- *
- * The %GLContext must not have been realized.
- *
- * By default, GDK will attempt to automatically detect whether the
- * underlying GL implementation is OpenGL or OpenGL ES once the %GLContext
- * is realized.
- *
- * You should check the return value of get_use_es() after
- * calling realize() to decide whether to use the OpenGL or
- * OpenGL ES API, extensions, or shaders.
- *
- * @newin{3,22}
- *
- * @param use_es Whether the context should use OpenGL ES instead of OpenGL.
- */
- void set_use_es(bool use_es = true);
- _IGNORE(gdk_gl_context_set_use_es)
-
+#ifndef GDKMM_DISABLE_DEPRECATED
/** Undo a previous call to set_use_es().
*
* GDK will attempt to automatically detect whether the underlying
* GL implementation is OpenGL or OpenGL ES once the %GLContext is realized.
*
* @newin{3,24}
+ *
+ * @deprecated Use set_allowed_apis() instead.
*/
void unset_use_es();
+#endif // GDKMM_DISABLE_DEPRECATED
_WRAP_METHOD(bool get_use_es() const, gdk_gl_context_get_use_es)
_WRAP_METHOD(bool realize(), gdk_gl_context_realize, errthrow, newin "3,18")
@@ -105,6 +89,8 @@ public:
_WRAP_PROPERTY("shared-context", Glib::RefPtr<GLContext>, newin "3,18",
deprecated "Always returns an empty RefPtr. Use is_shared() to check if contexts can be shared.")
+ _WRAP_PROPERTY("allowed-apis", GLAPI)
+ _WRAP_PROPERTY("api", GLAPI)
};
} // namespace Gdk
diff --git a/meson.build b/meson.build
index b3215aa8..973c6597 100644
--- a/meson.build
+++ b/meson.build
@@ -103,7 +103,7 @@ install_pkgconfigdir = install_libdir / 'pkgconfig'
glibmm_req = '>= 2.68.0'
# Gtk supported pkg-config files on MSVC files for a good while, so just use that
-gtk_req = '>= 4.4.0'
+gtk_req = '>= 4.5.0'
gtk_dep = dependency('gtk4', version: gtk_req)
cairomm_req = '>= 1.15.4'
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 9a6fb114..92ca6741 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -43,6 +43,7 @@ _CONV_ENUM(Gdk,FillRule)
_CONV_INCLASS_ENUM(Gdk,FrameClock,Phase)
_CONV_ENUM(Gdk,FullscreenMode)
_CONV_ENUM(Gdk,Function)
+_CONV_ENUM(Gdk,GLAPI)
_CONV_ENUM(Gdk,Gravity)
_CONV_ENUM(Gdk,InputCondition)
_CONV_ENUM(Gdk,InputSource)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]