[gtkmm] Add Gdk::FrameClock and Gdk::FrameTimings
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Add Gdk::FrameClock and Gdk::FrameTimings
- Date: Wed, 31 Jan 2018 12:34:22 +0000 (UTC)
commit 5900c8847477697be65163935fb4951730f7c892
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed Jan 31 13:31:42 2018 +0100
Add Gdk::FrameClock and Gdk::FrameTimings
* gdk/src/frameclock.[ccg|hg]:
* gdk/src/frametimings.[ccg|hg]: New files.
* .gitignore:
* gdk/gdkmm.h:
* gdk/src/filelist.am: Add new filenames.
* gdk/src/gdk_docs_override.xml: Add substitutions for new enum
Gdk::FrameClock::Phase.
* gdk/src/gdk_extra_objects.defs: Add new objects.
* gdk/src/gdk_signals.defs: Add GdkFrameClock's signals.
* tools/extra_defs_gen/generate_defs_gdk.cc: Add GDK_TYPE_FRAME_CLOCK.
* tools/m4/convert_gdk.m: Add conversions for GdkFrameClock and
GdkFrameTImings.
.gitignore | 4 +
gdk/gdkmm.h | 1 +
gdk/src/filelist.am | 2 +
gdk/src/frameclock.ccg | 16 +++++
gdk/src/frameclock.hg | 101 +++++++++++++++++++++++++++++
gdk/src/frametimings.ccg | 16 +++++
gdk/src/frametimings.hg | 54 +++++++++++++++
gdk/src/gdk_docs_override.xml | 2 +
gdk/src/gdk_extra_objects.defs | 12 ++++
gdk/src/gdk_signals.defs | 44 +++++++++++++
tools/extra_defs_gen/generate_defs_gdk.cc | 1 +
tools/m4/convert_gdk.m4 | 7 ++
12 files changed, 260 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 7b39479..c7a2fc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,6 +79,10 @@ gdk/gdkmm/event.cc
gdk/gdkmm/event.h
gdk/gdkmm/events.cc
gdk/gdkmm/events.h
+gdk/gdkmm/frameclock.cc
+gdk/gdkmm/frameclock.h
+gdk/gdkmm/frametimings.cc
+gdk/gdkmm/frametimings.h
gdk/gdkmm/glcontext.cc
gdk/gdkmm/glcontext.h
gdk/gdkmm/monitor.cc
diff --git a/gdk/gdkmm.h b/gdk/gdkmm.h
index 7373527..0e948ef 100644
--- a/gdk/gdkmm.h
+++ b/gdk/gdkmm.h
@@ -32,6 +32,7 @@
#include <gdkmm/cursor.h>
#include <gdkmm/drawingcontext.h>
#include <gdkmm/events.h>
+#include <gdkmm/frameclock.h>
#include <gdkmm/glcontext.h>
#include <gdkmm/rectangle.h>
#include <gdkmm/display.h>
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index 9713c79..eb7e959 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -28,6 +28,8 @@ gdkmm_files_any_hg = \
enums.hg \
event.hg \
events.hg \
+ frameclock.hg \
+ frametimings.hg \
glcontext.hg \
monitor.hg \
pixbuf.hg \
diff --git a/gdk/src/frameclock.ccg b/gdk/src/frameclock.ccg
new file mode 100644
index 0000000..4fef46a
--- /dev/null
+++ b/gdk/src/frameclock.ccg
@@ -0,0 +1,16 @@
+/* Copyright (C) 2018 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
diff --git a/gdk/src/frameclock.hg b/gdk/src/frameclock.hg
new file mode 100644
index 0000000..1cededa
--- /dev/null
+++ b/gdk/src/frameclock.hg
@@ -0,0 +1,101 @@
+/* Copyright (C) 2018 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/object.h>
+#include <gdkmm/frametimings.h>
+
+_DEFS(gdkmm,gdk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+_CC_INCLUDE(gdk/gdk.h)
+
+extern "C" typedef struct _GdkFrameClock GdkFrameClock;
+
+namespace Gdk
+{
+/** Frame clock syncs painting to a window or display.
+ *
+ * A %Gdk::FrameClock tells the application when to update and repaint a
+ * window. This may be synced to the vertical refresh rate of the
+ * monitor, for example. Even when the frame clock uses a simple timer
+ * rather than a hardware-based vertical sync, the frame clock helps
+ * because it ensures everything paints at the same time (reducing the
+ * total number of frames). The frame clock can also automatically
+ * stop painting when it knows the frames will not be visible, or
+ * scale back animation framerates.
+ *
+ * %Gdk::FrameClock is designed to be compatible with an OpenGL-based
+ * implementation or with mozRequestAnimationFrame in Firefox,
+ * for example.
+ *
+ * A frame clock is idle until someone requests a frame with
+ * request_phase(). At some later point that makes
+ * sense for the synchronization being implemented, the clock will
+ * process a frame and emit signals for each phase that has been
+ * requested. (See the signals of the %Gdk::FrameClock class for
+ * documentation of the phases. Gdk::FrameClock::Phase::UPDATE and the
+ * signal_update() signal are most interesting for application
+ * writers, and are used to update the animations, using the frame time
+ * given by get_frame_time().
+ *
+ * The frame time is reported in microseconds and generally in the same
+ * timescale as g_get_monotonic_time(), however, it is not the same
+ * as g_get_monotonic_time(). The frame time does not advance during
+ * the time a frame is being painted, and outside of a frame, an attempt
+ * is made so that all calls to get_frame_time() that
+ * are called at a “similar” time get the same value. This means that
+ * if different animations are timed by looking at the difference in
+ * time between an initial value from get_frame_time()
+ * and the value inside the signal_update() signal of the clock,
+ * they will stay exactly synchronized.
+ *
+ * @newin{3,94}
+ */
+class FrameClock : public Glib::Object
+{
+ _CLASS_GOBJECT(FrameClock, GdkFrameClock, GDK_FRAME_CLOCK, Glib::Object, GObject)
+
+public:
+ _WRAP_ENUM(Phase, GdkFrameClockPhase)
+
+ _WRAP_METHOD(gint64 get_frame_time() const, gdk_frame_clock_get_frame_time)
+ _WRAP_METHOD(void request_phase(Phase phase), gdk_frame_clock_request_phase)
+ _WRAP_METHOD(void begin_updating(), gdk_frame_clock_begin_updating)
+ _WRAP_METHOD(void end_updating(), gdk_frame_clock_end_updating)
+ _WRAP_METHOD(gint64 get_frame_counter() const, gdk_frame_clock_get_frame_counter)
+ _WRAP_METHOD(gint64 get_history_start() const, gdk_frame_clock_get_history_start)
+ _WRAP_METHOD(Glib::RefPtr<FrameTimings> get_timings(gint64 frame_counter), gdk_frame_clock_get_timings,
refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const FrameTimings> get_timings(gint64 frame_counter) const,
gdk_frame_clock_get_timings, refreturn, constversion)
+ _WRAP_METHOD(Glib::RefPtr<FrameTimings> get_current_timings(), gdk_frame_clock_get_current_timings,
refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const FrameTimings> get_current_timings() const,
gdk_frame_clock_get_current_timings, refreturn, constversion)
+ _WRAP_METHOD(void get_refresh_info(gint64 base_time, gint64& refresh_interval_return,
+ gint64& presentation_time_return) const, gdk_frame_clock_get_refresh_info)
+
+ _IGNORE_SIGNAL("flush-events")dnl// Applications should not handle this signal.
+ _IGNORE_SIGNAL("before-paint")dnl// Applications should generally not handle this signal.
+
+ // no_default_handler because the wrapped C signals have no default handlers.
+ _WRAP_SIGNAL(void update(), "update", no_default_handler)
+ _WRAP_SIGNAL(void layout(), "layout", no_default_handler)
+ _WRAP_SIGNAL(void paint(), "paint", no_default_handler)
+
+ _IGNORE_SIGNAL("after-paint")dnl// Applications should generally not handle this signal.
+ _IGNORE_SIGNAL("resume-events")dnl// Applications should not handle this signal.
+
+ // There are no properties or vfuncs.
+};
+
+} // namespace Gdk
diff --git a/gdk/src/frametimings.ccg b/gdk/src/frametimings.ccg
new file mode 100644
index 0000000..4fef46a
--- /dev/null
+++ b/gdk/src/frametimings.ccg
@@ -0,0 +1,16 @@
+/* Copyright (C) 2018 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
diff --git a/gdk/src/frametimings.hg b/gdk/src/frametimings.hg
new file mode 100644
index 0000000..cc35bf5
--- /dev/null
+++ b/gdk/src/frametimings.hg
@@ -0,0 +1,54 @@
+/* Copyright (C) 2018 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+_DEFS(gdkmm,gdk)
+
+#include <glibmm/refptr.h>
+
+_CC_INCLUDE(gdk/gdk.h)
+
+extern "C" typedef struct _GdkFrameTimings GdkFrameTimings;
+
+namespace Gdk
+{
+
+/** Object holding timing information for a single frame.
+ *
+ * A %Gdk::FrameTimings object holds timing information for a single frame
+ * of the application’s displays. To retrieve %Gdk::FrameTimings objects,
+ * use Gdk::FrameClock::get_timings() or Gdk::FrameClock::get_current_timings().
+ * The information in %Gdk::FrameTimings is useful for precise synchronization
+ * of video with the event or audio streams, and for measuring
+ * quality metrics for the application’s display, such as latency and jitter.
+ *
+ * @newin{3,94}
+ */
+class FrameTimings final
+{
+ // GdkFrameTimings is registered as a boxed type, but it has custom
+ // reference-counting instead of copy/free functions, so we use it via RefPtr.
+ _CLASS_OPAQUE_REFCOUNTED(FrameTimings, GdkFrameTimings, NONE, gdk_frame_timings_ref,
gdk_frame_timings_unref)
+ _IGNORE(gdk_frame_timings_ref, gdk_frame_timings_unref)
+public:
+ _WRAP_METHOD(gint64 get_frame_counter() const, gdk_frame_timings_get_frame_counter)
+ _WRAP_METHOD(bool get_complete() const, gdk_frame_timings_get_complete)
+ _WRAP_METHOD(gint64 get_frame_time() const, gdk_frame_timings_get_frame_time)
+ _WRAP_METHOD(gint64 get_presentation_time() const, gdk_frame_timings_get_presentation_time)
+ _WRAP_METHOD(gint64 get_refresh_interval() const, gdk_frame_timings_get_refresh_interval)
+ _WRAP_METHOD(gint64 get_predicted_presentation_time() const,
gdk_frame_timings_get_predicted_presentation_time)
+};
+
+} // namespace Gdk
diff --git a/gdk/src/gdk_docs_override.xml b/gdk/src/gdk_docs_override.xml
index 117819d..74c914b 100644
--- a/gdk/src/gdk_docs_override.xml
+++ b/gdk/src/gdk_docs_override.xml
@@ -7,6 +7,7 @@
<substitute_type_name from="GdkCursorType" to="Gdk::Cursor::Type" />
<substitute_type_name from="GdkDeviceType" to="Gdk::Device::Type" />
<substitute_type_name from="GdkEventType" to="Gdk::Event::Type" />
+<substitute_type_name from="GdkFrameClockPhase" to="Gdk::FrameClock::Phase" />
<substitute_type_name from="GdkPixbufRotation" to="Gdk::Pixbuf::Rotation" />
<substitute_type_name from="GdkSeatCapabilities" to="Gdk::Seat::Capabilities" />
<substitute_type_name from="GdkWindowType" to="Gdk::Window::Type" />
@@ -41,6 +42,7 @@
<substitute_enumerator_name from_prefix="GDK_MODE_" to_prefix="Gdk::InputMode::" />
<substitute_enumerator_name from_prefix="GDK_SOURCE_" to_prefix="Gdk::InputSource::" />
<substitute_enumerator_name from_prefix="GDK_SUBPIXEL_LAYOUT_" to_prefix="Gdk::SubpixelLayout::" />
+<substitute_enumerator_name from_prefix="GDK_FRAME_CLOCK_PHASE_" to_prefix="Gdk::FrameClock::Phase::" />
<!-- Some enums have enumerators without unique prefixes. Handle these enumerators individually. -->
<substitute_enumerator_name from="GDK_NOTHING" to="Gdk::Event::Type::NOTHING" />
<substitute_enumerator_name from="GDK_POINTER_MOTION_HINT_MASK"
to="Gdk::EventMask::POINTER_MOTION_HINT_MASK" />
diff --git a/gdk/src/gdk_extra_objects.defs b/gdk/src/gdk_extra_objects.defs
index b8008e9..114b557 100644
--- a/gdk/src/gdk_extra_objects.defs
+++ b/gdk/src/gdk_extra_objects.defs
@@ -73,6 +73,18 @@
(gtype-id "GDK_TYPE_EVENT")
)
+(define-object FrameClock
+ (in-module "Gdk")
+ (c-name "GdkFrameClock")
+ (gtype-id "GDK_TYPE_FRAME_CLOCK")
+)
+
+(define-object FrameTimings
+ (in-module "Gdk")
+ (c-name "GdkFrameTimings")
+ (gtype-id "GDK_TYPE_FRAME_TIMINGS")
+)
+
(define-object GLContext
(in-module "Gdk")
(parent "GObject")
diff --git a/gdk/src/gdk_signals.defs b/gdk/src/gdk_signals.defs
index b3a3c6b..8da5020 100644
--- a/gdk/src/gdk_signals.defs
+++ b/gdk/src/gdk_signals.defs
@@ -508,6 +508,50 @@
(default-value "GDK_NOTHING")
)
+;; From GdkFrameClock
+
+(define-signal flush-events
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
+(define-signal before-paint
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
+(define-signal update
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
+(define-signal layout
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
+(define-signal paint
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
+(define-signal after-paint
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
+(define-signal resume-events
+ (of-object "GdkFrameClock")
+ (return-type "void")
+ (flags "Run Last")
+)
+
;; From GdkMonitor
(define-signal invalidate
diff --git a/tools/extra_defs_gen/generate_defs_gdk.cc b/tools/extra_defs_gen/generate_defs_gdk.cc
index 54c6541..b130a2f 100644
--- a/tools/extra_defs_gen/generate_defs_gdk.cc
+++ b/tools/extra_defs_gen/generate_defs_gdk.cc
@@ -48,6 +48,7 @@ int main(int /* argc */, char** /* argv */)
<< get_defs( GDK_TYPE_DRAW_CONTEXT )
<< get_defs( GDK_TYPE_DRAWING_CONTEXT )
<< get_defs( GDK_TYPE_EVENT )
+ << get_defs( GDK_TYPE_FRAME_CLOCK )
<< get_defs( GDK_TYPE_MONITOR )
<< get_defs( GDK_TYPE_PIXBUF )
<< get_defs( GDK_TYPE_PIXBUF_ANIMATION )
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index c76bf90..b307e87 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -40,6 +40,7 @@ _CONV_INCLASS_ENUM(Gdk,Event,Type)
_CONV_ENUM(Gdk,ExtensionMode)
_CONV_ENUM(Gdk,Fill)
_CONV_ENUM(Gdk,FillRule)
+_CONV_INCLASS_ENUM(Gdk,FrameClock,Phase)
_CONV_ENUM(Gdk,FullscreenMode)
_CONV_ENUM(Gdk,Function)
_CONV_ENUM(Gdk,Gravity)
@@ -246,6 +247,12 @@ _CONVERSION(`const Glib::RefPtr<ContentProvider>&',`GdkContentProvider*',__CONVE
_CONVERSION(`const Glib::RefPtr<const ContentProvider>&',`GdkContentProvider*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GdkContentProvider*',`Glib::RefPtr<ContentProvider>',`Glib::wrap($3)')
+# FrameClock, FrameTimings
+_CONVERSION(`GdkFrameClock*',`Glib::RefPtr<FrameClock>',`Glib::wrap($3)')
+_CONVERSION(`GdkFrameClock*',`Glib::RefPtr<Gdk::FrameClock>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<Gdk::FrameClock>&',`GdkFrameClock*',__CONVERT_REFPTR_TO_P)
+_CONVERSION(`GdkFrameTimings*',`Glib::RefPtr<FrameTimings>',`Glib::wrap($3)')
+
# XPM data
_CONVERSION(`const char*const*',`const char**',`const_cast<const char**>($3)',`$3')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]