From f1752ff3ba1828873f7f97f3842eadcc389e87a1 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 25 Oct 2010 13:08:52 +0100 Subject: [PATCH] Avoid mixing declarations and code Mixing declarations and code causes problems for MSVC as it is a C99 feature so we should try to avoid it. --- clutter/cally/cally-actor.c | 54 +++++++++++++----------- clutter/clutter-stage.c | 3 +- clutter/cogl/cogl/cogl-material-opengl.c | 9 +++- clutter/cogl/cogl/cogl-material.c | 4 +- clutter/x11/clutter-event-x11.c | 5 ++- tests/conform/test-cogl-blend-strings.c | 8 ++-- tests/conform/test-cogl-depth-test.c | 8 ++-- tests/conform/test-cogl-materials.c | 8 ++-- tests/conform/test-cogl-premult.c | 8 ++-- 9 files changed, 62 insertions(+), 45 deletions(-) diff --git a/clutter/cally/cally-actor.c b/clutter/cally/cally-actor.c index cc32383a1..a8bc25dd0 100644 --- a/clutter/cally/cally-actor.c +++ b/clutter/cally/cally-actor.c @@ -919,37 +919,43 @@ _get_top_level_origin (ClutterActor *actor, *y = 0; #ifdef HAVE_CLUTTER_GLX - ClutterActor *stage = NULL; - Display *display = NULL; - Window root_window; - Window stage_window; - Window child; - gint return_val = 0; + { + ClutterActor *stage = NULL; + Display *display = NULL; + Window root_window; + Window stage_window; + Window child; + gint return_val = 0; - stage = clutter_actor_get_stage (actor); + stage = clutter_actor_get_stage (actor); - display = clutter_x11_get_default_display (); /* FIXME: what happens if you use another - display with clutter_backend_x11_set_display ?*/ - root_window = clutter_x11_get_root_window (); - stage_window = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); + /* FIXME: what happens if you use another display with + clutter_backend_x11_set_display ?*/ + display = clutter_x11_get_default_display (); + root_window = clutter_x11_get_root_window (); + stage_window = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); - return_val = XTranslateCoordinates (display, stage_window, root_window, - 0, 0, x, y, - &child); + return_val = XTranslateCoordinates (display, stage_window, root_window, + 0, 0, x, y, + &child); - if (!return_val) - g_warning ("[x11] We were not able to get proper absolute position of the stage"); + if (!return_val) + g_warning ("[x11] We were not able to get proper absolute " + "position of the stage"); + } #else - static gboolean yet_warned = FALSE; + { + static gboolean yet_warned = FALSE; - if (!yet_warned) - { - yet_warned = TRUE; - - g_warning ("Using a clutter backend not supported. " - "atk_component_get_extents using ATK_XY_SCREEN could return a wrong screen position"); - } + if (!yet_warned) + { + yet_warned = TRUE; + g_warning ("Using a clutter backend not supported. " + "atk_component_get_extents using ATK_XY_SCREEN " + "could return a wrong screen position"); + } + } #endif } diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index d39ab01e9..ea00775b4 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -3258,12 +3258,13 @@ _clutter_stage_maybe_finish_queue_redraws (ClutterStage *stage) for (l = stolen_list; l; l = l->next) { ClutterStageQueueRedrawEntry *entry = l->data; + ClutterPaintVolume *clip; /* NB: Entries may be invalidated if the actor gets destroyed */ if (G_UNLIKELY (entry->actor == NULL)) continue; - ClutterPaintVolume *clip = entry->has_clip ? &entry->clip : NULL; + clip = entry->has_clip ? &entry->clip : NULL; _clutter_actor_finish_queue_redraw (entry->actor, clip); free_queue_redraw_entry (entry); diff --git a/clutter/cogl/cogl/cogl-material-opengl.c b/clutter/cogl/cogl/cogl-material-opengl.c index 42543aeae..20bb0c197 100644 --- a/clutter/cogl/cogl/cogl-material-opengl.c +++ b/clutter/cogl/cogl/cogl-material-opengl.c @@ -290,12 +290,14 @@ void _cogl_gl_use_program_wrapper (CoglHandle program_handle) { #ifdef COGL_MATERIAL_BACKEND_GLSL - _COGL_GET_CONTEXT (ctx, NO_RETVAL); #ifndef HAVE_COGL_GLES2 + CoglProgram *program = (CoglProgram *)program_handle; GLuint gl_program; + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + if (program_handle != COGL_INVALID_HANDLE) gl_program = program->gl_handle; else @@ -322,9 +324,14 @@ _cogl_gl_use_program_wrapper (CoglHandle program_handle) GE (glUseProgram (0)); ctx->current_gl_program = gl_program; + #else /* HAVE_COGL_GLES2 */ + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + ctx->drv.gles2.settings.user_program = program_handle; ctx->drv.gles2.settings_dirty = TRUE; + #endif /* HAVE_COGL_GLES2 */ #endif diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index 034e973dc..f829e08fe 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -5578,8 +5578,10 @@ dump_material_cb (CoglMaterialNode *node, void *user_data) if (material->differences & COGL_MATERIAL_STATE_BLEND) { - changes = TRUE; const char *blend_enable_name; + + changes = TRUE; + switch (material->blend_enable) { case COGL_MATERIAL_BLEND_ENABLE_AUTOMATIC: diff --git a/clutter/x11/clutter-event-x11.c b/clutter/x11/clutter-event-x11.c index 865d52c61..75e8142c9 100644 --- a/clutter/x11/clutter-event-x11.c +++ b/clutter/x11/clutter-event-x11.c @@ -734,12 +734,13 @@ event_translate (ClutterBackend *backend, case Expose: { - CLUTTER_NOTE (MULTISTAGE, "expose for stage: %p, redrawing", stage); - clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); XExposeEvent *expose = (XExposeEvent *)xevent; ClutterPaintVolume clip; ClutterVertex origin; + CLUTTER_NOTE (MULTISTAGE, "expose for stage: %p, redrawing", stage); + clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); + CLUTTER_NOTE (MULTISTAGE, "expose for stage: %p, " "redrawing (x=%d, y=%d, width=%d, height=%d)", diff --git a/tests/conform/test-cogl-blend-strings.c b/tests/conform/test-cogl-blend-strings.c index ba1be8a7a..0c6428a54 100644 --- a/tests/conform/test-cogl-blend-strings.c +++ b/tests/conform/test-cogl-blend-strings.c @@ -14,10 +14,10 @@ static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; #define BLUE 2 #define ALPHA 3 -#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24); -#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16); -#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8); -#define MASK_ALPHA(COLOR) (COLOR & 0xff); +#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24) +#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16) +#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8) +#define MASK_ALPHA(COLOR) (COLOR & 0xff) #define BLEND_CONSTANT_UNUSED 0xDEADBEEF #define TEX_CONSTANT_UNUSED 0xDEADBEEF diff --git a/tests/conform/test-cogl-depth-test.c b/tests/conform/test-cogl-depth-test.c index 4ea545a8b..52636866d 100644 --- a/tests/conform/test-cogl-depth-test.c +++ b/tests/conform/test-cogl-depth-test.c @@ -19,10 +19,10 @@ static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; #define BLUE 2 #define ALPHA 3 -#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24); -#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16); -#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8); -#define MASK_ALPHA(COLOR) (COLOR & 0xff); +#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24) +#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16) +#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8) +#define MASK_ALPHA(COLOR) (COLOR & 0xff) typedef struct _TestState { diff --git a/tests/conform/test-cogl-materials.c b/tests/conform/test-cogl-materials.c index 7e6b8b015..04238aea6 100644 --- a/tests/conform/test-cogl-materials.c +++ b/tests/conform/test-cogl-materials.c @@ -15,10 +15,10 @@ static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; #define BLUE 2 #define ALPHA 3 -#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24); -#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16); -#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8); -#define MASK_ALPHA(COLOR) (COLOR & 0xff); +#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24) +#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16) +#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8) +#define MASK_ALPHA(COLOR) (COLOR & 0xff) typedef struct _TestState { diff --git a/tests/conform/test-cogl-premult.c b/tests/conform/test-cogl-premult.c index 4ebafb1fc..c0a874d92 100644 --- a/tests/conform/test-cogl-premult.c +++ b/tests/conform/test-cogl-premult.c @@ -14,10 +14,10 @@ static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; #define BLUE 2 #define ALPHA 3 -#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24); -#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16); -#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8); -#define MASK_ALPHA(COLOR) (COLOR & 0xff); +#define MASK_RED(COLOR) ((COLOR & 0xff000000) >> 24) +#define MASK_GREEN(COLOR) ((COLOR & 0xff0000) >> 16) +#define MASK_BLUE(COLOR) ((COLOR & 0xff00) >> 8) +#define MASK_ALPHA(COLOR) (COLOR & 0xff) typedef struct _TestState {