2 * Copyright © 1999 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
24 #include <kdrive-config.h>
29 KdShadowFbAlloc(KdScreenInfo
* screen
, Bool rotate
)
33 int width
= rotate
? screen
->height
: screen
->width
;
34 int height
= rotate
? screen
->width
: screen
->height
;
35 int bpp
= screen
->fb
.bitsPerPixel
;
37 /* use fb computation for width */
38 paddedWidth
= ((width
* bpp
+ FB_MASK
) >> FB_SHIFT
) * sizeof(FbBits
);
39 buf
= malloc(paddedWidth
* height
);
42 if (screen
->fb
.shadow
)
43 free(screen
->fb
.frameBuffer
);
44 screen
->fb
.shadow
= TRUE
;
45 screen
->fb
.frameBuffer
= buf
;
46 screen
->fb
.byteStride
= paddedWidth
;
47 screen
->fb
.pixelStride
= paddedWidth
* 8 / bpp
;
52 KdShadowFbFree(KdScreenInfo
* screen
)
54 if (screen
->fb
.shadow
) {
55 free(screen
->fb
.frameBuffer
);
56 screen
->fb
.frameBuffer
= 0;
57 screen
->fb
.shadow
= FALSE
;
62 KdShadowSet(ScreenPtr pScreen
, int randr
, ShadowUpdateProc update
,
63 ShadowWindowProc window
)
65 KdScreenPriv(pScreen
);
66 KdScreenInfo
*screen
= pScreenPriv
->screen
;
68 shadowRemove(pScreen
, pScreen
->GetScreenPixmap(pScreen
));
69 if (screen
->fb
.shadow
) {
70 return shadowAdd(pScreen
, pScreen
->GetScreenPixmap(pScreen
),
71 update
, window
, randr
, 0);
77 KdShadowUnset(ScreenPtr pScreen
)
79 shadowRemove(pScreen
, pScreen
->GetScreenPixmap(pScreen
));