mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
mtk: Use an arc box for region
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3363>
This commit is contained in:
parent
8ec26dfd27
commit
9610665ab8
@ -21,7 +21,6 @@ if have_x11
|
||||
endif
|
||||
|
||||
mtk_private_headers = [
|
||||
'mtk-region-private.h',
|
||||
]
|
||||
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Mtk
|
||||
*
|
||||
* A low-level base library.
|
||||
*
|
||||
* Copyright (C) 2023 Red Hat
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <pixman.h>
|
||||
|
||||
struct _MtkRegion
|
||||
{
|
||||
gatomicrefcount ref_count;
|
||||
|
||||
pixman_region32_t inner_region;
|
||||
};
|
@ -22,8 +22,15 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <pixman.h>
|
||||
|
||||
#include "mtk/mtk-region.h"
|
||||
#include "mtk/mtk-region-private.h"
|
||||
|
||||
struct _MtkRegion
|
||||
{
|
||||
pixman_region32_t inner_region;
|
||||
};
|
||||
|
||||
/**
|
||||
* mtk_region_ref:
|
||||
@ -38,8 +45,15 @@ mtk_region_ref (MtkRegion *region)
|
||||
{
|
||||
g_return_val_if_fail (region != NULL, NULL);
|
||||
|
||||
g_atomic_ref_count_inc (®ion->ref_count);
|
||||
return region;
|
||||
return g_atomic_rc_box_acquire (region);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_region (gpointer data)
|
||||
{
|
||||
MtkRegion *region = data;
|
||||
|
||||
pixman_region32_fini (®ion->inner_region);
|
||||
}
|
||||
|
||||
void
|
||||
@ -47,11 +61,7 @@ mtk_region_unref (MtkRegion *region)
|
||||
{
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
if (g_atomic_ref_count_dec (®ion->ref_count))
|
||||
{
|
||||
pixman_region32_fini (®ion->inner_region);
|
||||
g_free (region);
|
||||
}
|
||||
g_atomic_rc_box_release_full (region, clear_region);
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (MtkRegion, mtk_region,
|
||||
@ -62,9 +72,8 @@ mtk_region_create (void)
|
||||
{
|
||||
MtkRegion *region;
|
||||
|
||||
region = g_new0 (MtkRegion, 1);
|
||||
region = g_atomic_rc_box_new0 (MtkRegion);
|
||||
|
||||
g_atomic_ref_count_init (®ion->ref_count);
|
||||
pixman_region32_init (®ion->inner_region);
|
||||
|
||||
return region;
|
||||
@ -181,7 +190,7 @@ mtk_region_union_rectangle (MtkRegion *region,
|
||||
pixman_region32_init_rect (&pixman_region,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
pixman_region32_union (®ion->inner_region,
|
||||
pixman_region32_union (®ion->inner_region,
|
||||
®ion->inner_region,
|
||||
&pixman_region);
|
||||
pixman_region32_fini (&pixman_region);
|
||||
@ -265,8 +274,8 @@ mtk_region_create_rectangle (const MtkRectangle *rect)
|
||||
MtkRegion *region;
|
||||
g_return_val_if_fail (rect != NULL, NULL);
|
||||
|
||||
region = g_new0 (MtkRegion, 1);
|
||||
g_atomic_ref_count_init (®ion->ref_count);
|
||||
region = g_atomic_rc_box_new0 (MtkRegion);
|
||||
|
||||
pixman_region32_init_rect (®ion->inner_region,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
@ -285,8 +294,7 @@ mtk_region_create_rectangles (const MtkRectangle *rects,
|
||||
g_return_val_if_fail (rects != NULL, NULL);
|
||||
g_return_val_if_fail (n_rects != 0, NULL);
|
||||
|
||||
region = g_new0 (MtkRegion, 1);
|
||||
g_atomic_ref_count_init (®ion->ref_count);
|
||||
region = g_atomic_rc_box_new0 (MtkRegion);
|
||||
|
||||
if (n_rects == 1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user