2 #include <common/nouveau_local.h>
3 #include <common/nouveau_screen.h>
4 #include "nouveau_context_vl.h"
5 #include "nouveau_swapbuffers.h"
8 nouveau_copy_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf,
9 const drm_clip_rect_t *rect)
11 struct nouveau_context_vl *nv = dri_drawable->private;
12 struct pipe_context *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
13 drm_clip_rect_t *pbox;
16 LOCK_HARDWARE(&nv->base);
17 if (!dri_drawable->num_cliprects) {
18 UNLOCK_HARDWARE(&nv->base);
21 pbox = dri_drawable->cliprects;
22 nbox = dri_drawable->num_cliprects;
24 for (i = 0; i < nbox; i++, pbox++) {
25 int sx, sy, dx, dy, w, h;
27 sx = pbox->x1 - dri_drawable->x;
28 sy = pbox->y1 - dri_drawable->y;
31 w = pbox->x2 - pbox->x1;
32 h = pbox->y2 - pbox->y1;
34 pipe->surface_copy(pipe, nv->base.frontbuffer,
35 dx, dy, surf, sx, sy, w, h);
38 FIRE_RING(nv->base.nvc->channel);
39 UNLOCK_HARDWARE(&nv->base);
43 nouveau_copy_sub_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf, int x, int y, int w, int h)
52 nouveau_copy_buffer(dri_drawable, surf, &rect);
57 nouveau_swap_buffers(dri_drawable_t *dri_drawable, struct pipe_surface *surf)
60 nouveau_copy_buffer(dri_drawable, surf, NULL);
64 nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
65 void *context_private)
67 struct nouveau_context_vl *nv;
68 dri_drawable_t *dri_drawable;
72 assert(context_private);
75 dri_drawable = nv->dri_drawable;
77 nouveau_copy_buffer(dri_drawable, surf, NULL);
81 nouveau_contended_lock(struct nouveau_context *nv)
83 struct nouveau_context_vl *nv_vl = (struct nouveau_context_vl*)nv;
84 dri_drawable_t *dri_drawable = nv_vl->dri_drawable;
85 dri_screen_t *dri_screen = nv_vl->dri_context->dri_screen;
87 /* If the window moved, may need to set a new cliprect now.
89 * NOTE: This releases and regains the hw lock, so all state
90 * checking must be done *after* this call:
93 DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable);