2008-06-23 Emmanuele Bassi <ebassi@openedhand.com>

Bug 982 - __COGL_GET_CONTEXT MS compiler issue (Haakon Sporsheim)

	* clutter/cogl/common/cogl-handle.h:
	* clutter/cogl/common/cogl-primitives.c: Remove C99-isms.

	* clutter/cogl/gl/cogl-fbo.c:
	* clutter/cogl/gl/cogl-primitives.c:
	* clutter/cogl/gl/cogl-texture.c:
	* clutter/cogl/gl/cogl.c: Ditto as above.

	* clutter/cogl/gles/cogl-fbo.c:
	* clutter/cogl/gles/cogl-primitives.c:
	* clutter/cogl/gles/cogl-texture.c: Ditto as above.
This commit is contained in:
Emmanuele Bassi 2008-06-23 11:01:30 +00:00
parent d5a2697d6f
commit 76b5a93afa
9 changed files with 59 additions and 62 deletions

View File

@ -60,10 +60,10 @@
static gint \ static gint \
_cogl_##type_name##_handle_find (CoglHandle handle) \ _cogl_##type_name##_handle_find (CoglHandle handle) \
{ \ { \
_COGL_GET_CONTEXT (ctx, -1); \
\
gint i; \ gint i; \
\ \
_COGL_GET_CONTEXT (ctx, -1); \
\
if (ctx->handle_array == NULL) \ if (ctx->handle_array == NULL) \
return -1; \ return -1; \
\ \
@ -78,10 +78,10 @@
static CoglHandle \ static CoglHandle \
_cogl_##type_name##_handle_new (Cogl##TypeName *obj) \ _cogl_##type_name##_handle_new (Cogl##TypeName *obj) \
{ \ { \
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); \
\
CoglHandle handle = (CoglHandle) obj; \ CoglHandle handle = (CoglHandle) obj; \
\ \
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); \
\
if (ctx->handle_array == NULL) \ if (ctx->handle_array == NULL) \
ctx->handle_array \ ctx->handle_array \
= g_array_new (FALSE, FALSE, sizeof (CoglHandle)); \ = g_array_new (FALSE, FALSE, sizeof (CoglHandle)); \
@ -94,10 +94,10 @@
static void \ static void \
_cogl_##type_name##_handle_release (CoglHandle handle) \ _cogl_##type_name##_handle_release (CoglHandle handle) \
{ \ { \
_COGL_GET_CONTEXT (ctx, NO_RETVAL); \
\
gint i; \ gint i; \
\ \
_COGL_GET_CONTEXT (ctx, NO_RETVAL); \
\
if ( (i = _cogl_##type_name##_handle_find (handle)) == -1) \ if ( (i = _cogl_##type_name##_handle_find (handle)) == -1) \
return; \ return; \
\ \

View File

@ -325,10 +325,11 @@ cogl_path_round_rectangle (ClutterFixed x,
ClutterFixed radius, ClutterFixed radius,
ClutterAngle arc_step) ClutterAngle arc_step)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
ClutterFixed inner_width = width - (radius << 1); ClutterFixed inner_width = width - (radius << 1);
ClutterFixed inner_height = height - (radius << 1); ClutterFixed inner_height = height - (radius << 1);
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_path_move_to (x, y + radius); cogl_path_move_to (x, y + radius);
cogl_path_arc_rel (radius, 0, cogl_path_arc_rel (radius, 0,
radius, radius, radius, radius,
@ -464,10 +465,10 @@ cogl_path_curve_to (ClutterFixed x1,
ClutterFixed x3, ClutterFixed x3,
ClutterFixed y3) ClutterFixed y3)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglBezCubic cubic; CoglBezCubic cubic;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Prepare cubic curve */ /* Prepare cubic curve */
cubic.p1 = ctx->path_pen; cubic.p1 = ctx->path_pen;
cubic.p2.x = x1; cubic.p2.x = x1;
@ -476,10 +477,10 @@ cogl_path_curve_to (ClutterFixed x1,
cubic.p3.y = y2; cubic.p3.y = y2;
cubic.p4.x = x3; cubic.p4.x = x3;
cubic.p4.y = y3; cubic.p4.y = y3;
/* Run subdivision */ /* Run subdivision */
_cogl_path_bezier3_sub (&cubic); _cogl_path_bezier3_sub (&cubic);
/* Add last point */ /* Add last point */
_cogl_path_add_node (cubic.p4.x, cubic.p4.y); _cogl_path_add_node (cubic.p4.x, cubic.p4.y);
ctx->path_pen = cubic.p4; ctx->path_pen = cubic.p4;

View File

@ -62,11 +62,6 @@ COGL_HANDLE_DEFINE (Fbo, offscreen, fbo_handles);
CoglHandle CoglHandle
cogl_offscreen_new_to_texture (CoglHandle texhandle) cogl_offscreen_new_to_texture (CoglHandle texhandle)
{ {
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
return COGL_INVALID_HANDLE;
CoglTexture *tex; CoglTexture *tex;
CoglFbo *fbo; CoglFbo *fbo;
CoglTexSliceSpan *x_span; CoglTexSliceSpan *x_span;
@ -75,6 +70,11 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
GLuint fbo_gl_handle; GLuint fbo_gl_handle;
GLenum status; GLenum status;
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
return COGL_INVALID_HANDLE;
/* Make texhandle is a valid texture object */ /* Make texhandle is a valid texture object */
if (!cogl_is_texture (texhandle)) if (!cogl_is_texture (texhandle))
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
@ -157,14 +157,14 @@ cogl_offscreen_blit_region (CoglHandle src_buffer,
int dst_w, int dst_w,
int dst_h) int dst_h)
{ {
CoglFbo *src_fbo;
CoglFbo *dst_fbo;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT)) if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
return; return;
CoglFbo *src_fbo;
CoglFbo *dst_fbo;
/* Make sure these are valid fbo handles */ /* Make sure these are valid fbo handles */
if (!cogl_is_offscreen (src_buffer)) if (!cogl_is_offscreen (src_buffer))
return; return;
@ -187,14 +187,14 @@ void
cogl_offscreen_blit (CoglHandle src_buffer, cogl_offscreen_blit (CoglHandle src_buffer,
CoglHandle dst_buffer) CoglHandle dst_buffer)
{ {
CoglFbo *src_fbo;
CoglFbo *dst_fbo;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT)) if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
return; return;
CoglFbo *src_fbo;
CoglFbo *dst_fbo;
/* Make sure these are valid fbo handles */ /* Make sure these are valid fbo handles */
if (!cogl_is_offscreen (src_buffer)) if (!cogl_is_offscreen (src_buffer))
return; return;
@ -216,10 +216,10 @@ cogl_offscreen_blit (CoglHandle src_buffer,
void void
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglFbo *fbo = NULL; CoglFbo *fbo = NULL;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (target == COGL_OFFSCREEN_BUFFER) if (target == COGL_OFFSCREEN_BUFFER)
{ {
/* Make sure it is a valid fbo handle */ /* Make sure it is a valid fbo handle */

View File

@ -85,10 +85,10 @@ void
_cogl_path_add_node (ClutterFixed x, _cogl_path_add_node (ClutterFixed x,
ClutterFixed y) ClutterFixed y)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglFloatVec2 *new_nodes = NULL; CoglFloatVec2 *new_nodes = NULL;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (ctx->path_nodes_size == ctx->path_nodes_cap) if (ctx->path_nodes_size == ctx->path_nodes_cap)
{ {
new_nodes = g_realloc (ctx->path_nodes, new_nodes = g_realloc (ctx->path_nodes,
@ -135,13 +135,13 @@ _cogl_path_stroke_nodes ()
void void
_cogl_path_fill_nodes () _cogl_path_fill_nodes ()
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
guint bounds_x; guint bounds_x;
guint bounds_y; guint bounds_y;
guint bounds_w; guint bounds_w;
guint bounds_h; guint bounds_h;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
GE( glClear (GL_STENCIL_BUFFER_BIT) ); GE( glClear (GL_STENCIL_BUFFER_BIT) );
GE( glEnable (GL_STENCIL_TEST) ); GE( glEnable (GL_STENCIL_TEST) );

View File

@ -1706,8 +1706,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
ClutterFixed tx2, ClutterFixed tx2,
ClutterFixed ty2) ClutterFixed ty2)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglSpanIter iter_x , iter_y; CoglSpanIter iter_x , iter_y;
ClutterFixed tw , th; ClutterFixed tw , th;
ClutterFixed tqx , tqy; ClutterFixed tqx , tqy;
@ -1718,14 +1716,15 @@ _cogl_texture_quad_sw (CoglTexture *tex,
ClutterFixed slice_qx1 , slice_qy1; ClutterFixed slice_qx1 , slice_qy1;
ClutterFixed slice_qx2 , slice_qy2; ClutterFixed slice_qx2 , slice_qy2;
GLuint gl_handle; GLuint gl_handle;
gulong enable_flags = 0;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
#if COGL_DEBUG #if COGL_DEBUG
printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n"); printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n");
#endif #endif
/* Prepare GL state */ /* Prepare GL state */
gulong enable_flags = 0;
enable_flags |= COGL_ENABLE_TEXTURE_2D; enable_flags |= COGL_ENABLE_TEXTURE_2D;
if (ctx->color_alpha < 255 if (ctx->color_alpha < 255
@ -1865,19 +1864,18 @@ _cogl_texture_quad_hw (CoglTexture *tex,
ClutterFixed tx2, ClutterFixed tx2,
ClutterFixed ty2) ClutterFixed ty2)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglTexSliceSpan *x_span; CoglTexSliceSpan *x_span;
CoglTexSliceSpan *y_span; CoglTexSliceSpan *y_span;
GLuint gl_handle; GLuint gl_handle;
gulong enable_flags = 0;
#if COGL_DEBUG #if COGL_DEBUG
printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n"); printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n");
#endif #endif
/* Prepare GL state */ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
gulong enable_flags = 0;
/* Prepare GL state */
enable_flags |= COGL_ENABLE_TEXTURE_2D; enable_flags |= COGL_ENABLE_TEXTURE_2D;
if (ctx->color_alpha < 255 if (ctx->color_alpha < 255

View File

@ -657,13 +657,13 @@ cogl_setup_viewport (guint width,
static void static void
_cogl_features_init () _cogl_features_init ()
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
ClutterFeatureFlags flags = 0; ClutterFeatureFlags flags = 0;
const gchar *gl_extensions; const gchar *gl_extensions;
GLint max_clip_planes = 0; GLint max_clip_planes = 0;
GLint stencil_bits = 0; GLint stencil_bits = 0;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
flags = COGL_FEATURE_TEXTURE_READ_PIXELS; flags = COGL_FEATURE_TEXTURE_READ_PIXELS;
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS); gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);

View File

@ -50,10 +50,10 @@
static gint static gint
_cogl_fbo_handle_find (CoglHandle handle) _cogl_fbo_handle_find (CoglHandle handle)
{ {
_COGL_GET_CONTEXT (ctx, -1);
gint i; gint i;
_COGL_GET_CONTEXT (ctx, -1);
if (ctx->fbo_handles == NULL) if (ctx->fbo_handles == NULL)
return -1; return -1;

View File

@ -42,8 +42,6 @@ _cogl_rectangle (gint x,
guint width, guint width,
guint height) guint height)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* 32-bit integers are not supported as coord types /* 32-bit integers are not supported as coord types
in GLES . Fixed type has got 16 bits left of the in GLES . Fixed type has got 16 bits left of the
point which is equal to short anyway. */ point which is equal to short anyway. */
@ -55,6 +53,8 @@ _cogl_rectangle (gint x,
(GLshort) (x + width), (GLshort) (y + height) (GLshort) (x + width), (GLshort) (y + height)
}; };
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (COGL_ENABLE_VERTEX_ARRAY cogl_enable (COGL_ENABLE_VERTEX_ARRAY
| (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0)); | (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0));
GE ( cogl_wrap_glVertexPointer (2, GL_SHORT, 0, rect_verts ) ); GE ( cogl_wrap_glVertexPointer (2, GL_SHORT, 0, rect_verts ) );
@ -68,8 +68,6 @@ _cogl_rectanglex (ClutterFixed x,
ClutterFixed width, ClutterFixed width,
ClutterFixed height) ClutterFixed height)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
GLfixed rect_verts[8] = { GLfixed rect_verts[8] = {
x, y, x, y,
x + width, y, x + width, y,
@ -77,6 +75,8 @@ _cogl_rectanglex (ClutterFixed x,
x + width, y + height x + width, y + height
}; };
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (COGL_ENABLE_VERTEX_ARRAY cogl_enable (COGL_ENABLE_VERTEX_ARRAY
| (ctx->color_alpha < 255 | (ctx->color_alpha < 255
? COGL_ENABLE_BLEND : 0)); ? COGL_ENABLE_BLEND : 0));
@ -104,10 +104,10 @@ void
_cogl_path_add_node (ClutterFixed x, _cogl_path_add_node (ClutterFixed x,
ClutterFixed y) ClutterFixed y)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglFixedVec2 *new_nodes = NULL; CoglFixedVec2 *new_nodes = NULL;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (ctx->path_nodes_size == ctx->path_nodes_cap) if (ctx->path_nodes_size == ctx->path_nodes_cap)
{ {
new_nodes = g_realloc (ctx->path_nodes, new_nodes = g_realloc (ctx->path_nodes,
@ -160,13 +160,13 @@ static gint compare_ints (gconstpointer a,
void void
_cogl_path_fill_nodes () _cogl_path_fill_nodes ()
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
guint bounds_x; guint bounds_x;
guint bounds_y; guint bounds_y;
guint bounds_w; guint bounds_w;
guint bounds_h; guint bounds_h;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
bounds_x = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.x); bounds_x = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.x);
bounds_y = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.y); bounds_y = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.y);
bounds_w = CLUTTER_FIXED_CEIL (ctx->path_nodes_max.x - ctx->path_nodes_min.x); bounds_w = CLUTTER_FIXED_CEIL (ctx->path_nodes_max.x - ctx->path_nodes_min.x);

View File

@ -1762,8 +1762,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
ClutterFixed tx2, ClutterFixed tx2,
ClutterFixed ty2) ClutterFixed ty2)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
CoglSpanIter iter_x , iter_y; CoglSpanIter iter_x , iter_y;
ClutterFixed tw , th; ClutterFixed tw , th;
ClutterFixed tqx , tqy; ClutterFixed tqx , tqy;
@ -1776,16 +1774,17 @@ _cogl_texture_quad_sw (CoglTexture *tex,
GLfixed tex_coords[8]; GLfixed tex_coords[8];
GLfixed quad_coords[8]; GLfixed quad_coords[8];
GLuint gl_handle; GLuint gl_handle;
gulong enable_flags = (COGL_ENABLE_TEXTURE_2D
| COGL_ENABLE_VERTEX_ARRAY
| COGL_ENABLE_TEXCOORD_ARRAY);
#if COGL_DEBUG #if COGL_DEBUG
printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n"); printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n");
#endif #endif
/* Prepare GL state */ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
gulong enable_flags = (COGL_ENABLE_TEXTURE_2D
| COGL_ENABLE_VERTEX_ARRAY
| COGL_ENABLE_TEXCOORD_ARRAY);
/* Prepare GL state */
if (ctx->color_alpha < 255 if (ctx->color_alpha < 255
|| tex->bitmap.format & COGL_A_BIT) || tex->bitmap.format & COGL_A_BIT)
{ {
@ -1917,23 +1916,22 @@ _cogl_texture_quad_hw (CoglTexture *tex,
ClutterFixed tx2, ClutterFixed tx2,
ClutterFixed ty2) ClutterFixed ty2)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
GLfixed tex_coords[8]; GLfixed tex_coords[8];
GLfixed quad_coords[8]; GLfixed quad_coords[8];
GLuint gl_handle; GLuint gl_handle;
CoglTexSliceSpan *x_span; CoglTexSliceSpan *x_span;
CoglTexSliceSpan *y_span; CoglTexSliceSpan *y_span;
gulong enable_flags = (COGL_ENABLE_TEXTURE_2D
| COGL_ENABLE_VERTEX_ARRAY
| COGL_ENABLE_TEXCOORD_ARRAY);
#if COGL_DEBUG #if COGL_DEBUG
printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n"); printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n");
#endif #endif
/* Prepare GL state */ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
gulong enable_flags = (COGL_ENABLE_TEXTURE_2D
| COGL_ENABLE_VERTEX_ARRAY
| COGL_ENABLE_TEXCOORD_ARRAY);
/* Prepare GL state */
if (ctx->color_alpha < 255 if (ctx->color_alpha < 255
|| tex->bitmap.format & COGL_A_BIT) || tex->bitmap.format & COGL_A_BIT)
{ {