This commit is contained in:
Niels De Graef 2020-04-07 17:58:56 +02:00
parent 1cb7146a2e
commit 919ae6b2b7
8 changed files with 122 additions and 121 deletions

View File

@ -20,7 +20,7 @@
/** /**
* SECTION:meta-multi-texture * SECTION:meta-multi-texture
* @title: MetaMultiTexture * @title: MetaMultiTexture
* @short_description: A texture that can have multiple planes. * @short_description: A texture that can have multiple subtextures.
* *
* #MetaMultiTexture allows one to deal with non-trivial formats that * #MetaMultiTexture allows one to deal with non-trivial formats that
* have multiple planes, requires subsampling and/or aren't in RGB. A common * have multiple planes, requires subsampling and/or aren't in RGB. A common
@ -28,8 +28,8 @@
* YUV colorspace, combined with subsampling. * YUV colorspace, combined with subsampling.
* *
* The basic idea of a #MetaMultiTexture is the following: * The basic idea of a #MetaMultiTexture is the following:
* - Each plane is represented by a separate #CoglTexture. That means that you * - Each subtextures is represented by a separate #CoglTexture. That means
* should add each of these planes as a layer to your CoglPipeline. * that you should add each of these planes as a layer to your #CoglPipeline.
* - When dealing with a color space that is not RGB, you can ask the * - When dealing with a color space that is not RGB, you can ask the
* #MetaMultiTexture to create a shader for you that does the conversion * #MetaMultiTexture to create a shader for you that does the conversion
* in the GPU. * in the GPU.
@ -47,8 +47,8 @@ struct _MetaMultiTexture
MetaMultiTextureFormat format; MetaMultiTextureFormat format;
guint n_planes; guint n_subtextures;
CoglTexture **planes; CoglTexture **subtextures;
}; };
G_DEFINE_TYPE (MetaMultiTexture, meta_multi_texture, G_TYPE_OBJECT); G_DEFINE_TYPE (MetaMultiTexture, meta_multi_texture, G_TYPE_OBJECT);
@ -87,41 +87,41 @@ meta_multi_texture_is_simple (MetaMultiTexture *self)
} }
/** /**
* meta_multi_texture_get_n_planes: * meta_multi_texture_get_n_subtexture:
* @self: a #MetaMultiTexture * @self: a #MetaMultiTexture
* *
* Returns the number of planes for this texture. Note that this is entirely * Returns the number of subtextures for this texture. For example, simple RGB
* dependent on the #CoglPixelFormat that is used. For example, simple RGB * textures will have a single subtexture, while some more convoluted formats
* textures will have a single plane, while some more convoluted formats like * like NV12 and YUV 4:4:4 can have 2 and 3 subtextures respectively.
* NV12 and YUV 4:4:4 can have 2 and 3 planes respectively.
* *
* Returns: The number of planes in this #MetaMultiTexture. * Returns: The number of subtextures in this #MetaMultiTexture.
*/ */
guint guint
meta_multi_texture_get_n_planes (MetaMultiTexture *self) meta_multi_texture_get_n_subtextures (MetaMultiTexture *self)
{ {
g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0); g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0);
return self->n_planes; return self->n_subtextures;
} }
/** /**
* meta_multi_texture_get_plane: * meta_multi_texture_get_subtexture:
* @self: a #MetaMultiTexture * @self: a #MetaMultiTexture
* @index: the index of the plane * @index: the index of the subtexture
* *
* Returns the n'th plane of the #MetaMultiTexture. Note that it's a programming * Returns the n'th subtexture of the #MetaMultiTexture. Note that it's a
* error to use with an index larger than meta_multi_texture_get_n_planes(). * programming error to use with an index larger than
* meta_multi_texture_get_n_subtextures().
* *
* Returns: (transfer none): The plane at the given @index. * Returns: (transfer none): The subtexture at the given @index.
*/ */
CoglTexture * CoglTexture *
meta_multi_texture_get_plane (MetaMultiTexture *self, guint index) meta_multi_texture_get_subtexture (MetaMultiTexture *self, guint index)
{ {
g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0); g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0);
g_return_val_if_fail (index < self->n_planes, NULL); g_return_val_if_fail (index < self->n_subtextures, NULL);
return self->planes[index]; return self->subtextures[index];
} }
/** /**
@ -139,7 +139,7 @@ meta_multi_texture_get_width (MetaMultiTexture *self)
{ {
g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0); g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0);
return cogl_texture_get_width (self->planes[0]); return cogl_texture_get_width (self->subtextures[0]);
} }
/** /**
@ -157,7 +157,7 @@ meta_multi_texture_get_height (MetaMultiTexture *self)
{ {
g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0); g_return_val_if_fail (META_IS_MULTI_TEXTURE (self), 0);
return cogl_texture_get_height (self->planes[0]); return cogl_texture_get_height (self->subtextures[0]);
} }
static void static void
@ -166,10 +166,10 @@ meta_multi_texture_finalize (GObject *object)
MetaMultiTexture *self = META_MULTI_TEXTURE (object); MetaMultiTexture *self = META_MULTI_TEXTURE (object);
int i; int i;
for (i = 0; i < self->n_planes; i++) for (i = 0; i < self->n_subtextures; i++)
cogl_clear_object (&self->planes[i]); cogl_clear_object (&self->subtextures[i]);
g_free (self->planes); g_free (self->subtextures);
G_OBJECT_CLASS (meta_multi_texture_parent_class)->finalize (object); G_OBJECT_CLASS (meta_multi_texture_parent_class)->finalize (object);
} }
@ -190,55 +190,55 @@ meta_multi_texture_class_init (MetaMultiTextureClass *klass)
/** /**
* meta_multi_texture_new: * meta_multi_texture_new:
* @format: The format of the #MetaMultiTexture * @format: The format of the #MetaMultiTexture
* @planes: (transfer full): The actual planes of the texture * @subtextures: (transfer full): The actual subtextures of the texture
* @n_planes: The number of planes * @n_subtextures: The number of subtextures
* *
* Creates a #MetaMultiTexture with the given @format. Each of the * Creates a #MetaMultiTexture with the given @format. Each of the
* #CoglTexture<!-- -->s represents a plane. * #CoglTexture<!-- -->s represents a subtexture.
* *
* Returns: (transfer full): A new #MetaMultiTexture. Use g_object_unref() when * Returns: (transfer full): A new #MetaMultiTexture. Use g_object_unref() when
* you're done with it. * you're done with it.
*/ */
MetaMultiTexture * MetaMultiTexture *
meta_multi_texture_new (MetaMultiTextureFormat format, meta_multi_texture_new (MetaMultiTextureFormat format,
CoglTexture **planes, CoglTexture **subtextures,
guint n_planes) guint n_subtextures)
{ {
MetaMultiTexture *self; MetaMultiTexture *self;
g_return_val_if_fail (planes != NULL, NULL); g_return_val_if_fail (subtextures != NULL, NULL);
g_return_val_if_fail (n_planes > 0, NULL); g_return_val_if_fail (n_subtextures > 0, NULL);
self = g_object_new (META_TYPE_MULTI_TEXTURE, NULL); self = g_object_new (META_TYPE_MULTI_TEXTURE, NULL);
self->format = format; self->format = format;
self->n_planes = n_planes; self->n_subtextures = n_subtextures;
self->planes = planes; self->subtextures = subtextures;
return self; return self;
} }
/** /**
* meta_multi_texture_new_simple: * meta_multi_texture_new_simple:
* @plane: (transfer full): The single plane of the texture * @subtexture: (transfer full): The single subtexture of the texture
* *
* Creates a #MetaMultiTexture for a "simple" texture, i.e. with only one * Creates a #MetaMultiTexture for a "simple" texture, i.e. with only one
* plane, in a format that can be represented using #CoglPixelFormat. * subtexture, in a format that can be represented using #CoglPixelFormat.
* *
* Returns: (transfer full): A new #MetaMultiTexture. Use g_object_unref() when * Returns: (transfer full): A new #MetaMultiTexture. Use g_object_unref() when
* you're done with it. * you're done with it.
*/ */
MetaMultiTexture * MetaMultiTexture *
meta_multi_texture_new_simple (CoglTexture *plane) meta_multi_texture_new_simple (CoglTexture *subtexture)
{ {
MetaMultiTexture *self; MetaMultiTexture *self;
g_return_val_if_fail (plane != NULL, NULL); g_return_val_if_fail (subtexture != NULL, NULL);
self = g_object_new (META_TYPE_MULTI_TEXTURE, NULL); self = g_object_new (META_TYPE_MULTI_TEXTURE, NULL);
self->format = META_MULTI_TEXTURE_FORMAT_SIMPLE; self->format = META_MULTI_TEXTURE_FORMAT_SIMPLE;
self->n_planes = 1; self->n_subtextures = 1;
self->planes = g_malloc (sizeof (CoglTexture *)); self->subtextures = g_malloc (sizeof (CoglTexture *));
self->planes[0] = plane; self->subtextures[0] = subtexture;
return self; return self;
} }
@ -264,17 +264,17 @@ meta_multi_texture_to_string (MetaMultiTexture *self)
g_string_append_printf (str, "MetaMultiTexture (%p) {\n", self); g_string_append_printf (str, "MetaMultiTexture (%p) {\n", self);
format_str = g_enum_to_string (META_TYPE_MULTI_TEXTURE_FORMAT, self->format); format_str = g_enum_to_string (META_TYPE_MULTI_TEXTURE_FORMAT, self->format);
g_string_append_printf (str, " .format = %s;\n", format_str); g_string_append_printf (str, " .format = %s;\n", format_str);
g_string_append_printf (str, " .n_planes = %u;\n", self->n_planes); g_string_append_printf (str, " .n_subtextures = %u;\n", self->n_subtextures);
g_string_append (str, " .planes = {\n"); g_string_append (str, " .subtextures = {\n");
for (i = 0; i < self->n_planes; i++) for (i = 0; i < self->n_subtextures; i++)
{ {
CoglTexture *plane = self->planes[i]; CoglTexture *subtexture = self->subtextures[i];
CoglPixelFormat plane_format = _cogl_texture_get_format (plane); CoglPixelFormat subtexture_format = _cogl_texture_get_format (subtexture);
g_string_append_printf (str, " (%p) { .format = %s },\n", g_string_append_printf (str, " (%p) { .format = %s },\n",
plane, subtexture,
cogl_pixel_format_to_string (plane_format)); cogl_pixel_format_to_string (subtexture_format));
} }
g_string_append (str, " }\n"); g_string_append (str, " }\n");

View File

@ -249,7 +249,7 @@ static CoglPipeline *
get_base_pipeline (MetaShapedTexture *stex, get_base_pipeline (MetaShapedTexture *stex,
CoglContext *ctx) CoglContext *ctx)
{ {
guint i, n_planes; guint i, n_subtextures;
MetaMultiTextureFormat format; MetaMultiTextureFormat format;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglMatrix matrix; CoglMatrix matrix;
@ -257,13 +257,13 @@ get_base_pipeline (MetaShapedTexture *stex,
if (stex->base_pipeline) if (stex->base_pipeline)
return stex->base_pipeline; return stex->base_pipeline;
/* We'll add as many layers as there are planes in the multi texture, /* We'll add as many layers as there are subtextures in the multi texture,
* plus an extra one for the mask */ * plus an extra one for the mask */
n_planes = meta_multi_texture_get_n_planes (stex->texture); n_subtextures = meta_multi_texture_get_n_subtextures (stex->texture);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
for (i = 0; i < n_planes; i++) for (i = 0; i < n_subtextures; i++)
{ {
cogl_pipeline_set_layer_wrap_mode_s (pipeline, i, cogl_pipeline_set_layer_wrap_mode_s (pipeline, i,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
@ -357,7 +357,7 @@ get_base_pipeline (MetaShapedTexture *stex,
0); 0);
} }
for (i = 0; i < n_planes + 1; i++) for (i = 0; i < n_subtextures + 1; i++)
cogl_pipeline_set_layer_matrix (pipeline, i, &matrix); cogl_pipeline_set_layer_matrix (pipeline, i, &matrix);
/* Add color conversion shaders if needed */ /* Add color conversion shaders if needed */
@ -375,7 +375,7 @@ get_base_pipeline (MetaShapedTexture *stex,
cogl_pipeline_add_snippet (pipeline, vertex_snippet); cogl_pipeline_add_snippet (pipeline, vertex_snippet);
cogl_pipeline_add_snippet (pipeline, fragment_snippet); cogl_pipeline_add_snippet (pipeline, fragment_snippet);
for (i = 0; i < n_planes; i++) for (i = 0; i < n_subtextures; i++)
cogl_pipeline_add_layer_snippet (pipeline, i, layer_snippet); cogl_pipeline_add_layer_snippet (pipeline, i, layer_snippet);
} }
@ -400,14 +400,14 @@ get_masked_pipeline (MetaShapedTexture *stex,
CoglContext *ctx) CoglContext *ctx)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
guint n_planes; guint n_subtextures;
if (stex->masked_pipeline) if (stex->masked_pipeline)
return stex->masked_pipeline; return stex->masked_pipeline;
pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx)); pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
n_planes = meta_multi_texture_get_n_planes (stex->texture); n_subtextures = meta_multi_texture_get_n_subtextures (stex->texture);
cogl_pipeline_set_layer_combine (pipeline, n_planes, cogl_pipeline_set_layer_combine (pipeline, n_subtextures,
"RGBA = MODULATE (PREVIOUS, TEXTURE[A])", "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
NULL); NULL);
@ -565,7 +565,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; guint n_subtextures;
ensure_size_valid (stex); ensure_size_valid (stex);
@ -597,8 +597,8 @@ do_paint_content (MetaShapedTexture *stex,
} }
else else
{ {
sample_width = cogl_texture_get_width (stex->texture); sample_width = meta_multi_texture_get_width (stex->texture);
sample_height = cogl_texture_get_height (stex->texture); sample_height = meta_multi_texture_get_height (stex->texture);
} }
if (meta_monitor_transform_is_rotated (stex->transform)) if (meta_monitor_transform_is_rotated (stex->transform))
flip_ints (&sample_width, &sample_height); flip_ints (&sample_width, &sample_height);
@ -641,7 +641,7 @@ do_paint_content (MetaShapedTexture *stex,
} }
} }
n_planes = meta_multi_texture_get_n_planes (paint_tex); n_subtextures = meta_multi_texture_get_n_subtextures (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)
@ -655,11 +655,11 @@ do_paint_content (MetaShapedTexture *stex,
opaque_pipeline = get_unblended_pipeline (stex, ctx); opaque_pipeline = get_unblended_pipeline (stex, ctx);
for (i = 0; i < n_planes; i++) for (i = 0; i < n_subtextures; i++)
{ {
CoglTexture *plane = meta_multi_texture_get_plane (paint_tex, i); CoglTexture *subtexture = meta_multi_texture_get_subtexture (paint_tex, i);
cogl_pipeline_set_layer_texture (opaque_pipeline, i, plane); cogl_pipeline_set_layer_texture (opaque_pipeline, i, subtexture);
cogl_pipeline_set_layer_filters (opaque_pipeline, i, filter, filter); cogl_pipeline_set_layer_filters (opaque_pipeline, i, filter, filter);
} }
@ -697,15 +697,15 @@ 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, n_planes, stex->mask_texture); cogl_pipeline_set_layer_texture (blended_pipeline, n_subtextures, stex->mask_texture);
cogl_pipeline_set_layer_filters (blended_pipeline, n_planes, filter, filter); cogl_pipeline_set_layer_filters (blended_pipeline, n_subtextures, filter, filter);
} }
for (i = 0; i < n_planes; i++) for (i = 0; i < n_subtextures; i++)
{ {
CoglTexture *plane = meta_multi_texture_get_plane (paint_tex, i); CoglTexture *subtexture = meta_multi_texture_get_subtexture (paint_tex, i);
cogl_pipeline_set_layer_texture (blended_pipeline, i, plane); cogl_pipeline_set_layer_texture (blended_pipeline, i, subtexture);
cogl_pipeline_set_layer_filters (blended_pipeline, i, filter, filter); cogl_pipeline_set_layer_filters (blended_pipeline, i, filter, filter);
} }
@ -1111,10 +1111,10 @@ meta_shaped_texture_has_alpha (MetaShapedTexture *stex)
return TRUE; return TRUE;
/* FIXME: for now we don't support alpha (except simple textures) */ /* FIXME: for now we don't support alpha (except simple textures) */
if (meta_multi_texture_get_n_planes (multi_texture) > 1) if (meta_multi_texture_get_n_subtextures (multi_texture) > 1)
return FALSE; return FALSE;
cogl_texture = meta_multi_texture_get_plane (multi_texture, 0); cogl_texture = meta_multi_texture_get_subtexture (multi_texture, 0);
switch (cogl_texture_get_components (cogl_texture)) switch (cogl_texture_get_components (cogl_texture))
{ {
case COGL_TEXTURE_COMPONENTS_A: case COGL_TEXTURE_COMPONENTS_A:
@ -1232,10 +1232,10 @@ should_get_via_offscreen (MetaShapedTexture *stex)
{ {
CoglTexture *cogl_texture; CoglTexture *cogl_texture;
if (meta_multi_texture_get_n_planes (stex->texture) > 1) if (meta_multi_texture_get_n_subtextures (stex->texture) > 1)
return FALSE; return FALSE;
cogl_texture = meta_multi_texture_get_plane (stex->texture, 0); cogl_texture = meta_multi_texture_get_subtexture (stex->texture, 0);
if (!cogl_texture_is_get_data_supported (cogl_texture)) if (!cogl_texture_is_get_data_supported (cogl_texture))
return TRUE; return TRUE;
@ -1422,8 +1422,8 @@ meta_shaped_texture_get_image (MetaShapedTexture *stex,
image_height); image_height);
} }
/* We know that we only have 1 plane at this point */ /* We know that we only have 1 subtexture at this point */
texture = meta_multi_texture_get_plane (stex->texture, 0); texture = meta_multi_texture_get_subtexture (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,

View File

@ -220,7 +220,7 @@ meta_surface_actor_x11_process_damage (MetaSurfaceActor *actor,
if (!meta_multi_texture_is_simple (self->texture)) if (!meta_multi_texture_is_simple (self->texture))
return; return;
pixmap = COGL_TEXTURE_PIXMAP_X11 (meta_multi_texture_get_plane (self->texture, 0)); pixmap = COGL_TEXTURE_PIXMAP_X11 (meta_multi_texture_get_subtexture (self->texture, 0));
cogl_texture_pixmap_x11_update_area (pixmap, x, y, width, height); cogl_texture_pixmap_x11_update_area (pixmap, x, y, width, height);
} }

View File

@ -348,25 +348,27 @@ texture_tower_create_texture (MetaTextureTower *tower,
int height) int height)
{ {
MetaMultiTextureFormat format; MetaMultiTextureFormat format;
guint i, n_planes; guint i, n_subtextures;
GPtrArray *planes; GPtrArray *subtextures;
CoglTexture **textures; CoglTexture **textures;
format = meta_multi_texture_get_format (tower->textures[0]); format = meta_multi_texture_get_format (tower->textures[0]);
n_planes = meta_multi_texture_format_get_n_planes (format); n_subtextures = meta_multi_texture_format_get_n_planes (format);
planes = g_ptr_array_new_full (n_planes, g_object_unref); subtextures = g_ptr_array_new_full (n_subtextures, g_object_unref);
for (i = 0; i < n_planes; i++) for (i = 0; i < n_subtextures; i++)
{ {
CoglTexture *texture; CoglTexture *texture;
texture = cogl_texture_new_with_size (width, height, texture = cogl_texture_new_with_size (width, height,
COGL_TEXTURE_NO_AUTO_MIPMAP, COGL_TEXTURE_NO_AUTO_MIPMAP,
TEXTURE_FORMAT); TEXTURE_FORMAT);
g_ptr_array_add (planes, texture); g_ptr_array_add (subtextures, texture);
} }
textures = (CoglTexture **) g_ptr_array_free (planes, FALSE); textures = (CoglTexture **) g_ptr_array_free (subtextures, FALSE);
tower->textures[level] = meta_multi_texture_new (format, textures, n_planes); tower->textures[level] = meta_multi_texture_new (format,
textures,
n_subtextures);
tower->invalid[level].x1 = 0; tower->invalid[level].x1 = 0;
tower->invalid[level].y1 = 0; tower->invalid[level].y1 = 0;
@ -381,7 +383,7 @@ texture_tower_revalidate (MetaTextureTower *tower,
MetaMultiTexture *src_tex = tower->textures[level - 1]; MetaMultiTexture *src_tex = tower->textures[level - 1];
int src_width = meta_multi_texture_get_width (src_tex); int src_width = meta_multi_texture_get_width (src_tex);
int src_height = meta_multi_texture_get_height (src_tex); int src_height = meta_multi_texture_get_height (src_tex);
guint src_n_planes = meta_multi_texture_get_n_planes (src_tex); guint src_n_subtextures = meta_multi_texture_get_n_subtextures (src_tex);
MetaMultiTexture *dest_tex = tower->textures[level]; MetaMultiTexture *dest_tex = tower->textures[level];
int dest_width = meta_multi_texture_get_width (dest_tex); int dest_width = meta_multi_texture_get_width (dest_tex);
int dest_height = meta_multi_texture_get_height (dest_tex); int dest_height = meta_multi_texture_get_height (dest_tex);
@ -390,16 +392,16 @@ texture_tower_revalidate (MetaTextureTower *tower,
/* FIXME: cogl_offscreen_texture_new_with_texture doesn't work for /* FIXME: cogl_offscreen_texture_new_with_texture doesn't work for
* multi-plane textures, so we have to make an FBO for each layer */ * multi-plane textures, so we have to make an FBO for each layer */
for (i = 0; i < src_n_planes; i++) for (i = 0; i < src_n_subtextures; i++)
{ {
Box *invalid = &tower->invalid[level]; Box *invalid = &tower->invalid[level];
CoglTexture *src_plane, *dest_plane; CoglTexture *src_subtexture, *dest_subtexture;
CoglFramebuffer *fb; CoglFramebuffer *fb;
GError *catch_error = NULL; GError *catch_error = NULL;
CoglPipeline *pipeline; CoglPipeline *pipeline;
src_plane = meta_multi_texture_get_plane (src_tex, i); src_subtexture = meta_multi_texture_get_subtexture (src_tex, i);
dest_plane = meta_multi_texture_get_plane (dest_tex, i); dest_subtexture = meta_multi_texture_get_subtexture (dest_tex, i);
if (g_list_nth (tower->fbos[level], i) != NULL) if (g_list_nth (tower->fbos[level], i) != NULL)
{ {
@ -407,7 +409,7 @@ texture_tower_revalidate (MetaTextureTower *tower,
} }
else else
{ {
fb = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (dest_plane)); fb = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (dest_subtexture));
tower->fbos[level] = g_list_append (tower->fbos[level], fb); tower->fbos[level] = g_list_append (tower->fbos[level], fb);
} }
@ -428,7 +430,7 @@ texture_tower_revalidate (MetaTextureTower *tower,
} }
pipeline = cogl_pipeline_copy (tower->pipeline_template); pipeline = cogl_pipeline_copy (tower->pipeline_template);
cogl_pipeline_set_layer_texture (pipeline, 0, src_plane); cogl_pipeline_set_layer_texture (pipeline, 0, src_subtexture);
cogl_framebuffer_draw_textured_rectangle (fb, pipeline, cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
invalid->x1, invalid->y1, invalid->x1, invalid->y1,

View File

@ -38,34 +38,34 @@ G_DECLARE_FINAL_TYPE (MetaMultiTexture, meta_multi_texture,
META_EXPORT META_EXPORT
MetaMultiTexture * meta_multi_texture_new (MetaMultiTextureFormat format, MetaMultiTexture * meta_multi_texture_new (MetaMultiTextureFormat format,
CoglTexture **planes, CoglTexture **subtextures,
guint n_planes); guint n_subtextures);
META_EXPORT META_EXPORT
MetaMultiTexture * meta_multi_texture_new_simple (CoglTexture *plane); MetaMultiTexture * meta_multi_texture_new_simple (CoglTexture *subtexture);
META_EXPORT META_EXPORT
MetaMultiTextureFormat meta_multi_texture_get_format (MetaMultiTexture *self); MetaMultiTextureFormat meta_multi_texture_get_format (MetaMultiTexture *self);
META_EXPORT META_EXPORT
gboolean meta_multi_texture_is_simple (MetaMultiTexture *self); gboolean meta_multi_texture_is_simple (MetaMultiTexture *self);
META_EXPORT META_EXPORT
guint meta_multi_texture_get_n_planes (MetaMultiTexture *self); guint meta_multi_texture_get_n_subtextures (MetaMultiTexture *self);
META_EXPORT META_EXPORT
CoglTexture * meta_multi_texture_get_plane (MetaMultiTexture *self, CoglTexture * meta_multi_texture_get_subtexture (MetaMultiTexture *self,
guint index); guint index);
META_EXPORT META_EXPORT
int meta_multi_texture_get_width (MetaMultiTexture *self); int meta_multi_texture_get_width (MetaMultiTexture *self);
META_EXPORT META_EXPORT
int meta_multi_texture_get_height (MetaMultiTexture *self); int meta_multi_texture_get_height (MetaMultiTexture *self);
META_EXPORT META_EXPORT
char * meta_multi_texture_to_string (MetaMultiTexture *self); char * meta_multi_texture_to_string (MetaMultiTexture *self);
G_END_DECLS G_END_DECLS

View File

@ -253,7 +253,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
meta_multi_texture_get_height (*texture) == height && meta_multi_texture_get_height (*texture) == height &&
meta_multi_texture_get_format (*texture) == multi_format) meta_multi_texture_get_format (*texture) == multi_format)
{ {
CoglTexture *cogl_texture = meta_multi_texture_get_plane (*texture, 0); CoglTexture *cogl_texture = meta_multi_texture_get_subtexture (*texture, 0);
if (cogl_texture_get_components (cogl_texture) == components && if (cogl_texture_get_components (cogl_texture) == components &&
_cogl_texture_get_format (cogl_texture) == cogl_format) _cogl_texture_get_format (cogl_texture) == cogl_format)
{ {
@ -321,8 +321,8 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
int format, width, height, y_inverted; int format, width, height, y_inverted;
MetaMultiTextureFormat multi_format = META_MULTI_TEXTURE_FORMAT_SIMPLE; MetaMultiTextureFormat multi_format = META_MULTI_TEXTURE_FORMAT_SIMPLE;
CoglPixelFormat cogl_format = COGL_PIXEL_FORMAT_ANY; CoglPixelFormat cogl_format = COGL_PIXEL_FORMAT_ANY;
guint i, n_planes; guint i, n_subtextures;
GPtrArray *planes; GPtrArray *subtextures;
if (buffer->egl_image.texture) if (buffer->egl_image.texture)
{ {
@ -361,12 +361,12 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
cogl_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE; cogl_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
break; break;
case EGL_TEXTURE_Y_UV_WL: case EGL_TEXTURE_Y_UV_WL:
/* Technically it can be anything with a separate Y and UV plane /* Technically it can be anything with a separate Y and UV subtexture
* but since this is only used for shaders later, it's ok */ * but since this is only used for shaders later, it's ok */
multi_format = META_MULTI_TEXTURE_FORMAT_NV12; multi_format = META_MULTI_TEXTURE_FORMAT_NV12;
break; break;
case EGL_TEXTURE_Y_U_V_WL: case EGL_TEXTURE_Y_U_V_WL:
/* Technically it can be anything with a separate Y and UV plane /* Technically it can be anything with a separate Y and UV subtexture
* but since this is only used for shaders later, it's ok */ * but since this is only used for shaders later, it's ok */
multi_format = META_MULTI_TEXTURE_FORMAT_YUV444; multi_format = META_MULTI_TEXTURE_FORMAT_YUV444;
break; break;
@ -377,20 +377,20 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
return FALSE; return FALSE;
} }
/* Each EGLImage is a plane in the final texture */ /* Each EGLImage is a subtexture in the final texture */
n_planes = meta_multi_texture_format_get_n_planes (multi_format); n_subtextures = meta_multi_texture_format_get_n_planes (multi_format);
planes = g_ptr_array_new_full (n_planes, cogl_object_unref); subtextures = g_ptr_array_new_full (n_subtextures, cogl_object_unref);
g_warning ("Got EGL with format %u", multi_format); g_warning ("Got EGL with format %u", multi_format);
for (i = 0; i < n_planes; i++) for (i = 0; i < n_subtextures; i++)
{ {
EGLint egl_attribs[3]; EGLint egl_attribs[3];
EGLImageKHR egl_img; EGLImageKHR egl_img;
CoglEglImageFlags flags; CoglEglImageFlags flags;
CoglTexture2D *texture_2d; CoglTexture2D *texture_2d;
/* Specify that we want the i'th plane */ /* Specify that we want the i'th subtexture */
egl_attribs[0] = EGL_WAYLAND_PLANE_WL; egl_attribs[0] = EGL_WAYLAND_PLANE_WL;
egl_attribs[1] = i; egl_attribs[1] = i;
egl_attribs[2] = EGL_NONE; egl_attribs[2] = EGL_NONE;
@ -418,13 +418,13 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
if (G_UNLIKELY (!texture_2d)) if (G_UNLIKELY (!texture_2d))
goto on_error; goto on_error;
g_ptr_array_add (planes, COGL_TEXTURE (texture_2d)); g_ptr_array_add (subtextures, COGL_TEXTURE (texture_2d));
} }
buffer->egl_image.texture = buffer->egl_image.texture =
meta_multi_texture_new (multi_format, meta_multi_texture_new (multi_format,
(CoglTexture**) g_ptr_array_free (planes, FALSE), (CoglTexture**) g_ptr_array_free (subtextures, FALSE),
n_planes); n_subtextures);
buffer->is_y_inverted = !!y_inverted; buffer->is_y_inverted = !!y_inverted;
g_clear_object (texture); g_clear_object (texture);
@ -433,7 +433,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
return TRUE; return TRUE;
on_error: on_error:
g_ptr_array_free (planes, TRUE); g_ptr_array_free (subtextures, TRUE);
return FALSE; return FALSE;
} }
@ -562,7 +562,7 @@ process_shm_buffer_damage (MetaWaylandBuffer *buffer,
shm_buffer_get_format (shm_buffer, &multi_format, &cogl_format, NULL); shm_buffer_get_format (shm_buffer, &multi_format, &cogl_format, NULL);
g_return_val_if_fail (multi_format == META_MULTI_TEXTURE_FORMAT_SIMPLE, FALSE); g_return_val_if_fail (multi_format == META_MULTI_TEXTURE_FORMAT_SIMPLE, FALSE);
cogl_texture = meta_multi_texture_get_plane (texture, 0); cogl_texture = meta_multi_texture_get_subtexture (texture, 0);
wl_shm_buffer_begin_access (shm_buffer); wl_shm_buffer_begin_access (shm_buffer);

View File

@ -71,7 +71,7 @@ update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
g_return_if_fail (meta_multi_texture_is_simple (texture)); g_return_if_fail (meta_multi_texture_is_simple (texture));
meta_cursor_sprite_set_texture (cursor_sprite, meta_cursor_sprite_set_texture (cursor_sprite,
meta_multi_texture_get_plane (texture, 0), meta_multi_texture_get_subtexture (texture, 0),
priv->hot_x * surface->scale, priv->hot_x * surface->scale,
priv->hot_y * surface->scale); priv->hot_y * surface->scale);
} }

View File

@ -205,7 +205,6 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
flags, flags,
error); error);
G_BREAKPOINT();
meta_egl_destroy_image (egl, egl_display, egl_image, NULL); meta_egl_destroy_image (egl, egl_display, egl_image, NULL);
if (cogl_texture == NULL) if (cogl_texture == NULL)