nouveau: gallium directory structure changed again..
[mesa.git] / src / gallium / winsys / drm / nouveau / nouveau_swapbuffers.c
1 #include "main/glheader.h"
2 #include "glapi/glthread.h"
3 #include <GL/internal/glcore.h>
4
5 #include "pipe/p_context.h"
6 #include "state_tracker/st_public.h"
7 #include "state_tracker/st_context.h"
8 #include "state_tracker/st_cb_fbo.h"
9
10 #include "nouveau_context.h"
11 #include "nouveau_local.h"
12 #include "nouveau_screen.h"
13 #include "nouveau_swapbuffers.h"
14
15 void
16 nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
17 const drm_clip_rect_t *rect)
18 {
19 struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate;
20 drm_clip_rect_t *pbox;
21 int nbox, i;
22
23 LOCK_HARDWARE(nv);
24 if (!dPriv->numClipRects) {
25 UNLOCK_HARDWARE(nv);
26 return;
27 }
28 pbox = dPriv->pClipRects;
29 nbox = dPriv->numClipRects;
30
31 nv->surface_copy_prep(nv, nv->frontbuffer, surf);
32 for (i = 0; i < nbox; i++, pbox++) {
33 int sx, sy, dx, dy, w, h;
34
35 sx = pbox->x1 - dPriv->x;
36 sy = pbox->y1 - dPriv->y;
37 dx = pbox->x1;
38 dy = pbox->y1;
39 w = pbox->x2 - pbox->x1;
40 h = pbox->y2 - pbox->y1;
41
42 nv->surface_copy(nv, dx, dy, sx, sy, w, h);
43 }
44
45 FIRE_RING(nv->nvc->channel);
46 UNLOCK_HARDWARE(nv);
47
48 if (nv->last_stamp != dPriv->lastStamp) {
49 struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
50 st_resize_framebuffer(nvfb->stfb, dPriv->w, dPriv->h);
51 nv->last_stamp = dPriv->lastStamp;
52 }
53 }
54
55 void
56 nouveau_copy_sub_buffer(__DRIdrawablePrivate *dPriv, int x, int y, int w, int h)
57 {
58 struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
59 struct pipe_surface *surf;
60
61 surf = st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT);
62 if (surf) {
63 drm_clip_rect_t rect;
64 rect.x1 = x;
65 rect.y1 = y;
66 rect.x2 = x + w;
67 rect.y2 = y + h;
68
69 st_notify_swapbuffers(nvfb->stfb);
70 nouveau_copy_buffer(dPriv, surf, &rect);
71 }
72 }
73
74 void
75 nouveau_swap_buffers(__DRIdrawablePrivate *dPriv)
76 {
77 struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
78 struct pipe_surface *surf;
79
80 surf = st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT);
81 if (surf) {
82 st_notify_swapbuffers(nvfb->stfb);
83 nouveau_copy_buffer(dPriv, surf, NULL);
84 }
85 }
86