mirror of
https://github.com/brl/mutter.git
synced 2025-02-23 16:34:10 +00:00
Create the 1x1 texture for the root background unsliced
When there was no root background pixmap, we were using a 1x1 repeating texture as a simple way of drawing a solid color without adding a second code path. However, when that 1x1 texture was combined into a larger "atlas texture", hardware repeat couldn't be used, so a small inefficiency from this approach became an enormous inefficiency as clutter drew every pixel of the background as a separate rectangle. https://bugzilla.gnome.org/show_bug.cgi?id=652507
This commit is contained in:
parent
61b5cfece4
commit
fe12294b92
@ -29,6 +29,10 @@
|
|||||||
* @green:
|
* @green:
|
||||||
* @blue:
|
* @blue:
|
||||||
* @alpha:
|
* @alpha:
|
||||||
|
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE;
|
||||||
|
* %COGL_TEXTURE_NO_SLICING is useful if the texture will be
|
||||||
|
* repeated to create a constant color fill, since hardware
|
||||||
|
* repeat can't be used for a sliced texture.
|
||||||
*
|
*
|
||||||
* Creates a texture that is a single pixel with the specified
|
* Creates a texture that is a single pixel with the specified
|
||||||
* unpremultiplied color components.
|
* unpremultiplied color components.
|
||||||
@ -39,7 +43,8 @@ CoglHandle
|
|||||||
meta_create_color_texture_4ub (guint8 red,
|
meta_create_color_texture_4ub (guint8 red,
|
||||||
guint8 green,
|
guint8 green,
|
||||||
guint8 blue,
|
guint8 blue,
|
||||||
guint8 alpha)
|
guint8 alpha,
|
||||||
|
CoglTextureFlags flags)
|
||||||
{
|
{
|
||||||
CoglColor color;
|
CoglColor color;
|
||||||
guint8 pixel[4];
|
guint8 pixel[4];
|
||||||
@ -53,7 +58,7 @@ meta_create_color_texture_4ub (guint8 red,
|
|||||||
pixel[3] = cogl_color_get_alpha_byte (&color);
|
pixel[3] = cogl_color_get_alpha_byte (&color);
|
||||||
|
|
||||||
return cogl_texture_new_from_data (1, 1,
|
return cogl_texture_new_from_data (1, 1,
|
||||||
COGL_TEXTURE_NONE,
|
flags,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
COGL_PIXEL_FORMAT_ANY,
|
||||||
4, pixel);
|
4, pixel);
|
||||||
@ -88,7 +93,8 @@ meta_create_texture_material (CoglHandle src_texture)
|
|||||||
{
|
{
|
||||||
CoglHandle dummy_texture;
|
CoglHandle dummy_texture;
|
||||||
|
|
||||||
dummy_texture = meta_create_color_texture_4ub (0xff, 0xff, 0xff, 0xff);
|
dummy_texture = meta_create_color_texture_4ub (0xff, 0xff, 0xff, 0xff,
|
||||||
|
COGL_TEXTURE_NONE);
|
||||||
|
|
||||||
texture_material_template = cogl_material_new ();
|
texture_material_template = cogl_material_new ();
|
||||||
cogl_material_set_layer (texture_material_template, 0, dummy_texture);
|
cogl_material_set_layer (texture_material_template, 0, dummy_texture);
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
CoglHandle meta_create_color_texture_4ub (guint8 red,
|
CoglHandle meta_create_color_texture_4ub (guint8 red,
|
||||||
guint8 green,
|
guint8 green,
|
||||||
guint8 blue,
|
guint8 blue,
|
||||||
guint8 alpha);
|
guint8 alpha,
|
||||||
|
CoglTextureFlags flags);
|
||||||
CoglHandle meta_create_texture_material (CoglHandle src_texture);
|
CoglHandle meta_create_texture_material (CoglHandle src_texture);
|
||||||
|
|
||||||
#endif /* __META_COGL_UTILS_H__ */
|
#endif /* __META_COGL_UTILS_H__ */
|
||||||
|
@ -113,8 +113,13 @@ set_texture_to_stage_color (MetaBackgroundActor *self)
|
|||||||
CoglHandle texture;
|
CoglHandle texture;
|
||||||
|
|
||||||
clutter_stage_get_color (CLUTTER_STAGE (stage), &color);
|
clutter_stage_get_color (CLUTTER_STAGE (stage), &color);
|
||||||
|
|
||||||
|
/* Slicing will prevent COGL from using hardware texturing for
|
||||||
|
* the tiled 1x1 pixmap, and will cause it to draw the window
|
||||||
|
* background in millions of separate 1x1 rectangles */
|
||||||
texture = meta_create_color_texture_4ub (color.red, color.green,
|
texture = meta_create_color_texture_4ub (color.red, color.green,
|
||||||
color.blue, 0xff);
|
color.blue, 0xff,
|
||||||
|
COGL_TEXTURE_NO_SLICING);
|
||||||
set_texture (self, texture);
|
set_texture (self, texture);
|
||||||
cogl_handle_unref (texture);
|
cogl_handle_unref (texture);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user