wined3d: Use BOOL type where appropriate

Frédéric Delanoy frederic.delanoy at gmail.com
Thu Dec 5 16:14:54 CST 2013


Note: in surface.c, used "?1:0" construct to avoid implicit BOOL arithmetic
---
 dlls/wined3d/arb_program_shader.c | 19 +++++++++----------
 dlls/wined3d/context.c            | 20 ++++++++++----------
 dlls/wined3d/device.c             |  2 +-
 dlls/wined3d/gl_compat.c          |  4 ++--
 dlls/wined3d/shader.c             | 20 ++++++++++----------
 dlls/wined3d/stateblock.c         | 22 +++++++++++-----------
 dlls/wined3d/surface.c            |  8 ++++----
 dlls/wined3d/utils.c              |  8 ++++----
 8 files changed, 51 insertions(+), 52 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 0821fc2..15a5028 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -1506,17 +1506,16 @@ static void shader_arb_get_src_param(const struct wined3d_shader_instruction *in
         const struct wined3d_shader_src_param *src, unsigned int tmpreg, char *outregstr)
 {
     /* Generate a line that does the input modifier computation and return the input register to use */
-    BOOL is_color = FALSE;
+    BOOL is_color = FALSE, insert_line;
     char regstr[256];
     char swzstr[20];
-    int insert_line;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
     struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data;
     const char *one = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_ONE);
     const char *two = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_TWO);
 
     /* Assume a new line will be added */
-    insert_line = 1;
+    insert_line = TRUE;
 
     /* Get register name */
     shader_arb_get_register_name(ins, &src->reg, regstr, &is_color);
@@ -1526,11 +1525,11 @@ static void shader_arb_get_src_param(const struct wined3d_shader_instruction *in
     {
     case WINED3DSPSM_NONE:
         sprintf(outregstr, "%s%s", regstr, swzstr);
-        insert_line = 0;
+        insert_line = FALSE;
         break;
     case WINED3DSPSM_NEG:
         sprintf(outregstr, "-%s%s", regstr, swzstr);
-        insert_line = 0;
+        insert_line = FALSE;
         break;
     case WINED3DSPSM_BIAS:
         shader_addline(buffer, "ADD T%c, %s, -coefdiv.x;\n", 'A' + tmpreg, regstr);
@@ -1564,7 +1563,7 @@ static void shader_arb_get_src_param(const struct wined3d_shader_instruction *in
     case WINED3DSPSM_ABS:
         if(ctx->target_version >= NV2) {
             sprintf(outregstr, "|%s%s|", regstr, swzstr);
-            insert_line = 0;
+            insert_line = FALSE;
         } else {
             shader_addline(buffer, "ABS T%c, %s;\n", 'A' + tmpreg, regstr);
         }
@@ -1576,11 +1575,11 @@ static void shader_arb_get_src_param(const struct wined3d_shader_instruction *in
             shader_addline(buffer, "ABS T%c, %s;\n", 'A' + tmpreg, regstr);
             sprintf(outregstr, "-T%c%s", 'A' + tmpreg, swzstr);
         }
-        insert_line = 0;
+        insert_line = FALSE;
         break;
     default:
         sprintf(outregstr, "%s%s", regstr, swzstr);
-        insert_line = 0;
+        insert_line = FALSE;
     }
 
     /* Return modified or original register, with swizzle */
@@ -4543,9 +4542,9 @@ static void find_arb_ps_compile_args(const struct wined3d_state *state,
     if (!d3d_info->vs_clipping && use_vs(state)
             && state->render_states[WINED3D_RS_CLIPPING]
             && state->render_states[WINED3D_RS_CLIPPLANEENABLE])
-        args->clip = 1;
+        args->clip = TRUE;
     else
-        args->clip = 0;
+        args->clip = FALSE;
 
     /* Skip if unused or local, or supported natively */
     int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 129926a..004a5c9 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -779,7 +779,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
 
         WARN("Failed to make GL context %p current on device context %p, last error %#x.\n",
                 ctx->glCtx, ctx->hdc, GetLastError());
-        ctx->valid = 0;
+        ctx->valid = FALSE;
         WARN("Trying fallback to the backup window.\n");
 
         /* FIXME: If the context is destroyed it's no longer associated with
@@ -815,7 +815,7 @@ static BOOL context_set_gl_context(struct wined3d_context *ctx)
             return FALSE;
         }
 
-        ctx->valid = 1;
+        ctx->valid = TRUE;
     }
     return TRUE;
 }
@@ -848,7 +848,7 @@ static void context_update_window(struct wined3d_context *context)
     if (context->valid)
         wined3d_release_dc(context->win_handle, context->hdc);
     else
-        context->valid = 1;
+        context->valid = TRUE;
 
     context->win_handle = context->swapchain->win_handle;
 
@@ -870,7 +870,7 @@ static void context_update_window(struct wined3d_context *context)
     return;
 
 err:
-    context->valid = 0;
+    context->valid = FALSE;
 }
 
 static void context_destroy_gl_resources(struct wined3d_context *context)
@@ -1018,7 +1018,7 @@ BOOL context_set_current(struct wined3d_context *ctx)
         }
         else
         {
-            old->current = 0;
+            old->current = FALSE;
         }
     }
 
@@ -1033,7 +1033,7 @@ BOOL context_set_current(struct wined3d_context *ctx)
         TRACE("Switching to D3D context %p, GL context %p, device context %p.\n", ctx, ctx->glCtx, ctx->hdc);
         if (!context_set_gl_context(ctx))
             return FALSE;
-        ctx->current = 1;
+        ctx->current = TRUE;
     }
     else if(wglGetCurrentContext())
     {
@@ -1477,7 +1477,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
 
     ret->render_offscreen = surface_is_offscreen(target);
     ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
-    ret->valid = 1;
+    ret->valid = TRUE;
 
     ret->glCtx = ctx;
     ret->win_handle = swapchain->win_handle;
@@ -1673,7 +1673,7 @@ void context_destroy(struct wined3d_device *device, struct wined3d_context *cont
         struct wined3d_gl_info *gl_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*gl_info));
         *gl_info = *context->gl_info;
         context->gl_info = gl_info;
-        context->destroyed = 1;
+        context->destroyed = TRUE;
         destroy = FALSE;
     }
 
@@ -2619,7 +2619,7 @@ void context_stream_info_from_declaration(struct wined3d_context *context,
 
     stream_info->use_map = 0;
     stream_info->swizzle_map = 0;
-    stream_info->all_vbo = 1;
+    stream_info->all_vbo = TRUE;
     stream_info->position_transformed = declaration->position_transformed;
 
     /* Translate the declaration into strided data. */
@@ -2739,7 +2739,7 @@ void context_stream_info_from_declaration(struct wined3d_context *context,
         }
 
         if (!buffer->buffer_object)
-            stream_info->all_vbo = 0;
+            stream_info->all_vbo = FALSE;
 
         if (buffer->query)
             context->buffer_queries[context->num_buffer_queries++] = buffer->query;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index f14aa57..a2f5e34 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -915,7 +915,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
 
     create_dummy_textures(device, context);
 
-    device->contexts[0]->last_was_rhw = 0;
+    device->contexts[0]->last_was_rhw = FALSE;
 
     switch (wined3d_settings.offscreen_rendering_mode)
     {
diff --git a/dlls/wined3d/gl_compat.c b/dlls/wined3d/gl_compat.c
index 4dd9062..22d902d 100644
--- a/dlls/wined3d/gl_compat.c
+++ b/dlls/wined3d/gl_compat.c
@@ -152,7 +152,7 @@ static void (WINE_GLAPI *old_fogcoord_glEnable) (GLenum cap) = NULL;
 static void WINE_GLAPI wine_glEnable(GLenum cap) {
     if(cap == GL_FOG) {
         struct wined3d_context *ctx = context_get_current();
-        ctx->fog_enabled = 1;
+        ctx->fog_enabled = TRUE;
         if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
     }
     old_fogcoord_glEnable(cap);
@@ -162,7 +162,7 @@ static void (WINE_GLAPI *old_fogcoord_glDisable) (GLenum cap) = NULL;
 static void WINE_GLAPI wine_glDisable(GLenum cap) {
     if(cap == GL_FOG) {
         struct wined3d_context *ctx = context_get_current();
-        ctx->fog_enabled = 0;
+        ctx->fog_enabled = FALSE;
         if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
     }
     old_fogcoord_glDisable(cap);
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 3a1fc12..f71f452 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -426,7 +426,7 @@ static void shader_record_register_usage(struct wined3d_shader *shader, struct w
                 if (!reg->idx[0].offset)
                     reg_maps->vpos = 1;
                 else if (reg->idx[0].offset == 1)
-                    reg_maps->usesfacing = 1;
+                    reg_maps->usesfacing = TRUE;
             }
             break;
 
@@ -794,15 +794,15 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
                 }
             }
 
-            if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = 1;
-            else if (ins.handler_idx == WINED3DSIH_DSY) reg_maps->usesdsy = 1;
-            else if (ins.handler_idx == WINED3DSIH_DSX) reg_maps->usesdsx = 1;
-            else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = 1;
-            else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = 1;
-            else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1;
-            else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1;
-            else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1;
-            else if (ins.handler_idx == WINED3DSIH_POW) reg_maps->usespow = 1;
+            if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_DSY) reg_maps->usesdsy = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_DSX) reg_maps->usesdsx = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = TRUE;
+            else if (ins.handler_idx == WINED3DSIH_POW) reg_maps->usespow = TRUE;
             else if (ins.handler_idx == WINED3DSIH_LOOP
                     || ins.handler_idx == WINED3DSIH_REP)
             {
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index f991362..9f85fed 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -236,14 +236,14 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states,
     unsigned int i;
 
     /* Single values */
-    states->primitive_type = 1;
-    states->indices = 1;
-    states->material = 1;
-    states->viewport = 1;
-    states->vertexDecl = 1;
-    states->pixelShader = 1;
-    states->vertexShader = 1;
-    states->scissorRect = 1;
+    states->primitive_type = TRUE;
+    states->indices = TRUE;
+    states->material = TRUE;
+    states->viewport = TRUE;
+    states->vertexDecl = TRUE;
+    states->pixelShader = TRUE;
+    states->vertexShader = TRUE;
+    states->scissorRect = TRUE;
 
     /* Fixed size arrays */
     states->streamSource = 0xffff;
@@ -270,7 +270,7 @@ static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states
     WORD sampler_mask = 0;
     unsigned int i;
 
-    states->pixelShader = 1;
+    states->pixelShader = TRUE;
 
     for (i = 0; i < sizeof(pixel_states_render) / sizeof(*pixel_states_render); ++i)
     {
@@ -296,8 +296,8 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
     WORD sampler_mask = 0;
     unsigned int i;
 
-    states->vertexDecl = 1;
-    states->vertexShader = 1;
+    states->vertexDecl = TRUE;
+    states->vertexShader = TRUE;
 
     for (i = 0; i < sizeof(vertex_states_render) / sizeof(*vertex_states_render); ++i)
     {
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 5b28e9b..40cf74b 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -389,7 +389,7 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
     const struct wined3d_format *format = surface->resource.format;
     SYSTEM_INFO sysInfo;
     BITMAPINFO *b_info;
-    int extraline = 0;
+    BOOL extraline = FALSE;
     DWORD *masks;
 
     TRACE("surface %p.\n", surface);
@@ -430,15 +430,15 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
     GetSystemInfo(&sysInfo);
     if( ((surface->resource.size + 3) % sysInfo.dwPageSize) < 4)
     {
-        extraline = 1;
+        extraline = TRUE;
         TRACE("Adding an extra line to the DIB section.\n");
     }
 
     b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
     /* TODO: Is there a nicer way to force a specific alignment? (8 byte for ddraw) */
     b_info->bmiHeader.biWidth = wined3d_surface_get_pitch(surface) / format->byte_count;
-    b_info->bmiHeader.biHeight = 0 - surface->resource.height - extraline;
-    b_info->bmiHeader.biSizeImage = (surface->resource.height + extraline)
+    b_info->bmiHeader.biHeight = 0 - surface->resource.height - (extraline ? 1 : 0);
+    b_info->bmiHeader.biSizeImage = (surface->resource.height + (extraline ? 1 : 0))
             * wined3d_surface_get_pitch(surface);
     b_info->bmiHeader.biPlanes = 1;
     b_info->bmiHeader.biBitCount = format->byte_count * 8;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index c37b677..0ea7110 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3628,7 +3628,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
     {
         memset(settings, 0, sizeof(*settings));
 
-        settings->transformed = 1;
+        settings->transformed = TRUE;
         settings->point_size = state->gl_primitive_type == GL_POINTS;
         if (!state->render_states[WINED3D_RS_FOGENABLE])
             settings->fog_mode = WINED3D_FFP_VS_FOG_OFF;
@@ -3648,7 +3648,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
         return;
     }
 
-    settings->transformed = 0;
+    settings->transformed = FALSE;
     settings->clipping = state->render_states[WINED3D_RS_CLIPPING]
             && state->render_states[WINED3D_RS_CLIPPLANEENABLE];
     settings->normal = !!(si->use_map & (1 << WINED3D_FFP_NORMAL));
@@ -3690,7 +3690,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
                     & WINED3D_FFP_LIGHT_TYPE_MASK) << WINED3D_FFP_LIGHT_TYPE_SHIFT(i);
     }
 
-    settings->ortho_fog = 0;
+    settings->ortho_fog = FALSE;
     if (!state->render_states[WINED3D_RS_FOGENABLE])
         settings->fog_mode = WINED3D_FFP_VS_FOG_OFF;
     else if (state->render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE)
@@ -3701,7 +3701,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
                 && state->transforms[WINED3D_TS_PROJECTION].u.m[1][3] == 0.0f
                 && state->transforms[WINED3D_TS_PROJECTION].u.m[2][3] == 0.0f
                 && state->transforms[WINED3D_TS_PROJECTION].u.m[3][3] == 1.0f)
-            settings->ortho_fog = 1;
+            settings->ortho_fog = TRUE;
     }
     else if (state->render_states[WINED3D_RS_FOGVERTEXMODE] == WINED3D_FOG_NONE)
         settings->fog_mode = WINED3D_FFP_VS_FOG_FOGCOORD;
-- 
1.8.5




More information about the wine-patches mailing list