Port to MtkRegion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
This commit is contained in:
Bilal Elmoussaoui 2023-09-04 16:30:38 +02:00 committed by Marge Bot
parent 7c98910488
commit 655b4a9c75
76 changed files with 928 additions and 1054 deletions

View File

@ -24,7 +24,7 @@
struct _ClutterDamageHistory
{
cairo_region_t *damages[DAMAGE_HISTORY_LENGTH];
MtkRegion *damages[DAMAGE_HISTORY_LENGTH];
int index;
};
@ -44,7 +44,7 @@ clutter_damage_history_free (ClutterDamageHistory *history)
int i;
for (i = 0; i < G_N_ELEMENTS (history->damages); i++)
g_clear_pointer (&history->damages[i], cairo_region_destroy);
g_clear_pointer (&history->damages[i], mtk_region_unref);
g_free (history);
}
@ -65,10 +65,10 @@ clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
void
clutter_damage_history_record (ClutterDamageHistory *history,
const cairo_region_t *damage)
const MtkRegion *damage)
{
g_clear_pointer (&history->damages[history->index], cairo_region_destroy);
history->damages[history->index] = cairo_region_copy (damage);
g_clear_pointer (&history->damages[history->index], mtk_region_unref);
history->damages[history->index] = mtk_region_copy (damage);
}
static inline int
@ -84,7 +84,7 @@ clutter_damage_history_step (ClutterDamageHistory *history)
history->index = step_damage_index (history->index, 1);
}
const cairo_region_t *
const MtkRegion *
clutter_damage_history_lookup (ClutterDamageHistory *history,
int age)
{

View File

@ -18,10 +18,10 @@
#pragma once
#include <cairo.h>
#include <glib.h>
#include "clutter/clutter-macros.h"
#include "mtk/mtk.h"
typedef struct _ClutterDamageHistory ClutterDamageHistory;
@ -37,11 +37,11 @@ gboolean clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
CLUTTER_EXPORT
void clutter_damage_history_record (ClutterDamageHistory *history,
const cairo_region_t *damage);
const MtkRegion *damage);
CLUTTER_EXPORT
void clutter_damage_history_step (ClutterDamageHistory *history);
CLUTTER_EXPORT
const cairo_region_t * clutter_damage_history_lookup (ClutterDamageHistory *history,
const MtkRegion * clutter_damage_history_lookup (ClutterDamageHistory *history,
int age);

View File

@ -115,7 +115,7 @@ void clutter_stage_update_device (ClutterStage *stage,
graphene_point_t point,
uint32_t time,
ClutterActor *new_actor,
cairo_region_t *region,
MtkRegion *region,
gboolean emit_crossing);
CLUTTER_EXPORT

View File

@ -21,7 +21,7 @@
ClutterPaintContext *
clutter_paint_context_new_for_view (ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
GArray *clip_frusta,
ClutterPaintFlag paint_flags);

View File

@ -31,7 +31,7 @@ struct _ClutterPaintContext
ClutterStageView *view;
ClutterFrame *frame;
cairo_region_t *redraw_clip;
MtkRegion *redraw_clip;
GArray *clip_frusta;
};
@ -41,7 +41,7 @@ G_DEFINE_BOXED_TYPE (ClutterPaintContext, clutter_paint_context,
ClutterPaintContext *
clutter_paint_context_new_for_view (ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
GArray *clip_frusta,
ClutterPaintFlag paint_flags)
{
@ -51,7 +51,7 @@ clutter_paint_context_new_for_view (ClutterStageView *view,
paint_context = g_new0 (ClutterPaintContext, 1);
g_ref_count_init (&paint_context->ref_count);
paint_context->view = view;
paint_context->redraw_clip = cairo_region_copy (redraw_clip);
paint_context->redraw_clip = mtk_region_copy (redraw_clip);
paint_context->clip_frusta = g_array_ref (clip_frusta);
paint_context->paint_flags = paint_flags;
@ -66,14 +66,14 @@ clutter_paint_context_new_for_view (ClutterStageView *view,
*/
ClutterPaintContext *
clutter_paint_context_new_for_framebuffer (CoglFramebuffer *framebuffer,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterPaintFlag paint_flags)
{
ClutterPaintContext *paint_context;
paint_context = g_new0 (ClutterPaintContext, 1);
g_ref_count_init (&paint_context->ref_count);
paint_context->redraw_clip = cairo_region_copy (redraw_clip);
paint_context->redraw_clip = mtk_region_copy (redraw_clip);
paint_context->paint_flags = paint_flags;
clutter_paint_context_push_framebuffer (paint_context, framebuffer);
@ -93,7 +93,7 @@ clutter_paint_context_dispose (ClutterPaintContext *paint_context)
{
g_list_free_full (paint_context->framebuffers, g_object_unref);
paint_context->framebuffers = NULL;
g_clear_pointer (&paint_context->redraw_clip, cairo_region_destroy);
g_clear_pointer (&paint_context->redraw_clip, mtk_region_unref);
g_clear_pointer (&paint_context->clip_frusta, g_array_unref);
g_clear_pointer (&paint_context->frame, clutter_frame_unref);
}
@ -134,7 +134,7 @@ clutter_paint_context_pop_framebuffer (ClutterPaintContext *paint_context)
paint_context->framebuffers);
}
const cairo_region_t *
const MtkRegion *
clutter_paint_context_get_redraw_clip (ClutterPaintContext *paint_context)
{
return paint_context->redraw_clip;

View File

@ -43,7 +43,7 @@ GType clutter_paint_context_get_type (void);
CLUTTER_EXPORT
ClutterPaintContext * clutter_paint_context_new_for_framebuffer (CoglFramebuffer *framebuffer,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterPaintFlag paint_flags);
CLUTTER_EXPORT
@ -69,7 +69,7 @@ CLUTTER_EXPORT
void clutter_paint_context_pop_framebuffer (ClutterPaintContext *paint_context);
CLUTTER_EXPORT
const cairo_region_t * clutter_paint_context_get_redraw_clip (ClutterPaintContext *paint_context);
const MtkRegion * clutter_paint_context_get_redraw_clip (ClutterPaintContext *paint_context);
CLUTTER_EXPORT
ClutterPaintFlag clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context);

View File

@ -61,7 +61,7 @@ ClutterActor *
clutter_pick_stack_search_actor (ClutterPickStack *pick_stack,
const graphene_point3d_t *point,
const graphene_ray_t *ray,
cairo_region_t **clear_area);
MtkRegion **clear_area);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPickStack, clutter_pick_stack_unref)

View File

@ -455,9 +455,9 @@ static void
calculate_clear_area (ClutterPickStack *pick_stack,
PickRecord *pick_rec,
int elem,
cairo_region_t **clear_area)
MtkRegion **clear_area)
{
cairo_region_t *area = NULL;
MtkRegion *area = NULL;
graphene_point3d_t verts[4];
MtkRectangle rect;
int i;
@ -478,7 +478,7 @@ calculate_clear_area (ClutterPickStack *pick_stack,
rect.height =
MIN (rect.height, floor (pick_rec->base.rect.y2 - pick_rec->base.rect.y1));
area = cairo_region_create_rectangle (&rect);
area = mtk_region_create_rectangle (&rect);
for (i = elem + 1; i < pick_stack->vertices_stack->len; i++)
{
@ -494,26 +494,24 @@ calculate_clear_area (ClutterPickStack *pick_stack,
if (!clutter_actor_get_paint_box (rec->actor, &paint_box))
continue;
cairo_region_subtract_rectangle (area,
&(MtkRectangle) {
.x = paint_box.x1,
.y = paint_box.y1,
.width = paint_box.x2 - paint_box.x1,
.height = paint_box.y2 - paint_box.y1,
});
mtk_region_subtract_rectangle (area,
&MTK_RECTANGLE_INIT (paint_box.x1, paint_box.y1,
paint_box.x2 - paint_box.x1,
paint_box.y2 - paint_box.y1)
);
}
if (clear_area)
*clear_area = g_steal_pointer (&area);
g_clear_pointer (&area, cairo_region_destroy);
g_clear_pointer (&area, mtk_region_unref);
}
ClutterActor *
clutter_pick_stack_search_actor (ClutterPickStack *pick_stack,
const graphene_point3d_t *point,
const graphene_ray_t *ray,
cairo_region_t **clear_area)
MtkRegion **clear_area)
{
int i;

View File

@ -44,7 +44,7 @@ typedef enum
CLUTTER_EXPORT
void clutter_stage_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame);
void clutter_stage_emit_before_update (ClutterStage *stage,
@ -122,7 +122,7 @@ void clutter_stage_update_device_entry (ClutterStage *self,
ClutterEventSequence *sequence,
graphene_point_t coords,
ClutterActor *actor,
cairo_region_t *clear_area);
MtkRegion *clear_area);
void clutter_stage_remove_device_entry (ClutterStage *self,
ClutterInputDevice *device,

View File

@ -23,11 +23,11 @@
CLUTTER_EXPORT
void clutter_stage_view_after_paint (ClutterStageView *view,
cairo_region_t *redraw_clip);
MtkRegion *redraw_clip);
CLUTTER_EXPORT
void clutter_stage_view_before_swap_buffer (ClutterStageView *view,
const cairo_region_t *swap_region);
const MtkRegion *swap_region);
gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);
@ -54,13 +54,13 @@ gboolean clutter_stage_view_has_full_redraw_clip (ClutterStageView *view);
gboolean clutter_stage_view_has_redraw_clip (ClutterStageView *view);
const cairo_region_t * clutter_stage_view_peek_redraw_clip (ClutterStageView *view);
const MtkRegion * clutter_stage_view_peek_redraw_clip (ClutterStageView *view);
CLUTTER_EXPORT
cairo_region_t * clutter_stage_view_take_redraw_clip (ClutterStageView *view);
MtkRegion * clutter_stage_view_take_redraw_clip (ClutterStageView *view);
CLUTTER_EXPORT
cairo_region_t * clutter_stage_view_take_accumulated_redraw_clip (ClutterStageView *view);
MtkRegion * clutter_stage_view_take_accumulated_redraw_clip (ClutterStageView *view);
CLUTTER_EXPORT
void clutter_stage_view_accumulate_redraw_clip (ClutterStageView *view);

View File

@ -84,9 +84,9 @@ typedef struct _ClutterStageViewPrivate
CoglScanout *next_scanout;
gboolean has_redraw_clip;
cairo_region_t *redraw_clip;
MtkRegion *redraw_clip;
gboolean has_accumulated_redraw_clip;
cairo_region_t *accumulated_redraw_clip;
MtkRegion *accumulated_redraw_clip;
float refresh_rate;
int64_t vblank_duration_us;
@ -232,7 +232,7 @@ paint_transformed_framebuffer (ClutterStageView *view,
CoglPipeline *pipeline,
CoglOffscreen *src_framebuffer,
CoglFramebuffer *dst_framebuffer,
const cairo_region_t *redraw_clip)
const MtkRegion *redraw_clip)
{
graphene_matrix_t matrix;
unsigned int n_rectangles, i;
@ -246,10 +246,8 @@ paint_transformed_framebuffer (ClutterStageView *view,
dst_height = cogl_framebuffer_get_height (dst_framebuffer);
clutter_stage_view_get_layout (view, &view_layout);
clutter_stage_view_transform_rect_to_onscreen (view,
&(MtkRectangle) {
.width = view_layout.width,
.height = view_layout.height,
},
&MTK_RECTANGLE_INIT (0, 0,
view_layout.width, view_layout.height),
view_layout.width,
view_layout.height,
&onscreen_layout);
@ -269,7 +267,7 @@ paint_transformed_framebuffer (ClutterStageView *view,
cogl_framebuffer_set_viewport (dst_framebuffer,
0, 0, dst_width, dst_height);
n_rectangles = cairo_region_num_rectangles (redraw_clip);
n_rectangles = mtk_region_num_rectangles (redraw_clip);
coordinates = g_newa (float, 2 * 4 * n_rectangles);
for (i = 0; i < n_rectangles; i++)
@ -277,7 +275,7 @@ paint_transformed_framebuffer (ClutterStageView *view,
MtkRectangle src_rect;
MtkRectangle dst_rect;
cairo_region_get_rectangle (redraw_clip, i, &src_rect);
src_rect = mtk_region_get_rectangle (redraw_clip, i);
src_rect.x -= view_layout.x;
src_rect.y -= view_layout.y;
@ -463,7 +461,7 @@ init_shadowfb (ClutterStageView *view)
void
clutter_stage_view_after_paint (ClutterStageView *view,
cairo_region_t *redraw_clip)
MtkRegion *redraw_clip)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
@ -520,14 +518,14 @@ flip_dma_buf_idx (int idx)
return (idx + 1) % 2;
}
static cairo_region_t *
static MtkRegion *
find_damaged_tiles (ClutterStageView *view,
const cairo_region_t *damage_region,
const MtkRegion *damage_region,
GError **error)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
cairo_region_t *tile_damage_region;
MtkRegion *tile_damage_region;
MtkRectangle damage_extents;
MtkRectangle fb_rect;
int prev_dma_buf_idx;
@ -573,7 +571,7 @@ find_damaged_tiles (ClutterStageView *view,
.height = height,
};
cairo_region_get_extents (damage_region, &damage_extents);
damage_extents = mtk_region_get_extents (damage_region);
tile_x_min = damage_extents.x / tile_size;
tile_x_max = ((damage_extents.x + damage_extents.width + tile_size - 1) /
@ -582,7 +580,7 @@ find_damaged_tiles (ClutterStageView *view,
tile_y_max = ((damage_extents.y + damage_extents.height + tile_size - 1) /
tile_size);
tile_damage_region = cairo_region_create ();
tile_damage_region = mtk_region_create ();
for (tile_y = tile_y_min; tile_y <= tile_y_max; tile_y++)
{
@ -595,14 +593,14 @@ find_damaged_tiles (ClutterStageView *view,
.height = tile_size,
};
if (cairo_region_contains_rectangle (damage_region, &tile) ==
CAIRO_REGION_OVERLAP_OUT)
if (mtk_region_contains_rectangle (damage_region, &tile) ==
MTK_REGION_OVERLAP_OUT)
continue;
mtk_rectangle_intersect (&tile, &fb_rect, &tile);
if (is_tile_dirty (&tile, current_data, prev_data, bpp, stride))
cairo_region_union_rectangle (tile_damage_region, &tile);
mtk_region_union_rectangle (tile_damage_region, &tile);
}
}
@ -623,7 +621,7 @@ find_damaged_tiles (ClutterStageView *view,
cogl_dma_buf_handle_munmap (prev_dma_buf_handle, prev_data, NULL);
cogl_dma_buf_handle_munmap (current_dma_buf_handle, current_data, NULL);
cairo_region_intersect (tile_damage_region, damage_region);
mtk_region_intersect (tile_damage_region, damage_region);
return tile_damage_region;
@ -661,32 +659,32 @@ swap_dma_buf_framebuffer (ClutterStageView *view)
static void
copy_shadowfb_to_onscreen (ClutterStageView *view,
const cairo_region_t *swap_region)
const MtkRegion *swap_region)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
ClutterDamageHistory *damage_history = priv->shadow.dma_buf.damage_history;
cairo_region_t *damage_region;
g_autoptr (MtkRegion) damage_region = NULL;
int age;
int i;
if (cairo_region_is_empty (swap_region))
if (mtk_region_is_empty (swap_region))
{
MtkRectangle full_damage = {
.width = cogl_framebuffer_get_width (priv->framebuffer),
.height = cogl_framebuffer_get_height (priv->framebuffer),
};
damage_region = cairo_region_create_rectangle (&full_damage);
damage_region = mtk_region_create_rectangle (&full_damage);
}
else
{
damage_region = cairo_region_copy (swap_region);
damage_region = mtk_region_copy (swap_region);
}
if (is_shadowfb_double_buffered (view))
{
CoglOnscreen *onscreen = COGL_ONSCREEN (priv->framebuffer);
cairo_region_t *changed_region;
g_autoptr (MtkRegion) changed_region = NULL;
if (cogl_onscreen_get_frame_counter (onscreen) >= 1)
{
@ -708,7 +706,7 @@ copy_shadowfb_to_onscreen (ClutterStageView *view,
}
else
{
changed_region = cairo_region_copy (damage_region);
changed_region = mtk_region_copy (damage_region);
}
if (changed_region)
@ -722,31 +720,27 @@ copy_shadowfb_to_onscreen (ClutterStageView *view,
{
for (age = 1; age <= buffer_age; age++)
{
const cairo_region_t *old_damage;
const MtkRegion *old_damage;
old_damage = clutter_damage_history_lookup (damage_history, age);
cairo_region_union (changed_region, old_damage);
mtk_region_union (changed_region, old_damage);
}
cairo_region_destroy (damage_region);
g_clear_pointer (&damage_region, mtk_region_unref);
damage_region = g_steal_pointer (&changed_region);
}
else
{
cairo_region_destroy (changed_region);
}
clutter_damage_history_step (damage_history);
}
}
for (i = 0; i < cairo_region_num_rectangles (damage_region); i++)
for (i = 0; i < mtk_region_num_rectangles (damage_region); i++)
{
CoglFramebuffer *shadowfb = COGL_FRAMEBUFFER (priv->shadow.framebuffer);
g_autoptr (GError) error = NULL;
MtkRectangle rect;
cairo_region_get_rectangle (damage_region, i, &rect);
rect = mtk_region_get_rectangle (damage_region, i);
if (!cogl_blit_framebuffer (shadowfb,
priv->framebuffer,
@ -756,20 +750,17 @@ copy_shadowfb_to_onscreen (ClutterStageView *view,
&error))
{
g_warning ("Failed to blit shadow buffer: %s", error->message);
cairo_region_destroy (damage_region);
return;
}
}
cairo_region_destroy (damage_region);
if (is_shadowfb_double_buffered (view))
swap_dma_buf_framebuffer (view);
}
void
clutter_stage_view_before_swap_buffer (ClutterStageView *view,
const cairo_region_t *swap_region)
const MtkRegion *swap_region)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
@ -930,18 +921,18 @@ clutter_stage_view_get_offscreen_transformation_matrix (ClutterStageView *view,
static void
maybe_mark_full_redraw (ClutterStageView *view,
cairo_region_t **region)
MtkRegion **region)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
if (cairo_region_num_rectangles (*region) == 1)
if (mtk_region_num_rectangles (*region) == 1)
{
MtkRectangle region_extents;
cairo_region_get_extents (*region, &region_extents);
region_extents = mtk_region_get_extents (*region);
if (mtk_rectangle_equal (&priv->layout, &region_extents))
g_clear_pointer (region, cairo_region_destroy);
g_clear_pointer (region, mtk_region_unref);
}
}
@ -957,7 +948,7 @@ clutter_stage_view_add_redraw_clip (ClutterStageView *view,
if (!clip)
{
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->redraw_clip, mtk_region_unref);
priv->has_redraw_clip = TRUE;
return;
}
@ -968,11 +959,11 @@ clutter_stage_view_add_redraw_clip (ClutterStageView *view,
if (!priv->redraw_clip)
{
if (!mtk_rectangle_equal (&priv->layout, clip))
priv->redraw_clip = cairo_region_create_rectangle (clip);
priv->redraw_clip = mtk_region_create_rectangle (clip);
}
else
{
cairo_region_union_rectangle (priv->redraw_clip, clip);
mtk_region_union_rectangle (priv->redraw_clip, clip);
maybe_mark_full_redraw (view, &priv->redraw_clip);
}
@ -997,7 +988,7 @@ clutter_stage_view_has_full_redraw_clip (ClutterStageView *view)
return priv->has_redraw_clip && !priv->redraw_clip;
}
const cairo_region_t *
const MtkRegion *
clutter_stage_view_peek_redraw_clip (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
@ -1006,7 +997,7 @@ clutter_stage_view_peek_redraw_clip (ClutterStageView *view)
return priv->redraw_clip;
}
cairo_region_t *
MtkRegion *
clutter_stage_view_take_redraw_clip (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
@ -1017,7 +1008,7 @@ clutter_stage_view_take_redraw_clip (ClutterStageView *view)
return g_steal_pointer (&priv->redraw_clip);
}
cairo_region_t *
MtkRegion *
clutter_stage_view_take_accumulated_redraw_clip (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
@ -1041,7 +1032,7 @@ clutter_stage_view_accumulate_redraw_clip (ClutterStageView *view)
if (priv->redraw_clip && priv->accumulated_redraw_clip)
{
cairo_region_union (priv->accumulated_redraw_clip, priv->redraw_clip);
mtk_region_union (priv->accumulated_redraw_clip, priv->redraw_clip);
maybe_mark_full_redraw (view, &priv->accumulated_redraw_clip);
}
else if (priv->redraw_clip && !priv->has_accumulated_redraw_clip)
@ -1050,10 +1041,10 @@ clutter_stage_view_accumulate_redraw_clip (ClutterStageView *view)
}
else
{
g_clear_pointer (&priv->accumulated_redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->accumulated_redraw_clip, mtk_region_unref);
}
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->redraw_clip, mtk_region_unref);
priv->has_accumulated_redraw_clip = TRUE;
priv->has_redraw_clip = FALSE;
}
@ -1486,8 +1477,8 @@ clutter_stage_view_dispose (GObject *object)
g_clear_object (&priv->offscreen);
g_clear_object (&priv->offscreen_pipeline);
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->accumulated_redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->redraw_clip, mtk_region_unref);
g_clear_pointer (&priv->accumulated_redraw_clip, mtk_region_unref);
g_clear_pointer (&priv->frame_clock, clutter_frame_clock_destroy);
G_OBJECT_CLASS (clutter_stage_view_parent_class)->dispose (object);

View File

@ -38,7 +38,6 @@
#include "clutter/clutter-build-config.h"
#include <math.h>
#include <cairo-gobject.h>
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
@ -102,7 +101,7 @@ typedef struct _PointerDeviceEntry
ClutterEventSequence *sequence;
graphene_point_t coords;
ClutterActor *current_actor;
cairo_region_t *clear_area;
MtkRegion *clear_area;
unsigned int press_count;
ClutterActor *implicit_grab_actor;
@ -403,7 +402,7 @@ static void
clutter_stage_do_paint_view (ClutterStage *stage,
ClutterStageView *view,
ClutterFrame *frame,
const cairo_region_t *redraw_clip)
const MtkRegion *redraw_clip)
{
ClutterPaintContext *paint_context;
MtkRectangle clip_rect;
@ -415,7 +414,7 @@ clutter_stage_do_paint_view (ClutterStage *stage,
int n_rectangles;
ClutterPaintFlag paint_flags;
n_rectangles = redraw_clip ? cairo_region_num_rectangles (redraw_clip) : 0;
n_rectangles = redraw_clip ? mtk_region_num_rectangles (redraw_clip) : 0;
if (redraw_clip && n_rectangles < MAX_FRUSTA)
{
int i;
@ -426,7 +425,7 @@ clutter_stage_do_paint_view (ClutterStage *stage,
for (i = 0; i < n_rectangles; i++)
{
cairo_region_get_rectangle (redraw_clip, i, &clip_rect);
clip_rect = mtk_region_get_rectangle (redraw_clip, i);
setup_clip_frustum (stage, &clip_rect, &clip_frustum);
g_array_append_val (clip_frusta, clip_frustum);
}
@ -437,7 +436,7 @@ clutter_stage_do_paint_view (ClutterStage *stage,
sizeof (graphene_frustum_t),
1);
if (redraw_clip)
cairo_region_get_extents (redraw_clip, &clip_rect);
clip_rect = mtk_region_get_extents (redraw_clip);
else
clutter_stage_view_get_layout (view, &clip_rect);
@ -477,7 +476,7 @@ clutter_stage_do_paint_view (ClutterStage *stage,
void
clutter_stage_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame)
{
ClutterStagePrivate *priv = stage->priv;
@ -1073,7 +1072,7 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
float y,
ClutterPickMode mode,
ClutterStageView *view,
cairo_region_t **clear_area)
MtkRegion **clear_area)
{
g_autoptr (ClutterPickStack) pick_stack = NULL;
ClutterPickContext *pick_context;
@ -1127,7 +1126,7 @@ _clutter_stage_do_pick (ClutterStage *stage,
float x,
float y,
ClutterPickMode mode,
cairo_region_t **clear_area)
MtkRegion **clear_area)
{
ClutterActor *actor = CLUTTER_ACTOR (stage);
ClutterStagePrivate *priv = stage->priv;
@ -1302,7 +1301,7 @@ clutter_stage_finalize (GObject *object)
static void
clutter_stage_real_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame)
{
clutter_stage_do_paint_view (stage, view, frame, redraw_clip);
@ -1571,7 +1570,7 @@ clutter_stage_class_init (ClutterStageClass *klass)
* ClutterStage::paint-view:
* @stage: the stage that received the event
* @view: a #ClutterStageView
* @redraw_clip: a #cairo_region_t with the redraw clip
* @redraw_clip: a #MtkRegion with the redraw clip
* @frame: a #ClutterFrame
*
* The signal is emitted before a [class@Clutter.StageView] is being
@ -1590,7 +1589,7 @@ clutter_stage_class_init (ClutterStageClass *klass)
_clutter_marshal_VOID__OBJECT_BOXED_BOXED,
G_TYPE_NONE, 3,
CLUTTER_TYPE_STAGE_VIEW,
CAIRO_GOBJECT_TYPE_REGION | G_SIGNAL_TYPE_STATIC_SCOPE,
MTK_TYPE_REGION | G_SIGNAL_TYPE_STATIC_SCOPE,
CLUTTER_TYPE_FRAME | G_SIGNAL_TYPE_STATIC_SCOPE);
g_signal_set_va_marshaller (stage_signals[PAINT_VIEW],
G_TYPE_FROM_CLASS (gobject_class),
@ -1945,7 +1944,7 @@ clutter_stage_read_pixels (ClutterStage *stage,
ClutterActorBox box;
GList *l;
ClutterStageView *view;
cairo_region_t *clip;
g_autoptr (MtkRegion) clip = NULL;
MtkRectangle clip_rect;
CoglFramebuffer *framebuffer;
float view_scale;
@ -1977,27 +1976,17 @@ clutter_stage_read_pixels (ClutterStage *stage,
view = l->data;
clutter_stage_view_get_layout (view, &clip_rect);
clip = cairo_region_create_rectangle (&clip_rect);
cairo_region_intersect_rectangle (clip,
&(MtkRectangle) {
.x = x,
.y = y,
.width = width,
.height = height,
});
cairo_region_get_extents (clip, &clip_rect);
clip = mtk_region_create_rectangle (&clip_rect);
mtk_region_intersect_rectangle (clip,
&MTK_RECTANGLE_INIT (x, y, width, height));
clip_rect = mtk_region_get_extents (clip);
if (clip_rect.width == 0 || clip_rect.height == 0)
{
cairo_region_destroy (clip);
return NULL;
}
framebuffer = clutter_stage_view_get_framebuffer (view);
clutter_stage_do_paint_view (stage, view, NULL, clip);
cairo_region_destroy (clip);
view_scale = clutter_stage_view_get_scale (view);
pixel_width = roundf (clip_rect.width * view_scale);
pixel_height = roundf (clip_rect.height * view_scale);
@ -2725,7 +2714,7 @@ clutter_stage_paint_to_framebuffer (ClutterStage *stage,
{
ClutterStagePrivate *priv = stage->priv;
ClutterPaintContext *paint_context;
cairo_region_t *redraw_clip;
g_autoptr (MtkRegion) redraw_clip = NULL;
if (paint_flags & CLUTTER_PAINT_FLAG_CLEAR)
{
@ -2735,12 +2724,11 @@ clutter_stage_paint_to_framebuffer (ClutterStage *stage,
cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color);
}
redraw_clip = cairo_region_create_rectangle (rect);
redraw_clip = mtk_region_create_rectangle (rect);
paint_context =
clutter_paint_context_new_for_framebuffer (framebuffer,
redraw_clip,
paint_flags);
cairo_region_destroy (redraw_clip);
cogl_framebuffer_push_matrix (framebuffer);
cogl_framebuffer_set_projection_matrix (framebuffer, &priv->projection);
@ -3048,7 +3036,7 @@ free_pointer_device_entry (PointerDeviceEntry *entry)
if (entry->current_actor)
_clutter_actor_set_has_pointer (entry->current_actor, FALSE);
g_clear_pointer (&entry->clear_area, cairo_region_destroy);
g_clear_pointer (&entry->clear_area, mtk_region_unref);
g_assert (!entry->press_count);
g_assert (entry->event_emission_chain->len == 0);
@ -3063,7 +3051,7 @@ clutter_stage_update_device_entry (ClutterStage *self,
ClutterEventSequence *sequence,
graphene_point_t coords,
ClutterActor *actor,
cairo_region_t *clear_area)
MtkRegion *clear_area)
{
ClutterStagePrivate *priv = self->priv;
PointerDeviceEntry *entry = NULL;
@ -3108,9 +3096,9 @@ clutter_stage_update_device_entry (ClutterStage *self,
_clutter_actor_set_has_pointer (actor, TRUE);
}
g_clear_pointer (&entry->clear_area, cairo_region_destroy);
g_clear_pointer (&entry->clear_area, mtk_region_unref);
if (clear_area)
entry->clear_area = cairo_region_reference (clear_area);
entry->clear_area = mtk_region_ref (clear_area);
}
void
@ -3446,7 +3434,7 @@ clutter_stage_update_device (ClutterStage *stage,
graphene_point_t point,
uint32_t time_ms,
ClutterActor *new_actor,
cairo_region_t *clear_area,
MtkRegion *clear_area,
gboolean emit_crossing)
{
ClutterInputDeviceType device_type;
@ -3587,7 +3575,7 @@ clutter_stage_check_in_clear_area (ClutterStage *stage,
if (!entry->clear_area)
return FALSE;
return cairo_region_contains_point (entry->clear_area,
return mtk_region_contains_point (entry->clear_area,
point.x, point.y);
}
@ -3601,7 +3589,7 @@ clutter_stage_pick_and_update_device (ClutterStage *stage,
uint32_t time_ms)
{
ClutterActor *new_actor;
cairo_region_t *clear_area = NULL;
MtkRegion *clear_area = NULL;
if ((flags & CLUTTER_DEVICE_UPDATE_IGNORE_CACHE) == 0)
{
@ -3632,7 +3620,7 @@ clutter_stage_pick_and_update_device (ClutterStage *stage,
clear_area,
!!(flags & CLUTTER_DEVICE_UPDATE_EMIT_CROSSING));
g_clear_pointer (&clear_area, cairo_region_destroy);
g_clear_pointer (&clear_area, mtk_region_unref);
return new_actor;
}

View File

@ -77,7 +77,7 @@ struct _ClutterStageClass
void (* paint_view) (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame);
};

View File

@ -273,7 +273,7 @@ _cogl_clip_stack_push_primitive (CoglClipStack *stack,
CoglClipStack *
cogl_clip_stack_push_region (CoglClipStack *stack,
cairo_region_t *region)
MtkRegion *region)
{
CoglClipStack *entry;
CoglClipStackRegion *entry_region;
@ -284,13 +284,13 @@ cogl_clip_stack_push_region (CoglClipStack *stack,
COGL_CLIP_STACK_REGION);
entry = (CoglClipStack *) entry_region;
cairo_region_get_extents (region, &bounds);
bounds = mtk_region_get_extents (region);
entry->bounds_x0 = bounds.x;
entry->bounds_x1 = bounds.x + bounds.width;
entry->bounds_y0 = bounds.y;
entry->bounds_y1 = bounds.y + bounds.height;
entry_region->region = cairo_region_reference (region);
entry_region->region = mtk_region_ref (region);
return entry;
}
@ -336,7 +336,7 @@ _cogl_clip_stack_unref (CoglClipStack *entry)
case COGL_CLIP_STACK_REGION:
{
CoglClipStackRegion *region = (CoglClipStackRegion *) entry;
cairo_region_destroy (region->region);
g_clear_pointer (&region->region, mtk_region_unref);
g_free (entry);
break;
}

View File

@ -157,7 +157,7 @@ struct _CoglClipStackRegion
{
CoglClipStack _parent_data;
cairo_region_t *region;
MtkRegion *region;
};
COGL_EXPORT CoglClipStack *
@ -182,7 +182,7 @@ _cogl_clip_stack_push_primitive (CoglClipStack *stack,
const float *viewport);
CoglClipStack *
cogl_clip_stack_push_region (CoglClipStack *stack,
cairo_region_t *region);
MtkRegion *region);
CoglClipStack *
_cogl_clip_stack_pop (CoglClipStack *stack);

View File

@ -2070,7 +2070,7 @@ cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
void
cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer,
cairo_region_t *region)
MtkRegion *region)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);

View File

@ -38,9 +38,9 @@
#include "cogl/cogl-indices.h"
#include "cogl/cogl-bitmap.h"
#include "cogl/cogl-texture.h"
#include "mtk/mtk.h"
#include <glib-object.h>
#include <cairo.h>
#include <graphene.h>
@ -529,7 +529,7 @@ cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
COGL_EXPORT void
cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer,
cairo_region_t *region);
MtkRegion *region);
/**
* cogl_framebuffer_pop_clip:

View File

@ -122,13 +122,13 @@ add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
static void
add_stencil_clip_region (CoglFramebuffer *framebuffer,
cairo_region_t *region,
MtkRegion *region,
gboolean merge)
{
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglMatrixEntry *old_projection_entry, *old_modelview_entry;
graphene_matrix_t matrix;
int num_rectangles = cairo_region_num_rectangles (region);
int num_rectangles = mtk_region_num_rectangles (region);
int i;
CoglVertexP2 *vertices;
graphene_point3d_t p;
@ -189,7 +189,7 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
float x2, y2, z2, w2;
CoglVertexP2 *v = vertices + i * 6;
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
x1 = rect.x;
y1 = rect.y;
@ -527,7 +527,7 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
/* If nrectangles <= 1, it can be fully represented with the
* scissor clip.
*/
if (cairo_region_num_rectangles (region->region) > 1 ||
if (mtk_region_num_rectangles (region->region) > 1 ||
G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_STENCILLING)))
{
COGL_NOTE (CLIPPING, "Adding stencil clip for region");

View File

@ -47,7 +47,7 @@
struct _MetaPointerConstraint
{
GObject parent_instance;
cairo_region_t *region;
MtkRegion *region;
double min_edge_distance;
};
@ -61,7 +61,7 @@ meta_pointer_constraint_finalize (GObject *object)
{
MetaPointerConstraint *constraint = META_POINTER_CONSTRAINT (object);
g_clear_pointer (&constraint->region, cairo_region_destroy);
g_clear_pointer (&constraint->region, mtk_region_unref);
G_OBJECT_CLASS (meta_pointer_constraint_parent_class)->finalize (object);
}
@ -81,19 +81,19 @@ meta_pointer_constraint_class_init (MetaPointerConstraintClass *klass)
MetaPointerConstraint *
meta_pointer_constraint_new (const cairo_region_t *region,
meta_pointer_constraint_new (const MtkRegion *region,
double min_edge_distance)
{
MetaPointerConstraint *constraint;
constraint = g_object_new (META_TYPE_POINTER_CONSTRAINT, NULL);
constraint->region = cairo_region_copy (region);
constraint->region = mtk_region_copy (region);
constraint->min_edge_distance = min_edge_distance;
return constraint;
}
cairo_region_t *
MtkRegion *
meta_pointer_constraint_get_region (MetaPointerConstraint *constraint)
{
return constraint->region;

View File

@ -32,10 +32,10 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (MetaPointerConstraint, meta_pointer_constraint,
META, POINTER_CONSTRAINT, GObject);
MetaPointerConstraint * meta_pointer_constraint_new (const cairo_region_t *region,
MetaPointerConstraint * meta_pointer_constraint_new (const MtkRegion *region,
double min_edge_distance);
cairo_region_t * meta_pointer_constraint_get_region (MetaPointerConstraint *constraint);
MtkRegion * meta_pointer_constraint_get_region (MetaPointerConstraint *constraint);
double meta_pointer_constraint_get_min_edge_distance (MetaPointerConstraint *constraint);

View File

@ -245,7 +245,7 @@ maybe_record_frame_on_idle (gpointer user_data)
static void
before_stage_painted (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data)
{
@ -265,7 +265,7 @@ before_stage_painted (MetaStage *stage,
static void
stage_painted (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data)
{
@ -283,12 +283,12 @@ stage_painted (MetaStage *stage,
if (redraw_clip)
{
switch (cairo_region_contains_rectangle (redraw_clip, area))
switch (mtk_region_contains_rectangle (redraw_clip, area))
{
case CAIRO_REGION_OVERLAP_IN:
case CAIRO_REGION_OVERLAP_PART:
case MTK_REGION_OVERLAP_IN:
case MTK_REGION_OVERLAP_PART:
break;
case CAIRO_REGION_OVERLAP_OUT:
case MTK_REGION_OVERLAP_OUT:
return;
}
}

View File

@ -149,7 +149,7 @@ maybe_record_frame_on_idle (gpointer user_data)
static void
stage_painted (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data)
{
@ -189,7 +189,7 @@ stage_painted (MetaStage *stage,
static void
before_stage_painted (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data)
{

View File

@ -112,7 +112,7 @@ typedef struct _MetaScreenCastStreamSrcPrivate
gboolean uses_dma_bufs;
GHashTable *dmabuf_handles;
cairo_region_t *redraw_clip;
MtkRegion *redraw_clip;
} MetaScreenCastStreamSrcPrivate;
static const struct {
@ -687,7 +687,7 @@ maybe_add_damaged_regions_metadata (MetaScreenCastStreamSrc *src,
int num_buffers_available;
i = 0;
n_rectangles = cairo_region_num_rectangles (priv->redraw_clip);
n_rectangles = mtk_region_num_rectangles (priv->redraw_clip);
num_buffers_available = 0;
spa_meta_for_each (meta_region, spa_meta_video_damage)
@ -714,7 +714,7 @@ maybe_add_damaged_regions_metadata (MetaScreenCastStreamSrc *src,
{
MtkRectangle rect;
cairo_region_get_rectangle (priv->redraw_clip, i, &rect);
rect = mtk_region_get_rectangle (priv->redraw_clip, i);
meta_region->region = SPA_REGION (rect.x, rect.y,
rect.width, rect.height);
@ -724,13 +724,13 @@ maybe_add_damaged_regions_metadata (MetaScreenCastStreamSrc *src,
}
}
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
g_clear_pointer (&priv->redraw_clip, mtk_region_unref);
}
MetaScreenCastRecordResult
meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src,
MetaScreenCastRecordFlag flags,
const cairo_region_t *redraw_clip)
const MtkRegion *redraw_clip)
{
int64_t now_us = g_get_monotonic_time ();
@ -743,7 +743,7 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src,
MetaScreenCastRecordResult
meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (MetaScreenCastStreamSrc *src,
MetaScreenCastRecordFlag flags,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
int64_t frame_timestamp_us)
{
MetaScreenCastStreamSrcPrivate *priv =
@ -762,9 +762,9 @@ meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (MetaScreenCastStr
if (redraw_clip)
{
if (priv->redraw_clip)
cairo_region_union (priv->redraw_clip, redraw_clip);
mtk_region_union (priv->redraw_clip, redraw_clip);
else
priv->redraw_clip = cairo_region_copy (redraw_clip);
priv->redraw_clip = mtk_region_copy (redraw_clip);
}
if (priv->buffer_count == 0)

View File

@ -91,11 +91,11 @@ gboolean meta_screen_cast_stream_src_is_enabled (MetaScreenCastStreamSrc *src);
MetaScreenCastRecordResult meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src,
MetaScreenCastRecordFlag flags,
const cairo_region_t *redraw_clip);
const MtkRegion *redraw_clip);
MetaScreenCastRecordResult meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (MetaScreenCastStreamSrc *src,
MetaScreenCastRecordFlag flags,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
int64_t frame_timestamp_us);
gboolean meta_screen_cast_stream_src_pending_follow_up_frame (MetaScreenCastStreamSrc *src);

View File

@ -196,7 +196,7 @@ uninhibit_hw_cursor (MetaScreenCastVirtualStreamSrc *virtual_src)
static void
actors_painted (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data)
{

View File

@ -25,8 +25,6 @@
#pragma once
#include <cairo.h>
#include "backends/meta-backend-types.h"
#include "clutter/clutter.h"

View File

@ -132,8 +132,8 @@ meta_stage_impl_resize (ClutterStageWindow *stage_window,
static void
paint_damage_region (ClutterStageWindow *stage_window,
ClutterStageView *view,
cairo_region_t *swap_region,
cairo_region_t *queued_redraw_clip)
MtkRegion *swap_region,
MtkRegion *queued_redraw_clip)
{
CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
@ -154,13 +154,13 @@ paint_damage_region (ClutterStageWindow *stage_window,
cogl_pipeline_set_color4ub (overlay_blue, 0x00, 0x00, 0x33, 0x33);
}
n_rects = cairo_region_num_rectangles (swap_region);
n_rects = mtk_region_num_rectangles (swap_region);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
float x_1, x_2, y_1, y_2;
cairo_region_get_rectangle (swap_region, i, &rect);
rect = mtk_region_get_rectangle (swap_region, i);
x_1 = rect.x;
x_2 = rect.x + rect.width;
y_1 = rect.y;
@ -180,13 +180,13 @@ paint_damage_region (ClutterStageWindow *stage_window,
cogl_pipeline_set_color4ub (overlay_red, 0x33, 0x00, 0x00, 0x33);
}
n_rects = cairo_region_num_rectangles (queued_redraw_clip);
n_rects = mtk_region_num_rectangles (queued_redraw_clip);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
float x_1, x_2, y_1, y_2;
cairo_region_get_rectangle (queued_redraw_clip, i, &rect);
rect = mtk_region_get_rectangle (queued_redraw_clip, i);
x_1 = rect.x;
x_2 = rect.x + rect.width;
y_1 = rect.y;
@ -202,7 +202,7 @@ paint_damage_region (ClutterStageWindow *stage_window,
static void
queue_damage_region (ClutterStageWindow *stage_window,
ClutterStageView *stage_view,
cairo_region_t *damage_region)
MtkRegion *damage_region)
{
int *damage, n_rects, i;
g_autofree int *freeme = NULL;
@ -211,7 +211,7 @@ queue_damage_region (ClutterStageWindow *stage_window,
int fb_width;
int fb_height;
if (cairo_region_is_empty (damage_region))
if (mtk_region_is_empty (damage_region))
return;
framebuffer = clutter_stage_view_get_onscreen (stage_view);
@ -222,7 +222,7 @@ queue_damage_region (ClutterStageWindow *stage_window,
fb_width = cogl_framebuffer_get_width (framebuffer);
fb_height = cogl_framebuffer_get_height (framebuffer);
n_rects = cairo_region_num_rectangles (damage_region);
n_rects = mtk_region_num_rectangles (damage_region);
if (n_rects < MAX_STACK_RECTS)
damage = g_newa (int, n_rects * 4);
@ -233,7 +233,7 @@ queue_damage_region (ClutterStageWindow *stage_window,
{
MtkRectangle rect;
cairo_region_get_rectangle (damage_region, i, &rect);
rect = mtk_region_get_rectangle (damage_region, i);
clutter_stage_view_transform_rect_to_onscreen (stage_view,
&rect,
@ -254,7 +254,7 @@ queue_damage_region (ClutterStageWindow *stage_window,
static void
swap_framebuffer (ClutterStageWindow *stage_window,
ClutterStageView *stage_view,
cairo_region_t *swap_region,
MtkRegion *swap_region,
gboolean swap_with_damage,
ClutterFrame *frame)
{
@ -273,13 +273,13 @@ swap_framebuffer (ClutterStageWindow *stage_window,
int *damage, n_rects, i;
CoglFrameInfo *frame_info;
n_rects = cairo_region_num_rectangles (swap_region);
n_rects = mtk_region_num_rectangles (swap_region);
damage = g_newa (int, n_rects * 4);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (swap_region, i, &rect);
rect = mtk_region_get_rectangle (swap_region, i);
damage[i * 4] = rect.x;
damage[i * 4 + 1] = rect.y;
damage[i * 4 + 2] = rect.width;
@ -333,8 +333,8 @@ swap_framebuffer (ClutterStageWindow *stage_window,
}
}
static cairo_region_t *
offset_scale_and_clamp_region (const cairo_region_t *region,
static MtkRegion *
offset_scale_and_clamp_region (const MtkRegion *region,
int offset_x,
int offset_y,
float scale)
@ -343,10 +343,10 @@ offset_scale_and_clamp_region (const cairo_region_t *region,
MtkRectangle *rects;
g_autofree MtkRectangle *freeme = NULL;
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
if (n_rects == 0)
return cairo_region_create ();
return mtk_region_create ();
if (n_rects < MAX_STACK_RECTS)
rects = g_newa (MtkRectangle, n_rects);
@ -358,7 +358,7 @@ offset_scale_and_clamp_region (const cairo_region_t *region,
MtkRectangle *rect = &rects[i];
graphene_rect_t tmp;
cairo_region_get_rectangle (region, i, rect);
*rect = mtk_region_get_rectangle (region, i);
tmp = mtk_rectangle_to_graphene_rect (rect);
graphene_rect_offset (&tmp, offset_x, offset_y);
@ -367,11 +367,11 @@ offset_scale_and_clamp_region (const cairo_region_t *region,
rect);
}
return cairo_region_create_rectangles (rects, n_rects);
return mtk_region_create_rectangles (rects, n_rects);
}
static cairo_region_t *
scale_offset_and_clamp_region (const cairo_region_t *region,
static MtkRegion *
scale_offset_and_clamp_region (const MtkRegion *region,
float scale,
int offset_x,
int offset_y)
@ -380,10 +380,10 @@ scale_offset_and_clamp_region (const cairo_region_t *region,
MtkRectangle *rects;
g_autofree MtkRectangle *freeme = NULL;
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
if (n_rects == 0)
return cairo_region_create ();
return mtk_region_create ();
if (n_rects < MAX_STACK_RECTS)
rects = g_newa (MtkRectangle, n_rects);
@ -395,7 +395,7 @@ scale_offset_and_clamp_region (const cairo_region_t *region,
MtkRectangle *rect = &rects[i];
graphene_rect_t tmp;
cairo_region_get_rectangle (region, i, rect);
*rect = mtk_region_get_rectangle (region, i);
tmp = mtk_rectangle_to_graphene_rect (rect);
graphene_rect_scale (&tmp, scale, scale, &tmp);
@ -405,13 +405,13 @@ scale_offset_and_clamp_region (const cairo_region_t *region,
rect);
}
return cairo_region_create_rectangles (rects, n_rects);
return mtk_region_create_rectangles (rects, n_rects);
}
static void
paint_stage (MetaStageImpl *stage_impl,
ClutterStageView *stage_view,
cairo_region_t *redraw_clip,
MtkRegion *redraw_clip,
ClutterFrame *frame)
{
ClutterStage *stage = stage_impl->wrapper;
@ -422,31 +422,31 @@ paint_stage (MetaStageImpl *stage_impl,
clutter_stage_view_after_paint (stage_view, redraw_clip);
}
static cairo_region_t *
static MtkRegion *
transform_swap_region_to_onscreen (ClutterStageView *stage_view,
cairo_region_t *swap_region)
MtkRegion *swap_region)
{
CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (stage_view);
int n_rects, i;
MtkRectangle *rects;
cairo_region_t *transformed_region;
MtkRegion *transformed_region;
int width, height;
width = cogl_framebuffer_get_width (onscreen);
height = cogl_framebuffer_get_height (onscreen);
n_rects = cairo_region_num_rectangles (swap_region);
n_rects = mtk_region_num_rectangles (swap_region);
rects = g_newa (MtkRectangle, n_rects);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (swap_region, i, &rects[i]);
rects[i] = mtk_region_get_rectangle (swap_region, i);
clutter_stage_view_transform_rect_to_onscreen (stage_view,
&rects[i],
width,
height,
&rects[i]);
}
transformed_region = cairo_region_create_rectangles (rects, n_rects);
transformed_region = mtk_region_create_rectangles (rects, n_rects);
return transformed_region;
}
@ -506,10 +506,10 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
gboolean buffer_has_valid_damage_history = FALSE;
gboolean has_buffer_age;
gboolean swap_with_damage;
cairo_region_t *redraw_clip;
cairo_region_t *queued_redraw_clip = NULL;
cairo_region_t *fb_clip_region;
cairo_region_t *swap_region;
g_autoptr (MtkRegion) redraw_clip = NULL;
g_autoptr (MtkRegion) queued_redraw_clip = NULL;
g_autoptr (MtkRegion) fb_clip_region = NULL;
g_autoptr (MtkRegion) swap_region = NULL;
ClutterDrawDebugFlag paint_debug_flags;
ClutterDamageHistory *damage_history;
float fb_scale;
@ -577,16 +577,16 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
.width = fb_width,
.height = fb_height,
};
fb_clip_region = cairo_region_create_rectangle (&fb_rect);
fb_clip_region = mtk_region_create_rectangle (&fb_rect);
g_clear_pointer (&redraw_clip, cairo_region_destroy);
redraw_clip = cairo_region_create_rectangle (&view_rect);
g_clear_pointer (&redraw_clip, mtk_region_unref);
redraw_clip = mtk_region_create_rectangle (&view_rect);
if (G_UNLIKELY (paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION))
queued_redraw_clip = cairo_region_reference (redraw_clip);
queued_redraw_clip = mtk_region_ref (redraw_clip);
}
g_return_if_fail (!cairo_region_is_empty (fb_clip_region));
g_return_if_fail (!mtk_region_is_empty (fb_clip_region));
/* XXX: It seems there will be a race here in that the stage
* window may be resized before the cogl_onscreen_swap_region
@ -598,11 +598,11 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
*/
/* swap_region does not need damage history, set it up before that */
if (!use_clipped_redraw)
swap_region = cairo_region_create ();
swap_region = mtk_region_create ();
else if (clutter_stage_view_has_shadowfb (stage_view))
swap_region = cairo_region_reference (fb_clip_region);
swap_region = mtk_region_ref (fb_clip_region);
else
swap_region = cairo_region_copy (fb_clip_region);
swap_region = mtk_region_copy (fb_clip_region);
swap_with_damage = FALSE;
if (has_buffer_age)
@ -615,17 +615,17 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
for (age = 1; age <= buffer_age; age++)
{
const cairo_region_t *old_damage;
const MtkRegion *old_damage;
old_damage =
clutter_damage_history_lookup (damage_history, age);
cairo_region_union (fb_clip_region, old_damage);
mtk_region_union (fb_clip_region, old_damage);
}
meta_topic (META_DEBUG_BACKEND,
"Reusing back buffer(age=%d) - repairing region: num rects: %d",
buffer_age,
cairo_region_num_rectangles (fb_clip_region));
mtk_region_num_rectangles (fb_clip_region));
swap_with_damage = TRUE;
}
@ -643,7 +643,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
* offset_scale_and_clamp_region. So we need to ensure redraw_clip
* is a superset of fb_clip_region to avoid such gaps.
*/
cairo_region_destroy (redraw_clip);
g_clear_pointer (&redraw_clip, mtk_region_unref);
redraw_clip = scale_offset_and_clamp_region (fb_clip_region,
1.0 / fb_scale,
view_rect.x,
@ -652,11 +652,10 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
if (paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)
{
cairo_region_t *debug_redraw_clip;
g_autoptr (MtkRegion) debug_redraw_clip = NULL;
debug_redraw_clip = cairo_region_create_rectangle (&view_rect);
debug_redraw_clip = mtk_region_create_rectangle (&view_rect);
paint_stage (stage_impl, stage_view, debug_redraw_clip, frame);
cairo_region_destroy (debug_redraw_clip);
}
else if (use_clipped_redraw)
{
@ -675,15 +674,15 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
paint_stage (stage_impl, stage_view, redraw_clip, frame);
}
g_clear_pointer (&redraw_clip, cairo_region_destroy);
g_clear_pointer (&fb_clip_region, cairo_region_destroy);
g_clear_pointer (&redraw_clip, mtk_region_unref);
g_clear_pointer (&fb_clip_region, mtk_region_unref);
COGL_TRACE_BEGIN_SCOPED (MetaStageImplRedrawViewSwapFramebuffer,
"Paint (swap framebuffer)");
if (queued_redraw_clip)
{
cairo_region_t *swap_region_in_stage_space;
g_autoptr (MtkRegion) swap_region_in_stage_space = NULL;
swap_region_in_stage_space =
scale_offset_and_clamp_region (swap_region,
@ -691,25 +690,22 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
view_rect.x,
view_rect.y);
cairo_region_subtract (swap_region_in_stage_space, queued_redraw_clip);
mtk_region_subtract (swap_region_in_stage_space, queued_redraw_clip);
paint_damage_region (stage_window, stage_view,
swap_region_in_stage_space, queued_redraw_clip);
cairo_region_destroy (queued_redraw_clip);
cairo_region_destroy (swap_region_in_stage_space);
}
if (clutter_stage_view_get_onscreen (stage_view) !=
clutter_stage_view_get_framebuffer (stage_view) &&
cairo_region_num_rectangles (swap_region) != 0)
mtk_region_num_rectangles (swap_region) != 0)
{
cairo_region_t *transformed_swap_region;
g_autoptr (MtkRegion) transformed_swap_region = NULL;
transformed_swap_region =
transform_swap_region_to_onscreen (stage_view, swap_region);
cairo_region_destroy (swap_region);
swap_region = transformed_swap_region;
g_clear_pointer (&swap_region, mtk_region_unref);
swap_region = g_steal_pointer (&transformed_swap_region);
}
swap_framebuffer (stage_window,
@ -717,8 +713,6 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
swap_region,
swap_with_damage,
frame);
cairo_region_destroy (swap_region);
}
static gboolean

View File

@ -38,7 +38,7 @@ typedef enum
typedef void (* MetaStageWatchFunc) (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data);

View File

@ -25,8 +25,6 @@
#pragma once
#include <cairo.h>
#include "backends/meta-stage-view.h"
G_BEGIN_DECLS

View File

@ -177,7 +177,7 @@ meta_stage_finalize (GObject *object)
static void
notify_watchers_for_mode (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
MetaStageWatchPhase watch_phase)
{
@ -215,7 +215,7 @@ meta_stage_paint (ClutterActor *actor,
MetaStage *stage = META_STAGE (actor);
ClutterStageView *view;
ClutterFrame *frame;
const cairo_region_t *redraw_clip;
const MtkRegion *redraw_clip;
CLUTTER_ACTOR_CLASS (meta_stage_parent_class)->paint (actor, paint_context);
@ -260,7 +260,7 @@ meta_stage_paint (ClutterActor *actor,
static void
meta_stage_paint_view (ClutterStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame)
{
MetaStage *meta_stage = META_STAGE (stage);

View File

@ -427,7 +427,7 @@ meta_backend_native_set_pointer_constraint (MetaBackend *backend,
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
MetaPointerConstraintImpl *constraint_impl = NULL;
cairo_region_t *region;
MtkRegion *region;
if (constraint)
{

View File

@ -32,7 +32,7 @@ struct _MetaPointerConstraintImplNative
{
MetaPointerConstraintImpl parent;
MetaPointerConstraint *constraint;
cairo_region_t *region;
MtkRegion *region;
double min_edge_distance;
};
@ -223,7 +223,7 @@ add_band_bottom_edges (MetaBox *boxes,
}
static void
region_to_outline (cairo_region_t *region,
region_to_outline (MtkRegion *region,
GArray *borders)
{
MetaBox *boxes;
@ -249,12 +249,12 @@ region_to_outline (cairo_region_t *region,
*
*/
num_boxes = cairo_region_num_rectangles (region);
num_boxes = mtk_region_num_rectangles (region);
boxes = g_new (MetaBox, num_boxes);
for (i = 0; i < num_boxes; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
boxes[i] = (MetaBox) {
.x1 = rect.x,
.y1 = rect.y,
@ -451,7 +451,7 @@ meta_pointer_constraint_impl_native_constraint (MetaPointerConstraintImpl *const
float *y_inout)
{
MetaPointerConstraintImplNative *constraint_impl_native;
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
float x, y;
g_autoptr (GArray) borders = NULL;
MetaLine2 motion;
@ -460,7 +460,7 @@ meta_pointer_constraint_impl_native_constraint (MetaPointerConstraintImpl *const
constraint_impl_native = META_POINTER_CONSTRAINT_IMPL_NATIVE (constraint_impl);
region = cairo_region_reference (constraint_impl_native->region);
region = mtk_region_ref (constraint_impl_native->region);
x = *x_inout;
y = *y_inout;
@ -484,7 +484,6 @@ meta_pointer_constraint_impl_native_constraint (MetaPointerConstraintImpl *const
* confined motion vectors.
*/
region_to_outline (region, borders);
cairo_region_destroy (region);
motion = (MetaLine2) {
.a = (MetaVector2) {
@ -590,19 +589,19 @@ meta_pointer_constraint_impl_native_ensure_constrained (MetaPointerConstraintImp
{
MetaPointerConstraintImplNative *constraint_impl_native;
graphene_point_t point;
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
float x;
float y;
constraint_impl_native = META_POINTER_CONSTRAINT_IMPL_NATIVE (constraint_impl);
region = cairo_region_reference (constraint_impl_native->region);
region = mtk_region_ref (constraint_impl_native->region);
clutter_seat_query_state (clutter_input_device_get_seat (device),
device, NULL, &point, NULL);
x = point.x;
y = point.y;
if (!cairo_region_contains_point (region, (int) x, (int) y))
if (!mtk_region_contains_point (region, (int) x, (int) y))
{
g_autoptr (GArray) borders = NULL;
float closest_distance_2 = FLT_MAX;
@ -632,8 +631,6 @@ meta_pointer_constraint_impl_native_ensure_constrained (MetaPointerConstraintImp
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
clutter_seat_warp_pointer (seat, x, y);
}
cairo_region_destroy (region);
}
static void
@ -642,7 +639,7 @@ meta_pointer_constraint_impl_native_finalize (GObject *object)
MetaPointerConstraintImplNative *constraint_impl_native;
constraint_impl_native = META_POINTER_CONSTRAINT_IMPL_NATIVE (object);
g_clear_pointer (&constraint_impl_native->region, cairo_region_destroy);
g_clear_pointer (&constraint_impl_native->region, mtk_region_unref);
G_OBJECT_CLASS (meta_pointer_constraint_impl_native_parent_class)->finalize (object);
}
@ -669,7 +666,7 @@ meta_pointer_constraint_impl_native_class_init (MetaPointerConstraintImplNativeC
MetaPointerConstraintImpl *
meta_pointer_constraint_impl_native_new (MetaPointerConstraint *constraint,
const cairo_region_t *region,
const MtkRegion *region,
double min_edge_distance)
{
MetaPointerConstraintImplNative *constraint_impl;
@ -677,7 +674,7 @@ meta_pointer_constraint_impl_native_new (MetaPointerConstraint *constraint,
constraint_impl = g_object_new (META_TYPE_POINTER_CONSTRAINT_IMPL_NATIVE,
NULL);
constraint_impl->constraint = constraint;
constraint_impl->region = cairo_region_copy (region);
constraint_impl->region = mtk_region_copy (region);
constraint_impl->min_edge_distance = min_edge_distance;
return META_POINTER_CONSTRAINT_IMPL (constraint_impl);

View File

@ -36,7 +36,7 @@ G_DECLARE_FINAL_TYPE (MetaPointerConstraintImplNative,
MetaPointerConstraintImpl)
MetaPointerConstraintImpl * meta_pointer_constraint_impl_native_new (MetaPointerConstraint *constraint_impl,
const cairo_region_t *region,
const MtkRegion *region,
double min_edge_distance);
G_END_DECLS

View File

@ -1024,7 +1024,7 @@ meta_compositor_real_before_paint (MetaCompositor *compositor,
ClutterActor *stage = meta_backend_get_stage (priv->backend);
ClutterStageView *stage_view;
MtkRectangle stage_rect;
cairo_region_t *unobscured_region;
MtkRegion *unobscured_region;
GList *l;
stage_rect = (MtkRectangle) {
@ -1033,17 +1033,17 @@ meta_compositor_real_before_paint (MetaCompositor *compositor,
clutter_actor_get_height (stage),
};
unobscured_region = cairo_region_create_rectangle (&stage_rect);
unobscured_region = mtk_region_create_rectangle (&stage_rect);
meta_cullable_cull_unobscured (META_CULLABLE (priv->window_group), unobscured_region);
cairo_region_destroy (unobscured_region);
mtk_region_unref (unobscured_region);
unobscured_region = cairo_region_create_rectangle (&stage_rect);
unobscured_region = mtk_region_create_rectangle (&stage_rect);
meta_cullable_cull_unobscured (META_CULLABLE (priv->top_window_group), unobscured_region);
cairo_region_destroy (unobscured_region);
mtk_region_unref (unobscured_region);
unobscured_region = cairo_region_create_rectangle (&stage_rect);
unobscured_region = mtk_region_create_rectangle (&stage_rect);
meta_cullable_cull_unobscured (META_CULLABLE (priv->feedback_group), unobscured_region);
cairo_region_destroy (unobscured_region);
mtk_region_unref (unobscured_region);
stage_view = meta_compositor_view_get_stage_view (compositor_view);

View File

@ -4,4 +4,4 @@
#include "meta/meta-background-actor.h"
cairo_region_t *meta_background_actor_get_clip_region (MetaBackgroundActor *self);
MtkRegion *meta_background_actor_get_clip_region (MetaBackgroundActor *self);

View File

@ -165,7 +165,7 @@ meta_background_actor_new (MetaDisplay *display,
static void
meta_background_actor_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
MetaBackgroundActor *self = META_BACKGROUND_ACTOR (cullable);
@ -177,7 +177,7 @@ meta_background_actor_cull_unobscured (MetaCullable *cullable,
static void
meta_background_actor_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
MetaBackgroundActor *self = META_BACKGROUND_ACTOR (cullable);
@ -198,11 +198,11 @@ cullable_iface_init (MetaCullableInterface *iface)
* meta_background_actor_get_clip_region:
* @self: a #MetaBackgroundActor
*
* Return value (transfer none): a #cairo_region_t that represents the part of
* Return value (transfer none): a #MtkRegion that represents the part of
* the background not obscured by other #MetaBackgroundActor or
* #MetaWindowActor objects.
*/
cairo_region_t *
MtkRegion *
meta_background_actor_get_clip_region (MetaBackgroundActor *self)
{
if (!self->content)

View File

@ -4,10 +4,10 @@
#include "meta/meta-background-content.h"
cairo_region_t *meta_background_content_get_clip_region (MetaBackgroundContent *self);
MtkRegion *meta_background_content_get_clip_region (MetaBackgroundContent *self);
void meta_background_content_cull_unobscured (MetaBackgroundContent *self,
cairo_region_t *unobscured_region);
MtkRegion *unobscured_region);
void meta_background_content_cull_redraw_clip (MetaBackgroundContent *self,
cairo_region_t *clip_region);
MtkRegion *clip_region);

View File

@ -232,8 +232,8 @@ struct _MetaBackgroundContent
MtkRectangle texture_area;
int texture_width, texture_height;
cairo_region_t *clip_region;
cairo_region_t *unobscured_region;
MtkRegion *clip_region;
MtkRegion *unobscured_region;
};
static void clutter_content_iface_init (ClutterContentInterface *iface);
@ -264,29 +264,29 @@ static GParamSpec *properties[N_PROPS] = { NULL, };
static void
set_clip_region (MetaBackgroundContent *self,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
g_clear_pointer (&self->clip_region, cairo_region_destroy);
g_clear_pointer (&self->clip_region, mtk_region_unref);
if (clip_region)
{
if (cairo_region_is_empty (clip_region))
self->clip_region = cairo_region_reference (clip_region);
if (mtk_region_is_empty (clip_region))
self->clip_region = mtk_region_ref (clip_region);
else
self->clip_region = cairo_region_copy (clip_region);
self->clip_region = mtk_region_copy (clip_region);
}
}
static void
set_unobscured_region (MetaBackgroundContent *self,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
g_clear_pointer (&self->unobscured_region, cairo_region_destroy);
g_clear_pointer (&self->unobscured_region, mtk_region_unref);
if (unobscured_region)
{
if (cairo_region_is_empty (unobscured_region))
self->unobscured_region = cairo_region_reference (unobscured_region);
if (mtk_region_is_empty (unobscured_region))
self->unobscured_region = mtk_region_ref (unobscured_region);
else
self->unobscured_region = cairo_region_copy (unobscured_region);
self->unobscured_region = mtk_region_copy (unobscured_region);
}
}
@ -661,12 +661,12 @@ meta_background_content_paint_content (ClutterContent *content,
ClutterActorBox actor_box;
MtkRectangle rect_within_actor;
MtkRectangle rect_within_stage;
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
int i, n_rects;
float transformed_x, transformed_y, transformed_width, transformed_height;
gboolean untransformed;
if ((self->clip_region && cairo_region_is_empty (self->clip_region)))
if ((self->clip_region && mtk_region_is_empty (self->clip_region)))
return;
clutter_actor_get_content_box (actor, &actor_box);
@ -704,22 +704,22 @@ meta_background_content_paint_content (ClutterContent *content,
{
if (self->clip_region)
{
region = cairo_region_copy (self->clip_region);
cairo_region_intersect_rectangle (region, &rect_within_stage);
region = mtk_region_copy (self->clip_region);
mtk_region_intersect_rectangle (region, &rect_within_stage);
}
else
{
const cairo_region_t *redraw_clip;
const MtkRegion *redraw_clip;
redraw_clip = clutter_paint_context_get_redraw_clip (paint_context);
if (redraw_clip)
{
region = cairo_region_copy (redraw_clip);
cairo_region_intersect_rectangle (region, &rect_within_stage);
region = mtk_region_copy (redraw_clip);
mtk_region_intersect_rectangle (region, &rect_within_stage);
}
else
{
region = cairo_region_create_rectangle (&rect_within_stage);
region = mtk_region_create_rectangle (&rect_within_stage);
}
}
}
@ -727,24 +727,21 @@ meta_background_content_paint_content (ClutterContent *content,
{
if (self->clip_region)
{
region = cairo_region_copy (self->clip_region);
cairo_region_intersect_rectangle (region, &rect_within_actor);
region = mtk_region_copy (self->clip_region);
mtk_region_intersect_rectangle (region, &rect_within_actor);
}
else
{
region = cairo_region_create_rectangle (&rect_within_actor);
region = mtk_region_create_rectangle (&rect_within_actor);
}
}
if (self->unobscured_region)
cairo_region_intersect (region, self->unobscured_region);
mtk_region_intersect (region, self->unobscured_region);
/* region is now in actor space */
if (cairo_region_is_empty (region))
{
cairo_region_destroy (region);
if (mtk_region_is_empty (region))
return;
}
setup_pipeline (self, actor, paint_context, &rect_within_actor);
set_glsl_parameters (self, &rect_within_actor);
@ -753,24 +750,22 @@ meta_background_content_paint_content (ClutterContent *content,
* fall back and draw the whole thing */
#define MAX_RECTS 64
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
if (n_rects <= MAX_RECTS)
{
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
paint_clipped_rectangle (self, node, &actor_box, &rect);
}
}
else
{
MtkRectangle rect;
cairo_region_get_extents (region, &rect);
rect = mtk_region_get_extents (region);
paint_clipped_rectangle (self, node, &actor_box, &rect);
}
cairo_region_destroy (region);
}
static gboolean
@ -1208,7 +1203,7 @@ meta_background_content_set_rounded_clip_bounds (MetaBackgroundContent *self,
clutter_content_invalidate (CLUTTER_CONTENT (self));
}
cairo_region_t *
MtkRegion *
meta_background_content_get_clip_region (MetaBackgroundContent *self)
{
return self->clip_region;
@ -1216,14 +1211,14 @@ meta_background_content_get_clip_region (MetaBackgroundContent *self)
void
meta_background_content_cull_unobscured (MetaBackgroundContent *self,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
set_unobscured_region (self, unobscured_region);
}
void
meta_background_content_cull_redraw_clip (MetaBackgroundContent *self,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
set_clip_region (self, clip_region);
}

View File

@ -31,14 +31,14 @@ meta_background_group_class_init (MetaBackgroundGroupClass *klass)
static void
meta_background_group_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
meta_cullable_cull_unobscured_children (cullable, unobscured_region);
}
static void
meta_background_group_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
meta_cullable_cull_redraw_clip_children (cullable, clip_region);
}

View File

@ -46,12 +46,12 @@ has_active_effects (ClutterActor *actor)
return FALSE;
}
static cairo_region_t *
region_apply_transform_expand_maybe_ref (cairo_region_t *region,
static MtkRegion *
region_apply_transform_expand_maybe_ref (MtkRegion *region,
graphene_matrix_t *transform)
{
if (cairo_region_is_empty (region))
return cairo_region_reference (region);
if (mtk_region_is_empty (region))
return mtk_region_ref (region);
return meta_region_apply_matrix_transform_expand (region, transform);
}
@ -76,11 +76,11 @@ region_apply_transform_expand_maybe_ref (cairo_region_t *region,
*/
typedef void (* ChildCullMethod) (MetaCullable *cullable,
cairo_region_t *region);
MtkRegion *region);
static void
cull_out_children_common (MetaCullable *cullable,
cairo_region_t *region,
MtkRegion *region,
ChildCullMethod method)
{
ClutterActor *actor = CLUTTER_ACTOR (cullable);
@ -121,7 +121,8 @@ cull_out_children_common (MetaCullable *cullable,
if (needs_culling)
{
cairo_region_t *actor_region, *reduced_region;
g_autoptr (MtkRegion) actor_region = NULL;
g_autoptr (MtkRegion) reduced_region = NULL;
graphene_matrix_t actor_transform, inverted_actor_transform;
clutter_actor_get_transform (child, &actor_transform);
@ -155,10 +156,7 @@ cull_out_children_common (MetaCullable *cullable,
g_assert (reduced_region);
cairo_region_intersect (region, reduced_region);
cairo_region_destroy (actor_region);
cairo_region_destroy (reduced_region);
mtk_region_intersect (region, reduced_region);
}
else
{
@ -179,7 +177,7 @@ cull_out_children_common (MetaCullable *cullable,
*/
void
meta_cullable_cull_unobscured_children (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
cull_out_children_common (cullable,
unobscured_region,
@ -198,7 +196,7 @@ meta_cullable_cull_unobscured_children (MetaCullable *cullable,
*/
void
meta_cullable_cull_redraw_clip_children (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
cull_out_children_common (cullable,
clip_region,
@ -228,7 +226,7 @@ meta_cullable_default_init (MetaCullableInterface *iface)
*/
void
meta_cullable_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
META_CULLABLE_GET_IFACE (cullable)->cull_unobscured (cullable, unobscured_region);
}
@ -252,7 +250,7 @@ meta_cullable_cull_unobscured (MetaCullable *cullable,
*/
void
meta_cullable_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
META_CULLABLE_GET_IFACE (cullable)->cull_redraw_clip (cullable, clip_region);
}

View File

@ -36,20 +36,20 @@ struct _MetaCullableInterface
GTypeInterface g_iface;
void (* cull_unobscured) (MetaCullable *cullable,
cairo_region_t *unobscured_region);
MtkRegion *unobscured_region);
void (* cull_redraw_clip) (MetaCullable *cullable,
cairo_region_t *clip_region);
MtkRegion *clip_region);
};
void meta_cullable_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region);
MtkRegion *unobscured_region);
void meta_cullable_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region);
MtkRegion *clip_region);
/* Utility methods for implementations */
void meta_cullable_cull_unobscured_children (MetaCullable *cullable,
cairo_region_t *unobscured_region);
MtkRegion *unobscured_region);
void meta_cullable_cull_redraw_clip_children (MetaCullable *cullable,
cairo_region_t *clip_region);
MtkRegion *clip_region);
G_END_DECLS

View File

@ -200,7 +200,7 @@ meta_shadow_paint (MetaShadow *shadow,
int window_width,
int window_height,
guint8 opacity,
cairo_region_t *clip,
MtkRegion *clip,
gboolean clip_strictly)
{
float texture_width = cogl_texture_get_width (shadow->texture);
@ -212,7 +212,7 @@ meta_shadow_paint (MetaShadow *shadow,
int dest_y[4];
int n_x, n_y;
if (clip && cairo_region_is_empty (clip))
if (clip && mtk_region_is_empty (clip))
return;
cogl_pipeline_set_color4ub (shadow->pipeline,
@ -279,7 +279,7 @@ meta_shadow_paint (MetaShadow *shadow,
for (i = 0; i < n_x; i++)
{
cairo_region_overlap_t overlap;
MtkRegionOverlap overlap;
dest_rect.x = dest_x[i];
dest_rect.width = dest_x[i + 1] - dest_x[i];
@ -288,11 +288,11 @@ meta_shadow_paint (MetaShadow *shadow,
continue;
if (clip)
overlap = cairo_region_contains_rectangle (clip, &dest_rect);
overlap = mtk_region_contains_rectangle (clip, &dest_rect);
else
overlap = CAIRO_REGION_OVERLAP_IN;
overlap = MTK_REGION_OVERLAP_IN;
if (overlap == CAIRO_REGION_OVERLAP_OUT)
if (overlap == MTK_REGION_OVERLAP_OUT)
continue;
/* There's quite a bit of overhead from allocating a new
@ -301,8 +301,8 @@ meta_shadow_paint (MetaShadow *shadow,
* unless we have to clip strictly it will be cheaper to
* just draw the entire rectangle.
*/
if (overlap == CAIRO_REGION_OVERLAP_IN ||
(overlap == CAIRO_REGION_OVERLAP_PART && !clip_strictly))
if (overlap == MTK_REGION_OVERLAP_IN ||
(overlap == MTK_REGION_OVERLAP_PART && !clip_strictly))
{
cogl_framebuffer_draw_textured_rectangle (framebuffer,
shadow->pipeline,
@ -311,21 +311,21 @@ meta_shadow_paint (MetaShadow *shadow,
src_x[i], src_y[j],
src_x[i + 1], src_y[j + 1]);
}
else if (overlap == CAIRO_REGION_OVERLAP_PART)
else if (overlap == MTK_REGION_OVERLAP_PART)
{
cairo_region_t *intersection;
g_autoptr (MtkRegion) intersection = NULL;
int n_rectangles, k;
intersection = cairo_region_create_rectangle (&dest_rect);
cairo_region_intersect (intersection, clip);
intersection = mtk_region_create_rectangle (&dest_rect);
mtk_region_intersect (intersection, clip);
n_rectangles = cairo_region_num_rectangles (intersection);
n_rectangles = mtk_region_num_rectangles (intersection);
for (k = 0; k < n_rectangles; k++)
{
MtkRectangle rect;
float src_x1, src_x2, src_y1, src_y2;
cairo_region_get_rectangle (intersection, k, &rect);
rect = mtk_region_get_rectangle (intersection, k);
/* Separately linear interpolate X and Y coordinates in the source
* based on the destination X and Y coordinates */
@ -346,8 +346,6 @@ meta_shadow_paint (MetaShadow *shadow,
rect.x + rect.width, rect.y + rect.height,
src_x1, src_y1, src_x2, src_y2);
}
cairo_region_destroy (intersection);
}
}
}
@ -565,7 +563,7 @@ blur_xspan (guchar *row,
}
static void
blur_rows (cairo_region_t *convolve_region,
blur_rows (MtkRegion *convolve_region,
int x_offset,
int y_offset,
guchar *buffer,
@ -579,12 +577,12 @@ blur_rows (cairo_region_t *convolve_region,
tmp_buffer = g_malloc (buffer_width);
n_rectangles = cairo_region_num_rectangles (convolve_region);
n_rectangles = mtk_region_num_rectangles (convolve_region);
for (i = 0; i < n_rectangles; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (convolve_region, i, &rect);
rect = mtk_region_get_rectangle (convolve_region, i);
for (j = y_offset + rect.y; j < y_offset + rect.y + rect.height; j++)
{
@ -703,7 +701,7 @@ flip_buffer (guchar *buffer,
static void
make_shadow (MetaShadow *shadow,
cairo_region_t *region)
MtkRegion *region)
{
ClutterBackend *backend = clutter_get_default_backend ();
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
@ -711,8 +709,8 @@ make_shadow (MetaShadow *shadow,
int d = get_box_filter_size (shadow->key.radius);
int spread = get_shadow_spread (shadow->key.radius);
MtkRectangle extents;
cairo_region_t *row_convolve_region;
cairo_region_t *column_convolve_region;
g_autoptr (MtkRegion) row_convolve_region = NULL;
g_autoptr (MtkRegion) column_convolve_region = NULL;
guchar *buffer;
int buffer_width;
int buffer_height;
@ -720,7 +718,7 @@ make_shadow (MetaShadow *shadow,
int y_offset;
int n_rectangles, j, k;
cairo_region_get_extents (region, &extents);
extents = mtk_region_get_extents (region);
/* In the case where top_fade >= 0 and the portion above the top
* edge of the shape will be cropped, it seems like we could create
@ -760,12 +758,12 @@ make_shadow (MetaShadow *shadow,
y_offset = spread;
/* Step 1: unblurred image */
n_rectangles = cairo_region_num_rectangles (region);
n_rectangles = mtk_region_num_rectangles (region);
for (k = 0; k < n_rectangles; k++)
{
MtkRectangle rect;
cairo_region_get_rectangle (region, k, &rect);
rect = mtk_region_get_rectangle (region, k);
for (j = y_offset + rect.y; j < y_offset + rect.y + rect.height; j++)
memset (buffer + buffer_width * j + x_offset + rect.x, 255, rect.width);
}
@ -813,8 +811,6 @@ make_shadow (MetaShadow *shadow,
g_error_free (error);
}
cairo_region_destroy (row_convolve_region);
cairo_region_destroy (column_convolve_region);
g_free (buffer);
shadow->pipeline = meta_create_texture_pipeline (shadow->texture);
@ -880,7 +876,7 @@ meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
MetaShadowParams *params;
MetaShadowCacheKey key;
MetaShadow *shadow;
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
int spread;
int shape_border_top, shape_border_right, shape_border_bottom, shape_border_left;
int inner_border_top, inner_border_right, inner_border_bottom, inner_border_left;
@ -983,8 +979,6 @@ meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
region = meta_window_shape_to_region (shape, center_width, center_height);
make_shadow (shadow, region);
cairo_region_destroy (region);
if (cacheable)
g_hash_table_insert (factory->shadows, &shadow->key, shadow);

View File

@ -37,7 +37,7 @@ void meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
int fallback_width,
int fallback_height);
cairo_region_t * meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex);
MtkRegion * meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex);
gboolean meta_shaped_texture_is_opaque (MetaShapedTexture *stex);
gboolean meta_shaped_texture_has_alpha (MetaShapedTexture *stex);
void meta_shaped_texture_set_transform (MetaShapedTexture *stex,
@ -67,9 +67,9 @@ float meta_shaped_texture_get_unscaled_width (MetaShapedTexture *stex);
float meta_shaped_texture_get_unscaled_height (MetaShapedTexture *stex);
void meta_shaped_texture_set_clip_region (MetaShapedTexture *stex,
cairo_region_t *clip_region);
MtkRegion *clip_region);
void meta_shaped_texture_set_opaque_region (MetaShapedTexture *stex,
cairo_region_t *opaque_region);
MtkRegion *opaque_region);
void meta_shaped_texture_ensure_size_valid (MetaShapedTexture *stex);

View File

@ -88,10 +88,10 @@ struct _MetaShapedTexture
gboolean is_y_inverted;
/* The region containing only fully opaque pixels */
cairo_region_t *opaque_region;
MtkRegion *opaque_region;
/* MetaCullable regions, see that documentation for more details */
cairo_region_t *clip_region;
MtkRegion *clip_region;
gboolean size_invalid;
MetaMonitorTransform transform;
@ -216,11 +216,11 @@ meta_shaped_texture_ensure_size_valid (MetaShapedTexture *stex)
void
meta_shaped_texture_set_clip_region (MetaShapedTexture *stex,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
g_clear_pointer (&stex->clip_region, cairo_region_destroy);
g_clear_pointer (&stex->clip_region, mtk_region_unref);
if (clip_region)
stex->clip_region = cairo_region_reference (clip_region);
stex->clip_region = mtk_region_ref (clip_region);
}
static void
@ -248,8 +248,8 @@ meta_shaped_texture_dispose (GObject *object)
meta_shaped_texture_set_mask_texture (stex, NULL);
meta_shaped_texture_reset_pipelines (stex);
g_clear_pointer (&stex->opaque_region, cairo_region_destroy);
g_clear_pointer (&stex->clip_region, cairo_region_destroy);
g_clear_pointer (&stex->opaque_region, mtk_region_unref);
g_clear_pointer (&stex->clip_region, mtk_region_unref);
g_clear_pointer (&stex->snippet, g_object_unref);
@ -627,7 +627,7 @@ do_paint_content (MetaShapedTexture *stex,
int dst_width, dst_height;
MtkRectangle content_rect;
gboolean use_opaque_region;
cairo_region_t *blended_tex_region;
MtkRegion *blended_tex_region;
CoglContext *ctx;
CoglPipelineFilter min_filter, mag_filter;
MetaTransforms transforms;
@ -710,16 +710,16 @@ do_paint_content (MetaShapedTexture *stex,
if (use_opaque_region)
{
if (stex->clip_region)
blended_tex_region = cairo_region_copy (stex->clip_region);
blended_tex_region = mtk_region_copy (stex->clip_region);
else
blended_tex_region = cairo_region_create_rectangle (&content_rect);
blended_tex_region = mtk_region_create_rectangle (&content_rect);
cairo_region_subtract (blended_tex_region, stex->opaque_region);
mtk_region_subtract (blended_tex_region, stex->opaque_region);
}
else
{
if (stex->clip_region)
blended_tex_region = cairo_region_reference (stex->clip_region);
blended_tex_region = mtk_region_ref (stex->clip_region);
else
blended_tex_region = NULL;
}
@ -730,13 +730,13 @@ do_paint_content (MetaShapedTexture *stex,
if (blended_tex_region)
{
int n_rects = cairo_region_num_rectangles (blended_tex_region);
int n_rects = mtk_region_num_rectangles (blended_tex_region);
if (n_rects > MAX_RECTS)
{
/* Fall back to taking the fully blended path. */
use_opaque_region = FALSE;
g_clear_pointer (&blended_tex_region, cairo_region_destroy);
g_clear_pointer (&blended_tex_region, mtk_region_unref);
}
}
@ -745,21 +745,21 @@ do_paint_content (MetaShapedTexture *stex,
/* First, paint the unblended parts, which are part of the opaque region. */
if (use_opaque_region)
{
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
int n_rects;
int i;
if (stex->clip_region)
{
region = cairo_region_copy (stex->clip_region);
cairo_region_intersect (region, stex->opaque_region);
region = mtk_region_copy (stex->clip_region);
mtk_region_intersect (region, stex->opaque_region);
}
else
{
region = cairo_region_reference (stex->opaque_region);
region = mtk_region_ref (stex->opaque_region);
}
if (!cairo_region_is_empty (region))
if (!mtk_region_is_empty (region))
{
CoglPipeline *opaque_pipeline;
@ -774,11 +774,11 @@ do_paint_content (MetaShapedTexture *stex,
min_filter, mag_filter);
}
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
paint_clipped_rectangle_node (stex, root_node,
opaque_pipeline,
&rect, alloc);
@ -794,8 +794,6 @@ do_paint_content (MetaShapedTexture *stex,
}
}
}
cairo_region_destroy (region);
}
/* Now, go ahead and paint the blended parts. */
@ -808,7 +806,7 @@ do_paint_content (MetaShapedTexture *stex,
* 1) and 3) are the times where we have to paint stuff. This tests
* for 1) and 3).
*/
if (!blended_tex_region || !cairo_region_is_empty (blended_tex_region))
if (!blended_tex_region || !mtk_region_is_empty (blended_tex_region))
{
CoglPipeline *blended_pipeline;
CoglColor color;
@ -840,12 +838,12 @@ do_paint_content (MetaShapedTexture *stex,
{
/* 1) blended_tex_region is not empty. Paint the rectangles. */
int i;
int n_rects = cairo_region_num_rectangles (blended_tex_region);
int n_rects = mtk_region_num_rectangles (blended_tex_region);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (blended_tex_region, i, &rect);
rect = mtk_region_get_rectangle (blended_tex_region, i);
if (!mtk_rectangle_intersect (&content_rect, &rect, &rect))
continue;
@ -892,7 +890,7 @@ do_paint_content (MetaShapedTexture *stex,
}
}
g_clear_pointer (&blended_tex_region, cairo_region_destroy);
g_clear_pointer (&blended_tex_region, mtk_region_unref);
}
static void
@ -905,7 +903,7 @@ meta_shaped_texture_paint_content (ClutterContent *content,
ClutterActorBox alloc;
uint8_t opacity;
if (stex->clip_region && cairo_region_is_empty (stex->clip_region))
if (stex->clip_region && mtk_region_is_empty (stex->clip_region))
return;
/* The GL EXT_texture_from_pixmap extension does allow for it to be
@ -1190,14 +1188,14 @@ meta_shaped_texture_get_texture (MetaShapedTexture *stex)
*/
void
meta_shaped_texture_set_opaque_region (MetaShapedTexture *stex,
cairo_region_t *opaque_region)
MtkRegion *opaque_region)
{
g_clear_pointer (&stex->opaque_region, cairo_region_destroy);
g_clear_pointer (&stex->opaque_region, mtk_region_unref);
if (opaque_region)
stex->opaque_region = cairo_region_reference (opaque_region);
stex->opaque_region = mtk_region_ref (opaque_region);
}
cairo_region_t *
MtkRegion *
meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex)
{
return stex->opaque_region;
@ -1248,18 +1246,16 @@ meta_shaped_texture_is_opaque (MetaShapedTexture *stex)
if (!stex->opaque_region)
return FALSE;
if (cairo_region_num_rectangles (stex->opaque_region) != 1)
if (mtk_region_num_rectangles (stex->opaque_region) != 1)
return FALSE;
cairo_region_get_extents (stex->opaque_region, &opaque_rect);
opaque_rect = mtk_region_get_extents (stex->opaque_region);
meta_shaped_texture_ensure_size_valid (stex);
return mtk_rectangle_equal (&opaque_rect,
&(MtkRectangle) {
.width = stex->dst_width,
.height = stex->dst_height
});
&MTK_RECTANGLE_INIT (0, 0,
stex->dst_width, stex->dst_height));
}
void

View File

@ -42,14 +42,14 @@ typedef struct _MetaSurfaceActorPrivate
{
MetaShapedTexture *texture;
cairo_region_t *input_region;
MtkRegion *input_region;
/* MetaCullable regions, see that documentation for more details */
cairo_region_t *unobscured_region;
MtkRegion *unobscured_region;
gboolean is_obscured;
/* Freeze/thaw accounting */
cairo_region_t *pending_damage;
MtkRegion *pending_damage;
guint frozen : 1;
} MetaSurfaceActorPrivate;
@ -75,7 +75,7 @@ typedef enum
IN_ACTOR_PERSPECTIVE
} ScalePerspectiveType;
static cairo_region_t *
static MtkRegion *
effective_unobscured_region (MetaSurfaceActor *surface_actor)
{
MetaSurfaceActorPrivate *priv =
@ -94,13 +94,13 @@ update_is_obscured (MetaSurfaceActor *surface_actor)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor);
cairo_region_t *unobscured_region;
MtkRegion *unobscured_region;
gboolean is_obscured;
unobscured_region = priv->unobscured_region;
if (unobscured_region)
is_obscured = cairo_region_is_empty (unobscured_region);
is_obscured = mtk_region_is_empty (unobscured_region);
else
is_obscured = FALSE;
@ -114,17 +114,17 @@ update_is_obscured (MetaSurfaceActor *surface_actor)
static void
set_unobscured_region (MetaSurfaceActor *surface_actor,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor);
g_clear_pointer (&priv->unobscured_region, cairo_region_destroy);
g_clear_pointer (&priv->unobscured_region, mtk_region_unref);
if (unobscured_region)
{
if (cairo_region_is_empty (unobscured_region))
if (mtk_region_is_empty (unobscured_region))
{
priv->unobscured_region = cairo_region_reference (unobscured_region);
priv->unobscured_region = mtk_region_ref (unobscured_region);
}
else
{
@ -139,9 +139,9 @@ set_unobscured_region (MetaSurfaceActor *surface_actor,
.height = height,
};
priv->unobscured_region = cairo_region_copy (unobscured_region);
priv->unobscured_region = mtk_region_copy (unobscured_region);
cairo_region_intersect_rectangle (priv->unobscured_region, &bounds);
mtk_region_intersect_rectangle (priv->unobscured_region, &bounds);
}
}
@ -150,26 +150,18 @@ set_unobscured_region (MetaSurfaceActor *surface_actor,
static void
set_clip_region (MetaSurfaceActor *surface_actor,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor);
MetaShapedTexture *stex = priv->texture;
if (clip_region && !cairo_region_is_empty (clip_region))
{
cairo_region_t *clip_region_copy;
clip_region_copy = cairo_region_copy (clip_region);
meta_shaped_texture_set_clip_region (stex, clip_region_copy);
cairo_region_destroy (clip_region_copy);
}
if (clip_region && !mtk_region_is_empty (clip_region))
meta_shaped_texture_set_clip_region (stex,
mtk_region_copy (clip_region));
else
{
meta_shaped_texture_set_clip_region (stex, clip_region);
}
}
static void
meta_surface_actor_pick (ClutterActor *actor,
@ -197,14 +189,14 @@ meta_surface_actor_pick (ClutterActor *actor,
int n_rects;
int i;
n_rects = cairo_region_num_rectangles (priv->input_region);
n_rects = mtk_region_num_rectangles (priv->input_region);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
ClutterActorBox box;
cairo_region_get_rectangle (priv->input_region, i, &rect);
rect = mtk_region_get_rectangle (priv->input_region, i);
box.x1 = rect.x;
box.y1 = rect.y;
@ -255,7 +247,7 @@ meta_surface_actor_dispose (GObject *object)
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
g_clear_pointer (&priv->input_region, cairo_region_destroy);
g_clear_pointer (&priv->input_region, mtk_region_unref);
g_clear_object (&priv->texture);
set_unobscured_region (self, NULL);
@ -306,7 +298,7 @@ meta_surface_actor_is_opaque (MetaSurfaceActor *self)
static void
subtract_opaque_region (MetaSurfaceActor *surface_actor,
cairo_region_t *region)
MtkRegion *region)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor);
@ -317,20 +309,20 @@ subtract_opaque_region (MetaSurfaceActor *surface_actor,
if (opacity == 0xff)
{
cairo_region_t *opaque_region;
MtkRegion *opaque_region;
opaque_region = meta_shaped_texture_get_opaque_region (priv->texture);
if (!opaque_region)
return;
cairo_region_subtract (region, opaque_region);
mtk_region_subtract (region, opaque_region);
}
}
static void
meta_surface_actor_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
MetaSurfaceActor *surface_actor = META_SURFACE_ACTOR (cullable);
@ -341,7 +333,7 @@ meta_surface_actor_cull_redraw_clip (MetaCullable *cullable,
static void
meta_surface_actor_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
MetaSurfaceActor *surface_actor = META_SURFACE_ACTOR (cullable);
@ -404,37 +396,35 @@ meta_surface_actor_update_area (MetaSurfaceActor *self,
if (meta_shaped_texture_update_area (priv->texture, x, y, width, height, &clip))
{
cairo_region_t *unobscured_region;
MtkRegion *unobscured_region;
unobscured_region = effective_unobscured_region (self);
if (unobscured_region)
{
cairo_region_t *intersection;
g_autoptr (MtkRegion) intersection = NULL;
if (cairo_region_is_empty (unobscured_region))
if (mtk_region_is_empty (unobscured_region))
return;
intersection = cairo_region_copy (unobscured_region);
cairo_region_intersect_rectangle (intersection, &clip);
intersection = mtk_region_copy (unobscured_region);
mtk_region_intersect_rectangle (intersection, &clip);
if (!cairo_region_is_empty (intersection))
if (!mtk_region_is_empty (intersection))
{
int i, n_rectangles;
n_rectangles = cairo_region_num_rectangles (intersection);
n_rectangles = mtk_region_num_rectangles (intersection);
for (i = 0; i < n_rectangles; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (intersection, i, &rect);
rect = mtk_region_get_rectangle (intersection, i);
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (self), &rect);
}
repaint_scheduled = TRUE;
}
cairo_region_destroy (intersection);
}
else
{
@ -473,7 +463,7 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
ClutterStageView *stage_view,
float *unobscurred_fraction)
{
cairo_region_t *unobscured_region;
MtkRegion *unobscured_region;
unobscured_region = effective_unobscured_region (self);
@ -482,7 +472,7 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
ClutterActor *stage = clutter_actor_get_stage (CLUTTER_ACTOR (self));
cairo_region_t *intersection_region;
g_autoptr (MtkRegion) intersection_region = NULL;
MtkRectangle stage_rect;
graphene_matrix_t transform;
graphene_rect_t actor_bounds;
@ -491,7 +481,7 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
int intersection_size = 0;
int n_rects, i;
if (cairo_region_is_empty (unobscured_region))
if (mtk_region_is_empty (unobscured_region))
return TRUE;
clutter_actor_get_relative_transformation_matrix (CLUTTER_ACTOR (self),
@ -501,19 +491,13 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
intersection_region = meta_region_apply_matrix_transform_expand (unobscured_region, &transform);
clutter_stage_view_get_layout (stage_view, &stage_rect);
cairo_region_intersect_rectangle (intersection_region,
mtk_region_intersect_rectangle (intersection_region,
&stage_rect);
if (cairo_region_is_empty (intersection_region))
{
cairo_region_destroy (intersection_region);
if (mtk_region_is_empty (intersection_region))
return TRUE;
}
else if (!unobscurred_fraction)
{
cairo_region_destroy (intersection_region);
return FALSE;
}
clutter_content_get_preferred_size (CLUTTER_CONTENT (priv->texture),
&bounds_width,
@ -523,15 +507,14 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
graphene_rect_round_extents (&actor_bounds, &actor_bounds);
bounds_size = graphene_rect_get_area (&actor_bounds);
n_rects = cairo_region_num_rectangles (intersection_region);
n_rects = mtk_region_num_rectangles (intersection_region);
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (intersection_region, i, &rect);
rect = mtk_region_get_rectangle (intersection_region, i);
intersection_size += rect.width * rect.height;
}
cairo_region_destroy (intersection_region);
g_return_val_if_fail (bounds_size > 0, FALSE);
@ -545,23 +528,22 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
void
meta_surface_actor_set_input_region (MetaSurfaceActor *self,
cairo_region_t *region)
MtkRegion *region)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
if (priv->input_region)
cairo_region_destroy (priv->input_region);
g_clear_pointer (&priv->input_region, mtk_region_unref);
if (region)
priv->input_region = cairo_region_reference (region);
priv->input_region = mtk_region_ref (region);
else
priv->input_region = NULL;
}
void
meta_surface_actor_set_opaque_region (MetaSurfaceActor *self,
cairo_region_t *region)
MtkRegion *region)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
@ -569,7 +551,7 @@ meta_surface_actor_set_opaque_region (MetaSurfaceActor *self,
meta_shaped_texture_set_opaque_region (priv->texture, region);
}
cairo_region_t *
MtkRegion *
meta_surface_actor_get_opaque_region (MetaSurfaceActor *self)
{
MetaSurfaceActorPrivate *priv =
@ -580,7 +562,10 @@ meta_surface_actor_get_opaque_region (MetaSurfaceActor *self)
void
meta_surface_actor_process_damage (MetaSurfaceActor *self,
int x, int y, int width, int height)
int x,
int y,
int width,
int height)
{
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
@ -603,9 +588,9 @@ meta_surface_actor_process_damage (MetaSurfaceActor *self,
MtkRectangle rect = { .x = x, .y = y, .width = width, .height = height };
if (!priv->pending_damage)
priv->pending_damage = cairo_region_create_rectangle (&rect);
priv->pending_damage = mtk_region_create_rectangle (&rect);
else
cairo_region_union_rectangle (priv->pending_damage, &rect);
mtk_region_union_rectangle (priv->pending_damage, &rect);
return;
}
@ -626,7 +611,7 @@ meta_surface_actor_set_frozen (MetaSurfaceActor *self,
if (!frozen && priv->pending_damage)
{
int i, n_rects = cairo_region_num_rectangles (priv->pending_damage);
int i, n_rects = mtk_region_num_rectangles (priv->pending_damage);
MtkRectangle rect;
/* Since we ignore damage events while a window is frozen for certain effects
@ -634,11 +619,11 @@ meta_surface_actor_set_frozen (MetaSurfaceActor *self,
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (priv->pending_damage, i, &rect);
rect = mtk_region_get_rectangle (priv->pending_damage, i);
meta_surface_actor_process_damage (self, rect.x, rect.y,
rect.width, rect.height);
}
g_clear_pointer (&priv->pending_damage, cairo_region_destroy);
g_clear_pointer (&priv->pending_damage, mtk_region_unref);
}
}

View File

@ -43,10 +43,10 @@ gboolean meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
float *unobscurred_fraction);
void meta_surface_actor_set_input_region (MetaSurfaceActor *self,
cairo_region_t *region);
MtkRegion *region);
void meta_surface_actor_set_opaque_region (MetaSurfaceActor *self,
cairo_region_t *region);
cairo_region_t * meta_surface_actor_get_opaque_region (MetaSurfaceActor *self);
MtkRegion *region);
MtkRegion * meta_surface_actor_get_opaque_region (MetaSurfaceActor *self);
void meta_surface_actor_process_damage (MetaSurfaceActor *actor,
int x, int y, int width, int height);

View File

@ -79,14 +79,14 @@ surface_container_new (MetaWindowActor *window_actor)
static void
surface_container_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
meta_cullable_cull_unobscured_children (cullable, unobscured_region);
}
static void
surface_container_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
meta_cullable_cull_redraw_clip_children (cullable, clip_region);
}
@ -273,7 +273,7 @@ meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor)
&traverse_data);
}
static cairo_region_t *
static MtkRegion *
calculate_background_cull_region (MetaWindowActorWayland *self)
{
MetaWindowActor *window_actor = META_WINDOW_ACTOR (self);
@ -288,12 +288,12 @@ calculate_background_cull_region (MetaWindowActorWayland *self)
.height = clutter_actor_get_height (self->background) * geometry_scale,
};
return cairo_region_create_rectangle (&rect);
return mtk_region_create_rectangle (&rect);
}
static void
subtract_background_opaque_region (MetaWindowActorWayland *self,
cairo_region_t *region)
MtkRegion *region)
{
if (!region)
return;
@ -301,19 +301,17 @@ subtract_background_opaque_region (MetaWindowActorWayland *self,
if (self->background &&
clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self)) == 0xff)
{
cairo_region_t *background_cull_region;
g_autoptr (MtkRegion) background_cull_region = NULL;
background_cull_region = calculate_background_cull_region (self);
cairo_region_subtract (region, background_cull_region);
cairo_region_destroy (background_cull_region);
mtk_region_subtract (region, background_cull_region);
}
}
static void
meta_window_actor_wayland_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
MetaWindowActorWayland *self =
META_WINDOW_ACTOR_WAYLAND (cullable);
@ -325,7 +323,7 @@ meta_window_actor_wayland_cull_unobscured (MetaCullable *cullable,
static void
meta_window_actor_wayland_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
MetaWindowActorWayland *self =
META_WINDOW_ACTOR_WAYLAND (cullable);

View File

@ -77,11 +77,11 @@ struct _MetaWindowActorX11
MetaShadow *unfocused_shadow;
/* A region that matches the shape of the window, including frame bounds */
cairo_region_t *shape_region;
MtkRegion *shape_region;
/* The region we should clip to when painting the shadow */
cairo_region_t *shadow_clip;
MtkRegion *shadow_clip;
/* The frame region */
cairo_region_t *frame_bounds;
MtkRegion *frame_bounds;
/* Extracted size-invariant shape used for shadows */
MetaWindowShape *shadow_shape;
@ -523,7 +523,7 @@ static void
get_shape_bounds (MetaWindowActorX11 *actor_x11,
MtkRectangle *bounds)
{
cairo_region_get_extents (actor_x11->shape_region, bounds);
*bounds = mtk_region_get_extents (actor_x11->shape_region);
}
static void
@ -587,7 +587,7 @@ clip_shadow_under_window (MetaWindowActorX11 *actor_x11)
*/
static void
set_clip_region_beneath (MetaWindowActorX11 *actor_x11,
cairo_region_t *beneath_region)
MtkRegion *beneath_region)
{
MetaWindow *window;
gboolean appears_focused;
@ -596,16 +596,16 @@ set_clip_region_beneath (MetaWindowActorX11 *actor_x11,
appears_focused = meta_window_appears_focused (window);
if (appears_focused ? actor_x11->focused_shadow : actor_x11->unfocused_shadow)
{
g_clear_pointer (&actor_x11->shadow_clip, cairo_region_destroy);
g_clear_pointer (&actor_x11->shadow_clip, mtk_region_unref);
if (beneath_region)
{
actor_x11->shadow_clip = cairo_region_copy (beneath_region);
actor_x11->shadow_clip = mtk_region_copy (beneath_region);
if (clip_shadow_under_window (actor_x11))
{
if (actor_x11->frame_bounds)
cairo_region_subtract (actor_x11->shadow_clip, actor_x11->frame_bounds);
mtk_region_subtract (actor_x11->shadow_clip, actor_x11->frame_bounds);
}
}
else
@ -699,12 +699,12 @@ meta_window_actor_x11_process_damage (MetaWindowActorX11 *actor_x11,
meta_window_actor_notify_damaged (META_WINDOW_ACTOR (actor_x11));
}
static cairo_region_t *
static MtkRegion *
scan_visible_region (guchar *mask_data,
int stride,
cairo_region_t *scan_area)
MtkRegion *scan_area)
{
int i, n_rects = cairo_region_num_rectangles (scan_area);
int i, n_rects = mtk_region_num_rectangles (scan_area);
MetaRegionBuilder builder;
meta_region_builder_init (&builder);
@ -714,7 +714,7 @@ scan_visible_region (guchar *mask_data,
int x, y;
MtkRectangle rect;
cairo_region_get_rectangle (scan_area, i, &rect);
rect = mtk_region_get_rectangle (scan_area, i);
for (y = rect.y; y < (rect.y + rect.height); y++)
{
@ -773,7 +773,7 @@ get_client_area_rect (MetaWindowActorX11 *actor_x11,
static void
build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
cairo_region_t *shape_region)
MtkRegion *shape_region)
{
ClutterBackend *backend = clutter_get_default_backend ();
MetaWindow *window =
@ -815,7 +815,8 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
if (window->frame)
{
cairo_region_t *frame_paint_region, *scanned_region;
g_autoptr (MtkRegion) frame_paint_region = NULL;
g_autoptr (MtkRegion) scanned_region = NULL;
MtkRectangle rect = { 0, 0, tex_width, tex_height };
MtkRectangle client_area;
MtkRectangle frame_rect;
@ -838,8 +839,8 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
}
/* Make sure we don't paint the frame over the client window. */
frame_paint_region = cairo_region_create_rectangle (&rect);
cairo_region_subtract_rectangle (frame_paint_region, &client_area);
frame_paint_region = mtk_region_create_rectangle (&rect);
mtk_region_subtract_rectangle (frame_paint_region, &client_area);
meta_region_to_cairo_path (frame_paint_region, cr);
cairo_clip (cr);
@ -848,9 +849,7 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11,
cairo_surface_flush (image);
scanned_region = scan_visible_region (mask_data, stride, frame_paint_region);
cairo_region_union (shape_region, scanned_region);
cairo_region_destroy (scanned_region);
cairo_region_destroy (frame_paint_region);
mtk_region_union (shape_region, scanned_region);
}
cairo_destroy (cr);
@ -897,32 +896,32 @@ update_shape_region (MetaWindowActorX11 *actor_x11)
{
MetaWindow *window =
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
cairo_region_t *region = NULL;
MtkRegion *region = NULL;
MtkRectangle client_area;
get_client_area_rect (actor_x11, &client_area);
if (window->frame && window->shape_region)
{
region = cairo_region_copy (window->shape_region);
cairo_region_translate (region, client_area.x, client_area.y);
region = mtk_region_copy (window->shape_region);
mtk_region_translate (region, client_area.x, client_area.y);
}
else if (window->shape_region != NULL)
{
region = cairo_region_reference (window->shape_region);
region = mtk_region_ref (window->shape_region);
}
else
{
/* If we don't have a shape on the server, that means that
* we have an implicit shape of one rectangle covering the
* entire window. */
region = cairo_region_create_rectangle (&client_area);
region = mtk_region_create_rectangle (&client_area);
}
if (window->shape_region || window->frame)
build_and_scan_frame_mask (actor_x11, region);
g_clear_pointer (&actor_x11->shape_region, cairo_region_destroy);
g_clear_pointer (&actor_x11->shape_region, mtk_region_unref);
actor_x11->shape_region = region;
g_clear_pointer (&actor_x11->shadow_shape, meta_window_shape_unref);
@ -937,24 +936,23 @@ update_input_region (MetaWindowActorX11 *actor_x11)
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
MetaSurfaceActor *surface =
meta_window_actor_get_surface (META_WINDOW_ACTOR (actor_x11));
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
if (window->shape_region && window->input_region)
{
MtkRectangle client_area;
cairo_region_t *frames_input;
cairo_region_t *client_input;
g_autoptr (MtkRegion) frames_input = NULL;
g_autoptr (MtkRegion) client_input = NULL;
get_client_area_rect (actor_x11, &client_area);
frames_input = cairo_region_copy (window->input_region);
cairo_region_subtract_rectangle (frames_input, &client_area);
frames_input = mtk_region_copy (window->input_region);
mtk_region_subtract_rectangle (frames_input, &client_area);
client_input = cairo_region_copy (actor_x11->shape_region);
cairo_region_intersect (client_input, window->input_region);
client_input = mtk_region_copy (actor_x11->shape_region);
mtk_region_intersect (client_input, window->input_region);
cairo_region_union (frames_input, client_input);
cairo_region_destroy (client_input);
mtk_region_union (frames_input, client_input);
region = g_steal_pointer (&frames_input);
}
@ -964,20 +962,15 @@ update_input_region (MetaWindowActorX11 *actor_x11)
meta_window_get_client_area_rect (window, &client_area);
region = cairo_region_copy (window->shape_region);
cairo_region_translate (region, client_area.x, client_area.y);
region = mtk_region_copy (window->shape_region);
mtk_region_translate (region, client_area.x, client_area.y);
}
else if (window->input_region)
{
region = cairo_region_reference (window->input_region);
}
region = mtk_region_ref (window->input_region);
else
{
region = NULL;
}
meta_surface_actor_set_input_region (surface, region);
cairo_region_destroy (region);
}
static gboolean
@ -1007,7 +1000,7 @@ update_opaque_region (MetaWindowActorX11 *actor_x11)
MetaWindow *window =
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
gboolean is_maybe_transparent;
cairo_region_t *opaque_region = NULL;
g_autoptr (MtkRegion) opaque_region = NULL;
MetaSurfaceActor *surface;
is_maybe_transparent = is_actor_maybe_transparent (actor_x11);
@ -1018,16 +1011,16 @@ update_opaque_region (MetaWindowActorX11 *actor_x11)
MtkRectangle client_area;
if (window->frame && window->frame->opaque_region)
opaque_region = cairo_region_copy (window->frame->opaque_region);
opaque_region = mtk_region_copy (window->frame->opaque_region);
get_client_area_rect (actor_x11, &client_area);
if (opaque_region && meta_window_x11_has_alpha_channel (window))
cairo_region_subtract_rectangle (opaque_region, &client_area);
mtk_region_subtract_rectangle (opaque_region, &client_area);
if (window->opaque_region)
{
cairo_region_t *client_opaque_region;
g_autoptr (MtkRegion) client_opaque_region = NULL;
/* The opaque region is defined to be a part of the
* window which ARGB32 will always paint with opaque
@ -1039,28 +1032,25 @@ update_opaque_region (MetaWindowActorX11 *actor_x11)
* to be undefined, and considered a client bug. In mutter's
* case, graphical glitches will occur.
*/
client_opaque_region = cairo_region_copy (window->opaque_region);
cairo_region_translate (client_opaque_region,
client_opaque_region = mtk_region_copy (window->opaque_region);
mtk_region_translate (client_opaque_region,
client_area.x, client_area.y);
if (opaque_region)
cairo_region_union (opaque_region, client_opaque_region);
mtk_region_union (opaque_region, client_opaque_region);
else
opaque_region = cairo_region_reference (client_opaque_region);
cairo_region_destroy (client_opaque_region);
opaque_region = mtk_region_ref (client_opaque_region);
}
cairo_region_intersect (opaque_region, actor_x11->shape_region);
mtk_region_intersect (opaque_region, actor_x11->shape_region);
}
else if (!is_maybe_transparent)
{
opaque_region = cairo_region_reference (actor_x11->shape_region);
opaque_region = mtk_region_ref (actor_x11->shape_region);
}
surface = meta_window_actor_get_surface (META_WINDOW_ACTOR (actor_x11));
meta_surface_actor_set_opaque_region (surface, opaque_region);
cairo_region_destroy (opaque_region);
}
static void
@ -1068,11 +1058,11 @@ update_frame_bounds (MetaWindowActorX11 *actor_x11)
{
MetaWindow *window =
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
cairo_region_t *frame_bounds = meta_window_get_frame_bounds (window);
g_clear_pointer (&actor_x11->frame_bounds, cairo_region_destroy);
MtkRegion *frame_bounds = meta_window_get_frame_bounds (window);
g_clear_pointer (&actor_x11->frame_bounds, mtk_region_unref);
if (frame_bounds)
actor_x11->frame_bounds = cairo_region_copy (frame_bounds);
actor_x11->frame_bounds = mtk_region_copy (frame_bounds);
}
static void
@ -1214,7 +1204,7 @@ meta_window_actor_x11_paint (ClutterActor *actor,
{
MetaShadowParams params;
MtkRectangle shape_bounds;
cairo_region_t *clip = actor_x11->shadow_clip;
MtkRegion *clip = actor_x11->shadow_clip;
CoglFramebuffer *framebuffer;
get_shape_bounds (actor_x11, &shape_bounds);
@ -1228,10 +1218,10 @@ meta_window_actor_x11_paint (ClutterActor *actor,
MtkRectangle bounds;
get_shadow_bounds (actor_x11, appears_focused, &bounds);
clip = cairo_region_create_rectangle (&bounds);
clip = mtk_region_create_rectangle (&bounds);
if (actor_x11->frame_bounds)
cairo_region_subtract (clip, actor_x11->frame_bounds);
mtk_region_subtract (clip, actor_x11->frame_bounds);
}
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
@ -1247,7 +1237,7 @@ meta_window_actor_x11_paint (ClutterActor *actor,
clip_shadow_under_window (actor_x11));
if (clip && clip != actor_x11->shadow_clip)
cairo_region_destroy (clip);
mtk_region_unref (clip);
}
CLUTTER_ACTOR_CLASS (meta_window_actor_x11_parent_class)->paint (actor,
@ -1487,7 +1477,7 @@ meta_window_actor_x11_constructed (GObject *object)
* Start off with an empty shape region to maintain the invariant that it's
* always set.
*/
actor_x11->shape_region = cairo_region_create ();
actor_x11->shape_region = mtk_region_create ();
G_OBJECT_CLASS (meta_window_actor_x11_parent_class)->constructed (object);
@ -1504,14 +1494,14 @@ meta_window_actor_x11_constructed (GObject *object)
static void
meta_window_actor_x11_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
meta_cullable_cull_unobscured_children (cullable, unobscured_region);
}
static void
meta_window_actor_x11_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
MetaWindowActorX11 *self = META_WINDOW_ACTOR_X11 (cullable);
@ -1549,9 +1539,9 @@ meta_window_actor_x11_dispose (GObject *object)
CLUTTER_ACTOR (surface_actor));
}
g_clear_pointer (&actor_x11->shape_region, cairo_region_destroy);
g_clear_pointer (&actor_x11->shadow_clip, cairo_region_destroy);
g_clear_pointer (&actor_x11->frame_bounds, cairo_region_destroy);
g_clear_pointer (&actor_x11->shape_region, mtk_region_unref);
g_clear_pointer (&actor_x11->shadow_clip, mtk_region_unref);
g_clear_pointer (&actor_x11->frame_bounds, mtk_region_unref);
g_clear_pointer (&actor_x11->shadow_class, g_free);
g_clear_pointer (&actor_x11->focused_shadow, meta_shadow_unref);

View File

@ -32,14 +32,14 @@ G_DEFINE_TYPE_WITH_CODE (MetaWindowGroup, meta_window_group, CLUTTER_TYPE_ACTOR,
static void
meta_window_group_cull_unobscured (MetaCullable *cullable,
cairo_region_t *unobscured_region)
MtkRegion *unobscured_region)
{
meta_cullable_cull_unobscured_children (cullable, unobscured_region);
}
static void
meta_window_group_cull_redraw_clip (MetaCullable *cullable,
cairo_region_t *clip_region)
MtkRegion *clip_region)
{
meta_cullable_cull_redraw_clip_children (cullable, clip_region);
}
@ -59,8 +59,8 @@ meta_window_group_paint (ClutterActor *actor,
ClutterActorClass *parent_actor_class =
CLUTTER_ACTOR_CLASS (meta_window_group_parent_class);
ClutterActor *stage = clutter_actor_get_stage (actor);
const cairo_region_t *redraw_clip;
cairo_region_t *clip_region;
const MtkRegion *redraw_clip;
g_autoptr (MtkRegion) clip_region = NULL;
graphene_matrix_t stage_to_actor;
redraw_clip = clutter_paint_context_get_redraw_clip (paint_context);
@ -125,8 +125,6 @@ meta_window_group_paint (ClutterActor *actor,
meta_cullable_cull_redraw_clip (META_CULLABLE (window_group), clip_region);
cairo_region_destroy (clip_region);
parent_actor_class->paint (actor, paint_context);
meta_cullable_cull_redraw_clip (META_CULLABLE (window_group), NULL);

View File

@ -40,7 +40,7 @@ struct _MetaWindowShape
};
MetaWindowShape *
meta_window_shape_new (cairo_region_t *region)
meta_window_shape_new (MtkRegion *region)
{
MetaWindowShape *shape;
MetaRegionIterator iter;
@ -54,9 +54,9 @@ meta_window_shape_new (cairo_region_t *region)
shape = g_new0 (MetaWindowShape, 1);
shape->ref_count = 1;
cairo_region_get_extents (region, &extents);
extents = mtk_region_get_extents (region);
shape->n_rectangles = cairo_region_num_rectangles (region);
shape->n_rectangles = mtk_region_num_rectangles (region);
if (shape->n_rectangles == 0)
{
@ -220,20 +220,20 @@ meta_window_shape_get_borders (MetaWindowShape *shape,
* @center_width: size of the central region horizontally
* @center_height: size of the central region vertically
*
* Converts the shape to to a cairo_region_t using the given width
* Converts the shape to to a MtkRegion using the given width
* and height for the central scaled region.
*
* Return value: a newly created region
*/
cairo_region_t *
MtkRegion *
meta_window_shape_to_region (MetaWindowShape *shape,
int center_width,
int center_height)
{
cairo_region_t *region;
MtkRegion *region;
int i;
region = cairo_region_create ();
region = mtk_region_create ();
for (i = 0; i < shape->n_rectangles; i++)
{
@ -249,7 +249,7 @@ meta_window_shape_to_region (MetaWindowShape *shape,
else if (rect.y >= shape->top + 1)
rect.y += center_height;
cairo_region_union_rectangle (region, &rect);
mtk_region_union_rectangle (region, &rect);
}
return region;

View File

@ -39,7 +39,7 @@
/* Various algorithms in this file require unioning together a set of rectangles
* that are unsorted or overlap; unioning such a set of rectangles 1-by-1
* using cairo_region_union_rectangle() produces O(N^2) behavior (if the union
* using mtk_region_union_rectangle() produces O(N^2) behavior (if the union
* adds or removes rectangles in the middle of the region, then it has to
* move all the rectangles after that.) To avoid this behavior, MetaRegionBuilder
* creates regions for small groups of rectangles and merges them together in
@ -47,7 +47,7 @@
*
* Possible improvement: From a glance at the code, accumulating all the rectangles
* into a flat array and then calling the (not usefully documented)
* cairo_region_create_rectangles() would have the same behavior and would be
* mtk_region_create_rectangles() would have the same behavior and would be
* simpler and a bit more efficient.
*/
@ -75,15 +75,15 @@ meta_region_builder_add_rectangle (MetaRegionBuilder *builder,
int i;
if (builder->levels[0] == NULL)
builder->levels[0] = cairo_region_create ();
builder->levels[0] = mtk_region_create ();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
cairo_region_union_rectangle (builder->levels[0], &rect);
if (cairo_region_num_rectangles (builder->levels[0]) >= MAX_CHUNK_RECTANGLES)
mtk_region_union_rectangle (builder->levels[0], &rect);
if (mtk_region_num_rectangles (builder->levels[0]) >= MAX_CHUNK_RECTANGLES)
{
for (i = 1; i < builder->n_levels + 1; i++)
{
@ -101,18 +101,18 @@ meta_region_builder_add_rectangle (MetaRegionBuilder *builder,
}
else
{
cairo_region_union (builder->levels[i], builder->levels[i - 1]);
cairo_region_destroy (builder->levels[i - 1]);
mtk_region_union (builder->levels[i], builder->levels[i - 1]);
mtk_region_unref (builder->levels[i - 1]);
builder->levels[i - 1] = NULL;
}
}
}
}
cairo_region_t *
MtkRegion *
meta_region_builder_finish (MetaRegionBuilder *builder)
{
cairo_region_t *result = NULL;
MtkRegion *result = NULL;
int i;
for (i = 0; i < builder->n_levels; i++)
@ -123,14 +123,14 @@ meta_region_builder_finish (MetaRegionBuilder *builder)
result = builder->levels[i];
else
{
cairo_region_union(result, builder->levels[i]);
cairo_region_destroy (builder->levels[i]);
mtk_region_union (result, builder->levels[i]);
mtk_region_unref (builder->levels[i]);
}
}
}
if (result == NULL)
result = cairo_region_create ();
result = mtk_region_create ();
return result;
}
@ -140,23 +140,23 @@ meta_region_builder_finish (MetaRegionBuilder *builder)
void
meta_region_iterator_init (MetaRegionIterator *iter,
cairo_region_t *region)
MtkRegion *region)
{
iter->region = region;
iter->i = 0;
iter->n_rectangles = cairo_region_num_rectangles (region);
iter->n_rectangles = mtk_region_num_rectangles (region);
iter->line_start = TRUE;
if (iter->n_rectangles > 1)
{
cairo_region_get_rectangle (region, 0, &iter->rectangle);
cairo_region_get_rectangle (region, 1, &iter->next_rectangle);
iter->rectangle = mtk_region_get_rectangle (region, 0);
iter->next_rectangle = mtk_region_get_rectangle (region, 1);
iter->line_end = iter->next_rectangle.y != iter->rectangle.y;
}
else if (iter->n_rectangles > 0)
{
cairo_region_get_rectangle (region, 0, &iter->rectangle);
iter->rectangle = mtk_region_get_rectangle (region, 0);
iter->line_end = TRUE;
}
}
@ -176,7 +176,7 @@ meta_region_iterator_next (MetaRegionIterator *iter)
if (iter->i + 1 < iter->n_rectangles)
{
cairo_region_get_rectangle (iter->region, iter->i + 1, &iter->next_rectangle);
iter->next_rectangle = mtk_region_get_rectangle (iter->region, iter->i + 1);
iter->line_end = iter->next_rectangle.y != iter->rectangle.y;
}
else
@ -185,28 +185,29 @@ meta_region_iterator_next (MetaRegionIterator *iter)
}
}
cairo_region_t *
meta_region_scale (cairo_region_t *region, int scale)
MtkRegion *
meta_region_scale (MtkRegion *region,
int scale)
{
int n_rects, i;
MtkRectangle *rects;
cairo_region_t *scaled_region;
MtkRegion *scaled_region;
if (scale == 1)
return cairo_region_copy (region);
return mtk_region_copy (region);
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rects[i]);
rects[i] = mtk_region_get_rectangle (region, i);
rects[i].x *= scale;
rects[i].y *= scale;
rects[i].width *= scale;
rects[i].height *= scale;
}
scaled_region = cairo_region_create_rectangles (rects, n_rects);
scaled_region = mtk_region_create_rectangles (rects, n_rects);
return scaled_region;
}
@ -231,8 +232,8 @@ add_expanded_rect (MetaRegionBuilder *builder,
width + 2 * x_amount, height + 2 * y_amount);
}
static cairo_region_t *
expand_region (cairo_region_t *region,
static MtkRegion *
expand_region (MtkRegion *region,
int x_amount,
int y_amount,
gboolean flip)
@ -243,12 +244,12 @@ expand_region (cairo_region_t *region,
meta_region_builder_init (&builder);
n = cairo_region_num_rectangles (region);
n = mtk_region_num_rectangles (region);
for (i = 0; i < n; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
add_expanded_rect (&builder,
rect.x, rect.y, rect.width, rect.height,
x_amount, y_amount, flip);
@ -259,8 +260,8 @@ expand_region (cairo_region_t *region,
/* This computes a (clipped version) of the inverse of the region
* and expands it by the given amount */
static cairo_region_t *
expand_region_inverse (cairo_region_t *region,
static MtkRegion *
expand_region_inverse (MtkRegion *region,
int x_amount,
int y_amount,
gboolean flip)
@ -273,7 +274,7 @@ expand_region_inverse (cairo_region_t *region,
meta_region_builder_init (&builder);
cairo_region_get_extents (region, &extents);
extents = mtk_region_get_extents (region);
add_expanded_rect (&builder,
extents.x, extents.y - 1, extents.width, 1,
x_amount, y_amount, flip);
@ -316,7 +317,7 @@ expand_region_inverse (cairo_region_t *region,
/**
* meta_make_border_region:
* @region: a #cairo_region_t
* @region: a #MtkRegion
* @x_amount: distance from the border to extend horizontally
* @y_amount: distance from the border to extend vertically
* @flip: if true, the result is computed with x and y interchanged
@ -332,41 +333,40 @@ expand_region_inverse (cairo_region_t *region,
*
* Return value: a new region which is the border of the given region
*/
cairo_region_t *
meta_make_border_region (cairo_region_t *region,
MtkRegion *
meta_make_border_region (MtkRegion *region,
int x_amount,
int y_amount,
gboolean flip)
{
cairo_region_t *border_region;
cairo_region_t *inverse_region;
g_autoptr (MtkRegion) border_region = NULL;
g_autoptr (MtkRegion) inverse_region = NULL;
border_region = expand_region (region, x_amount, y_amount, flip);
inverse_region = expand_region_inverse (region, x_amount, y_amount, flip);
cairo_region_intersect (border_region, inverse_region);
cairo_region_destroy (inverse_region);
mtk_region_intersect (border_region, inverse_region);
return border_region;
return g_steal_pointer (&border_region);
}
cairo_region_t *
meta_region_transform (const cairo_region_t *region,
MtkRegion *
meta_region_transform (const MtkRegion *region,
MetaMonitorTransform transform,
int width,
int height)
{
int n_rects, i;
MtkRectangle *rects;
cairo_region_t *transformed_region;
MtkRegion *transformed_region;
if (transform == META_MONITOR_TRANSFORM_NORMAL)
return cairo_region_copy (region);
return mtk_region_copy (region);
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rects[i]);
rects[i] = mtk_region_get_rectangle (region, i);
meta_rectangle_transform (&rects[i],
transform,
@ -375,20 +375,20 @@ meta_region_transform (const cairo_region_t *region,
&rects[i]);
}
transformed_region = cairo_region_create_rectangles (rects, n_rects);
transformed_region = mtk_region_create_rectangles (rects, n_rects);
return transformed_region;
}
cairo_region_t *
meta_region_crop_and_scale (cairo_region_t *region,
MtkRegion *
meta_region_crop_and_scale (MtkRegion *region,
graphene_rect_t *src_rect,
int dst_width,
int dst_height)
{
int n_rects, i;
MtkRectangle *rects;
cairo_region_t *viewport_region;
MtkRegion *viewport_region;
if (G_APPROX_VALUE (src_rect->size.width, dst_width, FLT_EPSILON) &&
G_APPROX_VALUE (src_rect->size.height, dst_height, FLT_EPSILON) &&
@ -397,12 +397,12 @@ meta_region_crop_and_scale (cairo_region_t *region,
G_APPROX_VALUE (roundf (src_rect->origin.y),
src_rect->origin.y, FLT_EPSILON))
{
viewport_region = cairo_region_copy (region);
viewport_region = mtk_region_copy (region);
if (!G_APPROX_VALUE (src_rect->origin.x, 0, FLT_EPSILON) ||
!G_APPROX_VALUE (src_rect->origin.y, 0, FLT_EPSILON))
{
cairo_region_translate (viewport_region,
mtk_region_translate (viewport_region,
(int) src_rect->origin.x,
(int) src_rect->origin.y);
}
@ -410,11 +410,11 @@ meta_region_crop_and_scale (cairo_region_t *region,
return viewport_region;
}
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rects[i]);
rects[i] = mtk_region_get_rectangle (region, i);
meta_rectangle_crop_and_scale (&rects[i],
src_rect,
@ -423,46 +423,46 @@ meta_region_crop_and_scale (cairo_region_t *region,
&rects[i]);
}
viewport_region = cairo_region_create_rectangles (rects, n_rects);
viewport_region = mtk_region_create_rectangles (rects, n_rects);
return viewport_region;
}
void
meta_region_to_cairo_path (cairo_region_t *region,
meta_region_to_cairo_path (MtkRegion *region,
cairo_t *cr)
{
MtkRectangle rect;
int n_rects, i;
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
}
}
cairo_region_t *
meta_region_apply_matrix_transform_expand (const cairo_region_t *region,
MtkRegion *
meta_region_apply_matrix_transform_expand (const MtkRegion *region,
graphene_matrix_t *transform)
{
int n_rects, i;
MtkRectangle *rects;
cairo_region_t *transformed_region;
MtkRegion *transformed_region;
if (graphene_matrix_is_identity (transform))
return cairo_region_copy (region);
return mtk_region_copy (region);
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects);
for (i = 0; i < n_rects; i++)
{
graphene_rect_t transformed_rect, rect;
MtkRectangle int_rect;
cairo_region_get_rectangle (region, i, &int_rect);
int_rect = mtk_region_get_rectangle (region, i);
rect = mtk_rectangle_to_graphene_rect (&int_rect);
graphene_matrix_transform_bounds (transform, &rect, &transformed_rect);
@ -472,7 +472,7 @@ meta_region_apply_matrix_transform_expand (const cairo_region_t *region,
&rects[i]);
}
transformed_region = cairo_region_create_rectangles (rects, n_rects);
transformed_region = mtk_region_create_rectangles (rects, n_rects);
return transformed_region;
}

View File

@ -34,7 +34,7 @@
* @line_start: whether the current rectangle starts a horizontal band
* @line_end: whether the current rectangle ends a horizontal band
*
* cairo_region_t is a yx banded region; sometimes its useful to iterate through
* MtkRegion is a yx banded region; sometimes its useful to iterate through
* such a region treating the start and end of each horizontal band in a distinct
* fashion.
*
@ -51,7 +51,7 @@
typedef struct _MetaRegionIterator MetaRegionIterator;
struct _MetaRegionIterator {
cairo_region_t *region;
MtkRegion *region;
MtkRectangle rectangle;
gboolean line_start;
gboolean line_end;
@ -76,7 +76,7 @@ struct _MetaRegionBuilder {
* |d |c |ab |
* |e | | |abcd|
*/
cairo_region_t *levels[META_REGION_BUILDER_MAX_LEVELS];
MtkRegion *levels[META_REGION_BUILDER_MAX_LEVELS];
int n_levels;
};
@ -86,34 +86,34 @@ void meta_region_builder_add_rectangle (MetaRegionBuilder *builder,
int y,
int width,
int height);
cairo_region_t * meta_region_builder_finish (MetaRegionBuilder *builder);
MtkRegion * meta_region_builder_finish (MetaRegionBuilder *builder);
void meta_region_iterator_init (MetaRegionIterator *iter,
cairo_region_t *region);
MtkRegion *region);
gboolean meta_region_iterator_at_end (MetaRegionIterator *iter);
void meta_region_iterator_next (MetaRegionIterator *iter);
cairo_region_t * meta_region_scale (cairo_region_t *region,
MtkRegion * meta_region_scale (MtkRegion *region,
int scale);
cairo_region_t * meta_make_border_region (cairo_region_t *region,
MtkRegion * meta_make_border_region (MtkRegion *region,
int x_amount,
int y_amount,
gboolean flip);
cairo_region_t * meta_region_transform (const cairo_region_t *region,
MtkRegion * meta_region_transform (const MtkRegion *region,
MetaMonitorTransform transform,
int width,
int height);
cairo_region_t * meta_region_crop_and_scale (cairo_region_t *region,
MtkRegion * meta_region_crop_and_scale (MtkRegion *region,
graphene_rect_t *src_rect,
int dst_width,
int dst_height);
void meta_region_to_cairo_path (cairo_region_t *region,
void meta_region_to_cairo_path (MtkRegion *region,
cairo_t *cr);
cairo_region_t *
meta_region_apply_matrix_transform_expand (const cairo_region_t *region,
MtkRegion *
meta_region_apply_matrix_transform_expand (const MtkRegion *region,
graphene_matrix_t *transform);

View File

@ -237,13 +237,8 @@ meta_window_destroy_frame (MetaWindow *window)
meta_x11_display_unregister_x_window (x11_display, frame->xwindow);
window->frame = NULL;
if (window->frame_bounds)
{
cairo_region_destroy (window->frame_bounds);
window->frame_bounds = NULL;
}
g_clear_pointer (&frame->opaque_region, cairo_region_destroy);
g_clear_pointer (&window->frame_bounds, mtk_region_unref);
g_clear_pointer (&frame->opaque_region, mtk_region_unref);
/* Move keybindings to window instead of frame */
meta_window_grab_keys (window);
@ -397,17 +392,17 @@ meta_frame_sync_to_window (MetaFrame *frame,
return need_resize;
}
cairo_region_t *
MtkRegion *
meta_frame_get_frame_bounds (MetaFrame *frame)
{
MetaFrameBorders borders;
cairo_region_t *bounds;
MtkRegion *bounds;
meta_frame_calc_borders (frame, &borders);
/* FIXME: currently just the client area, should shape closer to
* frame border, incl. rounded corners.
*/
bounds = cairo_region_create_rectangle (&(MtkRectangle) {
bounds = mtk_region_create_rectangle (&(MtkRectangle) {
borders.total.left,
borders.total.top,
frame->rect.width - borders.total.left - borders.total.right,
@ -584,17 +579,17 @@ meta_frame_get_sync_counter (MetaFrame *frame)
void
meta_frame_set_opaque_region (MetaFrame *frame,
cairo_region_t *region)
MtkRegion *region)
{
MetaWindow *window = frame->window;
if (cairo_region_equal (frame->opaque_region, region))
if (mtk_region_equal (frame->opaque_region, region))
return;
g_clear_pointer (&frame->opaque_region, cairo_region_destroy);
g_clear_pointer (&frame->opaque_region, mtk_region_unref);
if (region != NULL)
frame->opaque_region = cairo_region_reference (region);
frame->opaque_region = mtk_region_ref (region);
meta_compositor_window_shape_changed (window->display->compositor, window);
}

View File

@ -40,7 +40,7 @@ struct _MetaFrame
MetaFrameBorders cached_borders; /* valid if borders_cached is set */
cairo_region_t *opaque_region;
MtkRegion *opaque_region;
MetaSyncCounter sync_counter;
@ -67,7 +67,7 @@ gboolean meta_frame_sync_to_window (MetaFrame *frame,
void meta_frame_clear_cached_borders (MetaFrame *frame);
cairo_region_t *meta_frame_get_frame_bounds (MetaFrame *frame);
MtkRegion *meta_frame_get_frame_bounds (MetaFrame *frame);
void meta_frame_get_mask (MetaFrame *frame,
MtkRectangle *frame_rect,
@ -82,4 +82,4 @@ GSubprocess * meta_frame_launch_client (MetaX11Display *x11_display,
MetaSyncCounter * meta_frame_get_sync_counter (MetaFrame *frame);
void meta_frame_set_opaque_region (MetaFrame *frame,
cairo_region_t *region);
MtkRegion *region);

View File

@ -246,17 +246,17 @@ struct _MetaWindow
} fullscreen_monitors;
/* if non-NULL, the bounds of the window frame */
cairo_region_t *frame_bounds;
MtkRegion *frame_bounds;
/* if non-NULL, the bounding shape region of the window. Relative to
* the server-side client window. */
cairo_region_t *shape_region;
MtkRegion *shape_region;
/* if non-NULL, the opaque region _NET_WM_OPAQUE_REGION */
cairo_region_t *opaque_region;
MtkRegion *opaque_region;
/* the input shape region for picking */
cairo_region_t *input_region;
MtkRegion *input_region;
/* _NET_WM_WINDOW_OPACITY rescaled to 0xFF */
guint8 opacity;

View File

@ -313,17 +313,10 @@ meta_window_finalize (GObject *object)
{
MetaWindow *window = META_WINDOW (object);
if (window->frame_bounds)
cairo_region_destroy (window->frame_bounds);
if (window->shape_region)
cairo_region_destroy (window->shape_region);
if (window->opaque_region)
cairo_region_destroy (window->opaque_region);
if (window->input_region)
cairo_region_destroy (window->input_region);
g_clear_pointer (&window->frame_bounds, mtk_region_unref);
g_clear_pointer (&window->shape_region, mtk_region_unref);
g_clear_pointer (&window->opaque_region, mtk_region_unref);
g_clear_pointer (&window->input_region, mtk_region_unref);
if (window->transient_for)
g_object_unref (window->transient_for);
@ -3945,10 +3938,7 @@ meta_window_move_resize_internal (MetaWindow *window,
}
if ((result & META_MOVE_RESIZE_RESULT_FRAME_SHAPE_CHANGED) && window->frame_bounds)
{
cairo_region_destroy (window->frame_bounds);
window->frame_bounds = NULL;
}
g_clear_pointer (&window->frame_bounds, mtk_region_unref);
meta_window_foreach_transient (window, maybe_move_attached_window, NULL);
@ -7024,11 +7014,11 @@ meta_window_get_frame_type (MetaWindow *window)
*
* Gets a region representing the outer bounds of the window's frame.
*
* Return value: (transfer none) (nullable): a #cairo_region_t
* Return value: (transfer none) (nullable): a #MtkRegion
* holding the outer bounds of the window, or %NULL if the window
* doesn't have a frame.
*/
cairo_region_t *
MtkRegion *
meta_window_get_frame_bounds (MetaWindow *window)
{
if (!window->frame_bounds)

View File

@ -22,8 +22,6 @@
#pragma once
#include <cairo.h>
#include "clutter/clutter.h"
#include "cogl/cogl.h"
#include "meta/meta-window-shape.h"
@ -112,7 +110,7 @@ void meta_shadow_paint (MetaShadow *shadow,
int window_width,
int window_height,
guint8 opacity,
cairo_region_t *clip,
MtkRegion *clip,
gboolean clip_strictly);
META_EXPORT

View File

@ -22,7 +22,6 @@
#pragma once
#include <cairo.h>
#include <glib-object.h>
#include <meta/common.h>
@ -45,7 +44,7 @@ GType meta_window_shape_get_type (void) G_GNUC_CONST;
typedef struct _MetaWindowShape MetaWindowShape;
META_EXPORT
MetaWindowShape * meta_window_shape_new (cairo_region_t *region);
MetaWindowShape * meta_window_shape_new (MtkRegion *region);
META_EXPORT
MetaWindowShape * meta_window_shape_ref (MetaWindowShape *shape);
@ -68,6 +67,6 @@ void meta_window_shape_get_borders (MetaWindowShape *shape,
int *border_left);
META_EXPORT
cairo_region_t *meta_window_shape_to_region (MetaWindowShape *shape,
MtkRegion * meta_window_shape_to_region (MetaWindowShape *shape,
int center_width,
int center_height);

View File

@ -20,7 +20,6 @@
#pragma once
#include <glib-object.h>
#include <cairo.h>
#include <X11/Xlib.h>
#include <meta/boxes.h>
@ -355,7 +354,7 @@ META_EXPORT
MetaFrameType meta_window_get_frame_type (MetaWindow *window);
META_EXPORT
cairo_region_t *meta_window_get_frame_bounds (MetaWindow *window);
MtkRegion *meta_window_get_frame_bounds (MetaWindow *window);
META_EXPORT
MetaWindow *meta_window_get_tile_match (MetaWindow *window);

View File

@ -233,7 +233,7 @@ get_pixel (CoglFramebuffer *fb,
static void
view_painted_cb (ClutterStage *stage,
ClutterStageView *view,
cairo_region_t *redraw_clip,
MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer data)
{

View File

@ -272,7 +272,7 @@ typedef struct
static void
on_after_paint (MetaStage *stage,
ClutterStageView *view,
const cairo_region_t *redraw_clip,
const MtkRegion *redraw_clip,
ClutterFrame *frame,
gpointer user_data)
{

View File

@ -148,7 +148,7 @@ on_scanout_before_paint (ClutterStage *stage,
static void
on_scanout_paint_view (ClutterStage *stage,
ClutterStageView *stage_view,
cairo_region_t *region,
MtkRegion *region,
ClutterFrame *frame,
KmsRenderingTest *test)
{
@ -389,7 +389,7 @@ on_scanout_fallback_before_paint (ClutterStage *stage,
static void
on_scanout_fallback_paint_view (ClutterStage *stage,
ClutterStageView *stage_view,
cairo_region_t *region,
MtkRegion *region,
ClutterFrame *frame,
KmsRenderingTest *test)
{

View File

@ -35,7 +35,6 @@
#include "wayland/meta-pointer-confinement-wayland.h"
#include <glib-object.h>
#include <cairo.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-pointer-constraint.h"
@ -225,7 +224,7 @@ meta_pointer_confinement_wayland_create_constraint (MetaPointerConfinementWaylan
MetaPointerConfinementWaylandPrivate *priv;
MetaPointerConstraint *constraint;
MetaWaylandSurface *surface;
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
int geometry_scale;
float dx, dy;
double min_edge_distance;
@ -239,19 +238,19 @@ meta_pointer_confinement_wayland_create_constraint (MetaPointerConfinementWaylan
geometry_scale = meta_wayland_surface_get_geometry_scale (surface);
if (geometry_scale != 1)
{
cairo_region_t *scaled_region;
g_autoptr (MtkRegion) scaled_region = NULL;
scaled_region = meta_region_scale (region, geometry_scale);
cairo_region_destroy (region);
region = scaled_region;
g_clear_pointer (&region, mtk_region_unref);
region = g_steal_pointer (&scaled_region);
}
meta_wayland_surface_get_absolute_coordinates (surface, 0, 0, &dx, &dy);
cairo_region_translate (region, dx, dy);
mtk_region_translate (region, dx, dy);
min_edge_distance = wl_fixed_to_double (1) * geometry_scale;
constraint = meta_pointer_constraint_new (region, min_edge_distance);
cairo_region_destroy (region);
constraint = meta_pointer_constraint_new (g_steal_pointer (&region),
min_edge_distance);
return constraint;
}

View File

@ -62,7 +62,7 @@ meta_pointer_lock_wayland_create_constraint (MetaPointerConfinementWayland *conf
MetaPointerConstraint *constraint;
graphene_point_t point;
MtkRectangle rect;
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
float sx, sy, x, y;
clutter_seat_query_state (seat, pointer, NULL, &point, NULL);
@ -75,10 +75,9 @@ meta_pointer_lock_wayland_create_constraint (MetaPointerConfinementWayland *conf
meta_wayland_surface_get_absolute_coordinates (surface, sx, sy, &x, &y);
rect = (MtkRectangle) { .x = x, .y = y, .width = 1, .height = 1 };
region = cairo_region_create_rectangle (&rect);
region = mtk_region_create_rectangle (&rect);
constraint = meta_pointer_constraint_new (region, 0.0);
cairo_region_destroy (region);
constraint = meta_pointer_constraint_new (g_steal_pointer (&region), 0.0);
return constraint;
}

View File

@ -218,12 +218,11 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
{
if (surface->input_region)
{
cairo_region_t *input_region;
g_autoptr (MtkRegion) input_region = NULL;
input_region = cairo_region_copy (surface->input_region);
cairo_region_intersect_rectangle (input_region, &surface_rect);
input_region = mtk_region_copy (surface->input_region);
mtk_region_intersect_rectangle (input_region, &surface_rect);
meta_surface_actor_set_input_region (surface_actor, input_region);
cairo_region_destroy (input_region);
}
else
{
@ -232,20 +231,18 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
if (!meta_shaped_texture_has_alpha (stex))
{
cairo_region_t *opaque_region;
g_autoptr (MtkRegion) opaque_region = NULL;
opaque_region = cairo_region_create_rectangle (&surface_rect);
opaque_region = mtk_region_create_rectangle (&surface_rect);
meta_surface_actor_set_opaque_region (surface_actor, opaque_region);
cairo_region_destroy (opaque_region);
}
else if (surface->opaque_region)
{
cairo_region_t *opaque_region;
g_autoptr (MtkRegion) opaque_region = NULL;
opaque_region = cairo_region_copy (surface->opaque_region);
cairo_region_intersect_rectangle (opaque_region, &surface_rect);
opaque_region = mtk_region_copy (surface->opaque_region);
mtk_region_intersect_rectangle (opaque_region, &surface_rect);
meta_surface_actor_set_opaque_region (surface_actor, opaque_region);
cairo_region_destroy (opaque_region);
}
else
{

View File

@ -675,7 +675,7 @@ meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer)
static gboolean
process_shm_buffer_damage (MetaWaylandBuffer *buffer,
MetaMultiTexture *texture,
cairo_region_t *region,
MtkRegion *region,
GError **error)
{
struct wl_shm_buffer *shm_buffer;
@ -684,7 +684,7 @@ process_shm_buffer_damage (MetaWaylandBuffer *buffer,
CoglPixelFormat format;
CoglTexture *cogl_texture;
n_rectangles = cairo_region_num_rectangles (region);
n_rectangles = mtk_region_num_rectangles (region);
shm_buffer = wl_shm_buffer_get (buffer->resource);
@ -702,7 +702,7 @@ process_shm_buffer_damage (MetaWaylandBuffer *buffer,
int bpp;
bpp = cogl_pixel_format_get_bytes_per_pixel (format, 0);
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
if (!_cogl_texture_set_region (cogl_texture,
rect.width, rect.height,
@ -726,7 +726,7 @@ process_shm_buffer_damage (MetaWaylandBuffer *buffer,
void
meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
MetaMultiTexture *texture,
cairo_region_t *region)
MtkRegion *region)
{
gboolean res = FALSE;
GError *error = NULL;

View File

@ -22,7 +22,6 @@
#pragma once
#include <cairo.h>
#include <wayland-server.h>
#include "cogl/cogl.h"
@ -100,7 +99,7 @@ void meta_wayland_buffer_dec_use_count (MetaWaylandBuff
gboolean meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer);
void meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
MetaMultiTexture *texture,
cairo_region_t *region);
MtkRegion *region);
CoglScanout * meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
CoglOnscreen *onscreen);

View File

@ -176,8 +176,8 @@ meta_wayland_cursor_surface_apply_state (MetaWaylandSurfaceRole *surface_role,
wl_list_init (&pending->frame_callback_list);
if (pending->newly_attached &&
((!cairo_region_is_empty (pending->surface_damage) ||
!cairo_region_is_empty (pending->buffer_damage)) ||
((!mtk_region_is_empty (pending->surface_damage) ||
!mtk_region_is_empty (pending->buffer_damage)) ||
!priv->buffer))
update_cursor_sprite_texture (META_WAYLAND_CURSOR_SURFACE (surface_role));
}

View File

@ -55,7 +55,7 @@ struct _MetaWaylandPointerConstraint
MetaWaylandSurface *surface;
gboolean is_enabled;
cairo_region_t *region;
MtkRegion *region;
struct wl_resource *resource;
MetaWaylandPointerGrab grab;
MetaWaylandSeat *seat;
@ -85,7 +85,7 @@ typedef struct _MetaWaylandSurfacePointerConstraintsData
typedef struct
{
MetaWaylandPointerConstraint *constraint;
cairo_region_t *region;
MtkRegion *region;
gulong applied_handler_id;
} MetaWaylandPendingConstraintState;
@ -322,7 +322,7 @@ meta_wayland_pointer_constraint_new (MetaWaylandSurface *su
if (region)
{
constraint->region =
cairo_region_copy (meta_wayland_region_peek_cairo_region (region));
mtk_region_copy (meta_wayland_region_peek_cairo_region (region));
}
else
{
@ -437,7 +437,7 @@ meta_wayland_pointer_constraint_destroy (MetaWaylandPointerConstraint *constrain
meta_wayland_pointer_constraint_disable (constraint);
wl_resource_set_user_data (constraint->resource, NULL);
g_clear_pointer (&constraint->region, cairo_region_destroy);
g_clear_pointer (&constraint->region, mtk_region_unref);
g_object_unref (constraint);
}
@ -446,14 +446,13 @@ is_within_constraint_region (MetaWaylandPointerConstraint *constraint,
wl_fixed_t sx,
wl_fixed_t sy)
{
cairo_region_t *region;
g_autoptr (MtkRegion) region = NULL;
gboolean is_within;
region = meta_wayland_pointer_constraint_calculate_effective_region (constraint);
is_within = cairo_region_contains_point (region,
is_within = mtk_region_contains_point (region,
wl_fixed_to_int (sx),
wl_fixed_to_int (sy));
cairo_region_destroy (region);
return is_within;
}
@ -606,15 +605,15 @@ meta_wayland_pointer_constraint_maybe_enable_for_window (MetaWindow *window)
}
}
cairo_region_t *
MtkRegion *
meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerConstraint *constraint)
{
cairo_region_t *region;
MtkRegion *region;
MetaWindow *window;
region = meta_wayland_surface_calculate_input_region (constraint->surface);
if (constraint->region)
cairo_region_intersect (region, constraint->region);
mtk_region_intersect (region, constraint->region);
window = meta_wayland_surface_get_window (constraint->surface);
if (window && window->frame)
@ -630,12 +629,10 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
frame->bottom_height);
if (actual_width > 0 && actual_height > 0)
{
cairo_region_intersect_rectangle (region, &(MtkRectangle) {
.x = frame->child_x,
.y = frame->child_y,
.width = actual_width,
.height = actual_height
});
mtk_region_intersect_rectangle (region, &MTK_RECTANGLE_INIT (frame->child_x,
frame->child_y,
actual_width,
actual_height));
}
}
@ -669,7 +666,7 @@ pointer_constraint_resource_destroyed (struct wl_resource *resource)
static void
pending_constraint_state_free (MetaWaylandPendingConstraintState *constraint_pending)
{
g_clear_pointer (&constraint_pending->region, cairo_region_destroy);
g_clear_pointer (&constraint_pending->region, mtk_region_unref);
if (constraint_pending->constraint)
g_object_remove_weak_pointer (G_OBJECT (constraint_pending->constraint),
(gpointer *) &constraint_pending->constraint);
@ -759,7 +756,7 @@ pending_constraint_state_applied (MetaWaylandSurfaceState *pending,
if (!constraint)
return;
g_clear_pointer (&constraint->region, cairo_region_destroy);
g_clear_pointer (&constraint->region, mtk_region_unref);
if (constraint_pending->region)
{
constraint->region = constraint_pending->region;
@ -815,11 +812,11 @@ meta_wayland_pointer_constraint_set_pending_region (MetaWaylandPointerConstraint
constraint_pending = ensure_pending_constraint_state (constraint);
g_clear_pointer (&constraint_pending->region, cairo_region_destroy);
g_clear_pointer (&constraint_pending->region, mtk_region_unref);
if (region)
{
constraint_pending->region =
cairo_region_copy (meta_wayland_region_peek_cairo_region (region));
mtk_region_copy (meta_wayland_region_peek_cairo_region (region));
}
}

View File

@ -35,7 +35,7 @@ G_DECLARE_FINAL_TYPE (MetaWaylandPointerConstraint,
void meta_wayland_pointer_constraints_init (MetaWaylandCompositor *compositor);
cairo_region_t * meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerConstraint *constraint);
MtkRegion * meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerConstraint *constraint);
MetaWaylandSurface * meta_wayland_pointer_constraint_get_surface (MetaWaylandPointerConstraint *constraint);

View File

@ -28,7 +28,7 @@
struct _MetaWaylandRegion
{
struct wl_resource *resource;
cairo_region_t *region;
MtkRegion *region;
};
static void
@ -49,7 +49,7 @@ wl_region_add (struct wl_client *client,
MetaWaylandRegion *region = wl_resource_get_user_data (resource);
MtkRectangle rectangle = { x, y, width, height };
cairo_region_union_rectangle (region->region, &rectangle);
mtk_region_union_rectangle (region->region, &rectangle);
}
static void
@ -63,7 +63,7 @@ wl_region_subtract (struct wl_client *client,
MetaWaylandRegion *region = wl_resource_get_user_data (resource);
MtkRectangle rectangle = { x, y, width, height };
cairo_region_subtract_rectangle (region->region, &rectangle);
mtk_region_subtract_rectangle (region->region, &rectangle);
}
static const struct wl_region_interface meta_wayland_wl_region_interface = {
@ -77,7 +77,7 @@ wl_region_destructor (struct wl_resource *resource)
{
MetaWaylandRegion *region = wl_resource_get_user_data (resource);
cairo_region_destroy (region->region);
g_clear_pointer (&region->region, mtk_region_unref);
g_free (region);
}
@ -92,12 +92,12 @@ meta_wayland_region_create (MetaWaylandCompositor *compositor,
region->resource = wl_resource_create (client, &wl_region_interface, wl_resource_get_version (compositor_resource), id);
wl_resource_set_implementation (region->resource, &meta_wayland_wl_region_interface, region, wl_region_destructor);
region->region = cairo_region_create ();
region->region = mtk_region_create ();
return region;
}
cairo_region_t *
MtkRegion *
meta_wayland_region_peek_cairo_region (MetaWaylandRegion *region)
{
return region->region;

View File

@ -22,7 +22,6 @@
#pragma once
#include <cairo.h>
#include <glib.h>
#include <wayland-server.h>
@ -33,4 +32,4 @@ MetaWaylandRegion * meta_wayland_region_create (MetaWaylandCompositor *composito
struct wl_resource *compositor_resource,
guint32 id);
cairo_region_t * meta_wayland_region_peek_cairo_region (MetaWaylandRegion *region);
MtkRegion * meta_wayland_region_peek_cairo_region (MetaWaylandRegion *region);

View File

@ -263,8 +263,8 @@ meta_wayland_surface_assign_role (MetaWaylandSurface *surface,
static void
surface_process_damage (MetaWaylandSurface *surface,
cairo_region_t *surface_region,
cairo_region_t *buffer_region)
MtkRegion *surface_region,
MtkRegion *buffer_region)
{
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
MtkRectangle buffer_rect;
@ -282,12 +282,12 @@ surface_process_damage (MetaWaylandSurface *surface,
.height = meta_wayland_surface_get_buffer_height (surface),
};
if (!cairo_region_is_empty (surface_region))
if (!mtk_region_is_empty (surface_region))
{
MtkRectangle surface_rect;
cairo_region_t *scaled_region;
cairo_region_t *transformed_region;
cairo_region_t *viewport_region;
g_autoptr (MtkRegion) scaled_region = NULL;
g_autoptr (MtkRegion) transformed_region = NULL;
g_autoptr (MtkRegion) viewport_region = NULL;
graphene_rect_t src_rect;
/* Intersect the damage region with the surface region before scaling in
@ -297,7 +297,7 @@ surface_process_damage (MetaWaylandSurface *surface,
.width = meta_wayland_surface_get_width (surface),
.height = meta_wayland_surface_get_height (surface),
};
cairo_region_intersect_rectangle (surface_region, &surface_rect);
mtk_region_intersect_rectangle (surface_region, &surface_rect);
/* The damage region must be in the same coordinate space as the buffer,
* i.e. scaled with surface->scale. */
@ -343,14 +343,10 @@ surface_process_damage (MetaWaylandSurface *surface,
/* Now add the scaled, cropped and transformed damage region to the
* buffer damage. Buffer damage is already in the correct coordinate
* space. */
cairo_region_union (buffer_region, transformed_region);
cairo_region_destroy (viewport_region);
cairo_region_destroy (scaled_region);
cairo_region_destroy (transformed_region);
mtk_region_union (buffer_region, transformed_region);
}
cairo_region_intersect_rectangle (buffer_region, &buffer_rect);
mtk_region_intersect_rectangle (buffer_region, &buffer_rect);
meta_wayland_buffer_process_damage (buffer, surface->output_state.texture,
buffer_region);
@ -360,11 +356,11 @@ surface_process_damage (MetaWaylandSurface *surface,
{
int i, n_rectangles;
n_rectangles = cairo_region_num_rectangles (buffer_region);
n_rectangles = mtk_region_num_rectangles (buffer_region);
for (i = 0; i < n_rectangles; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (buffer_region, i, &rect);
rect = mtk_region_get_rectangle (buffer_region, i);
meta_surface_actor_process_damage (actor,
rect.x, rect.y,
@ -403,8 +399,8 @@ meta_wayland_surface_state_set_default (MetaWaylandSurfaceState *state)
state->opaque_region = NULL;
state->opaque_region_set = FALSE;
state->surface_damage = cairo_region_create ();
state->buffer_damage = cairo_region_create ();
state->surface_damage = mtk_region_create ();
state->buffer_damage = mtk_region_create ();
wl_list_init (&state->frame_callback_list);
state->has_new_geometry = FALSE;
@ -442,10 +438,10 @@ meta_wayland_surface_state_clear (MetaWaylandSurfaceState *state)
g_clear_object (&state->texture);
g_clear_pointer (&state->surface_damage, cairo_region_destroy);
g_clear_pointer (&state->buffer_damage, cairo_region_destroy);
g_clear_pointer (&state->input_region, cairo_region_destroy);
g_clear_pointer (&state->opaque_region, cairo_region_destroy);
g_clear_pointer (&state->surface_damage, mtk_region_unref);
g_clear_pointer (&state->buffer_damage, mtk_region_unref);
g_clear_pointer (&state->input_region, mtk_region_unref);
g_clear_pointer (&state->opaque_region, mtk_region_unref);
g_clear_pointer (&state->xdg_positioner, g_free);
if (state->buffer_destroy_handler_id)
@ -500,15 +496,15 @@ meta_wayland_surface_state_merge_into (MetaWaylandSurfaceState *from,
wl_list_insert_list (&to->frame_callback_list, &from->frame_callback_list);
wl_list_init (&from->frame_callback_list);
cairo_region_union (to->surface_damage, from->surface_damage);
cairo_region_union (to->buffer_damage, from->buffer_damage);
mtk_region_union (to->surface_damage, from->surface_damage);
mtk_region_union (to->buffer_damage, from->buffer_damage);
if (from->input_region_set)
{
if (to->input_region)
cairo_region_union (to->input_region, from->input_region);
mtk_region_union (to->input_region, from->input_region);
else
to->input_region = cairo_region_reference (from->input_region);
to->input_region = mtk_region_ref (from->input_region);
to->input_region_set = TRUE;
}
@ -516,9 +512,9 @@ meta_wayland_surface_state_merge_into (MetaWaylandSurfaceState *from,
if (from->opaque_region_set)
{
if (to->opaque_region)
cairo_region_union (to->opaque_region, from->opaque_region);
mtk_region_union (to->opaque_region, from->opaque_region);
else
to->opaque_region = cairo_region_reference (from->opaque_region);
to->opaque_region = mtk_region_ref (from->opaque_region);
to->opaque_region_set = TRUE;
}
@ -800,8 +796,8 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
meta_wayland_surface_get_width (surface) != old_width ||
meta_wayland_surface_get_height (surface) != old_height;
if (!cairo_region_is_empty (state->surface_damage) ||
!cairo_region_is_empty (state->buffer_damage))
if (!mtk_region_is_empty (state->surface_damage) ||
!mtk_region_is_empty (state->buffer_damage))
{
surface_process_damage (surface,
state->surface_damage,
@ -814,22 +810,16 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
if (state->opaque_region_set)
{
if (surface->opaque_region)
cairo_region_destroy (surface->opaque_region);
g_clear_pointer (&surface->opaque_region, mtk_region_unref);
if (state->opaque_region)
surface->opaque_region = cairo_region_reference (state->opaque_region);
else
surface->opaque_region = NULL;
surface->opaque_region = mtk_region_ref (state->opaque_region);
}
if (state->input_region_set)
{
if (surface->input_region)
cairo_region_destroy (surface->input_region);
g_clear_pointer (&surface->input_region, mtk_region_unref);
if (state->input_region)
surface->input_region = cairo_region_reference (state->input_region);
else
surface->input_region = NULL;
surface->input_region = mtk_region_ref (state->input_region);
}
/*
@ -1072,7 +1062,7 @@ wl_surface_damage (struct wl_client *client,
.width = width,
.height = height
};
cairo_region_union_rectangle (pending->surface_damage, &rectangle);
mtk_region_union_rectangle (pending->surface_damage, &rectangle);
}
static void
@ -1114,12 +1104,12 @@ wl_surface_set_opaque_region (struct wl_client *client,
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWaylandSurfaceState *pending = surface->pending_state;
g_clear_pointer (&pending->opaque_region, cairo_region_destroy);
g_clear_pointer (&pending->opaque_region, mtk_region_unref);
if (region_resource)
{
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
cairo_region_t *cr_region = meta_wayland_region_peek_cairo_region (region);
pending->opaque_region = cairo_region_copy (cr_region);
MtkRegion *cr_region = meta_wayland_region_peek_cairo_region (region);
pending->opaque_region = mtk_region_copy (cr_region);
}
pending->opaque_region_set = TRUE;
}
@ -1132,12 +1122,12 @@ wl_surface_set_input_region (struct wl_client *client,
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWaylandSurfaceState *pending = surface->pending_state;
g_clear_pointer (&pending->input_region, cairo_region_destroy);
g_clear_pointer (&pending->input_region, mtk_region_unref);
if (region_resource)
{
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
cairo_region_t *cr_region = meta_wayland_region_peek_cairo_region (region);
pending->input_region = cairo_region_copy (cr_region);
MtkRegion *cr_region = meta_wayland_region_peek_cairo_region (region);
pending->input_region = mtk_region_copy (cr_region);
}
pending->input_region_set = TRUE;
}
@ -1241,7 +1231,7 @@ wl_surface_damage_buffer (struct wl_client *client,
.width = width,
.height = height
};
cairo_region_union_rectangle (pending->buffer_damage, &rectangle);
mtk_region_union_rectangle (pending->buffer_damage, &rectangle);
}
static void
@ -1469,10 +1459,8 @@ meta_wayland_surface_finalize (GObject *object)
g_clear_object (&surface->output_state.texture);
g_clear_object (&surface->buffer);
if (surface->opaque_region)
cairo_region_destroy (surface->opaque_region);
if (surface->input_region)
cairo_region_destroy (surface->input_region);
g_clear_pointer (&surface->opaque_region, mtk_region_unref);
g_clear_pointer (&surface->input_region, mtk_region_unref);
meta_wayland_compositor_remove_frame_callback_surface (compositor, surface);
meta_wayland_compositor_remove_presentation_feedback_surface (compositor,
@ -2076,10 +2064,10 @@ meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role)
return priv->surface;
}
cairo_region_t *
MtkRegion *
meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface)
{
cairo_region_t *region;
MtkRegion *region;
MtkRectangle buffer_rect;
if (!surface->buffer)
@ -2089,10 +2077,10 @@ meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface)
.width = meta_wayland_surface_get_width (surface),
.height = meta_wayland_surface_get_height (surface),
};
region = cairo_region_create_rectangle (&buffer_rect);
region = mtk_region_create_rectangle (&buffer_rect);
if (surface->input_region)
cairo_region_intersect (region, surface->input_region);
mtk_region_intersect (region, surface->input_region);
return region;
}

View File

@ -17,7 +17,6 @@
#pragma once
#include <cairo.h>
#include <glib.h>
#include <wayland-server.h>
#include <xkbcommon/xkbcommon.h>
@ -88,13 +87,13 @@ struct _MetaWaylandSurfaceState
int scale;
/* wl_surface.damage */
cairo_region_t *surface_damage;
MtkRegion *surface_damage;
/* wl_surface.damage_buffer */
cairo_region_t *buffer_damage;
MtkRegion *buffer_damage;
cairo_region_t *input_region;
MtkRegion *input_region;
gboolean input_region_set;
cairo_region_t *opaque_region;
MtkRegion *opaque_region;
gboolean opaque_region_set;
/* wl_surface.frame */
@ -162,8 +161,8 @@ struct _MetaWaylandSurface
struct wl_resource *resource;
MetaWaylandCompositor *compositor;
MetaWaylandSurfaceRole *role;
cairo_region_t *input_region;
cairo_region_t *opaque_region;
MtkRegion *input_region;
MtkRegion *opaque_region;
int scale;
int32_t offset_x, offset_y;
GHashTable *outputs;
@ -346,7 +345,7 @@ void meta_wayland_surface_get_absolute_coordinates (MetaWaylandSu
MetaWaylandSurface * meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role);
cairo_region_t * meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface);
MtkRegion * meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface);
gboolean meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surface,

View File

@ -647,15 +647,15 @@ reload_wm_name (MetaWindow *window,
static void
meta_window_set_opaque_region (MetaWindow *window,
cairo_region_t *region)
MtkRegion *region)
{
if (cairo_region_equal (window->opaque_region, region))
if (mtk_region_equal (window->opaque_region, region))
return;
g_clear_pointer (&window->opaque_region, cairo_region_destroy);
g_clear_pointer (&window->opaque_region, mtk_region_unref);
if (region != NULL)
window->opaque_region = cairo_region_reference (region);
window->opaque_region = mtk_region_ref (region);
meta_compositor_window_shape_changed (window->display->compositor, window);
}
@ -665,7 +665,7 @@ reload_opaque_region (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
cairo_region_t *opaque_region = NULL;
MtkRegion *opaque_region = NULL;
if (value->type != META_PROP_VALUE_INVALID)
{
@ -703,7 +703,7 @@ reload_opaque_region (MetaWindow *window,
rect_index++;
}
opaque_region = cairo_region_create_rectangles (rects, nrects);
opaque_region = mtk_region_create_rectangles (rects, nrects);
g_free (rects);
}
@ -714,7 +714,7 @@ reload_opaque_region (MetaWindow *window,
else if (window->frame && value->source_xwindow == window->frame->xwindow)
meta_frame_set_opaque_region (window->frame, opaque_region);
g_clear_pointer (&opaque_region, cairo_region_destroy);
g_clear_pointer (&opaque_region, mtk_region_unref);
}
static void

View File

@ -2365,7 +2365,7 @@ meta_window_x11_set_net_wm_state (MetaWindow *window)
update_gtk_edge_constraints (window);
}
static cairo_region_t *
static MtkRegion *
region_create_from_x_rectangles (const XRectangle *rects,
int n_rects)
{
@ -2380,20 +2380,20 @@ region_create_from_x_rectangles (const XRectangle *rects,
cairo_rects[i].height = rects[i].height;
}
return cairo_region_create_rectangles (cairo_rects, n_rects);
return mtk_region_create_rectangles (cairo_rects, n_rects);
}
static void
meta_window_set_input_region (MetaWindow *window,
cairo_region_t *region)
MtkRegion *region)
{
if (cairo_region_equal (window->input_region, region))
if (mtk_region_equal (window->input_region, region))
return;
g_clear_pointer (&window->input_region, cairo_region_destroy);
g_clear_pointer (&window->input_region, mtk_region_unref);
if (region != NULL)
window->input_region = cairo_region_reference (region);
window->input_region = mtk_region_ref (region);
meta_compositor_window_shape_changed (window->display->compositor, window);
}
@ -2401,17 +2401,17 @@ meta_window_set_input_region (MetaWindow *window,
#if 0
/* Print out a region; useful for debugging */
static void
print_region (cairo_region_t *region)
print_region (MtkRegion *region)
{
int n_rects;
int i;
n_rects = cairo_region_num_rectangles (region);
n_rects = mtk_region_num_rectangles (region);
g_print ("[");
for (i = 0; i < n_rects; i++)
{
MtkRectangle rect;
cairo_region_get_rectangle (region, i, &rect);
rect = mtk_region_get_rectangle (region, i);
g_print ("+%d+%dx%dx%d ",
rect.x, rect.y, rect.width, rect.height);
}
@ -2423,7 +2423,7 @@ void
meta_window_x11_update_input_region (MetaWindow *window)
{
MetaX11Display *x11_display = window->display->x11_display;
cairo_region_t *region = NULL;
g_autoptr (MtkRegion) region = NULL;
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
Window xwindow;
@ -2446,7 +2446,7 @@ meta_window_x11_update_input_region (MetaWindow *window)
if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
{
/* Translate the set of XShape rectangles that we
* get from the X server to a cairo_region. */
* get from the X server to a MtkRegion. */
XRectangle *rects = NULL;
int n_rects = -1, ordering;
@ -2479,7 +2479,7 @@ meta_window_x11_update_input_region (MetaWindow *window)
else if (n_rects == 0)
{
/* Client set an empty region. */
region = cairo_region_create ();
region = mtk_region_create ();
}
else if (n_rects == 1 &&
(rects[0].x == 0 &&
@ -2516,24 +2516,23 @@ meta_window_x11_update_input_region (MetaWindow *window)
* window would have gotten if it was unshaped. In our case,
* this is simply the client area.
*/
cairo_region_intersect_rectangle (region, &client_area);
mtk_region_intersect_rectangle (region, &client_area);
}
meta_window_set_input_region (window, region);
cairo_region_destroy (region);
}
static void
meta_window_set_shape_region (MetaWindow *window,
cairo_region_t *region)
MtkRegion *region)
{
if (cairo_region_equal (window->shape_region, region))
if (mtk_region_equal (window->shape_region, region))
return;
g_clear_pointer (&window->shape_region, cairo_region_destroy);
g_clear_pointer (&window->shape_region, mtk_region_unref);
if (region != NULL)
window->shape_region = cairo_region_reference (region);
window->shape_region = mtk_region_ref (region);
meta_compositor_window_shape_changed (window->display->compositor, window);
}
@ -2544,12 +2543,12 @@ meta_window_x11_update_shape_region (MetaWindow *window)
MetaX11Display *x11_display = window->display->x11_display;
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
cairo_region_t *region = NULL;
g_autoptr (MtkRegion) region = NULL;
if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
{
/* Translate the set of XShape rectangles that we
* get from the X server to a cairo_region. */
* get from the X server to a MtkRegion. */
XRectangle *rects = NULL;
int n_rects, ordering;
@ -2597,17 +2596,16 @@ meta_window_x11_update_shape_region (MetaWindow *window)
* window would have gotten if it was unshaped. In our case,
* this is simply the client area.
*/
cairo_region_intersect_rectangle (region, &client_area);
mtk_region_intersect_rectangle (region, &client_area);
/* Some applications might explicitly set their bounding region
* to the client area. Detect these cases, and throw out the
* bounding region in this case for decorated windows. */
if (window->decorated &&
cairo_region_contains_rectangle (region, &client_area) == CAIRO_REGION_OVERLAP_IN)
g_clear_pointer (&region, cairo_region_destroy);
mtk_region_contains_rectangle (region, &client_area) == MTK_REGION_OVERLAP_IN)
g_clear_pointer (&region, mtk_region_unref);
}
meta_window_set_shape_region (window, region);
cairo_region_destroy (region);
}
/* Generally meta_window_same_application() is a better idea