diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index e4f03df6b..7cde0140d 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -735,7 +735,7 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock, if (iface->new_frame) frame = iface->new_frame (frame_clock, frame_clock->listener.user_data); if (!frame) - frame = clutter_frame_new (); + frame = clutter_frame_new (ClutterFrame); frame->frame_count = frame_count; frame->has_target_presentation_time = frame_clock->is_next_presentation_time_valid; diff --git a/clutter/clutter/clutter-frame-private.h b/clutter/clutter/clutter-frame-private.h index 51a837f01..16c4f300c 100644 --- a/clutter/clutter/clutter-frame-private.h +++ b/clutter/clutter/clutter-frame-private.h @@ -34,7 +34,10 @@ struct _ClutterFrame }; CLUTTER_EXPORT -ClutterFrame * clutter_frame_new (void); +gpointer clutter_frame_new (size_t size); + +#define clutter_frame_new(FrameType) \ + ((FrameType *) (clutter_frame_new (sizeof (FrameType)))) ClutterFrameResult clutter_frame_get_result (ClutterFrame *frame); diff --git a/clutter/clutter/clutter-frame.c b/clutter/clutter/clutter-frame.c index 259cf7096..824cb59e2 100644 --- a/clutter/clutter/clutter-frame.c +++ b/clutter/clutter/clutter-frame.c @@ -35,12 +35,14 @@ clutter_frame_unref (ClutterFrame *frame) g_free (frame); } -ClutterFrame * -clutter_frame_new (void) +gpointer +(clutter_frame_new) (size_t size) { ClutterFrame *frame; - frame = g_new0 (ClutterFrame, 1); + g_assert (size >= sizeof (ClutterFrame)); + + frame = g_malloc0 (size); g_ref_count_init (&frame->ref_count); return frame; diff --git a/clutter/clutter/clutter-mutter.h b/clutter/clutter/clutter-mutter.h index d700b26a6..3250eb5d6 100644 --- a/clutter/clutter/clutter-mutter.h +++ b/clutter/clutter/clutter-mutter.h @@ -29,6 +29,7 @@ #include "clutter-backend-private.h" #include "clutter-damage-history.h" #include "clutter-event-private.h" +#include "clutter-frame-private.h" #include "clutter-input-device-private.h" #include "clutter-input-pointer-a11y-private.h" #include "clutter-macros.h" diff --git a/src/backends/native/meta-frame-native.c b/src/backends/native/meta-frame-native.c new file mode 100644 index 000000000..4c2549a8d --- /dev/null +++ b/src/backends/native/meta-frame-native.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 Red Hat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "config.h" + +#include "backends/native/meta-frame-native.h" + +#include "clutter/clutter-mutter.h" + +struct _MetaFrameNative +{ + ClutterFrame base; +}; + +MetaFrameNative * +meta_frame_native_new (void) +{ + return clutter_frame_new (MetaFrameNative); +} diff --git a/src/backends/native/meta-frame-native.h b/src/backends/native/meta-frame-native.h new file mode 100644 index 000000000..f52921ce6 --- /dev/null +++ b/src/backends/native/meta-frame-native.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2022 Red Hat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_FRAME_NATIVE_H +#define META_FRAME_NATIVE_H + +typedef struct _MetaFrameNative MetaFrameNative; + +MetaFrameNative * meta_frame_native_new (void); + +#endif /* META_FRAME_NATIVE_H */ diff --git a/src/backends/native/meta-renderer-view-native.c b/src/backends/native/meta-renderer-view-native.c index e64a1476a..52872ff3c 100644 --- a/src/backends/native/meta-renderer-view-native.c +++ b/src/backends/native/meta-renderer-view-native.c @@ -24,6 +24,8 @@ #include "backends/native/meta-renderer-view-native.h" +#include "backends/native/meta-frame-native.h" + struct _MetaRendererViewNative { MetaRendererView parent; @@ -32,9 +34,18 @@ struct _MetaRendererViewNative G_DEFINE_TYPE (MetaRendererViewNative, meta_renderer_view_native, META_TYPE_RENDERER_VIEW) +static ClutterFrame * +meta_renderer_view_native_new_frame (ClutterStageView *stage_view) +{ + return (ClutterFrame *) meta_frame_native_new (); +} + static void meta_renderer_view_native_class_init (MetaRendererViewNativeClass *klass) { + ClutterStageViewClass *stage_view_class = CLUTTER_STAGE_VIEW_CLASS (klass); + + stage_view_class->new_frame = meta_renderer_view_native_new_frame; } static void diff --git a/src/meson.build b/src/meson.build index 0bb5c6ce7..47852d7fd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -743,6 +743,8 @@ if have_native_backend 'backends/native/meta-drm-buffer.h', 'backends/native/meta-gpu-kms.c', 'backends/native/meta-gpu-kms.h', + 'backends/native/meta-frame-native.c', + 'backends/native/meta-frame-native.h', 'backends/native/meta-input-device-native.c', 'backends/native/meta-input-device-native.h', 'backends/native/meta-input-device-tool-native.c',