1 | /*
|
---|
2 | * $XFree86: xc/programs/Xserver/miext/shadow/shrotpack.h,v 1.3 2001/05/29 04:54:13 keithp Exp $
|
---|
3 | *
|
---|
4 | * Copyright © 2000 Keith Packard
|
---|
5 | *
|
---|
6 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
7 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
8 | * the above copyright notice appear in all copies and that both that
|
---|
9 | * copyright notice and this permission notice appear in supporting
|
---|
10 | * documentation, and that the name of Keith Packard not be used in
|
---|
11 | * advertising or publicity pertaining to distribution of the software without
|
---|
12 | * specific, written prior permission. Keith Packard makes no
|
---|
13 | * representations about the suitability of this software for any purpose. It
|
---|
14 | * is provided "as is" without express or implied warranty.
|
---|
15 | *
|
---|
16 | * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
---|
17 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
---|
18 | * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
---|
19 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
---|
20 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
---|
21 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
---|
22 | * PERFORMANCE OF THIS SOFTWARE.
|
---|
23 | */
|
---|
24 |
|
---|
25 | /*
|
---|
26 | * Thanks to Daniel Chemko <[email protected]> for making the 90 and 180
|
---|
27 | * orientations work.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifdef HAVE_DIX_CONFIG_H
|
---|
31 | #include <dix-config.h>
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <stdlib.h>
|
---|
35 |
|
---|
36 | #include <X11/X.h>
|
---|
37 | #include "scrnintstr.h"
|
---|
38 | #include "windowstr.h"
|
---|
39 | #include <X11/fonts/font.h>
|
---|
40 | #include "dixfontstr.h"
|
---|
41 | #include <X11/fonts/fontstruct.h>
|
---|
42 | #include "mi.h"
|
---|
43 | #include "regionstr.h"
|
---|
44 | #include "globals.h"
|
---|
45 | #include "gcstruct.h"
|
---|
46 | #include "shadow.h"
|
---|
47 | #include "fb.h"
|
---|
48 |
|
---|
49 | #define DANDEBUG 0
|
---|
50 |
|
---|
51 | #if ROTATE == 270
|
---|
52 |
|
---|
53 | #define SCRLEFT(x,y,w,h) (pScreen->height - ((y) + (h)))
|
---|
54 | #define SCRY(x,y,w,h) (x)
|
---|
55 | #define SCRWIDTH(x,y,w,h) (h)
|
---|
56 | #define FIRSTSHA(x,y,w,h) (((y) + (h) - 1) * shaStride + (x))
|
---|
57 | #define STEPDOWN(x,y,w,h) ((w)--)
|
---|
58 | #define NEXTY(x,y,w,h) ((x)++)
|
---|
59 | #define SHASTEPX(stride) -(stride)
|
---|
60 | #define SHASTEPY(stride) (1)
|
---|
61 |
|
---|
62 | #elif ROTATE == 90
|
---|
63 |
|
---|
64 | #define SCRLEFT(x,y,w,h) (y)
|
---|
65 | #define SCRY(x,y,w,h) (pScreen->width - ((x) + (w)) - 1)
|
---|
66 | #define SCRWIDTH(x,y,w,h) (h)
|
---|
67 | #define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x + w - 1))
|
---|
68 | #define STEPDOWN(x,y,w,h) ((w)--)
|
---|
69 | #define NEXTY(x,y,w,h) ((void)(x))
|
---|
70 | #define SHASTEPX(stride) (stride)
|
---|
71 | #define SHASTEPY(stride) (-1)
|
---|
72 |
|
---|
73 | #elif ROTATE == 180
|
---|
74 |
|
---|
75 | #define SCRLEFT(x,y,w,h) (pScreen->width - ((x) + (w)))
|
---|
76 | #define SCRY(x,y,w,h) (pScreen->height - ((y) + (h)) - 1)
|
---|
77 | #define SCRWIDTH(x,y,w,h) (w)
|
---|
78 | #define FIRSTSHA(x,y,w,h) ((y + h - 1) * shaStride + (x + w - 1))
|
---|
79 | #define STEPDOWN(x,y,w,h) ((h)--)
|
---|
80 | #define NEXTY(x,y,w,h) ((void)(y))
|
---|
81 | #define SHASTEPX(stride) (-1)
|
---|
82 | #define SHASTEPY(stride) -(stride)
|
---|
83 |
|
---|
84 | #else
|
---|
85 |
|
---|
86 | #define SCRLEFT(x,y,w,h) (x)
|
---|
87 | #define SCRY(x,y,w,h) (y)
|
---|
88 | #define SCRWIDTH(x,y,w,h) (w)
|
---|
89 | #define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x))
|
---|
90 | #define STEPDOWN(x,y,w,h) ((h)--)
|
---|
91 | #define NEXTY(x,y,w,h) ((y)++)
|
---|
92 | #define SHASTEPX(stride) (1)
|
---|
93 | #define SHASTEPY(stride) (stride)
|
---|
94 |
|
---|
95 | #endif
|
---|
96 |
|
---|
97 | void
|
---|
98 | FUNC (ScreenPtr pScreen,
|
---|
99 | shadowBufPtr pBuf)
|
---|
100 | {
|
---|
101 | RegionPtr damage = shadowDamage (pBuf);
|
---|
102 | PixmapPtr pShadow = pBuf->pPixmap;
|
---|
103 | int nbox = REGION_NUM_RECTS (damage);
|
---|
104 | BoxPtr pbox = REGION_RECTS (damage);
|
---|
105 | FbBits *shaBits;
|
---|
106 | Data *shaBase, *shaLine, *sha;
|
---|
107 | FbStride shaStride;
|
---|
108 | int scrBase, scrLine, scr;
|
---|
109 | int shaBpp;
|
---|
110 | int shaXoff, shaYoff; /* XXX assumed to be zero */
|
---|
111 | int x, y, w, h, width;
|
---|
112 | int i;
|
---|
113 | Data *winBase = NULL, *win;
|
---|
114 | CARD32 winSize;
|
---|
115 |
|
---|
116 | fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
|
---|
117 | shaBase = (Data *) shaBits;
|
---|
118 | shaStride = shaStride * sizeof (FbBits) / sizeof (Data);
|
---|
119 | #if (DANDEBUG > 1)
|
---|
120 | ErrorF ("-> Entering Shadow Update:\r\n |- Origins: pShadow=%x, pScreen=%x, damage=%x\r\n |- Metrics: shaStride=%d, shaBase=%x, shaBpp=%d\r\n | \n", pShadow, pScreen, damage, shaStride, shaBase, shaBpp);
|
---|
121 | #endif
|
---|
122 | while (nbox--)
|
---|
123 | {
|
---|
124 | x = pbox->x1;
|
---|
125 | y = pbox->y1;
|
---|
126 | w = (pbox->x2 - pbox->x1);
|
---|
127 | h = pbox->y2 - pbox->y1;
|
---|
128 |
|
---|
129 | #if (DANDEBUG > 2)
|
---|
130 | ErrorF (" |-> Redrawing box - Metrics: X=%d, Y=%d, Width=%d, Height=%d\n", x, y, w, h);
|
---|
131 | #endif
|
---|
132 | scrLine = SCRLEFT(x,y,w,h);
|
---|
133 | shaLine = shaBase + FIRSTSHA(x,y,w,h);
|
---|
134 |
|
---|
135 | while (STEPDOWN(x,y,w,h))
|
---|
136 | {
|
---|
137 | winSize = 0;
|
---|
138 | scrBase = 0;
|
---|
139 | width = SCRWIDTH(x,y,w,h);
|
---|
140 | scr = scrLine;
|
---|
141 | sha = shaLine;
|
---|
142 | #if (DANDEBUG > 3)
|
---|
143 | ErrorF (" | |-> StepDown - Metrics: width=%d, scr=%x, sha=%x\n", width, scr, sha);
|
---|
144 | #endif
|
---|
145 | while (width)
|
---|
146 | {
|
---|
147 | /* how much remains in this window */
|
---|
148 | i = scrBase + winSize - scr;
|
---|
149 | if (i <= 0 || scr < scrBase)
|
---|
150 | {
|
---|
151 | winBase = (Data *) (*pBuf->window) (pScreen,
|
---|
152 | SCRY(x,y,w,h),
|
---|
153 | scr * sizeof (Data),
|
---|
154 | SHADOW_WINDOW_WRITE,
|
---|
155 | &winSize,
|
---|
156 | pBuf->closure);
|
---|
157 | if(!winBase)
|
---|
158 | return;
|
---|
159 | scrBase = scr;
|
---|
160 | winSize /= sizeof (Data);
|
---|
161 | i = winSize;
|
---|
162 | #if(DANDEBUG > 4)
|
---|
163 | ErrorF (" | | |-> Starting New Line - Metrics: winBase=%x, scrBase=%x, winSize=%d\r\n | | | Xstride=%d, Ystride=%d, w=%d h=%d\n", winBase, scrBase, winSize, SHASTEPX(shaStride), SHASTEPY(shaStride), w, h);
|
---|
164 | #endif
|
---|
165 | }
|
---|
166 | win = winBase + (scr - scrBase);
|
---|
167 | if (i > width)
|
---|
168 | i = width;
|
---|
169 | width -= i;
|
---|
170 | scr += i;
|
---|
171 | #if(DANDEBUG > 5)
|
---|
172 | ErrorF (" | | |-> Writing Line - Metrics: win=%x, sha=%x\n", win, sha);
|
---|
173 | #endif
|
---|
174 | while (i--)
|
---|
175 | {
|
---|
176 | #if(DANDEBUG > 6)
|
---|
177 | ErrorF (" | | |-> Writing Pixel - Metrics: win=%x, sha=%d, remaining=%d\n", win, sha, i);
|
---|
178 | #endif
|
---|
179 | *win++ = *sha;
|
---|
180 | sha += SHASTEPX(shaStride);
|
---|
181 | } /* i */
|
---|
182 | } /* width */
|
---|
183 | shaLine += SHASTEPY(shaStride);
|
---|
184 | NEXTY(x,y,w,h);
|
---|
185 | } /* STEPDOWN */
|
---|
186 | pbox++;
|
---|
187 | } /* nbox */
|
---|
188 | }
|
---|