1
0
Fork 0

2007-06-08 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-actor.c:
        * clutter/clutter-debug.h:
        * clutter/clutter-main.c:
        * clutter/clutter-main.h:
        * clutter/clutter-private.h:
        * clutter/clutter-timeline.c:
        Add 'schedule' debug flag and new CLUTTER_TIMESTAMP macro.

        * clutter/clutter-texture.c:
        * clutter/clutter-texture.h:
        * clutter/cogl/cogl.h:
        * clutter/cogl/gl/cogl-defines.h:
        * clutter/cogl/gles/cogl-defines.h:
        * clutter/cogl/gl/cogl.c:
        * clutter/cogl/gles/cogl.c:
        Add initial experiemental YUV texture support.
        Move texture rect size checks into cogl.
        Better handle moving texture data from video -> system memory
        (if support available).
This commit is contained in:
Matthew Allum 2007-06-07 23:51:53 +00:00
parent 3649b4734b
commit 2c40b4b53d
14 changed files with 219 additions and 129 deletions

View file

@ -1,9 +1,31 @@
2007-06-08 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c:
* clutter/clutter-debug.h:
* clutter/clutter-main.c:
* clutter/clutter-main.h:
* clutter/clutter-private.h:
* clutter/clutter-timeline.c:
Add 'schedule' debug flag and new CLUTTER_TIMESTAMP macro.
* clutter/clutter-texture.c:
* clutter/clutter-texture.h:
* clutter/cogl/cogl.h:
* clutter/cogl/gl/cogl-defines.h:
* clutter/cogl/gles/cogl-defines.h:
* clutter/cogl/gl/cogl.c:
* clutter/cogl/gles/cogl.c:
Add initial experiemental YUV texture support.
Move texture rect size checks into cogl.
Better handle moving texture data from video -> system memory
(if support available).
2007-06-07 Neil J. Patel <njp@o-hand.com> 2007-06-07 Neil J. Patel <njp@o-hand.com>
* clutter/clutter-entry.c: (clutter_entry_class_init), * clutter/clutter-entry.c: (clutter_entry_class_init),
(clutter_entry_handle_key_event): (clutter_entry_handle_key_event):
* clutter/clutter-entry.h: * clutter/clutter-entry.h:
Added an 'activated' signal, whihc is emitted when the 'Enter' key is Added an 'activated' signal, which is emitted when the 'Enter' key is
pressed. pressed.
* examples/test-entry.c: (on_entry_activated), (main): * examples/test-entry.c: (on_entry_activated), (main):

View file

@ -1488,6 +1488,8 @@ clutter_actor_queue_redraw (ClutterActor *self)
if (!ctx->update_idle) if (!ctx->update_idle)
{ {
CLUTTER_TIMESTAMP (SCHEDULER,
"Adding ideler for actor: %p", self);
ctx->update_idle = g_idle_add_full (-100 , /* very high priority */ ctx->update_idle = g_idle_add_full (-100 , /* very high priority */
redraw_update_idle, redraw_update_idle,
NULL, NULL); NULL, NULL);

View file

@ -2,6 +2,7 @@
#define __CLUTTER_DEBUG_H__ #define __CLUTTER_DEBUG_H__
#include <glib.h> #include <glib.h>
#include "clutter-main.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -15,7 +16,8 @@ typedef enum {
CLUTTER_DEBUG_ALPHA = 1 << 6, CLUTTER_DEBUG_ALPHA = 1 << 6,
CLUTTER_DEBUG_BEHAVIOUR = 1 << 7, CLUTTER_DEBUG_BEHAVIOUR = 1 << 7,
CLUTTER_DEBUG_PANGO = 1 << 8, CLUTTER_DEBUG_PANGO = 1 << 8,
CLUTTER_DEBUG_BACKEND = 1 << 9 CLUTTER_DEBUG_BACKEND = 1 << 9,
CLUTTER_DEBUG_SCHEDULER = 1 << 10
} ClutterDebugFlag; } ClutterDebugFlag;
#ifdef CLUTTER_ENABLE_DEBUG #ifdef CLUTTER_ENABLE_DEBUG
@ -35,12 +37,19 @@ typedef enum {
g_warning (G_STRLOC ": GL Error %x", _err); \ g_warning (G_STRLOC ": GL Error %x", _err); \
} } G_STMT_END } } G_STMT_END
#define CLUTTER_TIMESTAMP(type,x,a...) G_STMT_START { \
if (clutter_debug_flags & CLUTTER_DEBUG_##type) \
{ g_message ("[" #type "]" " %li:" G_STRLOC ": " \
x, clutter_get_timestamp(), ##a); } \
} G_STMT_END
#else /* !CLUTTER_ENABLE_DEBUG */ #else /* !CLUTTER_ENABLE_DEBUG */
#define CLUTTER_NOTE(type,x,a...) #define CLUTTER_NOTE(type,x,a...)
#define CLUTTER_MARK() #define CLUTTER_MARK()
#define CLUTTER_DBG(x) #define CLUTTER_DBG(x)
#define CLUTTER_GLERR() #define CLUTTER_GLERR()
#define CLUTTER_TIMESTAMP(type,x,a...)
#endif /* CLUTTER_ENABLE_DEBUG */ #endif /* CLUTTER_ENABLE_DEBUG */

View file

@ -68,6 +68,7 @@ static const GDebugKey clutter_debug_keys[] = {
{ "behaviour", CLUTTER_DEBUG_BEHAVIOUR }, { "behaviour", CLUTTER_DEBUG_BEHAVIOUR },
{ "pango", CLUTTER_DEBUG_PANGO }, { "pango", CLUTTER_DEBUG_PANGO },
{ "backend", CLUTTER_DEBUG_BACKEND }, { "backend", CLUTTER_DEBUG_BACKEND },
{ "scheduler", CLUTTER_DEBUG_SCHEDULER },
}; };
#endif /* CLUTTER_ENABLE_DEBUG */ #endif /* CLUTTER_ENABLE_DEBUG */
@ -105,6 +106,8 @@ clutter_redraw (void)
stage = _clutter_backend_get_stage (ctx->backend); stage = _clutter_backend_get_stage (ctx->backend);
CLUTTER_TIMESTAMP (SCHEDULER, "Redraw start");
CLUTTER_NOTE (PAINT, " Redraw enter"); CLUTTER_NOTE (PAINT, " Redraw enter");
/* Setup FPS count */ /* Setup FPS count */
@ -155,6 +158,8 @@ clutter_redraw (void)
} }
CLUTTER_NOTE (PAINT, " Redraw leave"); CLUTTER_NOTE (PAINT, " Redraw leave");
CLUTTER_TIMESTAMP (SCHEDULER, "Redraw finish");
} }
/** /**
@ -175,6 +180,8 @@ clutter_do_event (ClutterEvent *event)
if (!stage) if (!stage)
return; return;
CLUTTER_TIMESTAMP (SCHEDULER, "Event recieved");
switch (event->type) switch (event->type)
{ {
case CLUTTER_NOTHING: case CLUTTER_NOTHING:
@ -336,13 +343,43 @@ clutter_context_get_default (void)
ctx->backend = g_object_new (_clutter_backend_impl_get_type (), NULL); ctx->backend = g_object_new (_clutter_backend_impl_get_type (), NULL);
ctx->is_initialized = FALSE; ctx->is_initialized = FALSE;
#ifdef CLUTTER_ENABLE_DEBUG
ctx->timer = g_timer_new ();
g_timer_start (ctx->timer);
#endif
ClutterCntx = ctx; ClutterCntx = ctx;
} }
return ClutterCntx; return ClutterCntx;
} }
/**
* clutter_get_timestamp:
*
* Returns the approximate number of microseconds passed since clutter was
* intialised.
*
* Return value: Number of microseconds since clutter_init() was called.
*/
gulong
clutter_get_timestamp (void)
{
#ifdef CLUTTER_ENABLE_DEBUG
ClutterMainContext *ctx;
gdouble seconds;
ctx = clutter_context_get_default ();
/* FIXME: may need a custom timer for embedded setups */
seconds = g_timer_elapsed (ctx->timer, NULL);
return (gulong)(seconds / 0.0000001);
#else
return 0;
#endif
}
#ifdef CLUTTER_ENABLE_DEBUG #ifdef CLUTTER_ENABLE_DEBUG
static gboolean static gboolean
clutter_arg_debug_cb (const char *key, clutter_arg_debug_cb (const char *key,

View file

@ -68,6 +68,8 @@ void clutter_threads_leave (void);
void clutter_base_init (void); void clutter_base_init (void);
gulong clutter_get_timestamp (void);
G_END_DECLS G_END_DECLS
#endif #endif

View file

@ -56,7 +56,8 @@ struct _ClutterMainContext
guint main_loop_level; guint main_loop_level;
GSList *main_loops; GSList *main_loops;
guint is_initialized : 1; guint is_initialized : 1;
guint pick_mode :1; guint pick_mode :1; /* Indicates pick render mode */
GTimer *timer; /* Used for debugging scheduler */
}; };
#define CLUTTER_CONTEXT() (clutter_context_get_default ()) #define CLUTTER_CONTEXT() (clutter_context_get_default ())

View file

@ -112,23 +112,6 @@ enum
static int texture_signals[LAST_SIGNAL] = { 0 }; static int texture_signals[LAST_SIGNAL] = { 0 };
static gboolean
can_create_rect_arb (int width,
int height,
GLenum pixel_format,
GLenum pixel_type)
{
#if HAVE_COGL_GL
gint max_size = 0;
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &max_size);
return (max_size && width <= max_size && height <= max_size);
#endif
return FALSE;
}
static int static int
tile_dimension (int to_fill, tile_dimension (int to_fill,
int start_size, int start_size,
@ -178,7 +161,9 @@ texture_init_tiles (ClutterTexture *texture)
x_pot = clutter_util_next_p2 (priv->width); x_pot = clutter_util_next_p2 (priv->width);
y_pot = clutter_util_next_p2 (priv->height); y_pot = clutter_util_next_p2 (priv->height);
while (!(cogl_texture_can_size (priv->pixel_format, priv->pixel_type, while (!(cogl_texture_can_size (CGL_TEXTURE_2D,
priv->pixel_format,
priv->pixel_type,
x_pot, y_pot) x_pot, y_pot)
&& (x_pot - priv->width < priv->max_tile_waste) && (x_pot - priv->width < priv->max_tile_waste)
&& (y_pot - priv->height < priv->max_tile_waste))) && (y_pot - priv->height < priv->max_tile_waste)))
@ -250,18 +235,10 @@ texture_render_to_gl_quad (ClutterTexture *texture,
g_return_if_fail(priv->tiles != NULL); g_return_if_fail(priv->tiles != NULL);
/* OPT: Put in display list */
/* OPT: Optionally avoid tiling and use texture rectangles ext if
* supported.
*/
if (!priv->is_tiled) if (!priv->is_tiled)
{ {
cogl_texture_bind (priv->target_type, priv->tiles[0]); cogl_texture_bind (priv->target_type, priv->tiles[0]);
/* FIXME: FIXED */
if (priv->target_type == CGL_TEXTURE_2D) /* POT */ if (priv->target_type == CGL_TEXTURE_2D) /* POT */
{ {
tx = (float) priv->width / clutter_util_next_p2 (priv->width); tx = (float) priv->width / clutter_util_next_p2 (priv->width);
@ -393,7 +370,6 @@ texture_upload_data (ClutterTexture *texture,
CLUTTER_NOTE (TEXTURE, "syncing for single tile"); CLUTTER_NOTE (TEXTURE, "syncing for single tile");
cogl_texture_bind (priv->target_type, priv->tiles[0]); cogl_texture_bind (priv->target_type, priv->tiles[0]);
cogl_texture_set_alignment (priv->target_type, 4, priv->width); cogl_texture_set_alignment (priv->target_type, 4, priv->width);
cogl_texture_set_filters cogl_texture_set_filters
@ -569,8 +545,11 @@ clutter_texture_unrealize (ClutterActor *actor)
* where this behaviour can be better controlled. * where this behaviour can be better controlled.
*/ */
if (priv->local_pixbuf == NULL) if (priv->local_pixbuf == NULL)
priv->local_pixbuf = clutter_texture_get_pixbuf (texture); {
priv->local_pixbuf = clutter_texture_get_pixbuf (texture);
CLUTTER_NOTE (TEXTURE, "moved pixels into system (pixbuf) mem");
}
texture_free_gl_resources (texture); texture_free_gl_resources (texture);
} }
@ -599,16 +578,19 @@ clutter_texture_realize (ClutterActor *actor)
} }
else else
{ {
/* Dont allow realization with no pixbuf - note set_pixbuf/data if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_READ_PIXELS))
* will set realize flags. {
*/ /* Dont allow realization with no pixbuf - note set_pixbuf/data
CLUTTER_NOTE (TEXTURE, * will set realize flags.
"Texture has no image data cannot realize"); */
CLUTTER_NOTE (TEXTURE,
CLUTTER_NOTE (TEXTURE, "flags %i", actor->flags); "Texture has no image data cannot realize");
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
CLUTTER_NOTE (TEXTURE, "flags %i", actor->flags); CLUTTER_NOTE (TEXTURE, "flags %i", actor->flags);
return; CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
CLUTTER_NOTE (TEXTURE, "flags %i", actor->flags);
return;
}
} }
CLUTTER_NOTE (TEXTURE, "Texture realized"); CLUTTER_NOTE (TEXTURE, "Texture realized");
@ -1039,6 +1021,8 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
/* FIXME: cogl */ /* FIXME: cogl */
printf("grabbing single tile - %i x %i\n", priv->width, priv->height);
glBindTexture(priv->target_type, priv->tiles[0]); glBindTexture(priv->target_type, priv->tiles[0]);
glPixelStorei (GL_UNPACK_ROW_LENGTH, priv->width); glPixelStorei (GL_UNPACK_ROW_LENGTH, priv->width);
@ -1170,7 +1154,7 @@ clutter_texture_set_from_rgb_data (ClutterTexture *texture,
GError **error) GError **error)
{ {
ClutterTexturePrivate *priv; ClutterTexturePrivate *priv;
gboolean texture_dirty = TRUE; gboolean texture_dirty = TRUE, size_change = FALSE;
COGLenum prev_format; COGLenum prev_format;
priv = texture->priv; priv = texture->priv;
@ -1179,7 +1163,8 @@ clutter_texture_set_from_rgb_data (ClutterTexture *texture,
/* Needed for GL_RGBA (internal format) and gdk pixbuf usage */ /* Needed for GL_RGBA (internal format) and gdk pixbuf usage */
g_return_val_if_fail (bpp == 4, FALSE); g_return_val_if_fail (bpp == 4, FALSE);
texture_dirty = (width != priv->width || height != priv->height); texture_dirty = size_change = (width != priv->width
|| height != priv->height);
prev_format = priv->pixel_format; prev_format = priv->pixel_format;
@ -1190,6 +1175,7 @@ clutter_texture_set_from_rgb_data (ClutterTexture *texture,
if (flags & CLUTTER_TEXTURE_RGB_FLAG_BGR) if (flags & CLUTTER_TEXTURE_RGB_FLAG_BGR)
{ {
/* FIXME: We actually need to convert for GLES */
if (has_alpha) if (has_alpha)
priv->pixel_format = CGL_BGRA; priv->pixel_format = CGL_BGRA;
else else
@ -1210,10 +1196,11 @@ clutter_texture_set_from_rgb_data (ClutterTexture *texture,
if (priv->is_tiled == FALSE) if (priv->is_tiled == FALSE)
{ {
if (priv->target_type == CGL_TEXTURE_RECTANGLE_ARB if (priv->target_type == CGL_TEXTURE_RECTANGLE_ARB
&& !can_create_rect_arb (priv->width, && !cogl_texture_can_size (CGL_TEXTURE_RECTANGLE_ARB,
priv->height, priv->pixel_format,
priv->pixel_format, priv->pixel_type,
priv->pixel_type)) priv->width,
priv->height))
{ {
/* If we cant create NPOT tex of this size fall back to tiles */ /* If we cant create NPOT tex of this size fall back to tiles */
CLUTTER_NOTE (TEXTURE, CLUTTER_NOTE (TEXTURE,
@ -1226,11 +1213,11 @@ clutter_texture_set_from_rgb_data (ClutterTexture *texture,
} }
if (priv->target_type == CGL_TEXTURE_2D if (priv->target_type == CGL_TEXTURE_2D
&& !cogl_texture_can_size && !cogl_texture_can_size (CGL_TEXTURE_2D,
(priv->pixel_format, priv->pixel_format,
priv->pixel_type, priv->pixel_type,
clutter_util_next_p2(priv->width), clutter_util_next_p2(priv->width),
clutter_util_next_p2(priv->height))) clutter_util_next_p2(priv->height)))
{ {
priv->is_tiled = TRUE; priv->is_tiled = TRUE;
} }
@ -1256,7 +1243,7 @@ clutter_texture_set_from_rgb_data (ClutterTexture *texture,
CLUTTER_ACTOR_SET_FLAGS (CLUTTER_ACTOR (texture), CLUTTER_ACTOR_REALIZED); CLUTTER_ACTOR_SET_FLAGS (CLUTTER_ACTOR (texture), CLUTTER_ACTOR_REALIZED);
if (texture_dirty) if (size_change)
{ {
g_signal_emit (texture, texture_signals[SIZE_CHANGE], g_signal_emit (texture, texture_signals[SIZE_CHANGE],
0, priv->width, priv->height); 0, priv->width, priv->height);
@ -1300,9 +1287,8 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
ClutterTextureFlags flags, ClutterTextureFlags flags,
GError **error) GError **error)
{ {
#if 0 ClutterTexturePrivate *priv;
gboolean texture_dirty = TRUE; gboolean texture_dirty = TRUE, size_change = FALSE;
COGLenum prev_format;
if (!clutter_feature_available(CLUTTER_FEATURE_TEXTURE_YUV)) if (!clutter_feature_available(CLUTTER_FEATURE_TEXTURE_YUV))
return FALSE; return FALSE;
@ -1310,13 +1296,19 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
priv = texture->priv; priv = texture->priv;
/* FIXME: check other image props */ /* FIXME: check other image props */
texture_dirty = (width != priv->width || height != priv->height); size_change = (width != priv->width || height != priv->height);
texture_dirty = size_change || (priv->pixel_format != CGL_YCBCR_MESA);
priv->width = width; priv->width = width;
priv->height = height; priv->height = height;
priv->pixel_type = (flags & CLUTTER_TEXTURE_YUV_FLAG_YUV2) ?
/* #ifdef GL_YCBCR_MESA */ CGL_UNSIGNED_SHORT_8_8_REV_MESA :
CGL_UNSIGNED_SHORT_8_8_MESA;
priv->pixel_format = CGL_YCBCR_MESA; priv->pixel_format = CGL_YCBCR_MESA;
priv->target_type = CGL_TEXTURE_2D;
if (texture_dirty)
texture_free_gl_resources (texture);
if (!priv->tiles) if (!priv->tiles)
{ {
@ -1332,52 +1324,56 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
if (texture_dirty) if (texture_dirty)
{ {
if (cogl_texture_can_size(priv->pixel_format, /* FIXME: need to check size limits correctly - does not
priv->pixel_type, * seem to work if correct format and typre are used so
clutter_util_next_p2(priv->width), * this is really a guess...
clutter_util_next_p2(priv->height))) */
if (cogl_texture_can_size (CGL_TEXTURE_2D,
CGL_RGBA,
CGL_UNSIGNED_BYTE,
clutter_util_next_p2(priv->width),
clutter_util_next_p2(priv->height)))
{ {
glTexImage2D (CGL_TEXTURE_2D, cogl_texture_image_2d (priv->target_type,
0, priv->pixel_format,
GL_YCBCR_MESA, clutter_util_next_p2(priv->width),
clutter_util_next_p2(priv->width), clutter_util_next_p2(priv->height),
clutter_util_next_p2(priv->height), priv->pixel_format,
0, priv->pixel_type,
GL_YCBCR_MESA, NULL);
GL_UNSIGNED_SHORT_8_8_REV_MESA,
NULL);
} }
else else
/* No tiled support for YUV textures as yet */ return FALSE; /* FIXME: add tiling */
return FALSE; /* Set Error */
} }
if (flags & CLUTTER_TEXTURE_YUV_FLAG_YUV2) cogl_texture_sub_image_2d (priv->target_type,
0,
0,
priv->width,
priv->height,
priv->pixel_format,
priv->pixel_type,
data);
CLUTTER_ACTOR_SET_FLAGS (CLUTTER_ACTOR (texture), CLUTTER_ACTOR_REALIZED);
if (size_change)
{ {
glTexSubImage2D (GL_TEXTURE_2D, g_signal_emit (texture, texture_signals[SIZE_CHANGE],
0, 0, priv->width, priv->height);
0,
0, if (priv->sync_actor_size)
priv->width, clutter_actor_set_size (CLUTTER_ACTOR(texture),
priv->height priv->width,
CGL_YCBCR_MESA, priv->height);
CGL_UNSIGNED_SHORT_8_8_REV_MESA,
data);
} }
else
{ g_signal_emit (texture, texture_signals[PIXBUF_CHANGE], 0);
glTexSubImage2D (GL_TEXTURE_2D,
0, if (CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR(texture)))
0, clutter_actor_queue_redraw (CLUTTER_ACTOR(texture));
0,
priv->width, return TRUE;
priv->height
CGL_YCBCR_MESA,
CGL_UNSIGNED_SHORT_8_8_MESA,
data);
}
#endif
return FALSE;
} }
/** /**

View file

@ -70,7 +70,7 @@ struct _ClutterTextureClass
typedef enum ClutterTextureFlags typedef enum ClutterTextureFlags
{ {
CLUTTER_TEXTURE_RGB_FLAG_BGR = (1<<1), CLUTTER_TEXTURE_RGB_FLAG_BGR = (1<<1),
CLUTTER_TEXTURE_RGB_FLAG_PREMULT = (1<<2), CLUTTER_TEXTURE_RGB_FLAG_PREMULT = (1<<2), /* FIXME: not handled */
CLUTTER_TEXTURE_YUV_FLAG_YUV2 = (1<<3) CLUTTER_TEXTURE_YUV_FLAG_YUV2 = (1<<3)
/* FIXME: add compressed types ? */ /* FIXME: add compressed types ? */
} ClutterTextureFlags; } ClutterTextureFlags;

View file

@ -312,6 +312,8 @@ timeline_timeout_func (gpointer data)
priv = timeline->priv; priv = timeline->priv;
CLUTTER_TIMESTAMP (SCHEDULER, "Timeline:%p activated\n", timeline);
/* Figure out potential frame skips */ /* Figure out potential frame skips */
g_get_current_time (&timeval); g_get_current_time (&timeval);
@ -342,7 +344,11 @@ timeline_timeout_func (gpointer data)
n_frames = 1; n_frames = 1;
if (n_frames > 1) if (n_frames > 1)
CLUTTER_NOTE (MISC, "Skipping %i frames", n_frames); {
CLUTTER_TIMESTAMP (SCHEDULER,
"Timeline %p, skipping %i frames\n",
timeline, n_frames);
}
} }
else else
{ {

View file

@ -113,10 +113,12 @@ void
cogl_enable (gulong flags); cogl_enable (gulong flags);
gboolean gboolean
cogl_texture_can_size (COGLenum pixel_format, cogl_texture_can_size (COGLenum target,
COGLenum pixel_format,
COGLenum pixel_type, COGLenum pixel_type,
int width, int width,
int height); int height);
void void
cogl_texture_quad (gint x1, cogl_texture_quad (gint x1,
gint x2, gint x2,

View file

@ -671,6 +671,15 @@ typedef GLint COGLint;
#define CGL_TEXTURE_2D GL_TEXTURE_2D #define CGL_TEXTURE_2D GL_TEXTURE_2D
#define CGL_ARGB GL_ARGB #define CGL_ARGB GL_ARGB
#define CGL_TEXTURE_RECTANGLE_ARB GL_TEXTURE_RECTANGLE_ARB #define CGL_TEXTURE_RECTANGLE_ARB GL_TEXTURE_RECTANGLE_ARB
#ifdef GL_YCBCR_MESA
#define CGL_YCBCR_MESA GL_YCBCR_MESA
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA GL_UNSIGNED_SHORT_8_8_REV_MESA
#define CGL_UNSIGNED_SHORT_8_8_MESA GL_UNSIGNED_SHORT_8_8_MESA
#else
#define CGL_YCBCR_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_MESA 0
#endif
G_END_DECLS G_END_DECLS

View file

@ -300,21 +300,33 @@ cogl_clip_unset (void)
} }
gboolean gboolean
cogl_texture_can_size (COGLenum pixel_format, cogl_texture_can_size (COGLenum target,
COGLenum pixel_format,
COGLenum pixel_type, COGLenum pixel_type,
int width, int width,
int height) int height)
{ {
GLint new_width = 0; if (target == CGL_TEXTURE_RECTANGLE_ARB)
{
gint max_size = 0;
GE( glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA, GE( glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &max_size) );
width, height, 0 /* border */,
pixel_format, pixel_type, NULL) );
GE( glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, return (max_size && width <= max_size && height <= max_size);
GL_TEXTURE_WIDTH, &new_width) ); }
else /* Assumes CGL_TEXTURE_2D */
{
GLint new_width = 0;
return new_width != 0; GE( glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
width, height, 0 /* border */,
pixel_format, pixel_type, NULL) );
GE( glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0,
GL_TEXTURE_WIDTH, &new_width) );
return new_width != 0;
}
} }
void void

View file

@ -451,7 +451,13 @@ typedef GLint COGLint;
#define CGL_BGR GL_RGB #define CGL_BGR GL_RGB
#define CGL_BGRA GL_RGBA #define CGL_BGRA GL_RGBA
#define CGL_TEXTURE_RECTANGLE_ARB 0 /* Its unlikely we support this */ /* Its unlikely we support this */
#define CGL_TEXTURE_RECTANGLE_ARB 0
/* YUV textures also unsupported */
#define CGL_YCBCR_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_MESA 0
G_END_DECLS G_END_DECLS

View file

@ -267,29 +267,15 @@ cogl_clip_unset (void)
GE( glDisable (GL_STENCIL_TEST) ); GE( glDisable (GL_STENCIL_TEST) );
} }
gboolean gboolean
cogl_texture_can_size (COGLenum pixel_format, cogl_texture_can_size (COGLenum target,
COGLenum pixel_format,
COGLenum pixel_type, COGLenum pixel_type,
int width, int width,
int height) int height)
{ {
/* FIXME */ /* FIXME: How we get this is likely GLES implementation dependant. */
return TRUE; return TRUE;
#if 0
GLint new_width = 0;
GE( glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
width, height, 0 /* border */,
pixel_format, pixel_type, NULL) );
GE( glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0,
GL_TEXTURE_WIDTH, &new_width) );
return new_width != 0;
#endif
} }
void void