summaryrefslogtreecommitdiff
path: root/miext
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2016-12-09 14:52:35 -0500
committerAdam Jackson <ajax@redhat.com>2016-12-12 14:10:44 -0500
commit1ae09800863992cfb1d5d21c600e2bc29e3b6ab2 (patch)
tree42c6411fb9a4777a89455f5e01939954e4ad0aa0 /miext
parent2b486f052d8a7d3bada9eb2615aa19d79e999cbe (diff)
shadow: Lift 32->24 conversion from modesetting to dix
Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'miext')
-rw-r--r--miext/shadow/Makefile.am1
-rw-r--r--miext/shadow/sh3224.c138
-rw-r--r--miext/shadow/shadow.h3
3 files changed, 142 insertions, 0 deletions
diff --git a/miext/shadow/Makefile.am b/miext/shadow/Makefile.am
index 27cf41422..b611c9bb0 100644
--- a/miext/shadow/Makefile.am
+++ b/miext/shadow/Makefile.am
@@ -10,6 +10,7 @@ libshadow_la_SOURCES = \
c2p_core.h \
shadow.c \
shadow.h \
+ sh3224.c \
shafb4.c \
shafb8.c \
shalloc.c \
diff --git a/miext/shadow/sh3224.c b/miext/shadow/sh3224.c
new file mode 100644
index 000000000..ba541217e
--- /dev/null
+++ b/miext/shadow/sh3224.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include "shadow.h"
+#include "fb.h"
+
+#define Get8(a) ((CARD32) READ(a))
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Get24(a) ((Get8(a) << 16) | (Get8((a)+1) << 8) | Get8((a)+2))
+#define Put24(a,p) ((WRITE((a+0), (CARD8) ((p) >> 16))), \
+ (WRITE((a+1), (CARD8) ((p) >> 8))), \
+ (WRITE((a+2), (CARD8) (p))))
+#else
+#define Get24(a) (Get8(a) | (Get8((a)+1) << 8) | (Get8((a)+2)<<16))
+#define Put24(a,p) ((WRITE((a+0), (CARD8) (p))), \
+ (WRITE((a+1), (CARD8) ((p) >> 8))), \
+ (WRITE((a+2), (CARD8) ((p) >> 16))))
+#endif
+
+static void
+sh24_32BltLine(CARD8 *srcLine,
+ CARD8 *dstLine,
+ int width)
+{
+ CARD32 *src;
+ CARD8 *dst;
+ int w;
+ CARD32 pixel;
+
+ src = (CARD32 *) srcLine;
+ dst = dstLine;
+ w = width;
+
+ while (((long)dst & 3) && w) {
+ w--;
+ pixel = READ(src++);
+ Put24(dst, pixel);
+ dst += 3;
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4) {
+ CARD32 s0, s1;
+
+ s0 = READ(src++);
+ s1 = READ(src++);
+#if BITMAP_BIT_ORDER == LSBFirst
+ WRITE((CARD32 *) dst, (s0 & 0xffffff) | (s1 << 24));
+#else
+ WRITE((CARD32 *) dst, (s0 << 8) | ((s1 & 0xffffff) >> 16));
+#endif
+ s0 = READ(src++);
+#if BITMAP_BIT_ORDER == LSBFirst
+ WRITE((CARD32 *) (dst + 4),
+ ((s1 & 0xffffff) >> 8) | (s0 << 16));
+#else
+ WRITE((CARD32 *) (dst + 4),
+ (s1 << 16) | ((s0 & 0xffffff) >> 8));
+#endif
+ s1 = READ(src++);
+#if BITMAP_BIT_ORDER == LSBFirst
+ WRITE((CARD32 *) (dst + 8),
+ ((s0 & 0xffffff) >> 16) | (s1 << 8));
+#else
+ WRITE((CARD32 *) (dst + 8), (s0 << 24) | (s1 & 0xffffff));
+#endif
+ dst += 12;
+ w -= 4;
+ }
+ while (w--) {
+ pixel = READ(src++);
+ Put24(dst, pixel);
+ dst += 3;
+ }
+}
+
+void
+shadowUpdate32to24(ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage(pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = RegionNumRects(damage);
+ BoxPtr pbox = RegionRects(damage);
+ FbStride shaStride;
+ int shaBpp;
+ _X_UNUSED int shaXoff, shaYoff;
+ int x, y, w, h;
+ CARD32 winSize;
+ FbBits *shaBase, *shaLine;
+ CARD8 *winBase = NULL, *winLine;
+
+ fbGetDrawable(&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff,
+ shaYoff);
+
+ /* just get the initial window base + stride */
+ winBase = (*pBuf->window)(pScreen, 0, 0, SHADOW_WINDOW_WRITE,
+ &winSize, pBuf->closure);
+
+ while (nbox--) {
+ x = pbox->x1;
+ y = pbox->y1;
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+
+ winLine = winBase + y * winSize + (x * 3);
+ shaLine = shaBase + y * shaStride + ((x * shaBpp) >> FB_SHIFT);
+
+ while (h--) {
+ sh24_32BltLine((CARD8 *)shaLine, (CARD8 *)winLine, w);
+ winLine += winSize;
+ shaLine += shaStride;
+ }
+ pbox++;
+ }
+}
diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h
index 7f22169dc..0bbbe45b6 100644
--- a/miext/shadow/shadow.h
+++ b/miext/shadow/shadow.h
@@ -156,6 +156,9 @@ extern _X_EXPORT void
extern _X_EXPORT void
shadowUpdateRotate32(ScreenPtr pScreen, shadowBufPtr pBuf);
+extern _X_EXPORT void
+ shadowUpdate32to24(ScreenPtr pScreen, shadowBufPtr pBuf);
+
typedef void (*shadowUpdateProc) (ScreenPtr, shadowBufPtr);
extern _X_EXPORT shadowUpdateProc shadowUpdatePackedWeak(void);