Eliminate struct pipe_region.
[mesa.git] / src / mesa / pipe / softpipe / sp_clear.c
index e83bc053ef747a35915dfaed5df50c7d4ab8ba8c..496b38fd5f12b82ef5449823ebd0945286a80da5 100644 (file)
  */
 
 
+#include "pipe/p_defines.h"
 #include "sp_clear.h"
 #include "sp_context.h"
 #include "sp_surface.h"
-#include "colormac.h"
+#include "sp_state.h"
+#include "sp_tile_cache.h"
 
 
+/**
+ * Clear the given surface to the specified value.
+ * No masking, no scissor (clear entire buffer).
+ */
 void
-softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
-               GLboolean stencil, GLboolean accum)
+softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
+               unsigned clearValue)
 {
-   const struct softpipe_context *softpipe = softpipe_context(pipe);
-   const GLint x = softpipe->scissor.minx;
-   const GLint y = softpipe->scissor.miny;
-   const GLint w = softpipe->scissor.maxx - x;
-   const GLint h = softpipe->scissor.maxy - y;
-
-   if (color) {
-      GLuint i;
-      GLubyte clr[4];
+   struct softpipe_context *softpipe = softpipe_context(pipe);
 
-      UNCLAMPED_FLOAT_TO_UBYTE(clr[0], softpipe->clear_color.color[0]);
-      UNCLAMPED_FLOAT_TO_UBYTE(clr[1], softpipe->clear_color.color[1]);
-      UNCLAMPED_FLOAT_TO_UBYTE(clr[2], softpipe->clear_color.color[2]);
-      UNCLAMPED_FLOAT_TO_UBYTE(clr[3], softpipe->clear_color.color[3]);
+   softpipe_update_derived(softpipe); /* not needed?? */
 
-      for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
-         struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
-         struct softpipe_surface *sps = softpipe_surface(ps);
-         GLint j;
-         for (j = 0; j < h; j++) {
-            sps->write_mono_row_ub(sps, w, x, y + j, clr);
-         }
-      }
+   if (ps == sp_tile_cache_get_surface(softpipe, softpipe->zbuf_cache)) {
+      float clear[4];
+      clear[0] = 1.0; /* XXX hack */
+      sp_tile_cache_clear(softpipe->zbuf_cache, clear);
    }
-
-   if (depth) {
+   else if (ps == sp_tile_cache_get_surface(softpipe, softpipe->cbuf_cache[0])) {
+      float clear[4];
+      clear[0] = 0.2f; /* XXX hack */
+      clear[1] = 0.2f; /* XXX hack */
+      clear[2] = 0.2f; /* XXX hack */
+      clear[3] = 0.2f; /* XXX hack */
+      sp_tile_cache_clear(softpipe->cbuf_cache[0], clear);
    }
 
+   pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+
+
+#if 0
+   sp_clear_tile_cache(ps, clearValue);
+#endif
 }