[mutter] Create the 1x1 texture for the root background unsliced
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Create the 1x1 texture for the root background unsliced
- Date: Wed, 29 Jun 2011 16:27:28 +0000 (UTC)
commit fe12294b92794077e7512d0322a50a082d733b7a
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Mon Jun 13 17:18:27 2011 -0400
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
src/compositor/cogl-utils.c | 18 ++++++++++++------
src/compositor/cogl-utils.h | 9 +++++----
src/compositor/meta-background-actor.c | 7 ++++++-
3 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/src/compositor/cogl-utils.c b/src/compositor/cogl-utils.c
index 2e5183c..5dbe3df 100644
--- a/src/compositor/cogl-utils.c
+++ b/src/compositor/cogl-utils.c
@@ -29,6 +29,10 @@
* @green:
* @blue:
* @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
* unpremultiplied color components.
@@ -36,10 +40,11 @@
* Return value: (transfer full): a newly created Cogl texture
*/
CoglHandle
-meta_create_color_texture_4ub (guint8 red,
- guint8 green,
- guint8 blue,
- guint8 alpha)
+meta_create_color_texture_4ub (guint8 red,
+ guint8 green,
+ guint8 blue,
+ guint8 alpha,
+ CoglTextureFlags flags)
{
CoglColor color;
guint8 pixel[4];
@@ -53,7 +58,7 @@ meta_create_color_texture_4ub (guint8 red,
pixel[3] = cogl_color_get_alpha_byte (&color);
return cogl_texture_new_from_data (1, 1,
- COGL_TEXTURE_NONE,
+ flags,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_ANY,
4, pixel);
@@ -88,7 +93,8 @@ meta_create_texture_material (CoglHandle src_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 ();
cogl_material_set_layer (texture_material_template, 0, dummy_texture);
diff --git a/src/compositor/cogl-utils.h b/src/compositor/cogl-utils.h
index 74748ab..8d6742e 100644
--- a/src/compositor/cogl-utils.h
+++ b/src/compositor/cogl-utils.h
@@ -25,10 +25,11 @@
#include <cogl/cogl.h>
-CoglHandle meta_create_color_texture_4ub (guint8 red,
- guint8 green,
- guint8 blue,
- guint8 alpha);
+CoglHandle meta_create_color_texture_4ub (guint8 red,
+ guint8 green,
+ guint8 blue,
+ guint8 alpha,
+ CoglTextureFlags flags);
CoglHandle meta_create_texture_material (CoglHandle src_texture);
#endif /* __META_COGL_UTILS_H__ */
diff --git a/src/compositor/meta-background-actor.c b/src/compositor/meta-background-actor.c
index 7af8d62..4e68281 100644
--- a/src/compositor/meta-background-actor.c
+++ b/src/compositor/meta-background-actor.c
@@ -113,8 +113,13 @@ set_texture_to_stage_color (MetaBackgroundActor *self)
CoglHandle texture;
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,
- color.blue, 0xff);
+ color.blue, 0xff,
+ COGL_TEXTURE_NO_SLICING);
set_texture (self, texture);
cogl_handle_unref (texture);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]