1706f2543Smrg/*
2706f2543Smrg *
3706f2543Smrg * Copyright © 2000 Keith Packard
4706f2543Smrg *
5706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its
6706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that
7706f2543Smrg * the above copyright notice appear in all copies and that both that
8706f2543Smrg * copyright notice and this permission notice appear in supporting
9706f2543Smrg * documentation, and that the name of Keith Packard not be used in
10706f2543Smrg * advertising or publicity pertaining to distribution of the software without
11706f2543Smrg * specific, written prior permission.  Keith Packard makes no
12706f2543Smrg * representations about the suitability of this software for any purpose.  It
13706f2543Smrg * is provided "as is" without express or implied warranty.
14706f2543Smrg *
15706f2543Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17706f2543Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21706f2543Smrg * PERFORMANCE OF THIS SOFTWARE.
22706f2543Smrg */
23706f2543Smrg
24706f2543Smrg#ifndef _SHADOW_H_
25706f2543Smrg#define _SHADOW_H_
26706f2543Smrg
27706f2543Smrg#include "scrnintstr.h"
28706f2543Smrg
29706f2543Smrg#include "picturestr.h"
30706f2543Smrg
31706f2543Smrg#include "damage.h"
32706f2543Smrg#include "damagestr.h"
33706f2543Smrgtypedef struct _shadowBuf   *shadowBufPtr;
34706f2543Smrg
35706f2543Smrgtypedef void (*ShadowUpdateProc) (ScreenPtr pScreen,
36706f2543Smrg				  shadowBufPtr pBuf);
37706f2543Smrg
38706f2543Smrg#define SHADOW_WINDOW_RELOCATE 1
39706f2543Smrg#define SHADOW_WINDOW_READ 2
40706f2543Smrg#define SHADOW_WINDOW_WRITE 4
41706f2543Smrg
42706f2543Smrgtypedef void *(*ShadowWindowProc) (ScreenPtr	pScreen,
43706f2543Smrg				   CARD32	row,
44706f2543Smrg				   CARD32	offset,
45706f2543Smrg				   int		mode,
46706f2543Smrg				   CARD32	*size,
47706f2543Smrg				   void		*closure);
48706f2543Smrg
49706f2543Smrg/* BC hack: do not move the damage member.  see shadow.c for explanation. */
50706f2543Smrgtypedef struct _shadowBuf {
51706f2543Smrg    DamagePtr           pDamage;
52706f2543Smrg    ShadowUpdateProc	update;
53706f2543Smrg    ShadowWindowProc	window;
54706f2543Smrg    RegionRec		damage;
55706f2543Smrg    PixmapPtr		pPixmap;
56706f2543Smrg    void		*closure;
57706f2543Smrg    int			randr;
58706f2543Smrg
59706f2543Smrg    /* screen wrappers */
60706f2543Smrg    GetImageProcPtr     GetImage;
61706f2543Smrg    CloseScreenProcPtr  CloseScreen;
62706f2543Smrg} shadowBufRec;
63706f2543Smrg
64706f2543Smrg/* Match defines from randr extension */
65706f2543Smrg#define SHADOW_ROTATE_0	    1
66706f2543Smrg#define SHADOW_ROTATE_90    2
67706f2543Smrg#define SHADOW_ROTATE_180   4
68706f2543Smrg#define SHADOW_ROTATE_270   8
69706f2543Smrg#define SHADOW_ROTATE_ALL   (SHADOW_ROTATE_0|SHADOW_ROTATE_90|\
70706f2543Smrg			     SHADOW_ROTATE_180|SHADOW_ROTATE_270)
71706f2543Smrg#define SHADOW_REFLECT_X    16
72706f2543Smrg#define SHADOW_REFLECT_Y    32
73706f2543Smrg#define SHADOW_REFLECT_ALL  (SHADOW_REFLECT_X|SHADOW_REFLECT_Y)
74706f2543Smrg
75706f2543Smrgextern _X_EXPORT DevPrivateKey shadowScrPrivateKey;
76706f2543Smrg
77706f2543Smrg#define shadowGetBuf(pScr) ((shadowBufPtr) \
78706f2543Smrg    dixLookupPrivate(&(pScr)->devPrivates, shadowScrPrivateKey))
79706f2543Smrg#define shadowBuf(pScr)            shadowBufPtr pBuf = shadowGetBuf(pScr)
80706f2543Smrg#define shadowDamage(pBuf)  DamageRegion(pBuf->pDamage)
81706f2543Smrg
82706f2543Smrgextern _X_EXPORT Bool
83706f2543SmrgshadowSetup (ScreenPtr pScreen);
84706f2543Smrg
85706f2543Smrgextern _X_EXPORT Bool
86706f2543SmrgshadowAdd (ScreenPtr	    pScreen,
87706f2543Smrg	   PixmapPtr	    pPixmap,
88706f2543Smrg	   ShadowUpdateProc update,
89706f2543Smrg	   ShadowWindowProc window,
90706f2543Smrg	   int		    randr,
91706f2543Smrg	   void		    *closure);
92706f2543Smrg
93706f2543Smrgextern _X_EXPORT void
94706f2543SmrgshadowRemove (ScreenPtr pScreen, PixmapPtr pPixmap);
95706f2543Smrg
96706f2543Smrgextern _X_EXPORT Bool
97706f2543SmrgshadowInit (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
98706f2543Smrg
99706f2543Smrgextern _X_EXPORT void *
100706f2543SmrgshadowAlloc (int width, int height, int bpp);
101706f2543Smrg
102706f2543Smrgextern _X_EXPORT void
103706f2543SmrgshadowUpdatePacked (ScreenPtr	    pScreen,
104706f2543Smrg		    shadowBufPtr    pBuf);
105706f2543Smrg
106706f2543Smrgextern _X_EXPORT void
107706f2543SmrgshadowUpdatePlanar4 (ScreenPtr	    pScreen,
108706f2543Smrg		     shadowBufPtr   pBuf);
109706f2543Smrg
110706f2543Smrgextern _X_EXPORT void
111706f2543SmrgshadowUpdatePlanar4x8 (ScreenPtr    pScreen,
112706f2543Smrg		       shadowBufPtr pBuf);
113706f2543Smrg
114706f2543Smrgextern _X_EXPORT void
115706f2543SmrgshadowUpdateRotatePacked (ScreenPtr    pScreen,
116706f2543Smrg			  shadowBufPtr pBuf);
117706f2543Smrg
118706f2543Smrgextern _X_EXPORT void
119706f2543SmrgshadowUpdateRotate8_90 (ScreenPtr    pScreen,
120706f2543Smrg			shadowBufPtr pBuf);
121706f2543Smrg
122706f2543Smrgextern _X_EXPORT void
123706f2543SmrgshadowUpdateRotate16_90 (ScreenPtr    pScreen,
124706f2543Smrg			 shadowBufPtr pBuf);
125706f2543Smrg
126706f2543Smrgextern _X_EXPORT void
127706f2543SmrgshadowUpdateRotate16_90YX (ScreenPtr    pScreen,
128706f2543Smrg			   shadowBufPtr pBuf);
129706f2543Smrg
130706f2543Smrgextern _X_EXPORT void
131706f2543SmrgshadowUpdateRotate32_90 (ScreenPtr    pScreen,
132706f2543Smrg			 shadowBufPtr pBuf);
133706f2543Smrg
134706f2543Smrgextern _X_EXPORT void
135706f2543SmrgshadowUpdateRotate8_180 (ScreenPtr    pScreen,
136706f2543Smrg			 shadowBufPtr pBuf);
137706f2543Smrg
138706f2543Smrgextern _X_EXPORT void
139706f2543SmrgshadowUpdateRotate16_180 (ScreenPtr    pScreen,
140706f2543Smrg			  shadowBufPtr pBuf);
141706f2543Smrg
142706f2543Smrgextern _X_EXPORT void
143706f2543SmrgshadowUpdateRotate32_180 (ScreenPtr    pScreen,
144706f2543Smrg			  shadowBufPtr pBuf);
145706f2543Smrg
146706f2543Smrgextern _X_EXPORT void
147706f2543SmrgshadowUpdateRotate8_270 (ScreenPtr    pScreen,
148706f2543Smrg			 shadowBufPtr pBuf);
149706f2543Smrg
150706f2543Smrgextern _X_EXPORT void
151706f2543SmrgshadowUpdateRotate16_270 (ScreenPtr    pScreen,
152706f2543Smrg			  shadowBufPtr pBuf);
153706f2543Smrg
154706f2543Smrgextern _X_EXPORT void
155706f2543SmrgshadowUpdateRotate16_270YX (ScreenPtr    pScreen,
156706f2543Smrg			    shadowBufPtr pBuf);
157706f2543Smrg
158706f2543Smrgextern _X_EXPORT void
159706f2543SmrgshadowUpdateRotate32_270 (ScreenPtr    pScreen,
160706f2543Smrg			  shadowBufPtr pBuf);
161706f2543Smrg
162706f2543Smrgextern _X_EXPORT void
163706f2543SmrgshadowUpdateRotate8 (ScreenPtr    pScreen,
164706f2543Smrg		     shadowBufPtr pBuf);
165706f2543Smrg
166706f2543Smrgextern _X_EXPORT void
167706f2543SmrgshadowUpdateRotate16 (ScreenPtr    pScreen,
168706f2543Smrg		      shadowBufPtr pBuf);
169706f2543Smrg
170706f2543Smrgextern _X_EXPORT void
171706f2543SmrgshadowUpdateRotate32 (ScreenPtr    pScreen,
172706f2543Smrg		      shadowBufPtr pBuf);
173706f2543Smrg
174706f2543Smrgtypedef void (* shadowUpdateProc)(ScreenPtr, shadowBufPtr);
175706f2543Smrg
176706f2543Smrgextern _X_EXPORT shadowUpdateProc shadowUpdatePackedWeak(void);
177706f2543Smrgextern _X_EXPORT shadowUpdateProc shadowUpdatePlanar4Weak(void);
178706f2543Smrgextern _X_EXPORT shadowUpdateProc shadowUpdatePlanar4x8Weak(void);
179706f2543Smrgextern _X_EXPORT shadowUpdateProc shadowUpdateRotatePackedWeak(void);
180706f2543Smrg
181706f2543Smrg#endif /* _SHADOW_H_ */
182