2 * Copyright © 2013 Geert Uytterhoeven
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Based on shpacked.c, which is Copyright © 2000 Keith Packard
26 #ifdef HAVE_DIX_CONFIG_H
27 #include <dix-config.h>
33 #include "scrnintstr.h"
34 #include "windowstr.h"
35 #include <X11/fonts/font.h>
36 #include "dixfontstr.h"
37 #include <X11/fonts/fontstruct.h>
39 #include "regionstr.h"
48 * Perform a full C2P step on 16 4-bit pixels, stored in 2 32-bit words
50 * - 16 4-bit chunky pixels on input
51 * - permutated planar data (2 planes per 32-bit word) on output
54 static void c2p_16x4(CARD32 d
[2])
66 * Store a full block of iplan2p4 data after c2p conversion
69 static inline void store_iplan2p4(void *dst
, const CARD32 d
[2])
79 shadowUpdateIplan2p4(ScreenPtr pScreen
, shadowBufPtr pBuf
)
81 RegionPtr damage
= shadowDamage(pBuf
);
82 PixmapPtr pShadow
= pBuf
->pPixmap
;
83 int nbox
= RegionNumRects(damage
);
84 BoxPtr pbox
= RegionRects(damage
);
86 CARD16
*shaLine
, *sha
;
89 _X_UNUSED
int shaBpp
, shaXoff
, shaYoff
;
93 _X_UNUSED CARD32 winSize
;
99 fbGetDrawable(&pShadow
->drawable
, shaBase
, shaStride
, shaBpp
, shaXoff
,
101 shaStride
*= sizeof(FbBits
) / sizeof(CARD16
);
106 w
= pbox
->x2
- pbox
->x1
;
107 h
= pbox
->y2
- pbox
->y1
;
109 scrLine
= (x
& -16) / 2;
110 shaLine
= (CARD16
*)shaBase
+ y
* shaStride
+ scrLine
/ sizeof(CARD16
);
112 n
= ((x
& 15) + w
+ 15) / 16; /* number of c2p units in scanline */
116 win
= (CARD16
*) (*pBuf
->window
) (pScreen
,
124 for (i
= 0; i
< n
; i
++) {
125 memcpy(d
.bytes
, sha
, sizeof(d
.bytes
));
127 store_iplan2p4(win
, d
.words
);
128 sha
+= sizeof(d
.bytes
) / sizeof(*sha
);
129 win
+= sizeof(d
.bytes
) / sizeof(*win
);
131 shaLine
+= shaStride
;