gallium: Remove do_flip argument from surface_copy
[mesa.git] / src / gallium / winsys / drm / nouveau / dri / 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 "../common/nouveau_local.h"
11 #include "nouveau_context_dri.h"
12 #include "nouveau_screen_dri.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_dri *nv = dPriv->driContextPriv->driverPrivate;
20 struct pipe_context *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
21 drm_clip_rect_t *pbox;
22 int nbox, i;
23
24 LOCK_HARDWARE(&nv->base);
25 if (!dPriv->numClipRects) {
26 UNLOCK_HARDWARE(&nv->base);
27 return;
28 }
29 pbox = dPriv->pClipRects;
30 nbox = dPriv->numClipRects;
31
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 pipe->surface_copy(pipe, nv->base.frontbuffer,
43 dx, dy, surf, sx, sy, w, h);
44 }
45
46 FIRE_RING(nv->base.nvc->channel);
47 UNLOCK_HARDWARE(&nv->base);
48
49 if (nv->last_stamp != dPriv->lastStamp) {
50 struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
51 st_resize_framebuffer(nvfb->stfb, dPriv->w, dPriv->h);
52 nv->last_stamp = dPriv->lastStamp;
53 }
54 }
55
56 void
57 nouveau_copy_sub_buffer(__DRIdrawablePrivate *dPriv, int x, int y, int w, int h)
58 {
59 struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
60 struct pipe_surface *surf;
61
62 st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT, &surf);
63 if (surf) {
64 drm_clip_rect_t rect;
65 rect.x1 = x;
66 rect.y1 = y;
67 rect.x2 = x + w;
68 rect.y2 = y + h;
69
70 st_notify_swapbuffers(nvfb->stfb);
71 nouveau_copy_buffer(dPriv, surf, &rect);
72 }
73 }
74
75 void
76 nouveau_swap_buffers(__DRIdrawablePrivate *dPriv)
77 {
78 struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
79 struct pipe_surface *surf;
80
81 st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT, &surf);
82 if (surf) {
83 st_notify_swapbuffers(nvfb->stfb);
84 nouveau_copy_buffer(dPriv, surf, NULL);
85 }
86 }
87
88 void
89 nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
90 void *context_private)
91 {
92 struct nouveau_context_dri *nv = context_private;
93 __DRIdrawablePrivate *dPriv = nv->dri_drawable;
94
95 nouveau_copy_buffer(dPriv, surf, NULL);
96 }
97
98 void
99 nouveau_contended_lock(struct nouveau_context *nv)
100 {
101 struct nouveau_context_dri *nv_sub = (struct nouveau_context_dri*)nv;
102 __DRIdrawablePrivate *dPriv = nv_sub->dri_drawable;
103 __DRIscreenPrivate *sPriv = nv_sub->dri_screen;
104
105 /* If the window moved, may need to set a new cliprect now.
106 *
107 * NOTE: This releases and regains the hw lock, so all state
108 * checking must be done *after* this call:
109 */
110 if (dPriv)
111 DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
112 }
113