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 drm_clip_rect_t
*pbox
;
15 LOCK_HARDWARE(&nv
->base
);
16 if (!dri_drawable
->num_cliprects
) {
17 UNLOCK_HARDWARE(&nv
->base
);
20 pbox
= dri_drawable
->cliprects
;
21 nbox
= dri_drawable
->num_cliprects
;
23 nv
->base
.surface_copy_prep(&nv
->base
, nv
->base
.frontbuffer
, surf
);
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 nv
->base
.surface_copy(&nv
->base
, dx
, dy
, sx
, sy
, w
, h
);
37 FIRE_RING(nv
->base
.nvc
->channel
);
38 UNLOCK_HARDWARE(&nv
->base
);
42 nouveau_copy_sub_buffer(dri_drawable_t
*dri_drawable
, struct pipe_surface
*surf
, int x
, int y
, int w
, int h
)
51 nouveau_copy_buffer(dri_drawable
, surf
, &rect
);
56 nouveau_swap_buffers(dri_drawable_t
*dri_drawable
, struct pipe_surface
*surf
)
59 nouveau_copy_buffer(dri_drawable
, surf
, NULL
);
63 nouveau_flush_frontbuffer(struct pipe_winsys
*pws
, struct pipe_surface
*surf
,
64 void *context_private
)
66 struct nouveau_context_vl
*nv
;
67 dri_drawable_t
*dri_drawable
;
71 assert(context_private
);
74 dri_drawable
= nv
->dri_drawable
;
76 nouveau_copy_buffer(dri_drawable
, surf
, NULL
);
80 nouveau_contended_lock(struct nouveau_context
*nv
)
82 struct nouveau_context_vl
*nv_vl
= (struct nouveau_context_vl
*)nv
;
83 dri_drawable_t
*dri_drawable
= nv_vl
->dri_drawable
;
84 dri_screen_t
*dri_screen
= nv_vl
->dri_context
->dri_screen
;
86 /* If the window moved, may need to set a new cliprect now.
88 * NOTE: This releases and regains the hw lock, so all state
89 * checking must be done *after* this call:
92 DRI_VALIDATE_DRAWABLE_INFO(dri_screen
, dri_drawable
);