st/mesa: use new cso_set_viewport_dims() helper
authorBrian Paul <brianp@vmware.com>
Tue, 16 Feb 2016 17:22:32 +0000 (10:22 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 16 Feb 2016 17:22:32 +0000 (10:22 -0700)
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c

index 0db2514f451c7c91bdaa8ff2a34d1e213350f31f..abea7a0c1ae34dbcbca708c6836fa127ec67d3dc 100644 (file)
@@ -267,19 +267,9 @@ setup_render_state(struct gl_context *ctx,
    }
 
    /* viewport state: viewport matching window dims */
-   {
-      const GLboolean invert = st->state.fb_orientation == Y_0_TOP;
-      const GLfloat width = (GLfloat)st->state.framebuffer.width;
-      const GLfloat height = (GLfloat)st->state.framebuffer.height;
-      struct pipe_viewport_state vp;
-      vp.scale[0] =  0.5f * width;
-      vp.scale[1] = height * (invert ? -0.5f : 0.5f);
-      vp.scale[2] = 0.5f;
-      vp.translate[0] = 0.5f * width;
-      vp.translate[1] = 0.5f * height;
-      vp.translate[2] = 0.5f;
-      cso_set_viewport(cso, &vp);
-   }
+   cso_set_viewport_dims(cso, st->state.framebuffer.width,
+                         st->state.framebuffer.height,
+                         st->state.fb_orientation == Y_0_TOP);
 
    cso_set_vertex_elements(cso, 3, st->util_velems);
 
index 9af56dee2dcfc163928c211686c0d841b1f9a2be..264c8b90fb4e5bbedf19137d82c1ace5048bbd22 100644 (file)
@@ -277,17 +277,8 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
    cso_set_rasterizer(cso, &st->clear.raster);
 
    /* viewport state: viewport matching window dims */
-   {
-      const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
-      struct pipe_viewport_state vp;
-      vp.scale[0] = 0.5f * fb_width;
-      vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
-      vp.scale[2] = 0.5f;
-      vp.translate[0] = 0.5f * fb_width;
-      vp.translate[1] = 0.5f * fb_height;
-      vp.translate[2] = 0.5f;
-      cso_set_viewport(cso, &vp);
-   }
+   cso_set_viewport_dims(st->cso_context, fb_width, fb_height,
+                         st_fb_orientation(fb) == Y_0_TOP);
 
    set_fragment_shader(st);
    cso_set_tessctrl_shader_handle(cso, NULL);
index 192ab0639082e893a140c7127e21b7bcf0fe945f..fc046e4057200183fb86adf9b9ac5114c3079eaa 100644 (file)
@@ -596,18 +596,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
    }
 
    /* viewport state: viewport matching window dims */
-   {
-      const float w = (float) ctx->DrawBuffer->Width;
-      const float h = (float) ctx->DrawBuffer->Height;
-      struct pipe_viewport_state vp;
-      vp.scale[0] =  0.5f * w;
-      vp.scale[1] = -0.5f * h;
-      vp.scale[2] = 0.5f;
-      vp.translate[0] = 0.5f * w;
-      vp.translate[1] = 0.5f * h;
-      vp.translate[2] = 0.5f;
-      cso_set_viewport(cso, &vp);
-   }
+   cso_set_viewport_dims(cso, ctx->DrawBuffer->Width,
+                         ctx->DrawBuffer->Height, TRUE);
 
    cso_set_vertex_elements(cso, 3, st->util_velems);
    cso_set_stream_outputs(cso, 0, NULL, NULL);