Merge remote branch 'upstream/gallium-0.2' into nouveau-gallium-0.2
[mesa.git] / src / gallium / winsys / g3dvl / nouveau / nouveau_swapbuffers.c
1 #include "pipe/p_context.h"
2 #include "nouveau_context.h"
3 #include "nouveau_local.h"
4 #include "nouveau_screen.h"
5 #include "nouveau_swapbuffers.h"
6
7 void
8 nouveau_copy_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf,
9 const drm_clip_rect_t *rect)
10 {
11 struct nouveau_context *nv = dri_drawable->private;
12 drm_clip_rect_t *pbox;
13 int nbox, i;
14
15 LOCK_HARDWARE(nv);
16 if (!dri_drawable->num_cliprects) {
17 UNLOCK_HARDWARE(nv);
18 return;
19 }
20 pbox = dri_drawable->cliprects;
21 nbox = dri_drawable->num_cliprects;
22
23 nv->surface_copy_prep(nv, nv->frontbuffer, surf);
24 for (i = 0; i < nbox; i++, pbox++) {
25 int sx, sy, dx, dy, w, h;
26
27 sx = pbox->x1 - dri_drawable->x;
28 sy = pbox->y1 - dri_drawable->y;
29 dx = pbox->x1;
30 dy = pbox->y1;
31 w = pbox->x2 - pbox->x1;
32 h = pbox->y2 - pbox->y1;
33
34 nv->surface_copy(nv, dx, dy, sx, sy, w, h);
35 }
36
37 FIRE_RING(nv->nvc->channel);
38 UNLOCK_HARDWARE(nv);
39
40 //if (nv->last_stamp != dri_drawable->last_sarea_stamp)
41 //nv->last_stamp = dri_drawable->last_sarea_stamp;
42 }
43
44 void
45 nouveau_copy_sub_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf, int x, int y, int w, int h)
46 {
47 if (surf) {
48 drm_clip_rect_t rect;
49 rect.x1 = x;
50 rect.y1 = y;
51 rect.x2 = x + w;
52 rect.y2 = y + h;
53
54 nouveau_copy_buffer(dri_drawable, surf, &rect);
55 }
56 }
57
58 void
59 nouveau_swap_buffers(dri_drawable_t *dri_drawable, struct pipe_surface *surf)
60 {
61 if (surf)
62 nouveau_copy_buffer(dri_drawable, surf, NULL);
63 }
64