background: Merge the code for creating the color texture into here

It's unused anywhere else.
This commit is contained in:
Jasper St. Pierre 2014-08-07 13:41:40 -04:00
parent e3d5969282
commit 584460deec
3 changed files with 12 additions and 52 deletions

View File

@ -22,48 +22,6 @@
#include <clutter/clutter.h>
#include "cogl-utils.h"
/**
* meta_create_color_texture_4ub:
* @red: red component
* @green: green component
* @blue: blue component
* @alpha: alpha component
* @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.
*
* Return value: (transfer full): a newly created Cogl texture
*/
CoglTexture *
meta_create_color_texture_4ub (guint8 red,
guint8 green,
guint8 blue,
guint8 alpha,
CoglTextureFlags flags)
{
CoglColor color;
guint8 pixel[4];
cogl_color_init_from_4ub (&color, red, green, blue, alpha);
cogl_color_premultiply (&color);
pixel[0] = cogl_color_get_red_byte (&color);
pixel[1] = cogl_color_get_green_byte (&color);
pixel[2] = cogl_color_get_blue_byte (&color);
pixel[3] = cogl_color_get_alpha_byte (&color);
return cogl_texture_new_from_data (1, 1,
flags,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_ANY,
4, pixel);
}
/* Based on gnome-shell/src/st/st-private.c:_st_create_texture_material.c */
/**

View File

@ -23,11 +23,6 @@
#include <cogl/cogl.h>
CoglTexture * meta_create_color_texture_4ub (guint8 red,
guint8 green,
guint8 blue,
guint8 alpha,
CoglTextureFlags flags);
CoglPipeline * meta_create_texture_pipeline (CoglTexture *texture);
#endif /* __META_COGL_UTILS_H__ */

View File

@ -847,6 +847,7 @@ meta_background_load_color (MetaBackground *self,
CoglTexture *texture;
ClutterActor *stage = meta_get_stage_for_screen (priv->screen);
ClutterColor stage_color;
uint8_t pixels[4];
ensure_pipeline (self);
@ -859,11 +860,17 @@ meta_background_load_color (MetaBackground *self,
color = &stage_color;
}
texture = meta_create_color_texture_4ub (color->red,
color->green,
color->blue,
0xff,
COGL_TEXTURE_NO_SLICING);
pixels[0] = color->red;
pixels[1] = color->green;
pixels[2] = color->blue;
pixels[3] = 0xFF;
texture = cogl_texture_new_from_data (1, 1,
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_RGB_888,
COGL_PIXEL_FORMAT_ANY,
4,
pixels);
set_texture (self, COGL_TEXTURE (texture));
}