mirror of
https://github.com/brl/mutter.git
synced 2024-11-11 08:46:26 -05:00
Properly set the number of components on the CoglTextureRectangle
We need to set the number of components on the CoglTextureRectangle to prevent wasting too much GPU memory. As we need to do this before we call cogl_texture_set_region, just remove the meta_texture_rectangle_new wrapper, and make callers call cogl_texture_rectangle_new_with_size directly.
This commit is contained in:
parent
d2a1db8834
commit
3548e6da73
@ -26,36 +26,6 @@
|
|||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include "meta-texture-rectangle.h"
|
#include "meta-texture-rectangle.h"
|
||||||
|
|
||||||
CoglTexture *
|
|
||||||
meta_texture_rectangle_new (unsigned int width,
|
|
||||||
unsigned int height,
|
|
||||||
CoglPixelFormat format,
|
|
||||||
unsigned int rowstride,
|
|
||||||
const guint8 *data)
|
|
||||||
{
|
|
||||||
ClutterBackend *backend =
|
|
||||||
clutter_get_default_backend ();
|
|
||||||
CoglContext *context =
|
|
||||||
clutter_backend_get_cogl_context (backend);
|
|
||||||
CoglTextureRectangle *tex_rect;
|
|
||||||
|
|
||||||
tex_rect = cogl_texture_rectangle_new_with_size (context, width, height);
|
|
||||||
if (tex_rect == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
cogl_texture_set_region (COGL_TEXTURE (tex_rect),
|
|
||||||
0, 0, /* src_x/y */
|
|
||||||
0, 0, /* dst_x/y */
|
|
||||||
width, height, /* dst_width/height */
|
|
||||||
width, height, /* width/height */
|
|
||||||
format,
|
|
||||||
rowstride,
|
|
||||||
data);
|
|
||||||
|
|
||||||
return COGL_TEXTURE (tex_rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
texture_rectangle_check_cb (CoglTexture *sub_texture,
|
texture_rectangle_check_cb (CoglTexture *sub_texture,
|
||||||
const float *sub_texture_coords,
|
const float *sub_texture_coords,
|
||||||
|
@ -28,13 +28,6 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
CoglTexture *
|
|
||||||
meta_texture_rectangle_new (unsigned int width,
|
|
||||||
unsigned int height,
|
|
||||||
CoglPixelFormat format,
|
|
||||||
unsigned int rowstride,
|
|
||||||
const guint8 *data);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_texture_rectangle_check (CoglTexture *texture);
|
meta_texture_rectangle_check (CoglTexture *texture);
|
||||||
|
|
||||||
|
@ -359,14 +359,10 @@ texture_tower_create_texture (MetaTextureTower *tower,
|
|||||||
if ((!is_power_of_two (width) || !is_power_of_two (height)) &&
|
if ((!is_power_of_two (width) || !is_power_of_two (height)) &&
|
||||||
meta_texture_rectangle_check (tower->textures[level - 1]))
|
meta_texture_rectangle_check (tower->textures[level - 1]))
|
||||||
{
|
{
|
||||||
tower->textures[level] =
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
meta_texture_rectangle_new (width, height,
|
CoglContext *context = clutter_backend_get_cogl_context (backend);
|
||||||
/* data format */
|
|
||||||
TEXTURE_FORMAT,
|
tower->textures[level] = cogl_texture_rectangle_new_with_size (context, width, height);
|
||||||
/* rowstride */
|
|
||||||
width * 4,
|
|
||||||
/* data */
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2165,7 +2165,16 @@ build_and_scan_frame_mask (MetaWindowActor *self,
|
|||||||
|
|
||||||
if (meta_texture_rectangle_check (paint_tex))
|
if (meta_texture_rectangle_check (paint_tex))
|
||||||
{
|
{
|
||||||
mask_texture = meta_texture_rectangle_new (tex_width, tex_height,
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
|
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_region (mask_texture,
|
||||||
|
0, 0, /* src_x/y */
|
||||||
|
0, 0, /* dst_x/y */
|
||||||
|
tex_width, tex_height, /* dst_width/height */
|
||||||
|
tex_width, tex_height, /* width/height */
|
||||||
COGL_PIXEL_FORMAT_A_8,
|
COGL_PIXEL_FORMAT_A_8,
|
||||||
stride, mask_data);
|
stride, mask_data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user