[gnome-flashback] crtc: make implementations inherit GfCrtc
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] crtc: make implementations inherit GfCrtc
- Date: Sat, 11 Jul 2020 18:43:00 +0000 (UTC)
commit b9b8c9fd064cb5a934c44447f65a596cdb800e77
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Jul 10 12:59:33 2020 +0300
crtc: make implementations inherit GfCrtc
Based on mutter commits:
https://gitlab.gnome.org/GNOME/mutter/-/commit/1ce9e379d99a8e15b3d0
https://gitlab.gnome.org/GNOME/mutter/-/commit/bad1a7fd0c13aaa1c817
backends/gf-crtc-private.h | 15 +++----
backends/gf-crtc-xrandr-private.h | 43 +++++++++++---------
backends/gf-crtc-xrandr.c | 78 +++++++++++++++++-------------------
backends/gf-crtc.c | 5 +--
backends/gf-gpu-xrandr.c | 6 +--
backends/gf-monitor-manager-xrandr.c | 8 ++--
6 files changed, 75 insertions(+), 80 deletions(-)
---
diff --git a/backends/gf-crtc-private.h b/backends/gf-crtc-private.h
index 4edcf1e..388da77 100644
--- a/backends/gf-crtc-private.h
+++ b/backends/gf-crtc-private.h
@@ -43,14 +43,6 @@ typedef struct
GfCrtcMode *mode;
} GfCrtcConfig;
-struct _GfCrtc
-{
- GObject parent;
-
- gpointer driver_private;
- GDestroyNotify driver_notify;
-};
-
struct _GfCrtcMode
{
GObject parent;
@@ -78,7 +70,12 @@ typedef struct
} GfCrtcAssignment;
#define GF_TYPE_CRTC (gf_crtc_get_type ())
-G_DECLARE_FINAL_TYPE (GfCrtc, gf_crtc, GF, CRTC, GObject)
+G_DECLARE_DERIVABLE_TYPE (GfCrtc, gf_crtc, GF, CRTC, GObject)
+
+struct _GfCrtcClass
+{
+ GObjectClass parent_class;
+};
#define GF_TYPE_CRTC_MODE (gf_crtc_mode_get_type ())
G_DECLARE_FINAL_TYPE (GfCrtcMode, gf_crtc_mode, GF, CRTC_MODE, GObject)
diff --git a/backends/gf-crtc-xrandr-private.h b/backends/gf-crtc-xrandr-private.h
index 00c031c..105e304 100644
--- a/backends/gf-crtc-xrandr-private.h
+++ b/backends/gf-crtc-xrandr-private.h
@@ -30,26 +30,29 @@
G_BEGIN_DECLS
-GfCrtc *gf_create_xrandr_crtc (GfGpuXrandr *gpu_xrandr,
- XRRCrtcInfo *xrandr_crtc,
- RRCrtc crtc_id,
- XRRScreenResources *resources);
-
-gboolean gf_crtc_xrandr_set_config (GfCrtc *crtc,
- xcb_randr_crtc_t xrandr_crtc,
- xcb_timestamp_t timestamp,
- int x,
- int y,
- xcb_randr_mode_t mode,
- xcb_randr_rotation_t rotation,
- xcb_randr_output_t *outputs,
- int n_outputs,
- xcb_timestamp_t *out_timestamp);
-
-gboolean gf_crtc_xrandr_is_assignment_changed (GfCrtc *crtc,
- GfCrtcAssignment *crtc_assignment);
-
-GfCrtcMode *gf_crtc_xrandr_get_current_mode (GfCrtc *crtc);
+#define GF_TYPE_CRTC_XRANDR (gf_crtc_xrandr_get_type ())
+G_DECLARE_FINAL_TYPE (GfCrtcXrandr, gf_crtc_xrandr, GF, CRTC_XRANDR, GfCrtc)
+
+GfCrtcXrandr *gf_crtc_xrandr_new (GfGpuXrandr *gpu_xrandr,
+ XRRCrtcInfo *xrandr_crtc,
+ RRCrtc crtc_id,
+ XRRScreenResources *resources);
+
+gboolean gf_crtc_xrandr_set_config (GfCrtcXrandr *self,
+ xcb_randr_crtc_t xrandr_crtc,
+ xcb_timestamp_t timestamp,
+ int x,
+ int y,
+ xcb_randr_mode_t mode,
+ xcb_randr_rotation_t rotation,
+ xcb_randr_output_t *outputs,
+ int n_outputs,
+ xcb_timestamp_t *out_timestamp);
+
+gboolean gf_crtc_xrandr_is_assignment_changed (GfCrtcXrandr *self,
+ GfCrtcAssignment *crtc_assignment);
+
+GfCrtcMode *gf_crtc_xrandr_get_current_mode (GfCrtcXrandr *self);
G_END_DECLS
diff --git a/backends/gf-crtc-xrandr.c b/backends/gf-crtc-xrandr.c
index 4c48279..ffd9c8e 100644
--- a/backends/gf-crtc-xrandr.c
+++ b/backends/gf-crtc-xrandr.c
@@ -33,19 +33,17 @@
#define ALL_ROTATIONS (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
-typedef struct
+struct _GfCrtcXrandr
{
+ GfCrtc parent;
+
GfRectangle rect;
GfMonitorTransform transform;
GfCrtcMode *current_mode;
-} GfCrtcXrandr;
+};
-static void
-gf_crtc_destroy_notify (GfCrtc *crtc)
-{
- g_free (crtc->driver_private);
-}
+G_DEFINE_TYPE (GfCrtcXrandr, gf_crtc_xrandr, GF_TYPE_CRTC)
static GfMonitorTransform
gf_monitor_transform_from_xrandr (Rotation rotation)
@@ -119,16 +117,25 @@ gf_monitor_transform_from_xrandr_all (Rotation rotation)
return ret;
}
-GfCrtc *
-gf_create_xrandr_crtc (GfGpuXrandr *gpu_xrandr,
- XRRCrtcInfo *xrandr_crtc,
- RRCrtc crtc_id,
- XRRScreenResources *resources)
+static void
+gf_crtc_xrandr_class_init (GfCrtcXrandrClass *self_class)
+{
+}
+
+static void
+gf_crtc_xrandr_init (GfCrtcXrandr *self)
+{
+}
+
+GfCrtcXrandr *
+gf_crtc_xrandr_new (GfGpuXrandr *gpu_xrandr,
+ XRRCrtcInfo *xrandr_crtc,
+ RRCrtc crtc_id,
+ XRRScreenResources *resources)
{
GfGpu *gpu;
GfMonitorTransform all_transforms;
- GfCrtc *crtc;
GfCrtcXrandr *crtc_xrandr;
unsigned int i;
GList *modes;
@@ -137,13 +144,12 @@ gf_create_xrandr_crtc (GfGpuXrandr *gpu_xrandr,
all_transforms = gf_monitor_transform_from_xrandr_all (xrandr_crtc->rotations);
- crtc = g_object_new (GF_TYPE_CRTC,
- "id", crtc_id,
- "gpu", gpu,
- "all-transforms", all_transforms,
- NULL);
+ crtc_xrandr = g_object_new (GF_TYPE_CRTC_XRANDR,
+ "id", crtc_id,
+ "gpu", gpu,
+ "all-transforms", all_transforms,
+ NULL);
- crtc_xrandr = g_new0 (GfCrtcXrandr, 1);
crtc_xrandr->rect = (GfRectangle) {
.x = xrandr_crtc->x,
.y = xrandr_crtc->y,
@@ -152,9 +158,6 @@ gf_create_xrandr_crtc (GfGpuXrandr *gpu_xrandr,
};
crtc_xrandr->transform = gf_monitor_transform_from_xrandr (xrandr_crtc->rotation);
- crtc->driver_private = crtc_xrandr;
- crtc->driver_notify = (GDestroyNotify) gf_crtc_destroy_notify;
-
modes = gf_gpu_get_modes (gpu);
for (i = 0; i < (guint) resources->nmode; i++)
{
@@ -167,17 +170,17 @@ gf_create_xrandr_crtc (GfGpuXrandr *gpu_xrandr,
if (crtc_xrandr->current_mode)
{
- gf_crtc_set_config (crtc,
+ gf_crtc_set_config (GF_CRTC (crtc_xrandr),
&crtc_xrandr->rect,
crtc_xrandr->current_mode,
crtc_xrandr->transform);
}
- return crtc;
+ return crtc_xrandr;
}
gboolean
-gf_crtc_xrandr_set_config (GfCrtc *crtc,
+gf_crtc_xrandr_set_config (GfCrtcXrandr *self,
xcb_randr_crtc_t xrandr_crtc,
xcb_timestamp_t timestamp,
int x,
@@ -201,7 +204,7 @@ gf_crtc_xrandr_set_config (GfCrtc *crtc,
xcb_randr_set_crtc_config_reply_t *reply;
xcb_generic_error_t *xcb_error;
- gpu = gf_crtc_get_gpu (crtc);
+ gpu = gf_crtc_get_gpu (GF_CRTC (self));
gpu_xrandr = GF_GPU_XRANDR (gpu);
backend = gf_gpu_get_backend (gpu);
@@ -236,24 +239,21 @@ gf_crtc_xrandr_set_config (GfCrtc *crtc,
}
gboolean
-gf_crtc_xrandr_is_assignment_changed (GfCrtc *crtc,
+gf_crtc_xrandr_is_assignment_changed (GfCrtcXrandr *self,
GfCrtcAssignment *crtc_assignment)
{
- GfCrtcXrandr *crtc_xrandr;
unsigned int i;
- crtc_xrandr = crtc->driver_private;
-
- if (crtc_xrandr->current_mode != crtc_assignment->mode)
+ if (self->current_mode != crtc_assignment->mode)
return TRUE;
- if (crtc_xrandr->rect.x != crtc_assignment->layout.x)
+ if (self->rect.x != crtc_assignment->layout.x)
return TRUE;
- if (crtc_xrandr->rect.y != crtc_assignment->layout.y)
+ if (self->rect.y != crtc_assignment->layout.y)
return TRUE;
- if (crtc_xrandr->transform != crtc_assignment->transform)
+ if (self->transform != crtc_assignment->transform)
return TRUE;
for (i = 0; i < crtc_assignment->outputs->len; i++)
@@ -264,7 +264,7 @@ gf_crtc_xrandr_is_assignment_changed (GfCrtc *crtc,
output = ((GfOutput **) crtc_assignment->outputs->pdata)[i];
assigned_crtc = gf_output_get_assigned_crtc (output);
- if (assigned_crtc != crtc)
+ if (assigned_crtc != GF_CRTC (self))
return TRUE;
}
@@ -272,11 +272,7 @@ gf_crtc_xrandr_is_assignment_changed (GfCrtc *crtc,
}
GfCrtcMode *
-gf_crtc_xrandr_get_current_mode (GfCrtc *crtc)
+gf_crtc_xrandr_get_current_mode (GfCrtcXrandr *self)
{
- GfCrtcXrandr *crtc_xrandr;
-
- crtc_xrandr = crtc->driver_private;
-
- return crtc_xrandr->current_mode;
+ return self->current_mode;
}
diff --git a/backends/gf-crtc.c b/backends/gf-crtc.c
index 9fe4ec7..464c98e 100644
--- a/backends/gf-crtc.c
+++ b/backends/gf-crtc.c
@@ -45,7 +45,7 @@ enum
static GParamSpec *crtc_properties[LAST_PROP] = { NULL };
-G_DEFINE_TYPE_WITH_PRIVATE (GfCrtc, gf_crtc, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GfCrtc, gf_crtc, G_TYPE_OBJECT)
static void
gf_crtc_finalize (GObject *object)
@@ -56,9 +56,6 @@ gf_crtc_finalize (GObject *object)
crtc = GF_CRTC (object);
priv = gf_crtc_get_instance_private (crtc);
- if (crtc->driver_notify)
- crtc->driver_notify (crtc);
-
g_clear_pointer (&priv->config, g_free);
G_OBJECT_CLASS (gf_crtc_parent_class)->finalize (object);
diff --git a/backends/gf-gpu-xrandr.c b/backends/gf-gpu-xrandr.c
index 5f98125..1403f0c 100644
--- a/backends/gf-gpu-xrandr.c
+++ b/backends/gf-gpu-xrandr.c
@@ -162,13 +162,13 @@ gf_gpu_xrandr_read_current (GfGpu *gpu,
{
XRRCrtcInfo *xrandr_crtc;
RRCrtc crtc_id;
- GfCrtc *crtc;
+ GfCrtcXrandr *crtc_xrandr;
crtc_id = resources->crtcs[i];
xrandr_crtc = XRRGetCrtcInfo (xdisplay, resources, crtc_id);
- crtc = gf_create_xrandr_crtc (gpu_xrandr, xrandr_crtc, crtc_id, resources);
+ crtc_xrandr = gf_crtc_xrandr_new (gpu_xrandr, xrandr_crtc, crtc_id, resources);
- crtcs = g_list_append (crtcs, crtc);
+ crtcs = g_list_append (crtcs, crtc_xrandr);
XRRFreeCrtcInfo (xrandr_crtc);
}
diff --git a/backends/gf-monitor-manager-xrandr.c b/backends/gf-monitor-manager-xrandr.c
index d47912b..e5648d2 100644
--- a/backends/gf-monitor-manager-xrandr.c
+++ b/backends/gf-monitor-manager-xrandr.c
@@ -182,7 +182,8 @@ xrandr_set_crtc_config (GfMonitorManagerXrandr *xrandr,
{
xcb_timestamp_t new_timestamp;
- if (!gf_crtc_xrandr_set_config (crtc, xrandr_crtc, timestamp,
+ if (!gf_crtc_xrandr_set_config (GF_CRTC_XRANDR (crtc),
+ xrandr_crtc, timestamp,
x, y, mode, rotation,
outputs, n_outputs,
&new_timestamp))
@@ -210,10 +211,11 @@ is_crtc_assignment_changed (GfCrtc *crtc,
if (crtc_assignment->crtc != crtc)
continue;
- return gf_crtc_xrandr_is_assignment_changed (crtc, crtc_assignment);
+ return gf_crtc_xrandr_is_assignment_changed (GF_CRTC_XRANDR (crtc),
+ crtc_assignment);
}
- return !!gf_crtc_xrandr_get_current_mode (crtc);
+ return !!gf_crtc_xrandr_get_current_mode (GF_CRTC_XRANDR (crtc));
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]