mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
mtk: Move Rectangle.from_graphene_rect from Meta
And drop the clutter helper Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
This commit is contained in:
parent
152fdc89fc
commit
1abef24154
@ -37,7 +37,6 @@
|
|||||||
#include "clutter/clutter-settings.h"
|
#include "clutter/clutter-settings.h"
|
||||||
#include "clutter/clutter-stage-manager.h"
|
#include "clutter/clutter-stage-manager.h"
|
||||||
#include "clutter/clutter-stage.h"
|
#include "clutter/clutter-stage.h"
|
||||||
#include "mtk/mtk.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -201,11 +200,6 @@ void _clutter_util_fully_transform_vertices (const graphene_matrix_t *modelvie
|
|||||||
graphene_point3d_t *vertices_out,
|
graphene_point3d_t *vertices_out,
|
||||||
int n_vertices);
|
int n_vertices);
|
||||||
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
void _clutter_util_rectangle_int_extents (const graphene_rect_t *src,
|
|
||||||
MtkRectangle *dest);
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
PangoDirection _clutter_pango_unichar_direction (gunichar ch);
|
PangoDirection _clutter_pango_unichar_direction (gunichar ch);
|
||||||
|
|
||||||
|
@ -119,22 +119,6 @@ _clutter_util_fully_transform_vertices (const graphene_matrix_t *modelview,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
_clutter_util_rectangle_int_extents (const graphene_rect_t *src,
|
|
||||||
MtkRectangle *dest)
|
|
||||||
{
|
|
||||||
graphene_rect_t tmp = *src;
|
|
||||||
|
|
||||||
graphene_rect_round_extents (&tmp, &tmp);
|
|
||||||
|
|
||||||
*dest = (MtkRectangle) {
|
|
||||||
.x = tmp.origin.x,
|
|
||||||
.y = tmp.origin.y,
|
|
||||||
.width = tmp.size.width,
|
|
||||||
.height = tmp.size.height,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GType value_type;
|
GType value_type;
|
||||||
|
@ -297,3 +297,53 @@ mtk_rectangle_to_graphene_rect (MtkRectangle *rect)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtk_rectangle_from_graphene_rect:
|
||||||
|
* @rect: A rectangle
|
||||||
|
* @rounding_strategy: The rounding strategy
|
||||||
|
* @dest: (out caller-allocates): an empty #MtkRectangle, to be filled
|
||||||
|
* with the coordinates of `rect`.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mtk_rectangle_from_graphene_rect (const graphene_rect_t *rect,
|
||||||
|
MtkRoundingStrategy rounding_strategy,
|
||||||
|
MtkRectangle *dest)
|
||||||
|
{
|
||||||
|
switch (rounding_strategy)
|
||||||
|
{
|
||||||
|
case MTK_ROUNDING_STRATEGY_SHRINK:
|
||||||
|
{
|
||||||
|
*dest = (MtkRectangle) {
|
||||||
|
.x = ceilf (rect->origin.x),
|
||||||
|
.y = ceilf (rect->origin.y),
|
||||||
|
.width = floorf (rect->size.width),
|
||||||
|
.height = floorf (rect->size.height),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MTK_ROUNDING_STRATEGY_GROW:
|
||||||
|
{
|
||||||
|
graphene_rect_t clamped = *rect;
|
||||||
|
|
||||||
|
graphene_rect_round_extents (&clamped, &clamped);
|
||||||
|
|
||||||
|
*dest = (MtkRectangle) {
|
||||||
|
.x = clamped.origin.x,
|
||||||
|
.y = clamped.origin.y,
|
||||||
|
.width = clamped.size.width,
|
||||||
|
.height = clamped.size.height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MTK_ROUNDING_STRATEGY_ROUND:
|
||||||
|
{
|
||||||
|
*dest = (MtkRectangle) {
|
||||||
|
.x = roundf (rect->origin.x),
|
||||||
|
.y = roundf (rect->origin.y),
|
||||||
|
.width = roundf (rect->size.width),
|
||||||
|
.height = roundf (rect->size.height),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,6 +29,14 @@
|
|||||||
|
|
||||||
#define MTK_TYPE_RECTANGLE (mtk_rectangle_get_type ())
|
#define MTK_TYPE_RECTANGLE (mtk_rectangle_get_type ())
|
||||||
|
|
||||||
|
typedef enum _MtkRoundingStrategy
|
||||||
|
{
|
||||||
|
MTK_ROUNDING_STRATEGY_SHRINK,
|
||||||
|
MTK_ROUNDING_STRATEGY_GROW,
|
||||||
|
MTK_ROUNDING_STRATEGY_ROUND,
|
||||||
|
} MtkRoundingStrategy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MtkRectangle:
|
* MtkRectangle:
|
||||||
* @x: X coordinate of the top-left corner
|
* @x: X coordinate of the top-left corner
|
||||||
@ -122,3 +130,8 @@ gboolean mtk_rectangle_contains_rect (const MtkRectangle *outer_rect,
|
|||||||
MTK_EXPORT
|
MTK_EXPORT
|
||||||
graphene_rect_t mtk_rectangle_to_graphene_rect (MtkRectangle *rect);
|
graphene_rect_t mtk_rectangle_to_graphene_rect (MtkRectangle *rect);
|
||||||
|
|
||||||
|
MTK_EXPORT
|
||||||
|
void mtk_rectangle_from_graphene_rect (const graphene_rect_t *rect,
|
||||||
|
MtkRoundingStrategy rounding_strategy,
|
||||||
|
MtkRectangle *dest);
|
||||||
|
|
||||||
|
@ -856,8 +856,8 @@ meta_monitor_normal_derive_layout (MetaMonitor *monitor,
|
|||||||
|
|
||||||
g_return_if_fail (crtc_config);
|
g_return_if_fail (crtc_config);
|
||||||
|
|
||||||
meta_rectangle_from_graphene_rect (&crtc_config->layout,
|
mtk_rectangle_from_graphene_rect (&crtc_config->layout,
|
||||||
META_ROUNDING_STRATEGY_ROUND,
|
MTK_ROUNDING_STRATEGY_ROUND,
|
||||||
layout);
|
layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +369,8 @@ offset_scale_and_clamp_region (const cairo_region_t *region,
|
|||||||
tmp = mtk_rectangle_to_graphene_rect (rect);
|
tmp = mtk_rectangle_to_graphene_rect (rect);
|
||||||
graphene_rect_offset (&tmp, offset_x, offset_y);
|
graphene_rect_offset (&tmp, offset_x, offset_y);
|
||||||
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
||||||
_clutter_util_rectangle_int_extents (&tmp, rect);
|
mtk_rectangle_from_graphene_rect (&tmp, MTK_ROUNDING_STRATEGY_GROW,
|
||||||
|
rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cairo_region_create_rectangles (rects, n_rects);
|
return cairo_region_create_rectangles (rects, n_rects);
|
||||||
@ -405,7 +406,9 @@ scale_offset_and_clamp_region (const cairo_region_t *region,
|
|||||||
tmp = mtk_rectangle_to_graphene_rect (rect);
|
tmp = mtk_rectangle_to_graphene_rect (rect);
|
||||||
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
||||||
graphene_rect_offset (&tmp, offset_x, offset_y);
|
graphene_rect_offset (&tmp, offset_x, offset_y);
|
||||||
_clutter_util_rectangle_int_extents (&tmp, rect);
|
mtk_rectangle_from_graphene_rect (&tmp,
|
||||||
|
MTK_ROUNDING_STRATEGY_GROW,
|
||||||
|
rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cairo_region_create_rectangles (rects, n_rects);
|
return cairo_region_create_rectangles (rects, n_rects);
|
||||||
|
@ -1431,8 +1431,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
|
|||||||
else
|
else
|
||||||
scale = 1.0;
|
scale = 1.0;
|
||||||
|
|
||||||
meta_rectangle_from_graphene_rect (&crtc_config->layout,
|
mtk_rectangle_from_graphene_rect (&crtc_config->layout,
|
||||||
META_ROUNDING_STRATEGY_ROUND,
|
MTK_ROUNDING_STRATEGY_ROUND,
|
||||||
&view_layout);
|
&view_layout);
|
||||||
view_native = g_object_new (META_TYPE_RENDERER_VIEW_NATIVE,
|
view_native = g_object_new (META_TYPE_RENDERER_VIEW_NATIVE,
|
||||||
"name", meta_output_get_name (output),
|
"name", meta_output_get_name (output),
|
||||||
|
@ -127,8 +127,8 @@ meta_renderer_x11_nested_create_view (MetaRenderer *renderer,
|
|||||||
else
|
else
|
||||||
offscreen = NULL;
|
offscreen = NULL;
|
||||||
|
|
||||||
meta_rectangle_from_graphene_rect (&crtc_config->layout,
|
mtk_rectangle_from_graphene_rect (&crtc_config->layout,
|
||||||
META_ROUNDING_STRATEGY_ROUND,
|
MTK_ROUNDING_STRATEGY_ROUND,
|
||||||
&view_layout);
|
&view_layout);
|
||||||
|
|
||||||
mode_info = meta_crtc_mode_get_info (crtc_config->mode);
|
mode_info = meta_crtc_mode_get_info (crtc_config->mode);
|
||||||
|
@ -1040,7 +1040,7 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
|
|||||||
|
|
||||||
meta_rectangle_scale_double (clip,
|
meta_rectangle_scale_double (clip,
|
||||||
1.0 / stex->buffer_scale,
|
1.0 / stex->buffer_scale,
|
||||||
META_ROUNDING_STRATEGY_GROW,
|
MTK_ROUNDING_STRATEGY_GROW,
|
||||||
clip);
|
clip);
|
||||||
|
|
||||||
if (meta_monitor_transform_is_rotated (stex->transform))
|
if (meta_monitor_transform_is_rotated (stex->transform))
|
||||||
|
@ -467,8 +467,8 @@ meta_region_apply_matrix_transform_expand (const cairo_region_t *region,
|
|||||||
|
|
||||||
graphene_matrix_transform_bounds (transform, &rect, &transformed_rect);
|
graphene_matrix_transform_bounds (transform, &rect, &transformed_rect);
|
||||||
|
|
||||||
meta_rectangle_from_graphene_rect (&transformed_rect,
|
mtk_rectangle_from_graphene_rect (&transformed_rect,
|
||||||
META_ROUNDING_STRATEGY_GROW,
|
MTK_ROUNDING_STRATEGY_GROW,
|
||||||
&rects[i]);
|
&rects[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,13 +40,6 @@ typedef enum
|
|||||||
FIXED_DIRECTION_Y = 1 << 1,
|
FIXED_DIRECTION_Y = 1 << 1,
|
||||||
} FixedDirections;
|
} FixedDirections;
|
||||||
|
|
||||||
typedef enum _MetaRoundingStrategy
|
|
||||||
{
|
|
||||||
META_ROUNDING_STRATEGY_SHRINK,
|
|
||||||
META_ROUNDING_STRATEGY_GROW,
|
|
||||||
META_ROUNDING_STRATEGY_ROUND,
|
|
||||||
} MetaRoundingStrategy;
|
|
||||||
|
|
||||||
/* Output functions -- note that the output buffer had better be big enough:
|
/* Output functions -- note that the output buffer had better be big enough:
|
||||||
* rect_to_string: RECT_LENGTH
|
* rect_to_string: RECT_LENGTH
|
||||||
* region_to_string: (RECT_LENGTH+strlen(separator_string)) *
|
* region_to_string: (RECT_LENGTH+strlen(separator_string)) *
|
||||||
@ -251,7 +244,7 @@ gboolean meta_rectangle_is_adjacent_to (MtkRectangle *rect,
|
|||||||
META_EXPORT_TEST
|
META_EXPORT_TEST
|
||||||
void meta_rectangle_scale_double (const MtkRectangle *rect,
|
void meta_rectangle_scale_double (const MtkRectangle *rect,
|
||||||
double scale,
|
double scale,
|
||||||
MetaRoundingStrategy rounding_strategy,
|
MtkRoundingStrategy rounding_strategy,
|
||||||
MtkRectangle *dest);
|
MtkRectangle *dest);
|
||||||
|
|
||||||
META_EXPORT_TEST
|
META_EXPORT_TEST
|
||||||
@ -261,10 +254,6 @@ void meta_rectangle_transform (const MtkRectangle *rect,
|
|||||||
int height,
|
int height,
|
||||||
MtkRectangle *dest);
|
MtkRectangle *dest);
|
||||||
|
|
||||||
void meta_rectangle_from_graphene_rect (const graphene_rect_t *rect,
|
|
||||||
MetaRoundingStrategy rounding_strategy,
|
|
||||||
MtkRectangle *dest);
|
|
||||||
|
|
||||||
void meta_rectangle_crop_and_scale (const MtkRectangle *rect,
|
void meta_rectangle_crop_and_scale (const MtkRectangle *rect,
|
||||||
graphene_rect_t *src_rect,
|
graphene_rect_t *src_rect,
|
||||||
int dst_width,
|
int dst_width,
|
||||||
|
@ -1852,14 +1852,14 @@ meta_rectangle_is_adjacent_to (MtkRectangle *rect,
|
|||||||
void
|
void
|
||||||
meta_rectangle_scale_double (const MtkRectangle *rect,
|
meta_rectangle_scale_double (const MtkRectangle *rect,
|
||||||
double scale,
|
double scale,
|
||||||
MetaRoundingStrategy rounding_strategy,
|
MtkRoundingStrategy rounding_strategy,
|
||||||
MtkRectangle *dest)
|
MtkRectangle *dest)
|
||||||
{
|
{
|
||||||
graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y,
|
graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y,
|
||||||
rect->width, rect->height);
|
rect->width, rect->height);
|
||||||
|
|
||||||
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
||||||
meta_rectangle_from_graphene_rect (&tmp, rounding_strategy, dest);
|
mtk_rectangle_from_graphene_rect (&tmp, rounding_strategy, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1946,49 +1946,6 @@ meta_rectangle_transform (const MtkRectangle *rect,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
meta_rectangle_from_graphene_rect (const graphene_rect_t *rect,
|
|
||||||
MetaRoundingStrategy rounding_strategy,
|
|
||||||
MtkRectangle *dest)
|
|
||||||
{
|
|
||||||
switch (rounding_strategy)
|
|
||||||
{
|
|
||||||
case META_ROUNDING_STRATEGY_SHRINK:
|
|
||||||
{
|
|
||||||
*dest = (MtkRectangle) {
|
|
||||||
.x = ceilf (rect->origin.x),
|
|
||||||
.y = ceilf (rect->origin.y),
|
|
||||||
.width = floorf (rect->size.width),
|
|
||||||
.height = floorf (rect->size.height),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case META_ROUNDING_STRATEGY_GROW:
|
|
||||||
{
|
|
||||||
graphene_rect_t clamped = *rect;
|
|
||||||
|
|
||||||
graphene_rect_round_extents (&clamped, &clamped);
|
|
||||||
|
|
||||||
*dest = (MtkRectangle) {
|
|
||||||
.x = clamped.origin.x,
|
|
||||||
.y = clamped.origin.y,
|
|
||||||
.width = clamped.size.width,
|
|
||||||
.height = clamped.size.height,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case META_ROUNDING_STRATEGY_ROUND:
|
|
||||||
{
|
|
||||||
*dest = (MtkRectangle) {
|
|
||||||
.x = roundf (rect->origin.x),
|
|
||||||
.y = roundf (rect->origin.y),
|
|
||||||
.width = roundf (rect->size.width),
|
|
||||||
.height = roundf (rect->size.height),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_rectangle_crop_and_scale (const MtkRectangle *rect,
|
meta_rectangle_crop_and_scale (const MtkRectangle *rect,
|
||||||
graphene_rect_t *src_rect,
|
graphene_rect_t *src_rect,
|
||||||
@ -2005,5 +1962,5 @@ meta_rectangle_crop_and_scale (const MtkRectangle *rect,
|
|||||||
&tmp);
|
&tmp);
|
||||||
graphene_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y);
|
graphene_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y);
|
||||||
|
|
||||||
meta_rectangle_from_graphene_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest);
|
mtk_rectangle_from_graphene_rect (&tmp, MTK_ROUNDING_STRATEGY_GROW, dest);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user