int dstX, int dstY, int width, int height)
{
if (exa->num_bound_samplers == 0 ) { /* solid fill */
- renderer_draw_solid_rect(exa->renderer,
- dstX, dstY, dstX + width, dstY + height,
- exa->solid_color);
+ renderer_begin_solid(exa->renderer);
+ renderer_solid(exa->renderer,
+ dstX, dstY, dstX + width, dstY + height,
+ exa->solid_color);
+ renderer_draw_flush(exa->renderer);
} else {
int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY};
float *src_matrix = NULL;
cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs);
cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs);
+ renderer_begin_solid(exa->renderer);
+
return TRUE;
}
struct exa_pixmap_priv *pixmap,
int x0, int y0, int x1, int y1)
{
- renderer_draw_solid_rect(exa->renderer,
- x0, y0, x1, y1, exa->solid_color);
+ renderer_solid(exa->renderer,
+ x0, y0, x1, y1, exa->solid_color);
}
#include "util/u_rect.h"
#define DEBUG_PRINT 0
-#define DEBUG_SOLID 0
#define ACCEL_ENABLED TRUE
/*
if (!priv)
return;
+ renderer_draw_flush(exa->renderer);
+
xorg_exa_common_done(exa);
}
XORG_FALLBACK("format %s", pf_name(priv->tex->format));
}
-#if DEBUG_SOLID
- fg = 0xffff0000;
-#endif
-
return ACCEL_ENABLED && xorg_solid_bind_state(exa, priv, fg);
}
debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1);
#endif
-#if 0
- if (x0 == 0 && y0 == 0 &&
- x1 == priv->tex->width[0] &&
- y1 == priv->tex->height[0]) {
- exa->ctx->clear(exa->pipe, PIPE_CLEAR_COLOR,
- exa->solid_color, 1., 0);
- } else
-#endif
-
-#if DEBUG_SOLID
- exa->solid_color[0] = 0.f;
- exa->solid_color[1] = 1.f;
- exa->solid_color[2] = 0.f;
- exa->solid_color[3] = 1.f;
- xorg_solid(exa, priv, 0, 0, 1024, 768);
- exa->solid_color[0] = 1.f;
- exa->solid_color[1] = 0.f;
- exa->solid_color[2] = 0.f;
- exa->solid_color[3] = 1.f;
- xorg_solid(exa, priv, 0, 0, 300, 300);
- xorg_solid(exa, priv, 300, 300, 350, 350);
- xorg_solid(exa, priv, 350, 350, 500, 500);
-
- xorg_solid(exa, priv,
- priv->tex->width[0] - 10,
- priv->tex->height[0] - 10,
- priv->tex->width[0],
- priv->tex->height[0]);
-
- exa->solid_color[0] = 0.f;
- exa->solid_color[1] = 0.f;
- exa->solid_color[2] = 1.f;
- exa->solid_color[3] = 1.f;
-
- exa->has_solid_color = FALSE;
- ExaPrepareCopy(pPixmap, pPixmap, 0, 0, GXcopy, 0xffffffff);
- ExaCopy(pPixmap, 0, 0, 50, 50, 500, 500);
-#else
xorg_solid(exa, priv, x0, y0, x1, y1) ;
-#endif
}
static Bool
return buf;
}
+static INLINE void
+renderer_draw(struct xorg_renderer *r)
+{
+ struct pipe_context *pipe = r->pipe;
+ struct pipe_buffer *buf = 0;
+
+ if (!r->num_vertices)
+ return;
+
+ buf = renderer_buffer_create(r);
+
+
+ if (buf) {
+ util_draw_vertex_buffer(pipe, buf, 0,
+ PIPE_PRIM_QUADS,
+ 4, /* verts */
+ 2); /* attribs/vert */
+
+ pipe_buffer_reference(&buf, NULL);
+ }
+}
+
+static INLINE void
+renderer_draw_conditional(struct xorg_renderer *r,
+ int next_batch)
+{
+ if (r->num_vertices + next_batch >= BUF_SIZE ||
+ (next_batch == 0 && r->num_vertices))
+ renderer_draw(r);
+}
+
static void
renderer_init_state(struct xorg_renderer *r)
{
}
}
-void renderer_draw_solid_rect(struct xorg_renderer *r,
- int x0, int y0,
- int x1, int y1,
- float *color)
-{
- struct pipe_context *pipe = r->pipe;
- struct pipe_buffer *buf = 0;
-
- /*
- debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
- x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
- /* 1st vertex */
- add_vertex_color(r, x0, y0, color);
- /* 2nd vertex */
- add_vertex_color(r, x1, y0, color);
- /* 3rd vertex */
- add_vertex_color(r, x1, y1, color);
- /* 4th vertex */
- add_vertex_color(r, x0, y1, color);
-
- buf = renderer_buffer_create(r);
-
-
- if (buf) {
- util_draw_vertex_buffer(pipe, buf, 0,
- PIPE_PRIM_QUADS,
- 4, /* verts */
- 2); /* attribs/vert */
-
- pipe_buffer_reference(&buf, NULL);
- }
-}
-
void renderer_draw_textures(struct xorg_renderer *r,
int *pos,
int width, int height,
}
}
-void renderer_begin_solid(struct xorg_renderer *r,
- float *color)
+void renderer_begin_solid(struct xorg_renderer *r)
{
+ r->num_vertices = 0;
}
void renderer_solid(struct xorg_renderer *r,
int x0, int y0,
- int x1, int y1)
+ int x1, int y1,
+ float *color)
{
+ /*
+ debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
+ x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
+
+ renderer_draw_conditional(r, 4 * 8);
+
+ /* 1st vertex */
+ add_vertex_color(r, x0, y0, color);
+ /* 2nd vertex */
+ add_vertex_color(r, x1, y0, color);
+ /* 3rd vertex */
+ add_vertex_color(r, x1, y1, color);
+ /* 4th vertex */
+ add_vertex_color(r, x0, y1, color);
}
-void renderer_end_solid(struct xorg_renderer *r)
+void renderer_draw_flush(struct xorg_renderer *r)
{
+ renderer_draw_conditional(r, 0);
}
struct exa_pixmap_priv *src_priv, int sx, int sy,
int width, int height);
-void renderer_draw_solid_rect(struct xorg_renderer *r,
- int x0, int y0,
- int x1, int y1,
- float *color);
-
void renderer_draw_textures(struct xorg_renderer *r,
int *pos,
int width, int height,
int dst_x, int dst_y, int dst_w, int dst_h,
struct pipe_texture **textures);
-void renderer_begin_solid(struct xorg_renderer *r,
- float *color);
+void renderer_begin_solid(struct xorg_renderer *r);
void renderer_solid(struct xorg_renderer *r,
int x0, int y0,
- int x1, int y1);
-void renderer_end_solid(struct xorg_renderer *r);
+ int x1, int y1,
+ float *color);
+void renderer_draw_flush(struct xorg_renderer *r);
#endif