mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 11:50:21 +00:00
gdk: Add GdkDrawContext
This will be the base class for GdkVulkanContext and GdkGLContext.
This commit is contained in:
parent
e38bd27d58
commit
db8e3065bd
@ -1275,6 +1275,22 @@ gdk_frame_timings_get_predicted_presentation_time
|
||||
gdk_frame_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gdkdrawcontext</FILE>
|
||||
GdkDrawContext
|
||||
gdk_draw_context_get_display
|
||||
gdk_draw_context_get_window
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_DRAW_CONTEXT
|
||||
GDK_IS_DRAW_CONTEXT
|
||||
GDK_TYPE_DRAW_CONTEXT
|
||||
GDK_DRAW_CONTEXT_CLASS
|
||||
GDK_DRAW_CONTEXT_GET_CLASS
|
||||
GDK_IS_DRAW_CONTEXT_CLASS
|
||||
gdk_draw_context_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gdkglcontext</FILE>
|
||||
GdkGLContext
|
||||
|
@ -67,6 +67,7 @@ gdk_public_h_sources = \
|
||||
gdkdisplay.h \
|
||||
gdkdisplaymanager.h \
|
||||
gdkdnd.h \
|
||||
gdkdrawcontext.h \
|
||||
gdkdrawingcontext.h \
|
||||
gdkevents.h \
|
||||
gdkframetimings.h \
|
||||
@ -106,6 +107,7 @@ gdk_private_headers = \
|
||||
gdkdisplaymanagerprivate.h \
|
||||
gdkdisplayprivate.h \
|
||||
gdkdndprivate.h \
|
||||
gdkdrawcontextprivate.h \
|
||||
gdkdrawingcontextprivate.h \
|
||||
gdkframeclockidle.h \
|
||||
gdkframeclockprivate.h \
|
||||
@ -133,6 +135,7 @@ gdk_c_sources = \
|
||||
gdkdisplay.c \
|
||||
gdkdisplaymanager.c \
|
||||
gdkdnd.c \
|
||||
gdkdrawcontext.c \
|
||||
gdkdrawingcontext.c \
|
||||
gdkevents.c \
|
||||
gdkframetimings.c \
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <gdk/gdkdisplay.h>
|
||||
#include <gdk/gdkdisplaymanager.h>
|
||||
#include <gdk/gdkdnd.h>
|
||||
#include <gdk/gdkdrawcontext.h>
|
||||
#include <gdk/gdkdrawingcontext.h>
|
||||
#include <gdk/gdkenumtypes.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
|
201
gdk/gdkdrawcontext.c
Normal file
201
gdk/gdkdrawcontext.c
Normal file
@ -0,0 +1,201 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkdrawcontext.c: base class for rendering system support
|
||||
*
|
||||
* Copyright © 2016 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdrawcontextprivate.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
/**
|
||||
* SECTION:gdkdrawcontext
|
||||
* @Title: GdkDrawContext
|
||||
* @Short_description: Drawing context base class
|
||||
*
|
||||
* #GdkDrawContext is the base object used by contexts implementing different
|
||||
* rendering methods, such as #GdkGLContext or #GdkVulkanContext. They provide
|
||||
* shared functionality between those contexts.
|
||||
*
|
||||
* You will always interact with one of those subclasses.
|
||||
*/
|
||||
typedef struct _GdkDrawContextPrivate GdkDrawContextPrivate;
|
||||
|
||||
struct _GdkDrawContextPrivate {
|
||||
GdkWindow *window;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_DISPLAY,
|
||||
PROP_WINDOW,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
static GParamSpec *pspecs[LAST_PROP] = { NULL, };
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrawContext, gdk_draw_context, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gdk_draw_context_dispose (GObject *gobject)
|
||||
{
|
||||
GdkDrawContext *context = GDK_DRAW_CONTEXT (gobject);
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
|
||||
g_clear_object (&priv->window);
|
||||
|
||||
G_OBJECT_CLASS (gdk_draw_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_context_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDrawContext *context = GDK_DRAW_CONTEXT (gobject);
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_WINDOW:
|
||||
priv->window = g_value_dup_object (value);
|
||||
g_assert (priv->window != NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_context_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDrawContext *context = GDK_DRAW_CONTEXT (gobject);
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, gdk_draw_context_get_display (context));
|
||||
break;
|
||||
|
||||
case PROP_WINDOW:
|
||||
g_value_set_object (value, priv->window);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_context_class_init (GdkDrawContextClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->set_property = gdk_draw_context_set_property;
|
||||
gobject_class->get_property = gdk_draw_context_get_property;
|
||||
gobject_class->dispose = gdk_draw_context_dispose;
|
||||
|
||||
/**
|
||||
* GdkDrawContext:display:
|
||||
*
|
||||
* The #GdkDisplay used to create the #GdkDrawContext.
|
||||
*
|
||||
* Since: 3.90
|
||||
*/
|
||||
pspecs[PROP_DISPLAY] =
|
||||
g_param_spec_object ("display",
|
||||
P_("Display"),
|
||||
P_("The GDK display used to create the context"),
|
||||
GDK_TYPE_DISPLAY,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkDrawContext:window:
|
||||
*
|
||||
* The #GdkWindow the gl context is bound to.
|
||||
*
|
||||
* Since: 3.90
|
||||
*/
|
||||
pspecs[PROP_WINDOW] =
|
||||
g_param_spec_object ("window",
|
||||
P_("Window"),
|
||||
P_("The GDK window bound to the context"),
|
||||
GDK_TYPE_WINDOW,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, LAST_PROP, pspecs);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_draw_context_init (GdkDrawContext *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_draw_context_get_display:
|
||||
* @context: a #GdkDrawContext
|
||||
*
|
||||
* Retrieves the #GdkDisplay the @context is created for
|
||||
*
|
||||
* Returns: (nullable) (transfer none): a #GdkDisplay or %NULL
|
||||
*
|
||||
* Since: 3.90
|
||||
*/
|
||||
GdkDisplay *
|
||||
gdk_draw_context_get_display (GdkDrawContext *context)
|
||||
{
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAW_CONTEXT (context), NULL);
|
||||
|
||||
return priv->window ? gdk_window_get_display (priv->window) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_draw_context_get_window:
|
||||
* @context: a #GdkDrawContext
|
||||
*
|
||||
* Retrieves the #GdkWindow used by the @context.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): a #GdkWindow or %NULL
|
||||
*
|
||||
* Since: 3.90
|
||||
*/
|
||||
GdkWindow *
|
||||
gdk_draw_context_get_window (GdkDrawContext *context)
|
||||
{
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAW_CONTEXT (context), NULL);
|
||||
|
||||
return priv->window;
|
||||
}
|
||||
|
47
gdk/gdkdrawcontext.h
Normal file
47
gdk/gdkdrawcontext.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkdrawcontext.h: base class for rendering system support
|
||||
*
|
||||
* Copyright © 2016 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DRAW_CONTEXT__
|
||||
#define __GDK_DRAW_CONTEXT__
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_DRAW_CONTEXT (gdk_draw_context_get_type ())
|
||||
#define GDK_DRAW_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_DRAW_CONTEXT, GdkDrawContext))
|
||||
#define GDK_IS_DRAW_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_DRAW_CONTEXT))
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GType gdk_draw_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GdkDisplay * gdk_draw_context_get_display (GdkDrawContext *context);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GdkWindow * gdk_draw_context_get_window (GdkDrawContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DRAW_CONTEXT__ */
|
46
gdk/gdkdrawcontextprivate.h
Normal file
46
gdk/gdkdrawcontextprivate.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkdrawcontext.h: base class for rendering system support
|
||||
*
|
||||
* Copyright © 2016 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DRAW_CONTEXT_PRIVATE__
|
||||
#define __GDK_DRAW_CONTEXT_PRIVATE__
|
||||
|
||||
#include "gdkdrawcontext.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_DRAW_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAW_CONTEXT, GdkDrawContextClass))
|
||||
#define GDK_IS_DRAW_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAW_CONTEXT))
|
||||
#define GDK_DRAW_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAW_CONTEXT, GdkDrawContextClass))
|
||||
|
||||
typedef struct _GdkDrawContextClass GdkDrawContextClass;
|
||||
|
||||
struct _GdkDrawContext
|
||||
{
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
struct _GdkDrawContextClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */
|
@ -145,6 +145,7 @@ typedef struct _GdkAppLaunchContext GdkAppLaunchContext;
|
||||
typedef struct _GdkSeat GdkSeat;
|
||||
|
||||
typedef struct _GdkDrawingContext GdkDrawingContext;
|
||||
typedef struct _GdkDrawContext GdkDrawContext;
|
||||
typedef struct _GdkGLContext GdkGLContext;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user