compositor: Don't use cogl_texture_new_with_data in the obvious cases
It's a deprecated API that can surprise us. Namely, when the internal format passed is COGL_PIXEL_FORMAT_ANY, it will *always* allocate an RGBA8888 pixel format texture, even if we only passed it a RGB format or even an A8 format. cogl_texture_2d_new_with_data is the newer, better API and doesn't have these warts.
This commit is contained in:
parent
584460deec
commit
d72bf0cd5d
@ -785,6 +785,8 @@ meta_background_load_gradient (MetaBackground *self,
|
|||||||
ClutterColor *color,
|
ClutterColor *color,
|
||||||
ClutterColor *second_color)
|
ClutterColor *second_color)
|
||||||
{
|
{
|
||||||
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
|
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||||
MetaBackgroundPrivate *priv = self->priv;
|
MetaBackgroundPrivate *priv = self->priv;
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
guint width, height;
|
guint width, height;
|
||||||
@ -820,12 +822,11 @@ meta_background_load_gradient (MetaBackground *self,
|
|||||||
pixels[6] = second_color->blue;
|
pixels[6] = second_color->blue;
|
||||||
pixels[7] = 0xFF;
|
pixels[7] = 0xFF;
|
||||||
|
|
||||||
texture = cogl_texture_new_from_data (width, height,
|
texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, width, height,
|
||||||
COGL_TEXTURE_NO_SLICING,
|
COGL_PIXEL_FORMAT_RGB_888,
|
||||||
COGL_PIXEL_FORMAT_RGB_888,
|
4,
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
pixels,
|
||||||
4,
|
NULL));
|
||||||
pixels);
|
|
||||||
set_texture (self, COGL_TEXTURE (texture));
|
set_texture (self, COGL_TEXTURE (texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,6 +844,8 @@ void
|
|||||||
meta_background_load_color (MetaBackground *self,
|
meta_background_load_color (MetaBackground *self,
|
||||||
ClutterColor *color)
|
ClutterColor *color)
|
||||||
{
|
{
|
||||||
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
|
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||||
MetaBackgroundPrivate *priv = self->priv;
|
MetaBackgroundPrivate *priv = self->priv;
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
ClutterActor *stage = meta_get_stage_for_screen (priv->screen);
|
ClutterActor *stage = meta_get_stage_for_screen (priv->screen);
|
||||||
@ -865,12 +868,11 @@ meta_background_load_color (MetaBackground *self,
|
|||||||
pixels[2] = color->blue;
|
pixels[2] = color->blue;
|
||||||
pixels[3] = 0xFF;
|
pixels[3] = 0xFF;
|
||||||
|
|
||||||
texture = cogl_texture_new_from_data (1, 1,
|
texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, 1, 1,
|
||||||
COGL_TEXTURE_NO_SLICING,
|
COGL_PIXEL_FORMAT_RGB_888,
|
||||||
COGL_PIXEL_FORMAT_RGB_888,
|
4,
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
pixels,
|
||||||
4,
|
NULL));
|
||||||
pixels);
|
|
||||||
set_texture (self, COGL_TEXTURE (texture));
|
set_texture (self, COGL_TEXTURE (texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,6 +970,8 @@ meta_background_load_file_finish (MetaBackground *self,
|
|||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
|
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
LoadFileTaskData *task_data;
|
LoadFileTaskData *task_data;
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
@ -976,6 +980,7 @@ meta_background_load_file_finish (MetaBackground *self,
|
|||||||
guchar *pixels;
|
guchar *pixels;
|
||||||
gboolean has_alpha;
|
gboolean has_alpha;
|
||||||
gboolean loaded = FALSE;
|
gboolean loaded = FALSE;
|
||||||
|
CoglPixelFormat pixel_format;
|
||||||
|
|
||||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||||
|
|
||||||
@ -994,15 +999,13 @@ meta_background_load_file_finish (MetaBackground *self,
|
|||||||
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||||
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||||
|
|
||||||
texture = cogl_texture_new_from_data (width,
|
pixel_format = has_alpha ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888;
|
||||||
height,
|
|
||||||
COGL_TEXTURE_NO_ATLAS,
|
texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, width, height,
|
||||||
has_alpha ?
|
pixel_format,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888 :
|
row_stride,
|
||||||
COGL_PIXEL_FORMAT_RGB_888,
|
pixels,
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
NULL));
|
||||||
row_stride,
|
|
||||||
pixels);
|
|
||||||
|
|
||||||
if (texture == NULL)
|
if (texture == NULL)
|
||||||
{
|
{
|
||||||
|
@ -704,6 +704,8 @@ static void
|
|||||||
make_shadow (MetaShadow *shadow,
|
make_shadow (MetaShadow *shadow,
|
||||||
cairo_region_t *region)
|
cairo_region_t *region)
|
||||||
{
|
{
|
||||||
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
|
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||||
int d = get_box_filter_size (shadow->key.radius);
|
int d = get_box_filter_size (shadow->key.radius);
|
||||||
int spread = get_shadow_spread (shadow->key.radius);
|
int spread = get_shadow_spread (shadow->key.radius);
|
||||||
cairo_rectangle_int_t extents;
|
cairo_rectangle_int_t extents;
|
||||||
@ -793,15 +795,15 @@ make_shadow (MetaShadow *shadow,
|
|||||||
* in the case of top_fade >= 0. We also account for padding at the left for symmetry
|
* in the case of top_fade >= 0. We also account for padding at the left for symmetry
|
||||||
* though that doesn't currently occur.
|
* though that doesn't currently occur.
|
||||||
*/
|
*/
|
||||||
shadow->texture = cogl_texture_new_from_data (shadow->outer_border_left + extents.width + shadow->outer_border_right,
|
shadow->texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx,
|
||||||
shadow->outer_border_top + extents.height + shadow->outer_border_bottom,
|
shadow->outer_border_left + extents.width + shadow->outer_border_right,
|
||||||
COGL_TEXTURE_NONE,
|
shadow->outer_border_top + extents.height + shadow->outer_border_bottom,
|
||||||
COGL_PIXEL_FORMAT_A_8,
|
COGL_PIXEL_FORMAT_A_8,
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
buffer_width,
|
||||||
buffer_width,
|
(buffer +
|
||||||
(buffer +
|
(y_offset - shadow->outer_border_top) * buffer_width +
|
||||||
(y_offset - shadow->outer_border_top) * buffer_width +
|
(x_offset - shadow->outer_border_left)),
|
||||||
(x_offset - shadow->outer_border_left)));
|
NULL));
|
||||||
|
|
||||||
cairo_region_destroy (row_convolve_region);
|
cairo_region_destroy (row_convolve_region);
|
||||||
cairo_region_destroy (column_convolve_region);
|
cairo_region_destroy (column_convolve_region);
|
||||||
|
@ -1657,6 +1657,8 @@ build_and_scan_frame_mask (MetaWindowActor *self,
|
|||||||
cairo_rectangle_int_t *client_area,
|
cairo_rectangle_int_t *client_area,
|
||||||
cairo_region_t *shape_region)
|
cairo_region_t *shape_region)
|
||||||
{
|
{
|
||||||
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
|
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
guchar *mask_data;
|
guchar *mask_data;
|
||||||
guint tex_width, tex_height;
|
guint tex_width, tex_height;
|
||||||
@ -1719,10 +1721,7 @@ build_and_scan_frame_mask (MetaWindowActor *self,
|
|||||||
|
|
||||||
if (meta_texture_rectangle_check (paint_tex))
|
if (meta_texture_rectangle_check (paint_tex))
|
||||||
{
|
{
|
||||||
ClutterBackend *backend = clutter_get_default_backend ();
|
mask_texture = COGL_TEXTURE (cogl_texture_rectangle_new_with_size (ctx, tex_width, tex_height));
|
||||||
CoglContext *context = clutter_backend_get_cogl_context (backend);
|
|
||||||
|
|
||||||
mask_texture = COGL_TEXTURE (cogl_texture_rectangle_new_with_size (context, tex_width, tex_height));
|
|
||||||
cogl_texture_set_components (mask_texture, COGL_TEXTURE_COMPONENTS_A);
|
cogl_texture_set_components (mask_texture, COGL_TEXTURE_COMPONENTS_A);
|
||||||
cogl_texture_set_region (mask_texture,
|
cogl_texture_set_region (mask_texture,
|
||||||
0, 0, /* src_x/y */
|
0, 0, /* src_x/y */
|
||||||
@ -1734,15 +1733,9 @@ build_and_scan_frame_mask (MetaWindowActor *self,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Note: we don't allow slicing for this texture because we
|
mask_texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, tex_width, tex_height,
|
||||||
* need to use it with multi-texturing which doesn't support
|
COGL_PIXEL_FORMAT_A_8,
|
||||||
* sliced textures */
|
stride, mask_data, NULL));
|
||||||
mask_texture = cogl_texture_new_from_data (tex_width, tex_height,
|
|
||||||
COGL_TEXTURE_NO_SLICING,
|
|
||||||
COGL_PIXEL_FORMAT_A_8,
|
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
|
||||||
stride,
|
|
||||||
mask_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_shaped_texture_set_mask_texture (stex, mask_texture);
|
meta_shaped_texture_set_mask_texture (stex, mask_texture);
|
||||||
|
Loading…
Reference in New Issue
Block a user