- struct bitmap_cache *cache = st->bitmap.cache;
- struct pipe_context *pipe = st->pipe;
- struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surf;
- void *dest;
+ if (st->ctx->DrawBuffer) {
+ struct bitmap_cache *cache = st->bitmap.cache;
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_surface *surf;
+ void *dest;
+
+ assert(cache->xmin <= cache->xmax);
+ /*
+ printf("flush size %d x %d at %d, %d\n",
+ cache->xmax - cache->xmin,
+ cache->ymax - cache->ymin,
+ cache->xpos, cache->ypos);
+ */
+
+ /* update the texture map image */
+ surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0);
+ dest = pipe_surface_map(surf);
+ memcpy(dest, cache->buffer, sizeof(cache->buffer));
+ pipe_surface_unmap(surf);
+ pipe_surface_reference(&surf, NULL);
+
+ /* flush in case the previous texture contents haven't been
+ * used yet. XXX this is not ideal! Revisit.
+ */
+ st->pipe->flush( st->pipe, 0x0, NULL );