[Cogl] [PATCH 2/3] rename CoglFrameTimings to CoglSwapInfo

Owen Taylor otaylor at redhat.com
Thu Jan 24 10:14:11 PST 2013


Looks fine in combination with your later change to the compromise
CoglFrameInfo.

There a couple of minor whitespace errors left-over here, but they seem
to get overridden by later stuff in your branch.

Reviewed-by: Owen W. Taylor <otaylor at fishsoup.net>

On Tue, 2012-12-04 at 15:47 +0000, Robert Bragg wrote:
> From: Robert Bragg <robert at linux.intel.com>
> 
> The aim is to pass an opaque structure to the swap buffers notification
> callbacks and enable access to frame timing information this way. Since
> there could be numerous non-timing related things to report here too
> this gives the structure a more general name.
> 
> TODO: fold this back into owen's patch
> ---
>  cogl/Makefile.am                  |    6 +-
>  cogl/cogl-frame-timings-private.h |   44 ------------
>  cogl/cogl-frame-timings.c         |   78 ----------------------
>  cogl/cogl-frame-timings.h         |  133 -------------------------------------
>  cogl/cogl-glx-display-private.h   |    2 +-
>  cogl/cogl-onscreen-private.h      |   22 +++---
>  cogl/cogl-onscreen.c              |   60 ++++++++--------
>  cogl/cogl-onscreen.h              |   54 ++++++++--------
>  cogl/cogl-swap-info-private.h     |   44 ++++++++++++
>  cogl/cogl-swap-info.c             |   78 ++++++++++++++++++++++
>  cogl/cogl-swap-info.h             |  133 +++++++++++++++++++++++++++++++++++++
>  cogl/winsys/cogl-winsys-glx.c     |   61 +++++++++--------
>  12 files changed, 359 insertions(+), 356 deletions(-)
>  delete mode 100644 cogl/cogl-frame-timings-private.h
>  delete mode 100644 cogl/cogl-frame-timings.c
>  delete mode 100644 cogl/cogl-frame-timings.h
>  create mode 100644 cogl/cogl-swap-info-private.h
>  create mode 100644 cogl/cogl-swap-info.c
>  create mode 100644 cogl/cogl-swap-info.h
> 
> diff --git a/cogl/Makefile.am b/cogl/Makefile.am
> index efa94c4..d03c84c 100644
> --- a/cogl/Makefile.am
> +++ b/cogl/Makefile.am
> @@ -104,7 +104,7 @@ cogl_experimental_h = \
>  	$(srcdir)/cogl-attribute.h 		\
>  	$(srcdir)/cogl-primitive.h 		\
>  	$(srcdir)/cogl-clip-state.h		\
> -	$(srcdir)/cogl-frame-timings.h		\
> +	$(srcdir)/cogl-swap-info.h		\
>  	$(srcdir)/cogl-framebuffer.h		\
>  	$(srcdir)/cogl-onscreen.h		\
>  	$(srcdir)/cogl-output.h			\
> @@ -343,8 +343,8 @@ cogl_sources_c = \
>  	$(srcdir)/cogl-spans.c				\
>  	$(srcdir)/cogl-journal-private.h		\
>  	$(srcdir)/cogl-journal.c			\
> -	$(srcdir)/cogl-frame-timings-private.h		\
> -	$(srcdir)/cogl-frame-timings.c			\
> +	$(srcdir)/cogl-swap-info-private.h		\
> +	$(srcdir)/cogl-swap-info.c			\
>  	$(srcdir)/cogl-framebuffer-private.h		\
>  	$(srcdir)/cogl-framebuffer.c 			\
>  	$(srcdir)/cogl-onscreen-private.h		\
> diff --git a/cogl/cogl-frame-timings-private.h b/cogl/cogl-frame-timings-private.h
> deleted file mode 100644
> index b17cd34..0000000
> --- a/cogl/cogl-frame-timings-private.h
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/*
> - * Cogl
> - *
> - * An object oriented GL/GLES Abstraction/Utility Layer
> - *
> - * Copyright (C) 2012 Red Hat, Inc.
> - *
> - * 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 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/>.
> - *
> - *
> - */
> -
> -#ifndef __COGL_FRAME_TIMINGS_PRIVATE_H
> -#define __COGL_FRAME_TIMINGS_PRIVATE_H
> -
> -#include "cogl-frame-timings.h"
> -#include "cogl-object-private.h"
> -
> -struct _CoglFrameTimings
> -{
> -  CoglObject _parent;
> -
> -  int64_t frame_counter;
> -  int64_t frame_time;
> -  int64_t presentation_time;
> -  int64_t refresh_interval;
> -
> -  guint complete : 1;
> -};
> -
> -CoglFrameTimings *_cogl_frame_timings_new (void);
> -
> -#endif /* __COGL_FRAME_TIMINGS_PRIVATE_H */
> diff --git a/cogl/cogl-frame-timings.c b/cogl/cogl-frame-timings.c
> deleted file mode 100644
> index ba8003e..0000000
> --- a/cogl/cogl-frame-timings.c
> +++ /dev/null
> @@ -1,78 +0,0 @@
> -/*
> - * Cogl
> - *
> - * An object oriented GL/GLES Abstraction/Utility Layer
> - *
> - * Copyright (C) 2012 Red Hat, Inc.
> - *
> - * 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 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/>.
> - *
> - *
> - */
> -
> -#ifdef HAVE_CONFIG_H
> -#include "config.h"
> -#endif
> -
> -#include "cogl-frame-timings-private.h"
> -
> -static void _cogl_frame_timings_free (CoglFrameTimings *frame_timings);
> -
> -COGL_OBJECT_DEFINE (FrameTimings, frame_timings);
> -
> -CoglFrameTimings *
> -_cogl_frame_timings_new (void)
> -{
> -  CoglFrameTimings *timings;
> -
> -  timings = g_slice_new0 (CoglFrameTimings);
> -
> -  return _cogl_frame_timings_object_new (timings);
> -}
> -
> -static void
> -_cogl_frame_timings_free (CoglFrameTimings *timings)
> -{
> -  g_slice_free (CoglFrameTimings, timings);
> -}
> -
> -CoglBool
> -cogl_frame_timings_get_complete (CoglFrameTimings *timings)
> -{
> -  return timings->complete;
> -}
> -
> -gint64
> -cogl_frame_timings_get_frame_counter (CoglFrameTimings *timings)
> -{
> -  return timings->frame_counter;
> -}
> -
> -gint64
> -cogl_frame_timings_get_frame_time (CoglFrameTimings *timings)
> -{
> -  return timings->frame_time;
> -}
> -
> -gint64
> -cogl_frame_timings_get_presentation_time (CoglFrameTimings *timings)
> -{
> -  return timings->presentation_time;
> -}
> -
> -gint64
> -cogl_frame_timings_get_refresh_interval (CoglFrameTimings *timings)
> -{
> -  return timings->refresh_interval;
> -}
> diff --git a/cogl/cogl-frame-timings.h b/cogl/cogl-frame-timings.h
> deleted file mode 100644
> index c00e920..0000000
> --- a/cogl/cogl-frame-timings.h
> +++ /dev/null
> @@ -1,133 +0,0 @@
> -/*
> - * Cogl
> - *
> - * An object oriented GL/GLES Abstraction/Utility Layer
> - *
> - * Copyright (C) 2012 Red Hat, Inc.
> - *
> - * 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 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/>.
> - *
> - *
> - *
> - * Authors:
> - *   Owen Taylor <otaylor at redhat.com>
> - */
> -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
> -#error "Only <cogl/cogl.h> can be included directly."
> -#endif
> -
> -#ifndef __COGL_FRAME_TIMINGS_H
> -#define __COGL_FRAME_TIMINGS_H
> -
> -#include <cogl/cogl-types.h>
> -#include <glib.h>
> -
> -G_BEGIN_DECLS
> -
> -typedef struct _CoglFrameTimings CoglFrameTimings;
> -#define COGL_FRAME_TIMINGS(X) ((CoglFrameTimings *)(X))
> -
> -/**
> - * cogl_is_frame_timings:
> - * @object: A #CoglObject pointer
> - *
> - * Gets whether the given object references a #CoglFrameTimings.
> - *
> - * Return value: %TRUE if the object references a #CoglFrameTimings
> - *   and %FALSE otherwise.
> - * Since: 2.0
> - * Stability: unstable
> - */
> -CoglBool
> -cogl_is_frame_timings (void *object);
> -
> -/**
> - * cogl_frame_timings_get_complete:
> - * @timings: a #CoglFrameTimings object
> - *
> - * Gets whether all information that will potentially be provided for
> - * the frame has been provided. Once a frame timings object is complete,
> - * no further changes will be made to it.
> - *
> - * Return value: whether the frame timings object is complete.
> - * Since: 2.0
> - * Stability: unstable
> - */
> -CoglBool cogl_frame_timings_get_complete (CoglFrameTimings *timings);
> -
> -/**
> - * cogl_frame_timings_get_frame_counter:
> - * @timings: a #CoglFrameTimings object
> - *
> - * Gets the frame counter for the #CoglOnscreen that corresponds
> - * to this frame.
> - *
> - * Return value: The frame counter value
> - * Since: 2.0
> - * Stability: unstable
> - */
> -int64_t cogl_frame_timings_get_frame_counter (CoglFrameTimings *timings);
> -
> -/**
> - * cogl_frame_timings_get_frame_time:
> - * @timings: a #CoglFrameTimings object
> - *
> - * Gets the time used for creating content for the frame. This
> - * is determined by the time passed to cogl_onscreen_begin_frame(),
> - * and will typically be the current time when rendering started
> - * for the frame.
> - *
> - * Return value: the time used for coreating content for the frame,
> - *  in the timescale of g_get_monotonic_time().
> - * Since: 2.0
> - * Stability: unstable
> - */
> -int64_t cogl_frame_timings_get_frame_time (CoglFrameTimings *timings);
> -
> -/**
> - * cogl_frame_timings_get_presentation_time:
> - * @timings: a #CoglFrameTimings object
> - *
> - * Gets the presentation time for the frame. This is the time at which
> - * the frame became visible to the user.
> - *
> - * Return value: the presentation time for the frame, in
> - *  the timescale of g_get_monotonic_time().
> - * Since: 2.0
> - * Stability: unstable
> - */
> -int64_t cogl_frame_timings_get_presentation_time (CoglFrameTimings *timings);
> -
> -/**
> - * cogl_frame_timings_get_refresh_interval:
> - * @timings: a #CoglFrameTimings object
> - *
> - * Gets the refresh interval for the output that the frame was on at the
> - * time the frame was presented. This is the number of microseconds between
> - * refreshes of the screen, and is equal to 1000000 / refresh_rate.
> - *
> - * Return value: the refresh interval, in microsecoonds.
> - *  .
> - * Since: 2.0
> - * Stability: unstable
> - */
> -int64_t cogl_frame_timings_get_refresh_interval (CoglFrameTimings *timings);
> -
> -G_END_DECLS
> -
> -#endif /* __COGL_FRAME_TIMINGS_H */
> -
> -
> -
> diff --git a/cogl/cogl-glx-display-private.h b/cogl/cogl-glx-display-private.h
> index cb0fd0d..5721d76 100644
> --- a/cogl/cogl-glx-display-private.h
> +++ b/cogl/cogl-glx-display-private.h
> @@ -52,7 +52,7 @@ typedef struct _CoglGLXDisplay
>    Window dummy_xwin;
>    CoglBool pending_swap_notify;
>    CoglBool pending_resize_notify;
> -  CoglBool pending_frame_timings_notify;
> +  CoglBool pending_swap_info_notify;
>  } CoglGLXDisplay;
>  
>  #endif /* __COGL_DISPLAY_GLX_PRIVATE_H */
> diff --git a/cogl/cogl-onscreen-private.h b/cogl/cogl-onscreen-private.h
> index 8c35f30..08fd5ec 100644
> --- a/cogl/cogl-onscreen-private.h
> +++ b/cogl/cogl-onscreen-private.h
> @@ -33,7 +33,7 @@
>  #include <windows.h>
>  #endif
>  
> -#define COGL_ONSCREEN_MAX_FRAME_TIMINGS 16
> +#define COGL_ONSCREEN_MAX_SWAP_INFOS 16
>  
>  typedef struct _CoglSwapBuffersNotifyEntry CoglSwapBuffersNotifyEntry;
>  
> @@ -61,15 +61,15 @@ struct _CoglResizeNotifyEntry
>    unsigned int id;
>  };
>  
> -typedef struct _CoglFrameTimingsCallbackEntry CoglFrameTimingsCallbackEntry;
> +typedef struct _CoglSwapInfoCallbackEntry CoglSwapInfoCallbackEntry;
>  
> -COGL_TAILQ_HEAD (CoglFrameTimingsCallbackList, CoglFrameTimingsCallbackEntry);
> +COGL_TAILQ_HEAD (CoglSwapInfoCallbackList, CoglSwapInfoCallbackEntry);
>  
> -struct _CoglFrameTimingsCallbackEntry
> +struct _CoglSwapInfoCallbackEntry
>  {
> -  COGL_TAILQ_ENTRY (CoglFrameTimingsCallbackEntry) list_node;
> +  COGL_TAILQ_ENTRY (CoglSwapInfoCallbackEntry) list_node;
>  
> -  CoglFrameTimingsCallback callback;
> +  CoglSwapInfoCallback callback;
>    void *user_data;
>    unsigned int id;
>  };
> @@ -95,15 +95,15 @@ struct _CoglOnscreen
>    CoglBool resizable;
>    CoglResizeNotifyList resize_callbacks;
>  
> -  CoglFrameTimingsCallbackList frame_timings_callbacks;
> +  CoglSwapInfoCallbackList swap_info_callbacks;
>  
>    int64_t frame_counter;
>    int64_t swap_frame_counter; /* frame counter at last all to
>                                 * cogl_onscreen_swap_region() or
>                                 * cogl_onscreen_swap_buffers() */
> -  CoglFrameTimings *frame_timings[COGL_ONSCREEN_MAX_FRAME_TIMINGS];
> -  int current_frame_timings;
> -  int n_frame_timings;
> +  CoglSwapInfo *swap_info[COGL_ONSCREEN_MAX_SWAP_INFOS];
> +  int current_swap_info;
> +  int n_swap_infos;
>  
>    void *winsys;
>  };
> @@ -122,6 +122,6 @@ void
>  _cogl_onscreen_notify_resize (CoglOnscreen *onscreen);
>  
>  void
> -_cogl_onscreen_notify_frame_timings (CoglOnscreen *onscreen);
> +_cogl_onscreen_notify_swap_info (CoglOnscreen *onscreen);
>  
>  #endif /* __COGL_ONSCREEN_PRIVATE_H */
> diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
> index 39ffa8d..3d17c8b 100644
> --- a/cogl/cogl-onscreen.c
> +++ b/cogl/cogl-onscreen.c
> @@ -27,7 +27,7 @@
>  
>  #include "cogl-util.h"
>  #include "cogl-onscreen-private.h"
> -#include "cogl-frame-timings-private.h"
> +#include "cogl-swap-info-private.h"
>  #include "cogl-framebuffer-private.h"
>  #include "cogl-onscreen-template-private.h"
>  #include "cogl-context-private.h"
> @@ -50,7 +50,7 @@ _cogl_onscreen_init_from_template (CoglOnscreen *onscreen,
>  
>    COGL_TAILQ_INIT (&onscreen->swap_callbacks);
>    COGL_TAILQ_INIT (&onscreen->resize_callbacks);
> -  COGL_TAILQ_INIT (&onscreen->frame_timings_callbacks);
> +  COGL_TAILQ_INIT (&onscreen->swap_info_callbacks);
>  
>    framebuffer->config = onscreen_template->config;
>    cogl_object_ref (framebuffer->config.swap_chain);
> @@ -80,7 +80,7 @@ _cogl_onscreen_new (void)
>    COGL_FRAMEBUFFER (onscreen)->allocated = TRUE;
>  
>    onscreen->frame_counter = -1;
> -  onscreen->current_frame_timings = COGL_ONSCREEN_MAX_FRAME_TIMINGS - 1;
> +  onscreen->current_swap_info = COGL_ONSCREEN_MAX_SWAP_INFOS - 1;
>  
>    /* XXX: Note we don't initialize onscreen->winsys in this case. */
>  
> @@ -484,16 +484,16 @@ cogl_onscreen_begin_frame (CoglOnscreen *onscreen,
>                             gint64        frame_time)
>  {
>    onscreen->frame_counter++;
> -  onscreen->current_frame_timings = (onscreen->current_frame_timings + 1) % COGL_ONSCREEN_MAX_FRAME_TIMINGS;
> +  onscreen->current_swap_info = (onscreen->current_swap_info + 1) % COGL_ONSCREEN_MAX_SWAP_INFOS;
>  
> -  if (onscreen->n_frame_timings < COGL_ONSCREEN_MAX_FRAME_TIMINGS)
> -    onscreen->n_frame_timings++;
> +  if (onscreen->n_swap_infos < COGL_ONSCREEN_MAX_SWAP_INFOS)
> +    onscreen->n_swap_infos++;
>    else
> -    cogl_object_unref (onscreen->frame_timings[onscreen->current_frame_timings]);
> +    cogl_object_unref (onscreen->swap_info[onscreen->current_swap_info]);
>  
> -  onscreen->frame_timings[onscreen->current_frame_timings] = _cogl_frame_timings_new ();
> -  onscreen->frame_timings[onscreen->current_frame_timings]->frame_counter = onscreen->frame_counter;
> -  onscreen->frame_timings[onscreen->current_frame_timings]->frame_time = frame_time;
> +  onscreen->swap_info[onscreen->current_swap_info] = _cogl_swap_info_new ();
> +  onscreen->swap_info[onscreen->current_swap_info]->frame_counter = onscreen->frame_counter;
> +  onscreen->swap_info[onscreen->current_swap_info]->frame_time = frame_time;
>  }
>  
>  static void
> @@ -508,11 +508,11 @@ cogl_onscreen_before_swap (CoglOnscreen *onscreen)
>  int64_t
>  cogl_onscreen_get_frame_history_start (CoglOnscreen *onscreen)
>  {
> -  return onscreen->frame_counter - onscreen->n_frame_timings;
> +  return onscreen->frame_counter - onscreen->n_swap_infos;
>  }
>  
> -CoglFrameTimings *
> -cogl_onscreen_get_frame_timings (CoglOnscreen *onscreen,
> +CoglSwapInfo *
> +cogl_onscreen_get_swap_info (CoglOnscreen *onscreen,
>                                   int64_t       frame_counter)
>  {
>    int pos;
> @@ -520,57 +520,57 @@ cogl_onscreen_get_frame_timings (CoglOnscreen *onscreen,
>    if (frame_counter > onscreen->frame_counter)
>      return NULL;
>  
> -  if (frame_counter <= onscreen->frame_counter - onscreen->n_frame_timings)
> +  if (frame_counter <= onscreen->frame_counter - onscreen->n_swap_infos)
>      return NULL;
>  
> -  pos = ((onscreen->current_frame_timings -
> -          (onscreen->frame_counter - frame_counter) + COGL_ONSCREEN_MAX_FRAME_TIMINGS)
> -         % COGL_ONSCREEN_MAX_FRAME_TIMINGS);
> +  pos = ((onscreen->current_swap_info -
> +          (onscreen->frame_counter - frame_counter) + COGL_ONSCREEN_MAX_SWAP_INFOS)
> +         % COGL_ONSCREEN_MAX_SWAP_INFOS);
>  
> -  return onscreen->frame_timings[pos];
> +  return onscreen->swap_info[pos];
>  }
>  
>  unsigned int
> -cogl_onscreen_add_frame_timings_callback (CoglOnscreen *onscreen,
> -                                          CoglFrameTimingsCallback callback,
> +cogl_onscreen_add_swap_info_callback (CoglOnscreen *onscreen,
> +                                          CoglSwapInfoCallback callback,
>                                            void *user_data)
>  {
> -  CoglFrameTimingsCallbackEntry *entry = g_slice_new (CoglFrameTimingsCallbackEntry);
> +  CoglSwapInfoCallbackEntry *entry = g_slice_new (CoglSwapInfoCallbackEntry);
>    static int next_resize_callback_id = 0;
>  
>    entry->callback = callback;
>    entry->user_data = user_data;
>    entry->id = next_resize_callback_id++;
>  
> -  COGL_TAILQ_INSERT_TAIL (&onscreen->frame_timings_callbacks, entry, list_node);
> +  COGL_TAILQ_INSERT_TAIL (&onscreen->swap_info_callbacks, entry, list_node);
>  
>    return entry->id;
>  }
>  
>  void
> -cogl_onscreen_remove_frame_timings_callback (CoglOnscreen *onscreen,
> +cogl_onscreen_remove_swap_info_callback (CoglOnscreen *onscreen,
>                                               unsigned int id)
>  {
> -  CoglFrameTimingsCallbackEntry *entry;
> +  CoglSwapInfoCallbackEntry *entry;
>  
> -  COGL_TAILQ_FOREACH (entry, &onscreen->frame_timings_callbacks, list_node)
> +  COGL_TAILQ_FOREACH (entry, &onscreen->swap_info_callbacks, list_node)
>      {
>        if (entry->id == id)
>          {
> -          COGL_TAILQ_REMOVE (&onscreen->frame_timings_callbacks, entry, list_node);
> -          g_slice_free (CoglFrameTimingsCallbackEntry, entry);
> +          COGL_TAILQ_REMOVE (&onscreen->swap_info_callbacks, entry, list_node);
> +          g_slice_free (CoglSwapInfoCallbackEntry, entry);
>            break;
>          }
>      }
>  }
>  
>  void
> -_cogl_onscreen_notify_frame_timings (CoglOnscreen *onscreen)
> +_cogl_onscreen_notify_swap_info (CoglOnscreen *onscreen)
>  {
> -  CoglFrameTimingsCallbackEntry *entry, *tmp;
> +  CoglSwapInfoCallbackEntry *entry, *tmp;
>  
>    COGL_TAILQ_FOREACH_SAFE (entry,
> -                           &onscreen->frame_timings_callbacks,
> +                           &onscreen->swap_info_callbacks,
>                             list_node,
>                             tmp)
>      entry->callback (onscreen, entry->user_data);
> diff --git a/cogl/cogl-onscreen.h b/cogl/cogl-onscreen.h
> index 3338991..de3f9f8 100644
> --- a/cogl/cogl-onscreen.h
> +++ b/cogl/cogl-onscreen.h
> @@ -34,7 +34,7 @@
>  
>  #include <cogl/cogl-context.h>
>  #include <cogl/cogl-framebuffer.h>
> -#include <cogl/cogl-frame-timings.h>
> +#include <cogl/cogl-swap-info.h>
>  #include <glib.h>
>  
>  G_BEGIN_DECLS
> @@ -554,23 +554,23 @@ cogl_onscreen_get_frame_counter (CoglOnscreen *onscreen);
>   *   content for this frame.
>   *
>   * Marks the beginning of a frame. This increases the frame
> - * counter value and creates a new #CoglFrameTimings objeect.
> + * counter value and creates a new #CoglSwapInfo objeect.
>   *
>   * Since: 2.0
>   */
>  void
>  cogl_onscreen_begin_frame (CoglOnscreen *onscreen,
> -                           gint64        frame_time);
> +                           gint64 frame_time);
>  
>  /**
>   * cogl_onscreen_get_frame_history_start:
>   * @onscreen: a #CoglOnscreen framebuffer
>   *
> - * Gets the frame counter for the oldest #CoglFrameTiming that is
> - * being kept in the history. cogl_onscreen_get_frame_timings() will
> + * Gets the frame counter for the oldest #CoglSwapInfo that is
> + * being kept in the history. cogl_onscreen_get_swap_info() will
>   * always return %NULl for any frame counter before this.
>   *
> - * Return value: the frame counter for the oldest #CoglFrameTimings
> + * Return value: the frame counter for the oldest #CoglSwapInfo
>   *  in the history.
>   * Since: 2.0
>   */
> @@ -579,31 +579,31 @@ cogl_onscreen_get_frame_history_start (CoglOnscreen *onscreen);
>  
> 
>  /**
> - * cogl_onscreen_get_frame_timings:
> + * cogl_onscreen_get_swap_info:
>   * @onscreen: A #CoglOnscreen framebuffer
>   * @frame_counter: the value of cogl_onscreen_get_frame_counter()
>   *       when the frame finished drawing.
>   *
>   * Gets frame timing information for a particular frame.
>   *
> - * Return value: a #CoglFrameTiming object, or %NULL if frame timing
> + * Return value: a #CoglSwapInfo object, or %NULL if swap info
>   *   information is not available for the given frame.
>   * Since: 2.0
>   */
> -CoglFrameTimings *
> -cogl_onscreen_get_frame_timings (CoglOnscreen *onscreen,
> -                                 int64_t       frame_counter);
> +CoglSwapInfo *
> +cogl_onscreen_get_swap_info (CoglOnscreen *onscreen,
> +                             int64_t frame_counter);
>  
>  /**
> - * CoglFrameTimingsCallback:
> + * CoglSwapInfoCallback:
>   * @onscreen: A #CoglOnscreen framebuffer that has updated timing information
>   * @user_data: The private passed to
> - *             cogl_onscreen_add_frame_timings_callback()
> + *             cogl_onscreen_add_swap_info_callback()
>   *
>   * Is a callback type used with the
> - * cogl_onscreen_add_frame_timings_callback() allowing applications to be
> + * cogl_onscreen_add_swap_info_callback() allowing applications to be
>   * notified whenever new frame timings information is available
> - * via cogl_onscreen_get_frame_timings().
> + * via cogl_onscreen_get_swap_info().
>   *
>   * <note>A frame timings callback will only ever be called while dispatching
>   * Cogl events from the system mainloop; so for example during
> @@ -613,17 +613,17 @@ cogl_onscreen_get_frame_timings (CoglOnscreen *onscreen,
>   *
>   * Since: 2.0
>   */
> -typedef void (*CoglFrameTimingsCallback) (CoglOnscreen *onscreen,
> -                                          void         *user_data);
> +typedef void (*CoglSwapInfoCallback) (CoglOnscreen *onscreen,
> +                                      void *user_data);
>  
>  /**
> - * cogl_onscreen_add_frame_timings_callback:
> + * cogl_onscreen_add_swap_info_callback:
>   * @onscreen: A #CoglOnscreen framebuffer
>   * @callback: A callback function to call when new frame timings information is available
>   * @user_data: A private pointer to be passed to @callback
>   *
>   * Installs a @callback function that should be called whenever new data
> - * is available via cogl_onscreen_get_frame_timings().
> + * is available via cogl_onscreen_get_swap_info().
>   *
>   * Return value: a unique identifier that can be used to remove to remove
>   *               the callback later.
> @@ -631,24 +631,24 @@ typedef void (*CoglFrameTimingsCallback) (CoglOnscreen *onscreen,
>   * Stability: unstable
>   */
>  unsigned int
> -cogl_onscreen_add_frame_timings_callback (CoglOnscreen            *onscreen,
> -                                          CoglFrameTimingsCallback callback,
> -                                          void                    *user_data);
> +cogl_onscreen_add_swap_info_callback (CoglOnscreen *onscreen,
> +                                      CoglSwapInfoCallback callback,
> +                                      void *user_data);
>  
>  /**
> - * cogl_onscreen_remove_frame_timings_callback:
> + * cogl_onscreen_remove_swap_info_callback:
>   * @onscreen: A #CoglOnscreen framebuffer
> - * @id: An identifier returned from cogl_onscreen_add_frame_timings_callback()
> + * @id: An identifier returned from cogl_onscreen_add_swap_info_callback()
>   *
>   * Removes a callback that was previously registered
> - * using cogl_onscreen_add_frame_timings_callback().
> + * using cogl_onscreen_add_swap_info_callback().
>   *
>   * Since: 1.10
>   * Stability: unstable
>   */
>  void
> -cogl_onscreen_remove_frame_timings_callback (CoglOnscreen *onscreen,
> -                                             unsigned int  id);
> +cogl_onscreen_remove_swap_info_callback (CoglOnscreen *onscreen,
> +                                         unsigned int id);
>  
>  G_END_DECLS
>  
> diff --git a/cogl/cogl-swap-info-private.h b/cogl/cogl-swap-info-private.h
> new file mode 100644
> index 0000000..8241beb
> --- /dev/null
> +++ b/cogl/cogl-swap-info-private.h
> @@ -0,0 +1,44 @@
> +/*
> + * Cogl
> + *
> + * An object oriented GL/GLES Abstraction/Utility Layer
> + *
> + * Copyright (C) 2012 Red Hat, Inc.
> + *
> + * 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 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/>.
> + *
> + *
> + */
> +
> +#ifndef __COGL_SWAP_INFO_PRIVATE_H
> +#define __COGL_SWAP_INFO_PRIVATE_H
> +
> +#include "cogl-swap-info.h"
> +#include "cogl-object-private.h"
> +
> +struct _CoglSwapInfo
> +{
> +  CoglObject _parent;
> +
> +  int64_t frame_counter;
> +  int64_t frame_time;
> +  int64_t presentation_time;
> +  int64_t refresh_interval;
> +
> +  guint complete : 1;
> +};
> +
> +CoglSwapInfo *_cogl_swap_info_new (void);
> +
> +#endif /* __COGL_SWAP_INFO_PRIVATE_H */
> diff --git a/cogl/cogl-swap-info.c b/cogl/cogl-swap-info.c
> new file mode 100644
> index 0000000..1ee4302
> --- /dev/null
> +++ b/cogl/cogl-swap-info.c
> @@ -0,0 +1,78 @@
> +/*
> + * Cogl
> + *
> + * An object oriented GL/GLES Abstraction/Utility Layer
> + *
> + * Copyright (C) 2012 Red Hat, Inc.
> + *
> + * 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 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/>.
> + *
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include "cogl-swap-info-private.h"
> +
> +static void _cogl_swap_info_free (CoglSwapInfo *info);
> +
> +COGL_OBJECT_DEFINE (SwapInfo, swap_info);
> +
> +CoglSwapInfo *
> +_cogl_swap_info_new (void)
> +{
> +  CoglSwapInfo *info;
> +
> +  info = g_slice_new0 (CoglSwapInfo);
> +
> +  return _cogl_swap_info_object_new (info);
> +}
> +
> +static void
> +_cogl_swap_info_free (CoglSwapInfo *info)
> +{
> +  g_slice_free (CoglSwapInfo, info);
> +}
> +
> +CoglBool
> +cogl_swap_info_get_complete (CoglSwapInfo *info)
> +{
> +  return info->complete;
> +}
> +
> +gint64
> +cogl_swap_info_get_frame_counter (CoglSwapInfo *info)
> +{
> +  return info->frame_counter;
> +}
> +
> +gint64
> +cogl_swap_info_get_frame_time (CoglSwapInfo *info)
> +{
> +  return info->frame_time;
> +}
> +
> +gint64
> +cogl_swap_info_get_presentation_time (CoglSwapInfo *info)
> +{
> +  return info->presentation_time;
> +}
> +
> +gint64
> +cogl_swap_info_get_refresh_interval (CoglSwapInfo *info)
> +{
> +  return info->refresh_interval;
> +}
> diff --git a/cogl/cogl-swap-info.h b/cogl/cogl-swap-info.h
> new file mode 100644
> index 0000000..710d005
> --- /dev/null
> +++ b/cogl/cogl-swap-info.h
> @@ -0,0 +1,133 @@
> +/*
> + * Cogl
> + *
> + * An object oriented GL/GLES Abstraction/Utility Layer
> + *
> + * Copyright (C) 2012 Red Hat, Inc.
> + *
> + * 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 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/>.
> + *
> + *
> + *
> + * Authors:
> + *   Owen Taylor <otaylor at redhat.com>
> + */
> +#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
> +#error "Only <cogl/cogl.h> can be included directly."
> +#endif
> +
> +#ifndef __COGL_SWAP_INFO_H
> +#define __COGL_SWAP_INFO_H
> +
> +#include <cogl/cogl-types.h>
> +#include <glib.h>
> +
> +G_BEGIN_DECLS
> +
> +typedef struct _CoglSwapInfo CoglSwapInfo;
> +#define COGL_SWAP_INFO(X) ((CoglSwapInfo *)(X))
> +
> +/**
> + * cogl_is_swap_info:
> + * @object: A #CoglObject pointer
> + *
> + * Gets whether the given object references a #CoglSwapInfo.
> + *
> + * Return value: %TRUE if the object references a #CoglSwapInfo
> + *   and %FALSE otherwise.
> + * Since: 2.0
> + * Stability: unstable
> + */
> +CoglBool
> +cogl_is_swap_info (void *object);
> +
> +/**
> + * cogl_swap_info_get_complete:
> + * @info: a #CoglSwapInfo object
> + *
> + * Gets whether all information that will potentially be provided for
> + * the frame has been provided. Once a swap info object is complete,
> + * no further changes will be made to it.
> + *
> + * Return value: whether the swap info object is complete.
> + * Since: 2.0
> + * Stability: unstable
> + */
> +CoglBool cogl_swap_info_get_complete (CoglSwapInfo *info);
> +
> +/**
> + * cogl_swap_info_get_frame_counter:
> + * @info: a #CoglSwapInfo object
> + *
> + * Gets the frame counter for the #CoglOnscreen that corresponds
> + * to this frame.
> + *
> + * Return value: The frame counter value
> + * Since: 2.0
> + * Stability: unstable
> + */
> +int64_t cogl_swap_info_get_frame_counter (CoglSwapInfo *info);
> +
> +/**
> + * cogl_swap_info_get_frame_time:
> + * @info: a #CoglSwapInfo object
> + *
> + * Gets the time used for creating content for the frame. This
> + * is determined by the time passed to cogl_onscreen_begin_frame(),
> + * and will typically be the current time when rendering started
> + * for the frame.
> + *
> + * Return value: the time used for coreating content for the frame,
> + *  in the timescale of g_get_monotonic_time().
> + * Since: 2.0
> + * Stability: unstable
> + */
> +int64_t cogl_swap_info_get_frame_time (CoglSwapInfo *info);
> +
> +/**
> + * cogl_swap_info_get_presentation_time:
> + * @info: a #CoglSwapInfo object
> + *
> + * Gets the presentation time for the frame. This is the time at which
> + * the frame became visible to the user.
> + *
> + * Return value: the presentation time for the frame, in
> + *  the timescale of g_get_monotonic_time().
> + * Since: 2.0
> + * Stability: unstable
> + */
> +int64_t cogl_swap_info_get_presentation_time (CoglSwapInfo *info);
> +
> +/**
> + * cogl_swap_info_get_refresh_interval:
> + * @info: a #CoglSwapInfo object
> + *
> + * Gets the refresh interval for the output that the frame was on at the
> + * time the frame was presented. This is the number of microseconds between
> + * refreshes of the screen, and is equal to 1000000 / refresh_rate.
> + *
> + * Return value: the refresh interval, in microsecoonds.
> + *  .
> + * Since: 2.0
> + * Stability: unstable
> + */
> +int64_t cogl_swap_info_get_refresh_interval (CoglSwapInfo *info);
> +
> +G_END_DECLS
> +
> +#endif /* __COGL_SWAP_INFO_H */
> +
> +
> +
> diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
> index 636a744..875239d 100644
> --- a/cogl/winsys/cogl-winsys-glx.c
> +++ b/cogl/winsys/cogl-winsys-glx.c
> @@ -42,7 +42,7 @@
>  #include "cogl-texture-2d-private.h"
>  #include "cogl-texture-rectangle-private.h"
>  #include "cogl-pipeline-opengl-private.h"
> -#include "cogl-frame-timings-private.h"
> +#include "cogl-swap-info-private.h"
>  #include "cogl-framebuffer-private.h"
>  #include "cogl-onscreen-private.h"
>  #include "cogl-swap-chain-private.h"
> @@ -85,7 +85,7 @@ typedef struct _CoglOnscreenGLX
>    uint32_t last_swap_vsync_counter;
>    CoglBool pending_swap_notify;
>    CoglBool pending_resize_notify;
> -  CoglBool pending_frame_timings_notify;
> +  CoglBool pending_swap_info_notify;
>  } CoglOnscreenGLX;
>  
>  typedef struct _CoglTexturePixmapGLX
> @@ -273,18 +273,18 @@ ust_to_monotonic_time (CoglRenderer *renderer,
>  }
>  
>  static void
> -set_timings_complete (CoglOnscreen *onscreen)
> +set_info_complete (CoglOnscreen *onscreen)
>  {
>    CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
>    CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
>    CoglGLXDisplay *glx_display = context->display->winsys;
> -  CoglFrameTimings *timings = cogl_onscreen_get_frame_timings (onscreen,
> -                                                               cogl_onscreen_get_frame_counter (onscreen));
> +  int frame_counter = cogl_onscreen_get_frame_counter (onscreen);
> +  CoglSwapInfo *info = cogl_onscreen_get_swap_info (onscreen, frame_counter);
>  
> -  timings->complete = TRUE;
> +  info->complete = TRUE;
>  
> -  glx_display->pending_frame_timings_notify = TRUE;
> -  glx_onscreen->pending_frame_timings_notify = TRUE;
> +  glx_display->pending_swap_info_notify = TRUE;
> +  glx_onscreen->pending_swap_info_notify = TRUE;
>  }
>  
>  static void
> @@ -294,7 +294,8 @@ notify_swap_buffers (CoglContext *context, GLXBufferSwapComplete *swap_event)
>    CoglDisplay *display = context->display;
>    CoglGLXDisplay *glx_display = display->winsys;
>    CoglOnscreenGLX *glx_onscreen;
> -  CoglFrameTimings *timings;
> +  int frame_counter;
> +  CoglSwapInfo *info;
>  
>    if (!onscreen)
>      return;
> @@ -306,14 +307,14 @@ notify_swap_buffers (CoglContext *context, GLXBufferSwapComplete *swap_event)
>    glx_display->pending_swap_notify = TRUE;
>    glx_onscreen->pending_swap_notify = TRUE;
>  
> -  timings = cogl_onscreen_get_frame_timings (onscreen,
> -                                             cogl_onscreen_get_frame_counter (onscreen));
> +  frame_counter = cogl_onscreen_get_frame_counter (onscreen);
> +  info = cogl_onscreen_get_swap_info (onscreen, frame_counter);
>    if (swap_event->ust != 0)
> -    timings->presentation_time = ust_to_monotonic_time (context->display->renderer,
> +    info->presentation_time = ust_to_monotonic_time (context->display->renderer,
>                                                          glx_onscreen->glxwin,
>                                                          swap_event->ust);
>  
> -  set_timings_complete (onscreen);
> +  set_info_complete (onscreen);
>  }
>  
>  static void
> @@ -1373,10 +1374,11 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
>    if (glx_renderer->pf_glXWaitForMsc ||
>        glx_renderer->pf_glXGetVideoSync)
>      {
> -      CoglFrameTimings *timings;
> +      int frame_counter;
> +      CoglSwapInfo *info;
>  
> -      timings = cogl_onscreen_get_frame_timings (onscreen,
> -                                                 cogl_onscreen_get_frame_counter (onscreen));
> +      frame_counter = cogl_onscreen_get_frame_counter (onscreen);
> +      info = cogl_onscreen_get_swap_info (onscreen, frame_counter);
>  
>        if (glx_renderer->pf_glXWaitForMsc)
>          {
> @@ -1391,7 +1393,7 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
>            glx_renderer->pf_glXWaitForMsc (xlib_renderer->xdpy, drawable,
>                                            0, 2, (msc + 1) % 2,
>                                            &ust, &msc, &sbc);
> -          timings->presentation_time = ust_to_monotonic_time (ctx->display->renderer,
> +          info->presentation_time = ust_to_monotonic_time (ctx->display->renderer,
>                                                                drawable,
>                                                                ust);
>          }
> @@ -1403,7 +1405,7 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
>            glx_renderer->pf_glXWaitVideoSync (2,
>                                               (current_count + 1) % 2,
>                                               &current_count);
> -          timings->presentation_time = g_get_monotonic_time ();
> +          info->presentation_time = g_get_monotonic_time ();
>          }
>      }
>  }
> @@ -1430,9 +1432,10 @@ set_refresh_interval_from_output (CoglOnscreen *onscreen,
>    float refresh_rate = cogl_output_get_refresh_rate (output);
>    if (refresh_rate != 0.0)
>      {
> -      CoglFrameTimings *timings = cogl_onscreen_get_frame_timings (onscreen,
> -                                                                   cogl_onscreen_get_frame_counter (onscreen));
> -      timings->refresh_interval = (int)(0.5 + (1000000. / refresh_rate));
> +      int frame_counter = cogl_onscreen_get_frame_counter (onscreen);
> +      CoglSwapInfo *info = cogl_onscreen_get_swap_info (onscreen, frame_counter);
> +
> +      info->refresh_interval = (int)(0.5 + (1000000. / refresh_rate));
>      }
>  }
>  
> @@ -1627,7 +1630,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
>          set_refresh_interval_from_output (onscreen, output);
>      }
>  
> -  set_timings_complete (onscreen);
> +  set_info_complete (onscreen);
>  }
>  
>  static void
> @@ -1712,7 +1715,7 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
>  
>    if (!(glx_renderer->pf_glXSwapInterval &&
>          _cogl_winsys_has_feature (COGL_WINSYS_FEATURE_VBLANK_WAIT)))
> -    set_timings_complete (onscreen);
> +    set_info_complete (onscreen);
>  }
>  
>  static uint32_t
> @@ -2386,7 +2389,7 @@ _cogl_winsys_poll_get_info (CoglContext *context,
>       immediately */
>    if (glx_display->pending_swap_notify ||
>        glx_display->pending_resize_notify ||
> -      glx_display->pending_frame_timings_notify)
> +      glx_display->pending_swap_info_notify)
>      *timeout = 0;
>  }
>  
> @@ -2413,10 +2416,10 @@ flush_pending_notifications_cb (void *data,
>            glx_onscreen->pending_resize_notify = FALSE;
>          }
>  
> -      if (glx_onscreen->pending_frame_timings_notify)
> +      if (glx_onscreen->pending_swap_info_notify)
>          {
> -          _cogl_onscreen_notify_frame_timings (onscreen);
> -          glx_onscreen->pending_frame_timings_notify = FALSE;
> +          _cogl_onscreen_notify_swap_info (onscreen);
> +          glx_onscreen->pending_swap_info_notify = FALSE;
>          }
>      }
>  }
> @@ -2435,14 +2438,14 @@ _cogl_winsys_poll_dispatch (CoglContext *context,
>  
>    if (glx_display->pending_swap_notify ||
>        glx_display->pending_resize_notify ||
> -      glx_display->pending_frame_timings_notify)
> +      glx_display->pending_swap_info_notify)
>      {
>        g_list_foreach (context->framebuffers,
>                        flush_pending_notifications_cb,
>                        NULL);
>        glx_display->pending_swap_notify = FALSE;
>        glx_display->pending_resize_notify = FALSE;
> -      glx_display->pending_frame_timings_notify = FALSE;
> +      glx_display->pending_swap_info_notify = FALSE;
>      }
>  }
>  




More information about the Cogl mailing list