Commit 75cffd0e authored by Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto Committed by Jonas Ådahl

shaped-texture: Implement ClutterContent

MetaWindowActor is the compositor-side representative of a
MetaWindow. Specifically it represents the geometry of the
window under Clutter scene graph. MetaWindowActors are backed
by MetaSurfaceActors, that represent the windowing system's
surfaces themselves. Naturally, these surfaces have textures
with the pixel content of the clients associated with them.
These textures are represented by MetaShapedTexture.

MetaShapedTextures are currently implemented as ClutterActor
subclasses that override the paint function to paint the
textures it holds.

Conceptually, however, Clutter has an abstraction layer for
contents of actors: ClutterContent. Which MetaShapedTexture
fits nicely, in fact.

Make MetaShapedTexture a ClutterContent implementation. This
forces a few changes in the stack:

 * MetaShapedTexture now handles buffer scale.

 * We now paint into ClutterPaintNode instead of the direct
   framebuffer.

 * Various pieces of Wayland code now use MetaSurfaceActor
   instead of MetaShapedTexture.

 * MetaSurfaceActorWayland doesn't override size negotiation
   vfuncs anymore

!409
parent e33d6b29
......@@ -30,7 +30,7 @@
#include "backends/meta-monitor-manager-private.h"
#include "meta/meta-shaped-texture.h"
ClutterActor *meta_shaped_texture_new (void);
MetaShapedTexture *meta_shaped_texture_new (void);
void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
CoglTexture *texture);
void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
......@@ -51,5 +51,13 @@ void meta_shaped_texture_set_viewport_dst_size (MetaShapedTexture *stex,
int dst_width,
int dst_height);
void meta_shaped_texture_reset_viewport_dst_size (MetaShapedTexture *stex);
void meta_shaped_texture_cull_out (MetaShapedTexture *stex,
cairo_region_t *unobscured_region,
cairo_region_t *clip_region,
uint8_t opacity);
void meta_shaped_texture_reset_culling (MetaShapedTexture *stex);
void meta_shaped_texture_set_buffer_scale (MetaShapedTexture *stex,
int buffer_scale);
int meta_shaped_texture_get_buffer_scale (MetaShapedTexture *stex);
#endif
This diff is collapsed.
......@@ -110,54 +110,6 @@ meta_surface_actor_wayland_get_window (MetaSurfaceActor *actor)
return surface->window;
}
static void
meta_surface_actor_wayland_get_preferred_width (ClutterActor *actor,
gfloat for_height,
gfloat *min_width_p,
gfloat *natural_width_p)
{
MetaSurfaceActorWayland *self = META_SURFACE_ACTOR_WAYLAND (actor);
MetaShapedTexture *stex;
double scale;
stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self));
clutter_actor_get_scale (CLUTTER_ACTOR (stex), &scale, NULL);
clutter_actor_get_preferred_width (CLUTTER_ACTOR (stex),
for_height,
min_width_p,
natural_width_p);
if (min_width_p)
*min_width_p *= scale;
if (natural_width_p)
*natural_width_p *= scale;
}
static void
meta_surface_actor_wayland_get_preferred_height (ClutterActor *actor,
gfloat for_width,
gfloat *min_height_p,
gfloat *natural_height_p)
{
MetaSurfaceActorWayland *self = META_SURFACE_ACTOR_WAYLAND (actor);
MetaShapedTexture *stex;
double scale;
stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self));
clutter_actor_get_scale (CLUTTER_ACTOR (stex), NULL, &scale);
clutter_actor_get_preferred_height (CLUTTER_ACTOR (stex),
for_width,
min_height_p,
natural_height_p);
if (min_height_p)
*min_height_p *= scale;
if (natural_height_p)
*natural_height_p *= scale;
}
static void
meta_surface_actor_wayland_paint (ClutterActor *actor)
{
......@@ -203,8 +155,6 @@ meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
actor_class->get_preferred_width = meta_surface_actor_wayland_get_preferred_width;
actor_class->get_preferred_height = meta_surface_actor_wayland_get_preferred_height;
actor_class->paint = meta_surface_actor_wayland_paint;
surface_actor_class->process_damage = meta_surface_actor_wayland_process_damage;
......
......@@ -159,13 +159,22 @@ meta_surface_actor_cull_out (MetaCullable *cullable,
cairo_region_t *unobscured_region,
cairo_region_t *clip_region)
{
meta_cullable_cull_out_children (cullable, unobscured_region, clip_region);
MetaSurfaceActor *surface_actor = META_SURFACE_ACTOR (cullable);
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor);
uint8_t opacity = clutter_actor_get_opacity (CLUTTER_ACTOR (cullable));
meta_shaped_texture_cull_out (priv->texture, unobscured_region, clip_region, opacity);
}
static void
meta_surface_actor_reset_culling (MetaCullable *cullable)
{
meta_cullable_reset_culling_children (cullable);
MetaSurfaceActor *surface_actor = META_SURFACE_ACTOR (cullable);
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor);
meta_shaped_texture_reset_culling (priv->texture);
}
static void
......@@ -189,10 +198,13 @@ meta_surface_actor_init (MetaSurfaceActor *self)
MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (self);
priv->texture = META_SHAPED_TEXTURE (meta_shaped_texture_new ());
priv->texture = meta_shaped_texture_new ();
g_signal_connect_object (priv->texture, "size-changed",
G_CALLBACK (texture_size_changed), self, 0);
clutter_actor_add_child (CLUTTER_ACTOR (self), CLUTTER_ACTOR (priv->texture));
clutter_actor_set_content (CLUTTER_ACTOR (self),
CLUTTER_CONTENT (priv->texture));
clutter_actor_set_request_mode (CLUTTER_ACTOR (self),
CLUTTER_REQUEST_CONTENT_SIZE);
}
cairo_surface_t *
......
......@@ -833,14 +833,14 @@ meta_window_actor_get_meta_window (MetaWindowActor *self)
*
* Return value: (transfer none): the #ClutterActor for the contents
*/
ClutterActor *
MetaShapedTexture *
meta_window_actor_get_texture (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (self);
if (priv->surface)
return CLUTTER_ACTOR (meta_surface_actor_get_texture (priv->surface));
return meta_surface_actor_get_texture (priv->surface);
else
return NULL;
}
......@@ -1902,19 +1902,19 @@ meta_window_actor_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
MetaShapedTexture *stex;
MetaRectangle buffer_rect;
MetaRectangle frame_rect;
double scale_x, scale_y;
int buffer_scale;
stex = meta_surface_actor_get_texture (priv->surface);
clutter_actor_get_scale (CLUTTER_ACTOR (stex), &scale_x, &scale_y);
buffer_scale = meta_shaped_texture_get_buffer_scale (stex);
window = priv->window;
meta_window_get_buffer_rect (window, &buffer_rect);
meta_window_get_frame_rect (window, &frame_rect);
bounds->x = (int) floor ((frame_rect.x - buffer_rect.x) / scale_x);
bounds->y = (int) floor ((frame_rect.y - buffer_rect.y) / scale_y);
bounds->width = (int) ceil (frame_rect.width / scale_x);
bounds->height = (int) ceil (frame_rect.height / scale_y);
bounds->x = (int) floor ((frame_rect.x - buffer_rect.x) / (float) buffer_scale);
bounds->y = (int) floor ((frame_rect.y - buffer_rect.y) / (float) buffer_scale);
bounds->width = (int) ceil (frame_rect.width / (float) buffer_scale);
bounds->height = (int) ceil (frame_rect.height / (float) buffer_scale);
}
static void
......@@ -1928,7 +1928,6 @@ meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (window_actor);
MetaShapedTexture *stex;
MetaRectangle bounds;
ClutterVertex v1 = { 0.f, }, v2 = { 0.f, };
......@@ -1941,8 +1940,9 @@ meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast
bounds.y,
bounds.y + bounds.height);
stex = meta_surface_actor_get_texture (priv->surface);
clutter_actor_apply_transform_to_point (CLUTTER_ACTOR (stex), &v1, &v2);
clutter_actor_apply_transform_to_point (CLUTTER_ACTOR (priv->surface),
&v1,
&v2);
*x_out = (double) v2.x;
*y_out = (double) v2.y;
......@@ -1969,22 +1969,19 @@ meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_w
out_cursor_scale)
{
MetaShapedTexture *stex;
double actor_scale;
double texture_scale;
float cursor_texture_scale;
stex = meta_surface_actor_get_texture (priv->surface);
clutter_actor_get_scale (CLUTTER_ACTOR (stex), &actor_scale, NULL);
texture_scale = meta_shaped_texture_get_buffer_scale (stex);
cursor_texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
*out_cursor_scale = actor_scale / cursor_texture_scale;
*out_cursor_scale = texture_scale / cursor_texture_scale;
}
if (out_relative_cursor_position)
{
MetaShapedTexture *stex;
stex = meta_surface_actor_get_texture (priv->surface);
clutter_actor_transform_stage_point (CLUTTER_ACTOR (stex),
clutter_actor_transform_stage_point (CLUTTER_ACTOR (priv->surface),
cursor_position->x,
cursor_position->y,
&out_relative_cursor_position->x,
......
......@@ -25,6 +25,7 @@
#include "clutter/clutter.h"
#include "meta/compositor.h"
#include "meta/meta-shaped-texture.h"
#define META_TYPE_WINDOW_ACTOR (meta_window_actor_get_type ())
......@@ -38,7 +39,7 @@ META_EXPORT
MetaWindow * meta_window_actor_get_meta_window (MetaWindowActor *self);
META_EXPORT
ClutterActor * meta_window_actor_get_texture (MetaWindowActor *self);
MetaShapedTexture *meta_window_actor_get_texture (MetaWindowActor *self);
META_EXPORT
void meta_window_actor_sync_visibility (MetaWindowActor *self);
......
......@@ -154,16 +154,13 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
meta_wayland_surface_role_get_surface (surface_role);
MetaSurfaceActor *surface_actor;
MetaShapedTexture *stex;
double actor_scale;
GList *l;
cairo_rectangle_int_t surface_rect;
int geometry_scale;
surface_actor = priv->actor;
stex = meta_surface_actor_get_texture (surface_actor);
actor_scale = meta_wayland_actor_surface_calculate_scale (actor_surface);
clutter_actor_set_scale (CLUTTER_ACTOR (stex), actor_scale, actor_scale);
meta_shaped_texture_set_buffer_scale (stex, surface->scale);
/* Wayland surface coordinate space -> stage coordinate space */
geometry_scale = meta_wayland_actor_surface_get_geometry_scale (actor_surface);
......
......@@ -1197,7 +1197,7 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data
surface_actor = meta_wayland_surface_get_actor (surface);
clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface_actor)),
clutter_actor_transform_stage_point (CLUTTER_ACTOR (surface_actor),
seat->pointer->grab_x,
seat->pointer->grab_y,
&surface_pos.x, &surface_pos.y);
......
......@@ -1581,7 +1581,7 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
else
{
ClutterActor *actor =
CLUTTER_ACTOR (meta_surface_actor_get_texture (meta_wayland_surface_get_actor (surface)));
CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface));
clutter_actor_transform_stage_point (actor, abs_x, abs_y, sx, sy);
*sx /= surface->scale;
......@@ -1597,7 +1597,7 @@ meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
float *y)
{
ClutterActor *actor =
CLUTTER_ACTOR (meta_surface_actor_get_texture (meta_wayland_surface_get_actor (surface)));
CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface));
ClutterVertex sv = {
.x = sx * surface->scale,
.y = sy * surface->scale,
......
......@@ -663,7 +663,7 @@ meta_wayland_tablet_tool_get_relative_coordinates (MetaWaylandTabletTool *tool,
surface_actor = meta_wayland_surface_get_actor (surface);
clutter_event_get_coords (event, &xf, &yf);
clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface_actor)),
clutter_actor_transform_stage_point (CLUTTER_ACTOR (surface_actor),
xf, yf, &xf, &yf);
*sx = wl_fixed_from_double (xf) / surface->scale;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment