mirror of
https://github.com/brl/mutter.git
synced 2024-11-28 02:50:41 -05:00
14c706e51b
Currently, Clutter does picking by drawing with Cogl and reading the pixel that's beneath the given point. Since Cogl has a journal that records drawing operations, and has optimizations to read a single pixel from a list of rectangle, it would be expected that we would hit this fast path and not flush the journal while picking. However, that's not the case: dithering, clipping with scissors, etc, can all flush the journal, issuing commands to the GPU and making picking slow. On NVidia-based systems, this glReadPixels() call is extremely costly. Introduce geometric picking, and avoid using the Cogl journal entirely. Do this by introducing a stack of actors in ClutterStage. This stack is cached, but for now, don't use the cache as much as possible. The picking routines are still tied to painting. When projecting the actor vertexes, do it manually and take the modelview matrix of the framebuffer into account as well. CPU usage on an Intel i7-7700, tested with two different GPUs/drivers: | | Intel | Nvidia | | ------: | --------: | -----: | | Moving the mouse: | | Before | 10% | 10% | | After | 6% | 6% | | Moving a window: | | Before | 23% | 81% | | After | 19% | 40% | Closes: https://gitlab.gnome.org/GNOME/mutter/issues/154, https://gitlab.gnome.org/GNOME/mutter/issues/691 Helps significantly with: https://gitlab.gnome.org/GNOME/mutter/issues/283, https://gitlab.gnome.org/GNOME/mutter/issues/590, https://gitlab.gnome.org/GNOME/mutter/issues/700 v2: Fix code style issues Simplify quadrilateral checks Remove the 0.5f hack Differentiate axis-aligned rectangles https://gitlab.gnome.org/GNOME/mutter/merge_requests/189
92 lines
3.2 KiB
C
92 lines
3.2 KiB
C
#ifndef __CLUTTER_DEBUG_H__
|
|
#define __CLUTTER_DEBUG_H__
|
|
|
|
#include <glib.h>
|
|
#include "clutter-main.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
typedef enum
|
|
{
|
|
CLUTTER_DEBUG_MISC = 1 << 0,
|
|
CLUTTER_DEBUG_ACTOR = 1 << 1,
|
|
CLUTTER_DEBUG_TEXTURE = 1 << 2,
|
|
CLUTTER_DEBUG_EVENT = 1 << 3,
|
|
CLUTTER_DEBUG_PAINT = 1 << 4,
|
|
CLUTTER_DEBUG_PANGO = 1 << 5,
|
|
CLUTTER_DEBUG_BACKEND = 1 << 6,
|
|
CLUTTER_DEBUG_SCHEDULER = 1 << 7,
|
|
CLUTTER_DEBUG_SCRIPT = 1 << 8,
|
|
CLUTTER_DEBUG_SHADER = 1 << 9,
|
|
CLUTTER_DEBUG_MULTISTAGE = 1 << 10,
|
|
CLUTTER_DEBUG_ANIMATION = 1 << 11,
|
|
CLUTTER_DEBUG_LAYOUT = 1 << 12,
|
|
CLUTTER_DEBUG_PICK = 1 << 13,
|
|
CLUTTER_DEBUG_EVENTLOOP = 1 << 14,
|
|
CLUTTER_DEBUG_CLIPPING = 1 << 15,
|
|
CLUTTER_DEBUG_OOB_TRANSFORMS = 1 << 16
|
|
} ClutterDebugFlag;
|
|
|
|
typedef enum
|
|
{
|
|
CLUTTER_DEBUG_NOP_PICKING = 1 << 0,
|
|
} ClutterPickDebugFlag;
|
|
|
|
typedef enum
|
|
{
|
|
CLUTTER_DEBUG_DISABLE_SWAP_EVENTS = 1 << 0,
|
|
CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS = 1 << 1,
|
|
CLUTTER_DEBUG_REDRAWS = 1 << 2,
|
|
CLUTTER_DEBUG_PAINT_VOLUMES = 1 << 3,
|
|
CLUTTER_DEBUG_DISABLE_CULLING = 1 << 4,
|
|
CLUTTER_DEBUG_DISABLE_OFFSCREEN_REDIRECT = 1 << 5,
|
|
CLUTTER_DEBUG_CONTINUOUS_REDRAW = 1 << 6,
|
|
CLUTTER_DEBUG_PAINT_DEFORM_TILES = 1 << 7,
|
|
CLUTTER_DEBUG_PAINT_DAMAGE_REGION = 1 << 8,
|
|
} ClutterDrawDebugFlag;
|
|
|
|
#ifdef CLUTTER_ENABLE_DEBUG
|
|
|
|
#define CLUTTER_HAS_DEBUG(type) ((clutter_debug_flags & CLUTTER_DEBUG_##type) != FALSE)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
/* Try the GCC extension for valists in macros */
|
|
#define CLUTTER_NOTE(type,x,a...) G_STMT_START { \
|
|
if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \
|
|
_clutter_debug_message ("[" #type "]:" G_STRLOC ": " x, ##a); \
|
|
} } G_STMT_END
|
|
|
|
#else /* !__GNUC__ */
|
|
/* Try the C99 version; unfortunately, this does not allow us to pass
|
|
* empty arguments to the macro, which means we have to
|
|
* do an intemediate printf.
|
|
*/
|
|
#define CLUTTER_NOTE(type,...) G_STMT_START { \
|
|
if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \
|
|
gchar *_fmt = g_strdup_printf (__VA_ARGS__); \
|
|
_clutter_debug_message ("[" #type "]:" G_STRLOC ": %s", _fmt); \
|
|
g_free (_fmt); \
|
|
} } G_STMT_END
|
|
#endif
|
|
|
|
#else /* !CLUTTER_ENABLE_DEBUG */
|
|
|
|
#define CLUTTER_NOTE(type,...) G_STMT_START { } G_STMT_END
|
|
#define CLUTTER_HAS_DEBUG(type) FALSE
|
|
|
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
|
|
|
extern guint clutter_debug_flags;
|
|
extern guint clutter_pick_debug_flags;
|
|
extern guint clutter_paint_debug_flags;
|
|
|
|
void _clutter_debug_messagev (const char *format,
|
|
va_list var_args) G_GNUC_PRINTF (1, 0);
|
|
void _clutter_debug_message (const char *format,
|
|
...) G_GNUC_PRINTF (1, 2);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __CLUTTER_DEBUG_H__ */
|