1 /* Copyright (c) 1993, 1997, Oracle and/or its affiliates. All rights reserved.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
25 ** mbufset.c - Routines to manipulate multibuffer set objects.
31 #endif /* SERVER_DGA */
32 #include "dga_incls.h"
34 #include "mbufsetstr.h"
36 static void dgai_mbufset_destroy (DgaMbufSetPtr pMbs
);
38 extern int dga_pixlist_add(Dga_token token
, Display
*dpy
, Pixmap pix
);
41 ** Create a client-side multibuffer set object based on information
42 ** in the shinfo of a window. The window must be locked prior to calling.
46 dgai_mbufset_create (_Dga_window dgawin
)
50 DgaMbufSetShinfoPtr pMbsInfo
;
52 unsigned long bufViewableFlags
, bufMask
;
57 infop
= (WXINFO
*) dgawin
->w_info
;
58 pMbsInfo
= &infop
->w_mbsInfo
;
59 token
= (Dga_token
) pMbsInfo
->nmbufShpxToken
;
60 pShinfoId
= &(pMbsInfo
->nmbufIds
[0]);
62 /* allocate mbufset client structure */
63 if (!(pMbs
= (DgaMbufSetPtr
) malloc(sizeof(DgaMbufSet
)))) {
67 numBufs
= infop
->wx_dbuf
.number_buffers
;
68 pMbs
->numBufs
= numBufs
;
70 for (i
= 0; i
< numBufs
; i
++) {
71 pMbs
->pNbPixmaps
[i
] = NULL
;
74 bufViewableFlags
= pMbsInfo
->bufViewableFlags
;
76 for (i
= 0; i
< numBufs
; i
++, pShinfoId
++) {
77 if (!(bufViewableFlags
& bufMask
)) {
78 if (!dga_pixlist_add(token
, dgawin
->w_dpy
, (Pixmap
)*pShinfoId
) ||
79 !(dgapix
= dga_pix_grab(token
, (Pixmap
)*pShinfoId
))) {
82 pMbs
->pNbPixmaps
[i
] = dgapix
;
83 pMbs
->pNbShinfo
[i
] = (SHARED_PIXMAP_INFO
*)dgapix
->p_infop
;
85 pMbs
->pNbShinfo
[i
] = NULL
;
90 pMbs
->cacheSeqs
[i
] = 0;
91 pMbs
->devInfoSeqs
[i
] = 0;
92 pMbs
->prevLocked
[i
] = 0;
93 bufMask
= bufMask
<< 1;
101 dgai_mbufset_destroy(pMbs
);
107 dgai_mbufset_incref (DgaMbufSetPtr pMbs
)
114 dgai_mbufset_destroy (DgaMbufSetPtr pMbs
)
118 for (i
= 0; i
< pMbs
->numBufs
; i
++) {
119 if (pMbs
->pNbPixmaps
[i
]) {
120 dga_pix_ungrab(pMbs
->pNbPixmaps
[i
]);
127 dgai_mbufset_decref (DgaMbufSetPtr pMbs
)
129 if ((int)(--(pMbs
->refcnt
)) <= 0) {
130 dgai_mbufset_destroy(pMbs
);