gallium: replace INLINE with inline
[mesa.git] / src / gallium / state_trackers / xa / xa_renderer.c
index 9ba78bed4df06c9a20aaefbfee7c404173e0ed9a..fda07e5b68e7d40f175127f16aa6156f8e245f99 100644 (file)
@@ -45,14 +45,14 @@ void
 renderer_set_constants(struct xa_context *r,
                       int shader_type, const float *params, int param_bytes);
 
-static INLINE boolean
+static inline boolean
 is_affine(float *matrix)
 {
     return floatIsZero(matrix[2]) && floatIsZero(matrix[5])
        && floatsEqual(matrix[8], 1);
 }
 
-static INLINE void
+static inline void
 map_point(float *mat, float x, float y, float *out_x, float *out_y)
 {
     if (!mat) {
@@ -71,7 +71,7 @@ map_point(float *mat, float x, float y, float *out_x, float *out_y)
     }
 }
 
-static INLINE void
+static inline void
 renderer_draw(struct xa_context *r)
 {
     int num_verts = r->buffer_size / (r->attrs_per_vertex * NUM_COMPONENTS);
@@ -79,14 +79,25 @@ renderer_draw(struct xa_context *r)
     if (!r->buffer_size)
        return;
 
+    if (!r->scissor_valid) {
+       r->scissor.minx = 0;
+       r->scissor.miny = 0;
+       r->scissor.maxx = r->dst->tex->width0;
+       r->scissor.maxy = r->dst->tex->height0;
+    }
+
+    r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor);
+
     cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
     util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
                                  num_verts,    /* verts */
                                  r->attrs_per_vertex); /* attribs/vert */
     r->buffer_size = 0;
+
+    xa_scissor_reset(r);
 }
 
-static INLINE void
+static inline void
 renderer_draw_conditional(struct xa_context *r, int next_batch)
 {
     if (r->buffer_size + next_batch >= XA_VB_SIZE ||
@@ -111,6 +122,7 @@ renderer_init_state(struct xa_context *r)
     raster.half_pixel_center = 1;
     raster.bottom_edge_rule = 1;
     raster.depth_clip = 1;
+    raster.scissor = 1;
     cso_set_rasterizer(r->cso, &raster);
 
     /* vertex elements state */
@@ -123,7 +135,7 @@ renderer_init_state(struct xa_context *r)
     }
 }
 
-static INLINE void
+static inline void
 add_vertex_color(struct xa_context *r, float x, float y, float color[4])
 {
     float *vertex = r->buffer + r->buffer_size;
@@ -141,7 +153,7 @@ add_vertex_color(struct xa_context *r, float x, float y, float color[4])
     r->buffer_size += 8;
 }
 
-static INLINE void
+static inline void
 add_vertex_1tex(struct xa_context *r, float x, float y, float s, float t)
 {
     float *vertex = r->buffer + r->buffer_size;
@@ -159,7 +171,7 @@ add_vertex_1tex(struct xa_context *r, float x, float y, float s, float t)
     r->buffer_size += 8;
 }
 
-static INLINE void
+static inline void
 add_vertex_2tex(struct xa_context *r,
                float x, float y, float s0, float t0, float s1, float t1)
 {
@@ -325,12 +337,16 @@ setup_vertex_data_yuv(struct xa_context *r,
  */
 void
 renderer_bind_destination(struct xa_context *r,
-                         struct pipe_surface *surface, int width, int height)
+                         struct pipe_surface *surface)
 {
+    int width = surface->width;
+    int height = surface->height;
 
     struct pipe_framebuffer_state fb;
     struct pipe_viewport_state viewport;
 
+    xa_scissor_reset(r);
+
     /* Framebuffer uses actual surface width/height
      */
     memset(&fb, 0, sizeof fb);
@@ -345,11 +361,9 @@ renderer_bind_destination(struct xa_context *r,
     viewport.scale[0] = width / 2.f;
     viewport.scale[1] = height / 2.f;
     viewport.scale[2] = 1.0;
-    viewport.scale[3] = 1.0;
     viewport.translate[0] = width / 2.f;
     viewport.translate[1] = height / 2.f;
     viewport.translate[2] = 0.0;
-    viewport.translate[3] = 0.0;
 
     /* Constant buffer set up to match viewport dimensions:
      */
@@ -406,6 +420,8 @@ renderer_copy_prepare(struct xa_context *r,
                                       PIPE_BIND_RENDER_TARGET));
     (void)screen;
 
+    renderer_bind_destination(r, dst_surface);
+
     /* set misc state we care about */
     {
        struct pipe_blend_state blend;
@@ -422,6 +438,7 @@ renderer_copy_prepare(struct xa_context *r,
     /* sampler */
     {
        struct pipe_sampler_state sampler;
+        const struct pipe_sampler_state *p_sampler = &sampler;
 
        memset(&sampler, 0, sizeof(sampler));
        sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@@ -431,13 +448,10 @@ renderer_copy_prepare(struct xa_context *r,
        sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
        sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
        sampler.normalized_coords = 1;
-       cso_single_sampler(r->cso, PIPE_SHADER_FRAGMENT, 0, &sampler);
-       cso_single_sampler_done(r->cso, PIPE_SHADER_FRAGMENT);
+        cso_set_samplers(r->cso, PIPE_SHADER_FRAGMENT, 1, &p_sampler);
+        r->num_bound_samplers = 1;
     }
 
-    renderer_bind_destination(r, dst_surface,
-                             dst_surface->width, dst_surface->height);
-
     /* texture/sampler view */
     {
        struct pipe_sampler_view templ;
@@ -514,11 +528,22 @@ renderer_draw_yuv(struct xa_context *r,
                          src_x, src_y, src_w, src_h,
                          dst_x, dst_y, dst_w, dst_h, srf);
 
+   if (!r->scissor_valid) {
+       r->scissor.minx = 0;
+       r->scissor.miny = 0;
+       r->scissor.maxx = r->dst->tex->width0;
+       r->scissor.maxy = r->dst->tex->height0;
+   }
+
+   r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor);
+
    cso_set_vertex_elements(r->cso, num_attribs, r->velems);
    util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
                                 4,     /* verts */
                                 num_attribs);  /* attribs/vert */
    r->buffer_size = 0;
+
+   xa_scissor_reset(r);
 }
 
 void