shaped-texture: Start using MetaMultiTexture

To be able to later support more complex YUV formats, we need to make
sure that MetaShapedTexture (the one who will actually render the
texture) can use the MetaMultiTexture class.
This commit is contained in:
Niels De Graef
2019-10-22 12:25:37 +02:00
parent 65a3b13b2f
commit c2e191fe3f
12 changed files with 282 additions and 204 deletions

View File

@@ -32,7 +32,7 @@
MetaShapedTexture *meta_shaped_texture_new (void); MetaShapedTexture *meta_shaped_texture_new (void);
void meta_shaped_texture_set_texture (MetaShapedTexture *stex, void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
CoglTexture *texture); MetaMultiTexture *multi_texture);
void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex, void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
gboolean is_y_inverted); gboolean is_y_inverted);
void meta_shaped_texture_set_snippet (MetaShapedTexture *stex, void meta_shaped_texture_set_snippet (MetaShapedTexture *stex,

View File

@@ -74,7 +74,7 @@ struct _MetaShapedTexture
MetaTextureTower *paint_tower; MetaTextureTower *paint_tower;
CoglTexture *texture; MetaMultiTexture *texture;
CoglTexture *mask_texture; CoglTexture *mask_texture;
CoglSnippet *snippet; CoglSnippet *snippet;
@@ -457,18 +457,18 @@ paint_clipped_rectangle_node (MetaShapedTexture *stex,
} }
static void static void
set_cogl_texture (MetaShapedTexture *stex, set_multi_texture (MetaShapedTexture *stex,
CoglTexture *cogl_tex) MetaMultiTexture *multi_tex)
{ {
int width, height; int width, height;
cogl_clear_object (&stex->texture); g_clear_object (&stex->texture);
if (cogl_tex != NULL) if (multi_tex != NULL)
{ {
stex->texture = cogl_object_ref (cogl_tex); stex->texture = g_object_ref (multi_tex);
width = cogl_texture_get_width (COGL_TEXTURE (cogl_tex)); width = meta_multi_texture_get_width (multi_tex);
height = cogl_texture_get_height (COGL_TEXTURE (cogl_tex)); height = meta_multi_texture_get_height (multi_tex);
} }
else else
{ {
@@ -490,7 +490,7 @@ set_cogl_texture (MetaShapedTexture *stex,
* damage. */ * damage. */
if (stex->create_mipmaps) if (stex->create_mipmaps)
meta_texture_tower_set_base_texture (stex->paint_tower, cogl_tex); meta_texture_tower_set_base_texture (stex->paint_tower, multi_tex);
} }
static gboolean static gboolean
@@ -522,7 +522,7 @@ static void
do_paint_content (MetaShapedTexture *stex, do_paint_content (MetaShapedTexture *stex,
ClutterPaintNode *root_node, ClutterPaintNode *root_node,
ClutterPaintContext *paint_context, ClutterPaintContext *paint_context,
CoglTexture *paint_tex, MetaMultiTexture *paint_tex,
ClutterActorBox *alloc, ClutterActorBox *alloc,
uint8_t opacity) uint8_t opacity)
{ {
@@ -534,6 +534,7 @@ do_paint_content (MetaShapedTexture *stex,
CoglPipelineFilter filter; CoglPipelineFilter filter;
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
int sample_width, sample_height; int sample_width, sample_height;
guint n_planes;
ensure_size_valid (stex); ensure_size_valid (stex);
@@ -609,6 +610,8 @@ do_paint_content (MetaShapedTexture *stex,
} }
} }
n_planes = meta_multi_texture_get_n_planes (paint_tex);
/* First, paint the unblended parts, which are part of the opaque region. */ /* First, paint the unblended parts, which are part of the opaque region. */
if (use_opaque_region) if (use_opaque_region)
{ {
@@ -620,8 +623,14 @@ do_paint_content (MetaShapedTexture *stex,
CoglPipeline *opaque_pipeline; CoglPipeline *opaque_pipeline;
opaque_pipeline = get_unblended_pipeline (stex, ctx); opaque_pipeline = get_unblended_pipeline (stex, ctx);
cogl_pipeline_set_layer_texture (opaque_pipeline, 0, paint_tex);
cogl_pipeline_set_layer_filters (opaque_pipeline, 0, filter, filter); for (i = 0; i < n_planes; i++)
{
CoglTexture *plane = meta_multi_texture_get_plane (paint_tex, i);
cogl_pipeline_set_layer_texture (opaque_pipeline, i, plane);
cogl_pipeline_set_layer_filters (opaque_pipeline, i, filter, filter);
}
n_rects = cairo_region_num_rectangles (stex->opaque_region); n_rects = cairo_region_num_rectangles (stex->opaque_region);
for (i = 0; i < n_rects; i++) for (i = 0; i < n_rects; i++)
@@ -648,6 +657,7 @@ do_paint_content (MetaShapedTexture *stex,
if (!blended_tex_region || !cairo_region_is_empty (blended_tex_region)) if (!blended_tex_region || !cairo_region_is_empty (blended_tex_region))
{ {
CoglPipeline *blended_pipeline; CoglPipeline *blended_pipeline;
guint i;
if (stex->mask_texture == NULL) if (stex->mask_texture == NULL)
{ {
@@ -656,16 +666,20 @@ do_paint_content (MetaShapedTexture *stex,
else else
{ {
blended_pipeline = get_masked_pipeline (stex, ctx); blended_pipeline = get_masked_pipeline (stex, ctx);
cogl_pipeline_set_layer_texture (blended_pipeline, 1, stex->mask_texture); cogl_pipeline_set_layer_texture (blended_pipeline, n_planes, stex->mask_texture);
cogl_pipeline_set_layer_filters (blended_pipeline, 1, filter, filter); cogl_pipeline_set_layer_filters (blended_pipeline, n_planes, filter, filter);
} }
cogl_pipeline_set_layer_texture (blended_pipeline, 0, paint_tex); for (i = 0; i < n_planes; i++)
cogl_pipeline_set_layer_filters (blended_pipeline, 0, filter, filter); {
CoglTexture *plane = meta_multi_texture_get_plane (paint_tex, i);
CoglColor color; cogl_pipeline_set_layer_texture (blended_pipeline, i, plane);
cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity); cogl_pipeline_set_layer_filters (blended_pipeline, i, filter, filter);
cogl_pipeline_set_color (blended_pipeline, &color); }
cogl_pipeline_set_color4ub (blended_pipeline,
opacity, opacity, opacity, opacity);
if (blended_tex_region) if (blended_tex_region)
{ {
@@ -702,11 +716,11 @@ do_paint_content (MetaShapedTexture *stex,
g_clear_pointer (&blended_tex_region, cairo_region_destroy); g_clear_pointer (&blended_tex_region, cairo_region_destroy);
} }
static CoglTexture * static MetaMultiTexture *
select_texture_for_paint (MetaShapedTexture *stex, select_texture_for_paint (MetaShapedTexture *stex,
ClutterPaintContext *paint_context) ClutterPaintContext *paint_context)
{ {
CoglTexture *texture = NULL; MetaMultiTexture *texture = NULL;
int64_t now; int64_t now;
if (!stex->texture) if (!stex->texture)
@@ -754,7 +768,7 @@ meta_shaped_texture_paint_content (ClutterContent *content,
{ {
MetaShapedTexture *stex = META_SHAPED_TEXTURE (content); MetaShapedTexture *stex = META_SHAPED_TEXTURE (content);
ClutterActorBox alloc; ClutterActorBox alloc;
CoglTexture *paint_tex = NULL; MetaMultiTexture *paint_tex = NULL;
uint8_t opacity; uint8_t opacity;
/* The GL EXT_texture_from_pixmap extension does allow for it to be /* The GL EXT_texture_from_pixmap extension does allow for it to be
@@ -817,7 +831,7 @@ meta_shaped_texture_set_create_mipmaps (MetaShapedTexture *stex,
if (create_mipmaps != stex->create_mipmaps) if (create_mipmaps != stex->create_mipmaps)
{ {
CoglTexture *base_texture; MetaMultiTexture *base_texture;
stex->create_mipmaps = create_mipmaps; stex->create_mipmaps = create_mipmaps;
base_texture = create_mipmaps ? stex->texture : NULL; base_texture = create_mipmaps ? stex->texture : NULL;
meta_texture_tower_set_base_texture (stex->paint_tower, base_texture); meta_texture_tower_set_base_texture (stex->paint_tower, base_texture);
@@ -964,18 +978,18 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
/** /**
* meta_shaped_texture_set_texture: * meta_shaped_texture_set_texture:
* @stex: The #MetaShapedTexture * @stex: The #MetaShapedTexture
* @pixmap: The #CoglTexture to display * @pixmap: The #MetaMultiTexture to display
*/ */
void void
meta_shaped_texture_set_texture (MetaShapedTexture *stex, meta_shaped_texture_set_texture (MetaShapedTexture *stex,
CoglTexture *texture) MetaMultiTexture *texture)
{ {
g_return_if_fail (META_IS_SHAPED_TEXTURE (stex)); g_return_if_fail (META_IS_SHAPED_TEXTURE (stex));
if (stex->texture == texture) if (stex->texture == texture)
return; return;
set_cogl_texture (stex, texture); set_multi_texture (stex, texture);
} }
/** /**
@@ -1016,11 +1030,11 @@ meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
* *
* Returns: (transfer none): the unshaped texture * Returns: (transfer none): the unshaped texture
*/ */
CoglTexture * MetaMultiTexture *
meta_shaped_texture_get_texture (MetaShapedTexture *stex) meta_shaped_texture_get_texture (MetaShapedTexture *stex)
{ {
g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), NULL); g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), NULL);
return COGL_TEXTURE (stex->texture); return stex->texture;
} }
/** /**
@@ -1058,13 +1072,19 @@ meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex)
gboolean gboolean
meta_shaped_texture_has_alpha (MetaShapedTexture *stex) meta_shaped_texture_has_alpha (MetaShapedTexture *stex)
{ {
CoglTexture *texture; MetaMultiTexture *multi_texture;
CoglTexture *cogl_texture;
texture = stex->texture; multi_texture = stex->texture;
if (!texture) if (!multi_texture)
return TRUE; return TRUE;
switch (cogl_texture_get_components (texture)) /* FIXME: for now we don't support alpha (except simple textures) */
if (meta_multi_texture_get_n_planes (multi_texture) > 1)
return FALSE;
cogl_texture = meta_multi_texture_get_plane (multi_texture, 0);
switch (cogl_texture_get_components (cogl_texture))
{ {
case COGL_TEXTURE_COMPONENTS_A: case COGL_TEXTURE_COMPONENTS_A:
case COGL_TEXTURE_COMPONENTS_RGBA: case COGL_TEXTURE_COMPONENTS_RGBA:
@@ -1082,12 +1102,12 @@ meta_shaped_texture_has_alpha (MetaShapedTexture *stex)
gboolean gboolean
meta_shaped_texture_is_opaque (MetaShapedTexture *stex) meta_shaped_texture_is_opaque (MetaShapedTexture *stex)
{ {
CoglTexture *texture; MetaMultiTexture *multi_texture;
cairo_rectangle_int_t opaque_rect; cairo_rectangle_int_t opaque_rect;
texture = stex->texture; multi_texture = stex->texture;
if (!texture) if (!multi_texture)
return FALSE; return TRUE;
if (!meta_shaped_texture_has_alpha (stex)) if (!meta_shaped_texture_has_alpha (stex))
return TRUE; return TRUE;
@@ -1179,7 +1199,13 @@ meta_shaped_texture_reset_viewport_dst_size (MetaShapedTexture *stex)
static gboolean static gboolean
should_get_via_offscreen (MetaShapedTexture *stex) should_get_via_offscreen (MetaShapedTexture *stex)
{ {
if (!cogl_texture_is_get_data_supported (stex->texture)) CoglTexture *cogl_texture;
if (meta_multi_texture_get_n_planes (stex->texture) > 1)
return FALSE;
cogl_texture = meta_multi_texture_get_plane (stex->texture, 0);
if (!cogl_texture_is_get_data_supported (cogl_texture))
return TRUE; return TRUE;
if (stex->has_viewport_src_rect || stex->has_viewport_dst_size) if (stex->has_viewport_src_rect || stex->has_viewport_dst_size)
@@ -1322,9 +1348,7 @@ meta_shaped_texture_get_image (MetaShapedTexture *stex,
g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), NULL); g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), NULL);
texture = COGL_TEXTURE (stex->texture); if (stex->texture == NULL)
if (texture == NULL)
return NULL; return NULL;
ensure_size_valid (stex); ensure_size_valid (stex);
@@ -1367,6 +1391,9 @@ meta_shaped_texture_get_image (MetaShapedTexture *stex,
image_height); image_height);
} }
/* We know that we only have 1 plane at this point */
texture = meta_multi_texture_get_plane (stex->texture, 0);
if (image_clip) if (image_clip)
texture = cogl_texture_new_from_sub_texture (texture, texture = cogl_texture_new_from_sub_texture (texture,
image_clip->x, image_clip->x,

View File

@@ -46,7 +46,7 @@ struct _MetaSurfaceActorX11
MetaDisplay *display; MetaDisplay *display;
CoglTexture *texture; MetaMultiTexture *texture;
Pixmap pixmap; Pixmap pixmap;
Damage damage; Damage damage;
@@ -109,7 +109,7 @@ detach_pixmap (MetaSurfaceActorX11 *self)
self->pixmap = None; self->pixmap = None;
meta_x11_error_trap_pop (display->x11_display); meta_x11_error_trap_pop (display->x11_display);
g_clear_pointer (&self->texture, cogl_object_unref); g_clear_object (&self->texture);
} }
static void static void
@@ -119,23 +119,23 @@ set_pixmap (MetaSurfaceActorX11 *self,
CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self)); MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self));
GError *error = NULL; GError *error = NULL;
CoglTexture *texture; CoglTexture *cogl_texture;
g_assert (self->pixmap == None); g_assert (self->pixmap == None);
self->pixmap = pixmap; self->pixmap = pixmap;
texture = COGL_TEXTURE (cogl_texture_pixmap_x11_new (ctx, self->pixmap, FALSE, &error)); cogl_texture = COGL_TEXTURE (cogl_texture_pixmap_x11_new (ctx, self->pixmap, FALSE, &error));
if (error != NULL) if (error != NULL)
{ {
g_warning ("Failed to allocate stex texture: %s", error->message); g_warning ("Failed to allocate stex texture: %s", error->message);
g_error_free (error); g_error_free (error);
} }
else if (G_UNLIKELY (!cogl_texture_pixmap_x11_is_using_tfp_extension (COGL_TEXTURE_PIXMAP_X11 (texture)))) else if (G_UNLIKELY (!cogl_texture_pixmap_x11_is_using_tfp_extension (COGL_TEXTURE_PIXMAP_X11 (cogl_texture))))
g_warning ("NOTE: Not using GLX TFP!\n"); g_warning ("NOTE: Not using GLX TFP!\n");
self->texture = texture; self->texture = meta_multi_texture_new_simple (cogl_texture);
meta_shaped_texture_set_texture (stex, texture); meta_shaped_texture_set_texture (stex, self->texture);
} }
static void static void
@@ -192,6 +192,7 @@ meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
int x, int y, int width, int height) int x, int y, int width, int height)
{ {
MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor); MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor);
CoglTexturePixmapX11 *pixmap;
self->received_damage = TRUE; self->received_damage = TRUE;
@@ -215,8 +216,12 @@ meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
if (!is_visible (self)) if (!is_visible (self))
return; return;
cogl_texture_pixmap_x11_update_area (COGL_TEXTURE_PIXMAP_X11 (self->texture), /* We don't support multi-plane or YUV based formats here */
x, y, width, height); if (!meta_multi_texture_is_simple (self->texture))
return;
pixmap = COGL_TEXTURE_PIXMAP_X11 (meta_multi_texture_get_plane (self->texture, 0));
cogl_texture_pixmap_x11_update_area (pixmap, x, y, width, height);
} }
static void static void

View File

@@ -58,8 +58,8 @@ typedef struct
struct _MetaTextureTower struct _MetaTextureTower
{ {
int n_levels; int n_levels;
CoglTexture *textures[MAX_TEXTURE_LEVELS]; MetaMultiTexture *textures[MAX_TEXTURE_LEVELS];
CoglOffscreen *fbos[MAX_TEXTURE_LEVELS]; GList *fbos[MAX_TEXTURE_LEVELS];
Box invalid[MAX_TEXTURE_LEVELS]; Box invalid[MAX_TEXTURE_LEVELS];
CoglPipeline *pipeline_template; CoglPipeline *pipeline_template;
}; };
@@ -113,7 +113,7 @@ meta_texture_tower_free (MetaTextureTower *tower)
*/ */
void void
meta_texture_tower_set_base_texture (MetaTextureTower *tower, meta_texture_tower_set_base_texture (MetaTextureTower *tower,
CoglTexture *texture) MetaMultiTexture *texture)
{ {
int i; int i;
@@ -126,20 +126,12 @@ meta_texture_tower_set_base_texture (MetaTextureTower *tower,
{ {
for (i = 1; i < tower->n_levels; i++) for (i = 1; i < tower->n_levels; i++)
{ {
if (tower->textures[i] != NULL) g_clear_object (&tower->textures[i]);
{ g_list_free_full (tower->fbos[i], cogl_object_unref);
cogl_object_unref (tower->textures[i]); tower->fbos[i] = NULL;
tower->textures[i] = NULL;
}
if (tower->fbos[i] != NULL)
{
cogl_object_unref (tower->fbos[i]);
tower->fbos[i] = NULL;
}
} }
cogl_object_unref (tower->textures[0]); g_object_unref (tower->textures[0]);
} }
tower->textures[0] = texture; tower->textures[0] = texture;
@@ -148,10 +140,10 @@ meta_texture_tower_set_base_texture (MetaTextureTower *tower,
{ {
int width, height; int width, height;
cogl_object_ref (tower->textures[0]); g_object_ref (tower->textures[0]);
width = cogl_texture_get_width (tower->textures[0]); width = meta_multi_texture_get_width (tower->textures[0]);
height = cogl_texture_get_height (tower->textures[0]); height = meta_multi_texture_get_height (tower->textures[0]);
tower->n_levels = 1 + MAX ((int)(M_LOG2E * log (width)), (int)(M_LOG2E * log (height))); tower->n_levels = 1 + MAX ((int)(M_LOG2E * log (width)), (int)(M_LOG2E * log (height)));
tower->n_levels = MIN(tower->n_levels, MAX_TEXTURE_LEVELS); tower->n_levels = MIN(tower->n_levels, MAX_TEXTURE_LEVELS);
@@ -192,8 +184,8 @@ meta_texture_tower_update_area (MetaTextureTower *tower,
if (tower->textures[0] == NULL) if (tower->textures[0] == NULL)
return; return;
texture_width = cogl_texture_get_width (tower->textures[0]); texture_width = meta_multi_texture_get_width (tower->textures[0]);
texture_height = cogl_texture_get_height (tower->textures[0]); texture_height = meta_multi_texture_get_height (tower->textures[0]);
invalid.x1 = x; invalid.x1 = x;
invalid.y1 = y; invalid.y1 = y;
@@ -355,9 +347,26 @@ texture_tower_create_texture (MetaTextureTower *tower,
int width, int width,
int height) int height)
{ {
tower->textures[level] = cogl_texture_new_with_size (width, height, MetaMultiTextureFormat format;
COGL_TEXTURE_NO_AUTO_MIPMAP, guint i, n_planes;
TEXTURE_FORMAT); GPtrArray *planes;
CoglTexture **textures;
format = meta_multi_texture_get_format (tower->textures[0]);
n_planes = meta_multi_texture_format_get_n_planes (format);
planes = g_ptr_array_new_full (n_planes, g_object_unref);
for (i = 0; i < n_planes; i++)
{
CoglTexture *texture;
texture = cogl_texture_new_with_size (width, height,
COGL_TEXTURE_NO_AUTO_MIPMAP,
TEXTURE_FORMAT);
g_ptr_array_add (planes, texture);
}
textures = (CoglTexture **) g_ptr_array_free (planes, FALSE);
tower->textures[level] = meta_multi_texture_new (format, textures, n_planes);
tower->invalid[level].x1 = 0; tower->invalid[level].x1 = 0;
tower->invalid[level].y1 = 0; tower->invalid[level].y1 = 0;
@@ -369,51 +378,69 @@ static void
texture_tower_revalidate (MetaTextureTower *tower, texture_tower_revalidate (MetaTextureTower *tower,
int level) int level)
{ {
CoglTexture *source_texture = tower->textures[level - 1]; MetaMultiTexture *src_tex = tower->textures[level - 1];
int source_texture_width = cogl_texture_get_width (source_texture); int src_width = meta_multi_texture_get_width (src_tex);
int source_texture_height = cogl_texture_get_height (source_texture); int src_height = meta_multi_texture_get_height (src_tex);
CoglTexture *dest_texture = tower->textures[level]; guint src_n_planes = meta_multi_texture_get_n_planes (src_tex);
int dest_texture_width = cogl_texture_get_width (dest_texture); MetaMultiTexture *dest_tex = tower->textures[level];
int dest_texture_height = cogl_texture_get_height (dest_texture); int dest_width = meta_multi_texture_get_width (dest_tex);
int dest_height = meta_multi_texture_get_height (dest_tex);
Box *invalid = &tower->invalid[level]; Box *invalid = &tower->invalid[level];
CoglFramebuffer *fb; guint i;
GError *catch_error = NULL;
CoglPipeline *pipeline;
if (tower->fbos[level] == NULL) /* FIXME: cogl_offscreen_texture_new_with_texture doesn't work for
tower->fbos[level] = cogl_offscreen_new_with_texture (dest_texture); * multi-plane textures, so we have to make an FBO for each layer */
for (i = 0; i < src_n_planes; i++)
fb = COGL_FRAMEBUFFER (tower->fbos[level]);
if (!cogl_framebuffer_allocate (fb, &catch_error))
{ {
g_error_free (catch_error); Box *invalid = &tower->invalid[level];
return; CoglTexture *src_plane, *dest_plane;
CoglFramebuffer *fb;
GError *catch_error = NULL;
CoglPipeline *pipeline;
src_plane = meta_multi_texture_get_plane (src_tex, i);
dest_plane = meta_multi_texture_get_plane (dest_tex, i);
if (g_list_nth (tower->fbos[level], i) != NULL)
{
fb = COGL_FRAMEBUFFER (g_list_nth (tower->fbos[level], i)->data);
}
else
{
fb = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (dest_plane));
tower->fbos[level] = g_list_append (tower->fbos[level], fb);
}
if (!cogl_framebuffer_allocate (fb, &catch_error))
{
g_error_free (catch_error);
return;
}
cogl_framebuffer_orthographic (fb, 0, 0, dest_width, dest_height, -1., 1.);
if (!tower->pipeline_template)
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
tower->pipeline_template = cogl_pipeline_new (ctx);
cogl_pipeline_set_blend (tower->pipeline_template, "RGBA = ADD (SRC_COLOR, 0)", NULL);
}
pipeline = cogl_pipeline_copy (tower->pipeline_template);
cogl_pipeline_set_layer_texture (pipeline, 0, src_plane);
cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
invalid->x1, invalid->y1,
invalid->x2, invalid->y2,
(2. * invalid->x1) / src_width,
(2. * invalid->y1) / src_height,
(2. * invalid->x2) / src_width,
(2. * invalid->y2) / src_height);
cogl_object_unref (pipeline);
} }
cogl_framebuffer_orthographic (fb, 0, 0, dest_texture_width, dest_texture_height, -1., 1.);
if (!tower->pipeline_template)
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
tower->pipeline_template = cogl_pipeline_new (ctx);
cogl_pipeline_set_blend (tower->pipeline_template, "RGBA = ADD (SRC_COLOR, 0)", NULL);
}
pipeline = cogl_pipeline_copy (tower->pipeline_template);
cogl_pipeline_set_layer_texture (pipeline, 0, tower->textures[level - 1]);
cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
invalid->x1, invalid->y1,
invalid->x2, invalid->y2,
(2. * invalid->x1) / source_texture_width,
(2. * invalid->y1) / source_texture_height,
(2. * invalid->x2) / source_texture_width,
(2. * invalid->y2) / source_texture_height);
cogl_object_unref (pipeline);
tower->invalid[level].x1 = tower->invalid[level].x2 = 0; tower->invalid[level].x1 = tower->invalid[level].x2 = 0;
tower->invalid[level].y1 = tower->invalid[level].y2 = 0; tower->invalid[level].y1 = tower->invalid[level].y2 = 0;
} }
@@ -432,8 +459,8 @@ texture_tower_revalidate (MetaTextureTower *tower,
* Return value: the COGL texture handle to use for painting, or * Return value: the COGL texture handle to use for painting, or
* %NULL if no base texture has yet been set. * %NULL if no base texture has yet been set.
*/ */
CoglTexture * MetaMultiTexture *
meta_texture_tower_get_paint_texture (MetaTextureTower *tower, meta_texture_tower_get_paint_texture (MetaTextureTower *tower,
ClutterPaintContext *paint_context) ClutterPaintContext *paint_context)
{ {
int texture_width, texture_height; int texture_width, texture_height;
@@ -444,8 +471,8 @@ meta_texture_tower_get_paint_texture (MetaTextureTower *tower,
if (tower->textures[0] == NULL) if (tower->textures[0] == NULL)
return NULL; return NULL;
texture_width = cogl_texture_get_width (tower->textures[0]); texture_width = meta_multi_texture_get_width (tower->textures[0]);
texture_height = cogl_texture_get_height (tower->textures[0]); texture_height = meta_multi_texture_get_height (tower->textures[0]);
level = get_paint_level (paint_context, texture_width, texture_height); level = get_paint_level (paint_context, texture_width, texture_height);
if (level < 0) /* singular paint matrix, scaled to nothing */ if (level < 0) /* singular paint matrix, scaled to nothing */

View File

@@ -24,6 +24,7 @@
#define __META_TEXTURE_TOWER_H__ #define __META_TEXTURE_TOWER_H__
#include "clutter/clutter.h" #include "clutter/clutter.h"
#include <meta/meta-multi-texture.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@@ -54,13 +55,13 @@ typedef struct _MetaTextureTower MetaTextureTower;
MetaTextureTower *meta_texture_tower_new (void); MetaTextureTower *meta_texture_tower_new (void);
void meta_texture_tower_free (MetaTextureTower *tower); void meta_texture_tower_free (MetaTextureTower *tower);
void meta_texture_tower_set_base_texture (MetaTextureTower *tower, void meta_texture_tower_set_base_texture (MetaTextureTower *tower,
CoglTexture *texture); MetaMultiTexture *texture);
void meta_texture_tower_update_area (MetaTextureTower *tower, void meta_texture_tower_update_area (MetaTextureTower *tower,
int x, int x,
int y, int y,
int width, int width,
int height); int height);
CoglTexture *meta_texture_tower_get_paint_texture (MetaTextureTower *tower, MetaMultiTexture *meta_texture_tower_get_paint_texture (MetaTextureTower *tower,
ClutterPaintContext *paint_context); ClutterPaintContext *paint_context);
G_END_DECLS G_END_DECLS

View File

@@ -28,6 +28,7 @@
#include "clutter/clutter.h" #include "clutter/clutter.h"
#include <meta/common.h> #include <meta/common.h>
#include <meta/meta-multi-texture.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@@ -45,7 +46,7 @@ void meta_shaped_texture_set_create_mipmaps (MetaShapedTexture *stex,
gboolean create_mipmaps); gboolean create_mipmaps);
META_EXPORT META_EXPORT
CoglTexture * meta_shaped_texture_get_texture (MetaShapedTexture *stex); MetaMultiTexture * meta_shaped_texture_get_texture (MetaShapedTexture *stex);
META_EXPORT META_EXPORT
void meta_shaped_texture_set_mask_texture (MetaShapedTexture *stex, void meta_shaped_texture_set_mask_texture (MetaShapedTexture *stex,

View File

@@ -155,7 +155,7 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer)
buffer->egl_stream.stream = stream; buffer->egl_stream.stream = stream;
buffer->type = META_WAYLAND_BUFFER_TYPE_EGL_STREAM; buffer->type = META_WAYLAND_BUFFER_TYPE_EGL_STREAM;
buffer->egl_stream.texture = COGL_TEXTURE (texture); buffer->egl_stream.texture = meta_multi_texture_new_simple (COGL_TEXTURE (texture));
buffer->is_y_inverted = meta_wayland_egl_stream_is_y_inverted (stream); buffer->is_y_inverted = meta_wayland_egl_stream_is_y_inverted (stream);
return TRUE; return TRUE;
@@ -182,46 +182,50 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer)
} }
static void static void
shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer, shm_buffer_get_format (struct wl_shm_buffer *shm_buffer,
CoglPixelFormat *format_out, MetaMultiTextureFormat *multi_format_out,
CoglTextureComponents *components_out) CoglPixelFormat *cogl_format_out,
CoglTextureComponents *components_out)
{ {
CoglPixelFormat format; MetaMultiTextureFormat multi_format = META_MULTI_TEXTURE_FORMAT_SIMPLE;
CoglPixelFormat cogl_format = COGL_PIXEL_FORMAT_ANY;
CoglTextureComponents components = COGL_TEXTURE_COMPONENTS_RGBA; CoglTextureComponents components = COGL_TEXTURE_COMPONENTS_RGBA;
switch (wl_shm_buffer_get_format (shm_buffer)) switch (wl_shm_buffer_get_format (shm_buffer))
{ {
#if G_BYTE_ORDER == G_BIG_ENDIAN #if G_BYTE_ORDER == G_BIG_ENDIAN
case WL_SHM_FORMAT_ARGB8888: case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE; cogl_format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
break; break;
case WL_SHM_FORMAT_XRGB8888: case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888; cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
components = COGL_TEXTURE_COMPONENTS_RGB; components = COGL_TEXTURE_COMPONENTS_RGB;
break; break;
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN #elif G_BYTE_ORDER == G_LITTLE_ENDIAN
case WL_SHM_FORMAT_ARGB8888: case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE; cogl_format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
break; break;
case WL_SHM_FORMAT_XRGB8888: case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888; cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
components = COGL_TEXTURE_COMPONENTS_RGB; components = COGL_TEXTURE_COMPONENTS_RGB;
break; break;
#endif #endif
default: default:
g_warn_if_reached (); g_warn_if_reached ();
format = COGL_PIXEL_FORMAT_ARGB_8888; cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
} }
if (format_out) if (multi_format_out)
*format_out = format; *multi_format_out = multi_format;
if (cogl_format_out)
*cogl_format_out = cogl_format;
if (components_out) if (components_out)
*components_out = components; *components_out = components;
} }
static gboolean static gboolean
shm_buffer_attach (MetaWaylandBuffer *buffer, shm_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error) GError **error)
{ {
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
@@ -229,43 +233,51 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
struct wl_shm_buffer *shm_buffer; struct wl_shm_buffer *shm_buffer;
int stride, width, height; int stride, width, height;
CoglPixelFormat format; MetaMultiTextureFormat multi_format;
CoglPixelFormat cogl_format;
CoglTextureComponents components; CoglTextureComponents components;
CoglBitmap *bitmap; CoglBitmap *bitmap;
CoglTexture *new_texture; CoglTexture *new_cogl_tex;
shm_buffer = wl_shm_buffer_get (buffer->resource); shm_buffer = wl_shm_buffer_get (buffer->resource);
stride = wl_shm_buffer_get_stride (shm_buffer); stride = wl_shm_buffer_get_stride (shm_buffer);
width = wl_shm_buffer_get_width (shm_buffer); width = wl_shm_buffer_get_width (shm_buffer);
height = wl_shm_buffer_get_height (shm_buffer); height = wl_shm_buffer_get_height (shm_buffer);
shm_buffer_get_cogl_pixel_format (shm_buffer, &format, &components); shm_buffer_get_format (shm_buffer, &multi_format, &cogl_format, &components);
/* We only support "simple" textures for now */
g_return_val_if_fail (multi_format == META_MULTI_TEXTURE_FORMAT_SIMPLE, FALSE);
if (*texture && if (*texture &&
cogl_texture_get_width (*texture) == width && meta_multi_texture_get_width (*texture) == width &&
cogl_texture_get_height (*texture) == height && meta_multi_texture_get_height (*texture) == height &&
cogl_texture_get_components (*texture) == components && meta_multi_texture_get_format (*texture) == multi_format)
_cogl_texture_get_format (*texture) == format)
{ {
buffer->is_y_inverted = TRUE; CoglTexture *cogl_texture = meta_multi_texture_get_plane (*texture, 0);
return TRUE; if (cogl_texture_get_components (cogl_texture) == components &&
_cogl_texture_get_format (cogl_texture) == cogl_format)
{
buffer->is_y_inverted = TRUE;
return TRUE;
}
} }
cogl_clear_object (texture); g_clear_object (texture);
wl_shm_buffer_begin_access (shm_buffer); wl_shm_buffer_begin_access (shm_buffer);
bitmap = cogl_bitmap_new_for_data (cogl_context, bitmap = cogl_bitmap_new_for_data (cogl_context,
width, height, width, height,
format, cogl_format,
stride, stride,
wl_shm_buffer_get_data (shm_buffer)); wl_shm_buffer_get_data (shm_buffer));
new_texture = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap)); new_cogl_tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
cogl_texture_set_components (new_texture, components); cogl_texture_set_components (new_cogl_tex, components);
if (!cogl_texture_allocate (new_texture, error)) if (!cogl_texture_allocate (new_cogl_tex, error))
{ {
g_clear_pointer (&new_texture, cogl_object_unref); g_clear_pointer (&new_cogl_tex, cogl_object_unref);
if (g_error_matches (*error, COGL_TEXTURE_ERROR, COGL_TEXTURE_ERROR_SIZE)) if (g_error_matches (*error, COGL_TEXTURE_ERROR, COGL_TEXTURE_ERROR_SIZE))
{ {
CoglTexture2DSliced *texture_sliced; CoglTexture2DSliced *texture_sliced;
@@ -275,11 +287,11 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
texture_sliced = texture_sliced =
cogl_texture_2d_sliced_new_from_bitmap (bitmap, cogl_texture_2d_sliced_new_from_bitmap (bitmap,
COGL_TEXTURE_MAX_WASTE); COGL_TEXTURE_MAX_WASTE);
new_texture = COGL_TEXTURE (texture_sliced); new_cogl_tex = COGL_TEXTURE (texture_sliced);
cogl_texture_set_components (new_texture, components); cogl_texture_set_components (new_cogl_tex, components);
if (!cogl_texture_allocate (new_texture, error)) if (!cogl_texture_allocate (new_cogl_tex, error))
g_clear_pointer (&new_texture, cogl_object_unref); g_clear_pointer (&new_cogl_tex, cogl_object_unref);
} }
} }
@@ -287,10 +299,10 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
wl_shm_buffer_end_access (shm_buffer); wl_shm_buffer_end_access (shm_buffer);
if (!new_texture) if (!new_cogl_tex)
return FALSE; return FALSE;
*texture = new_texture; *texture = meta_multi_texture_new_simple (new_cogl_tex);
buffer->is_y_inverted = TRUE; buffer->is_y_inverted = TRUE;
return TRUE; return TRUE;
@@ -298,7 +310,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
static gboolean static gboolean
egl_image_buffer_attach (MetaWaylandBuffer *buffer, egl_image_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error) GError **error)
{ {
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
@@ -314,8 +326,8 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
if (buffer->egl_image.texture) if (buffer->egl_image.texture)
{ {
cogl_clear_object (texture); g_clear_object (texture);
*texture = cogl_object_ref (buffer->egl_image.texture); *texture = g_object_ref (buffer->egl_image.texture);
return TRUE; return TRUE;
} }
@@ -376,11 +388,11 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
if (!texture_2d) if (!texture_2d)
return FALSE; return FALSE;
buffer->egl_image.texture = COGL_TEXTURE (texture_2d); buffer->egl_image.texture = meta_multi_texture_new_simple (COGL_TEXTURE (texture_2d));
buffer->is_y_inverted = !!y_inverted; buffer->is_y_inverted = !!y_inverted;
cogl_clear_object (texture); g_clear_object (texture);
*texture = cogl_object_ref (buffer->egl_image.texture); *texture = g_object_ref (buffer->egl_image.texture);
return TRUE; return TRUE;
} }
@@ -388,7 +400,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
#ifdef HAVE_WAYLAND_EGLSTREAM #ifdef HAVE_WAYLAND_EGLSTREAM
static gboolean static gboolean
egl_stream_buffer_attach (MetaWaylandBuffer *buffer, egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error) GError **error)
{ {
MetaWaylandEglStream *stream = buffer->egl_stream.stream; MetaWaylandEglStream *stream = buffer->egl_stream.stream;
@@ -398,8 +410,8 @@ egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
if (!meta_wayland_egl_stream_attach (stream, error)) if (!meta_wayland_egl_stream_attach (stream, error))
return FALSE; return FALSE;
cogl_clear_object (texture); g_clear_object (texture);
*texture = cogl_object_ref (buffer->egl_stream.texture); *texture = g_object_ref (buffer->egl_stream.texture);
return TRUE; return TRUE;
} }
@@ -408,8 +420,8 @@ egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
/** /**
* meta_wayland_buffer_attach: * meta_wayland_buffer_attach:
* @buffer: a pointer to a #MetaWaylandBuffer * @buffer: a pointer to a #MetaWaylandBuffer
* @texture: (inout) (transfer full): a #CoglTexture representing the surface * @texture: (inout) (transfer full): a #MetaMultiTexture representing the
* content * surface content
* @error: return location for error or %NULL * @error: return location for error or %NULL
* *
* This function should be passed a pointer to the texture used to draw the * This function should be passed a pointer to the texture used to draw the
@@ -426,7 +438,7 @@ egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
*/ */
gboolean gboolean
meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error) GError **error)
{ {
g_return_val_if_fail (buffer->resource, FALSE); g_return_val_if_fail (buffer->resource, FALSE);
@@ -493,21 +505,24 @@ meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer)
static gboolean static gboolean
process_shm_buffer_damage (MetaWaylandBuffer *buffer, process_shm_buffer_damage (MetaWaylandBuffer *buffer,
CoglTexture *texture, MetaMultiTexture *texture,
cairo_region_t *region, cairo_region_t *region,
GError **error) GError **error)
{ {
struct wl_shm_buffer *shm_buffer; struct wl_shm_buffer *shm_buffer;
int i, n_rectangles; int i, n_rectangles;
gboolean set_texture_failed = FALSE; gboolean set_texture_failed = FALSE;
CoglPixelFormat format; MetaMultiTextureFormat multi_format;
CoglPixelFormat cogl_format;
CoglTexture *cogl_texture;
n_rectangles = cairo_region_num_rectangles (region); n_rectangles = cairo_region_num_rectangles (region);
shm_buffer = wl_shm_buffer_get (buffer->resource); shm_buffer = wl_shm_buffer_get (buffer->resource);
shm_buffer_get_cogl_pixel_format (shm_buffer, &format, NULL); shm_buffer_get_format (shm_buffer, &multi_format, &cogl_format, NULL);
g_return_val_if_fail (cogl_pixel_format_get_n_planes (format) == 1, FALSE); g_return_val_if_fail (multi_format == META_MULTI_TEXTURE_FORMAT_SIMPLE, FALSE);
cogl_texture = meta_multi_texture_get_plane (texture, 0);
wl_shm_buffer_begin_access (shm_buffer); wl_shm_buffer_begin_access (shm_buffer);
@@ -518,12 +533,12 @@ process_shm_buffer_damage (MetaWaylandBuffer *buffer,
cairo_rectangle_int_t rect; cairo_rectangle_int_t rect;
int bpp; int bpp;
bpp = cogl_pixel_format_get_bytes_per_pixel (format, 0); bpp = cogl_pixel_format_get_bytes_per_pixel (cogl_format, 0);
cairo_region_get_rectangle (region, i, &rect); cairo_region_get_rectangle (region, i, &rect);
if (!_cogl_texture_set_region (texture, if (!_cogl_texture_set_region (cogl_texture,
rect.width, rect.height, rect.width, rect.height,
format, cogl_format,
stride, stride,
data + rect.x * bpp + rect.y * stride, data + rect.x * bpp + rect.y * stride,
rect.x, rect.y, rect.x, rect.y,
@@ -542,7 +557,7 @@ process_shm_buffer_damage (MetaWaylandBuffer *buffer,
void void
meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer, meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
CoglTexture *texture, MetaMultiTexture *texture,
cairo_region_t *region) cairo_region_t *region)
{ {
gboolean res = FALSE; gboolean res = FALSE;
@@ -582,12 +597,12 @@ meta_wayland_buffer_finalize (GObject *object)
{ {
MetaWaylandBuffer *buffer = META_WAYLAND_BUFFER (object); MetaWaylandBuffer *buffer = META_WAYLAND_BUFFER (object);
g_clear_pointer (&buffer->egl_image.texture, cogl_object_unref); g_clear_object (&buffer->egl_image.texture);
#ifdef HAVE_WAYLAND_EGLSTREAM #ifdef HAVE_WAYLAND_EGLSTREAM
g_clear_pointer (&buffer->egl_stream.texture, cogl_object_unref); g_clear_object (&buffer->egl_stream.texture);
g_clear_object (&buffer->egl_stream.stream); g_clear_object (&buffer->egl_stream.stream);
#endif #endif
g_clear_pointer (&buffer->dma_buf.texture, cogl_object_unref); g_clear_object (&buffer->dma_buf.texture);
g_clear_object (&buffer->dma_buf.dma_buf); g_clear_object (&buffer->dma_buf.dma_buf);
G_OBJECT_CLASS (meta_wayland_buffer_parent_class)->finalize (object); G_OBJECT_CLASS (meta_wayland_buffer_parent_class)->finalize (object);

View File

@@ -29,6 +29,7 @@
#include <wayland-server.h> #include <wayland-server.h>
#include "cogl/cogl.h" #include "cogl/cogl.h"
#include "meta/meta-multi-texture.h"
#include "wayland/meta-wayland-types.h" #include "wayland/meta-wayland-types.h"
#include "wayland/meta-wayland-egl-stream.h" #include "wayland/meta-wayland-egl-stream.h"
#include "wayland/meta-wayland-dma-buf.h" #include "wayland/meta-wayland-dma-buf.h"
@@ -56,19 +57,19 @@ struct _MetaWaylandBuffer
MetaWaylandBufferType type; MetaWaylandBufferType type;
struct { struct {
CoglTexture *texture; MetaMultiTexture *texture;
} egl_image; } egl_image;
#ifdef HAVE_WAYLAND_EGLSTREAM #ifdef HAVE_WAYLAND_EGLSTREAM
struct { struct {
MetaWaylandEglStream *stream; MetaWaylandEglStream *stream;
CoglTexture *texture; MetaMultiTexture *texture;
} egl_stream; } egl_stream;
#endif #endif
struct { struct {
MetaWaylandDmaBufBuffer *dma_buf; MetaWaylandDmaBufBuffer *dma_buf;
CoglTexture *texture; MetaMultiTexture *texture;
} dma_buf; } dma_buf;
}; };
@@ -81,12 +82,12 @@ struct wl_resource * meta_wayland_buffer_get_resource (MetaWaylandBuff
gboolean meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer); gboolean meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer);
gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer); gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer);
gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error); GError **error);
CoglSnippet * meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer); CoglSnippet * meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer);
gboolean meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer); gboolean meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer);
void meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer, void meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
CoglTexture *texture, MetaMultiTexture *texture,
cairo_region_t *region); cairo_region_t *region);
#endif /* META_WAYLAND_BUFFER_H */ #endif /* META_WAYLAND_BUFFER_H */

View File

@@ -90,7 +90,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
CoglPixelFormat cogl_format; CoglPixelFormat cogl_format;
EGLImageKHR egl_image; EGLImageKHR egl_image;
CoglEglImageFlags flags; CoglEglImageFlags flags;
CoglTexture2D *texture; CoglTexture2D *cogl_texture;
if (buffer->dma_buf.texture) if (buffer->dma_buf.texture)
return TRUE; return TRUE;
@@ -146,20 +146,20 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
return FALSE; return FALSE;
flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA; flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA;
texture = cogl_egl_texture_2d_new_from_image (cogl_context, cogl_texture = cogl_egl_texture_2d_new_from_image (cogl_context,
dma_buf->width, dma_buf->width,
dma_buf->height, dma_buf->height,
cogl_format, cogl_format,
egl_image, egl_image,
flags, flags,
error); error);
meta_egl_destroy_image (egl, egl_display, egl_image, NULL); meta_egl_destroy_image (egl, egl_display, egl_image, NULL);
if (!texture) if (!cogl_texture)
return FALSE; return FALSE;
buffer->dma_buf.texture = COGL_TEXTURE (texture); buffer->dma_buf.texture = meta_multi_texture_new_simple (COGL_TEXTURE (cogl_texture));
buffer->is_y_inverted = dma_buf->is_y_inverted; buffer->is_y_inverted = dma_buf->is_y_inverted;
return TRUE; return TRUE;
@@ -167,14 +167,14 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
gboolean gboolean
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error) GError **error)
{ {
if (!meta_wayland_dma_buf_realize_texture (buffer, error)) if (!meta_wayland_dma_buf_realize_texture (buffer, error))
return FALSE; return FALSE;
cogl_clear_object (texture); g_clear_object (texture);
*texture = cogl_object_ref (buffer->dma_buf.texture); *texture = g_object_ref (buffer->dma_buf.texture);
return TRUE; return TRUE;
} }

View File

@@ -31,6 +31,7 @@
#include <glib-object.h> #include <glib-object.h>
#include "cogl/cogl.h" #include "cogl/cogl.h"
#include "meta/meta-multi-texture.h"
#include "wayland/meta-wayland-types.h" #include "wayland/meta-wayland-types.h"
#define META_TYPE_WAYLAND_DMA_BUF_BUFFER (meta_wayland_dma_buf_buffer_get_type ()) #define META_TYPE_WAYLAND_DMA_BUF_BUFFER (meta_wayland_dma_buf_buffer_get_type ())
@@ -43,7 +44,7 @@ gboolean meta_wayland_dma_buf_init (MetaWaylandCompositor *compositor);
gboolean gboolean
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, MetaMultiTexture **texture,
GError **error); GError **error);
MetaWaylandDmaBufBuffer * MetaWaylandDmaBufBuffer *

View File

@@ -241,7 +241,7 @@ get_buffer_width (MetaWaylandSurface *surface)
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface); MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
if (buffer) if (buffer)
return cogl_texture_get_width (surface->texture); return meta_multi_texture_get_width (surface->texture);
else else
return 0; return 0;
} }
@@ -252,7 +252,7 @@ get_buffer_height (MetaWaylandSurface *surface)
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface); MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
if (buffer) if (buffer)
return cogl_texture_get_height (surface->texture); return meta_multi_texture_get_height (surface->texture);
else else
return 0; return 0;
} }
@@ -658,7 +658,7 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
} }
else else
{ {
cogl_clear_object (&surface->texture); g_clear_object (&surface->texture);
} }
/* If the newly attached buffer is going to be accessed directly without /* If the newly attached buffer is going to be accessed directly without
@@ -1277,7 +1277,7 @@ wl_surface_destructor (struct wl_resource *resource)
if (surface->buffer_held) if (surface->buffer_held)
meta_wayland_surface_unref_buffer_use_count (surface); meta_wayland_surface_unref_buffer_use_count (surface);
g_clear_pointer (&surface->texture, cogl_object_unref); g_clear_object (&surface->texture);
g_clear_object (&surface->buffer_ref.buffer); g_clear_object (&surface->buffer_ref.buffer);
g_clear_object (&surface->cached_state); g_clear_object (&surface->cached_state);
@@ -1854,7 +1854,7 @@ meta_wayland_surface_is_shortcuts_inhibited (MetaWaylandSurface *surface,
return g_hash_table_contains (surface->shortcut_inhibited_seats, seat); return g_hash_table_contains (surface->shortcut_inhibited_seats, seat);
} }
CoglTexture * MetaMultiTexture *
meta_wayland_surface_get_texture (MetaWaylandSurface *surface) meta_wayland_surface_get_texture (MetaWaylandSurface *surface)
{ {
return surface->texture; return surface->texture;

View File

@@ -153,7 +153,7 @@ struct _MetaWaylandSurface
GHashTable *outputs_to_destroy_notify_id; GHashTable *outputs_to_destroy_notify_id;
MetaMonitorTransform buffer_transform; MetaMonitorTransform buffer_transform;
CoglTexture *texture; MetaMultiTexture *texture;
/* Buffer reference state. */ /* Buffer reference state. */
struct { struct {
@@ -327,7 +327,7 @@ void meta_wayland_surface_restore_shortcuts (MetaWaylandSurface *
gboolean meta_wayland_surface_is_shortcuts_inhibited (MetaWaylandSurface *surface, gboolean meta_wayland_surface_is_shortcuts_inhibited (MetaWaylandSurface *surface,
MetaWaylandSeat *seat); MetaWaylandSeat *seat);
CoglTexture * meta_wayland_surface_get_texture (MetaWaylandSurface *surface); MetaMultiTexture * meta_wayland_surface_get_texture (MetaWaylandSurface *surface);
MetaSurfaceActor * meta_wayland_surface_get_actor (MetaWaylandSurface *surface); MetaSurfaceActor * meta_wayland_surface_get_actor (MetaWaylandSurface *surface);