Commit be7257c5 authored by Michel Dänzer's avatar Michel Dänzer Committed by Michel Dänzer
Browse files

Drop miext/shadow directory

Not used on this branch.
parent aa49cd5a
......@@ -414,7 +414,6 @@ inc = include_directories(
'glamor',
'mi',
'miext/damage',
'miext/shadow',
'miext/sync',
'dbe',
'dri3',
......@@ -499,7 +498,6 @@ subdir('composite')
subdir('damageext')
subdir('dbe')
subdir('miext/damage')
subdir('miext/shadow')
subdir('miext/sync')
subdir('present')
subdir('randr')
......
/*
* Fast C2P (Chunky-to-Planar) Conversion
*
* NOTES:
* - This code was inspired by Scout's C2P tutorial
* - It assumes to run on a big endian system
*
* Copyright © 2003-2008 Geert Uytterhoeven
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* Basic transpose step
*/
static inline void _transp(CARD32 d[], unsigned int i1, unsigned int i2,
unsigned int shift, CARD32 mask)
{
CARD32 t = (d[i1] ^ (d[i2] >> shift)) & mask;
d[i1] ^= t;
d[i2] ^= t << shift;
}
static inline void c2p_unsupported(void) {
BUG_WARN(1);
}
static inline CARD32 get_mask(unsigned int n)
{
switch (n) {
case 1:
return 0x55555555;
case 2:
return 0x33333333;
case 4:
return 0x0f0f0f0f;
case 8:
return 0x00ff00ff;
case 16:
return 0x0000ffff;
}
c2p_unsupported();
return 0;
}
/*
* Transpose operations on 8 32-bit words
*/
static inline void transp8(CARD32 d[], unsigned int n, unsigned int m)
{
CARD32 mask = get_mask(n);
switch (m) {
case 1:
/* First n x 1 block */
_transp(d, 0, 1, n, mask);
/* Second n x 1 block */
_transp(d, 2, 3, n, mask);
/* Third n x 1 block */
_transp(d, 4, 5, n, mask);
/* Fourth n x 1 block */
_transp(d, 6, 7, n, mask);
return;
case 2:
/* First n x 2 block */
_transp(d, 0, 2, n, mask);
_transp(d, 1, 3, n, mask);
/* Second n x 2 block */
_transp(d, 4, 6, n, mask);
_transp(d, 5, 7, n, mask);
return;
case 4:
/* Single n x 4 block */
_transp(d, 0, 4, n, mask);
_transp(d, 1, 5, n, mask);
_transp(d, 2, 6, n, mask);
_transp(d, 3, 7, n, mask);
return;
}
c2p_unsupported();
}
/*
* Transpose operations on 4 32-bit words
*/
static inline void transp4(CARD32 d[], unsigned int n, unsigned int m)
{
CARD32 mask = get_mask(n);
switch (m) {
case 1:
/* First n x 1 block */
_transp(d, 0, 1, n, mask);
/* Second n x 1 block */
_transp(d, 2, 3, n, mask);
return;
case 2:
/* Single n x 2 block */
_transp(d, 0, 2, n, mask);
_transp(d, 1, 3, n, mask);
return;
}
c2p_unsupported();
}
/*
* Transpose operations on 4 32-bit words (reverse order)
*/
static inline void transp4x(CARD32 d[], unsigned int n, unsigned int m)
{
CARD32 mask = get_mask(n);
switch (m) {
case 2:
/* Single n x 2 block */
_transp(d, 2, 0, n, mask);
_transp(d, 3, 1, n, mask);
return;
}
c2p_unsupported();
}
/*
* Transpose operations on 2 32-bit words
*/
static inline void transp2(CARD32 d[], unsigned int n)
{
CARD32 mask = get_mask(n);
/* Single n x 1 block */
_transp(d, 0, 1, n, mask);
return;
}
/*
* Transpose operations on 2 32-bit words (reverse order)
*/
static inline void transp2x(CARD32 d[], unsigned int n)
{
CARD32 mask = get_mask(n);
/* Single n x 1 block */
_transp(d, 1, 0, n, mask);
return;
}
srcs_miext_shadow = [
'shadow.c',
'sh3224.c',
'shafb4.c',
'shafb8.c',
'shiplan2p4.c',
'shiplan2p8.c',
'shpacked.c',
'shplanar8.c',
'shplanar.c',
'shrot16pack_180.c',
'shrot16pack_270.c',
'shrot16pack_270YX.c',
'shrot16pack_90.c',
'shrot16pack_90YX.c',
'shrot16pack.c',
'shrot32pack_180.c',
'shrot32pack_270.c',
'shrot32pack_90.c',
'shrot32pack.c',
'shrot8pack_180.c',
'shrot8pack_270.c',
'shrot8pack_90.c',
'shrot8pack.c',
'shrotate.c',
]
hdrs_miext_shadow = [
'shadow.h',
]
libxserver_miext_shadow = static_library('libxserver_miext_shadow',
srcs_miext_shadow,
include_directories: inc,
dependencies: common_dep,
)
/*
* 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 = DamageRegion(pBuf->pDamage);
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++;
}
}
/*
* 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 <stdlib.h>
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
#include "dixfontstr.h"
#include "mi.h"
#include "regionstr.h"
#include "globals.h"
#include "gcstruct.h"
#include "shadow.h"
static DevPrivateKeyRec shadowScrPrivateKeyRec;
#define shadowScrPrivateKey (&shadowScrPrivateKeyRec)
#define shadowGetBuf(pScr) ((shadowBufPtr) \
dixLookupPrivate(&(pScr)->devPrivates, shadowScrPrivateKey))
#define shadowBuf(pScr) shadowBufPtr pBuf = shadowGetBuf(pScr)
#define wrap(priv, real, mem) {\
priv->mem = real->mem; \
real->mem = shadow##mem; \
}
#define unwrap(priv, real, mem) {\
real->mem = priv->mem; \
}
static void
shadowRedisplay(ScreenPtr pScreen)
{
shadowBuf(pScreen);
RegionPtr pRegion;
if (!pBuf || !pBuf->pDamage || !pBuf->update)
return;
pRegion = DamageRegion(pBuf->pDamage);
if (RegionNotEmpty(pRegion)) {
(*pBuf->update) (pScreen, pBuf);
DamageEmpty(pBuf->pDamage);
}
}
static void
shadowBlockHandler(ScreenPtr pScreen, void *timeout)
{
shadowBuf(pScreen);
shadowRedisplay(pScreen);
unwrap(pBuf, pScreen, BlockHandler);
pScreen->BlockHandler(pScreen, timeout);
wrap(pBuf, pScreen, BlockHandler);
}
static void
shadowGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
unsigned int format, unsigned long planeMask, char *pdstLine)
{
ScreenPtr pScreen = pDrawable->pScreen;
shadowBuf(pScreen);
/* Many apps use GetImage to sync with the visible frame buffer */
if (pDrawable->type == DRAWABLE_WINDOW)
shadowRedisplay(pScreen);
unwrap(pBuf, pScreen, GetImage);
pScreen->GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
wrap(pBuf, pScreen, GetImage);
}
static Bool
shadowCloseScreen(ScreenPtr pScreen)
{
shadowBuf(pScreen);
unwrap(pBuf, pScreen, GetImage);
unwrap(pBuf, pScreen, CloseScreen);
unwrap(pBuf, pScreen, BlockHandler);
shadowRemove(pScreen, pBuf->pPixmap);
DamageDestroy(pBuf->pDamage);
if (pBuf->pPixmap)
pScreen->DestroyPixmap(pBuf->pPixmap);
free(pBuf);
return pScreen->CloseScreen(pScreen);
}
Bool
shadowSetup(ScreenPtr pScreen)
{
shadowBufPtr pBuf;
if (!dixRegisterPrivateKey(&shadowScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!DamageSetup(pScreen))
return FALSE;
pBuf = malloc(sizeof(shadowBufRec));
if (!pBuf)
return FALSE;
pBuf->pDamage = DamageCreate((DamageReportFunc) NULL,
(DamageDestroyFunc) NULL,
DamageReportNone, TRUE, pScreen, pScreen);
if (!pBuf->pDamage) {
free(pBuf);
return FALSE;
}
wrap(pBuf, pScreen, CloseScreen);
wrap(pBuf, pScreen, GetImage);
wrap(pBuf, pScreen, BlockHandler);
pBuf->update = 0;
pBuf->window = 0;
pBuf->pPixmap = 0;
pBuf->closure = 0;
pBuf->randr = 0;
dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
return TRUE;
}
Bool
shadowAdd(ScreenPtr pScreen, PixmapPtr pPixmap, ShadowUpdateProc update,
ShadowWindowProc window, int randr, void *closure)
{
shadowBuf(pScreen);
/*
* Map simple rotation values to bitmasks; fortunately,
* these are all unique
*/
switch (randr) {
case 0:
randr = SHADOW_ROTATE_0;
break;
case 90:
randr = SHADOW_ROTATE_90;
break;
case 180:
randr = SHADOW_ROTATE_180;
break;
case 270:
randr = SHADOW_ROTATE_270;
break;
}
pBuf->update = update;
pBuf->window = window;
pBuf->randr = randr;
pBuf->closure = closure;
pBuf->pPixmap = pPixmap;
DamageRegister(&pPixmap->drawable, pBuf->pDamage);
return TRUE;
}
void
shadowRemove(ScreenPtr pScreen, PixmapPtr pPixmap)
{
shadowBuf(pScreen);
if (pBuf->pPixmap) {
DamageUnregister(pBuf->pDamage);
pBuf->update = 0;
pBuf->window = 0;
pBuf->randr = 0;
pBuf->closure = 0;
pBuf->pPixmap = 0;
}
}
/*
*
* 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.
*/
#ifndef _SHADOW_H_
#define _SHADOW_H_
#include "scrnintstr.h"
#include "picturestr.h"
#include "damage.h"
#include "damagestr.h"
typedef struct _shadowBuf *shadowBufPtr;
typedef void (*ShadowUpdateProc) (ScreenPtr pScreen, shadowBufPtr pBuf);
#define SHADOW_WINDOW_RELOCATE 1
#define SHADOW_WINDOW_READ 2
#define SHADOW_WINDOW_WRITE 4
typedef void *(*ShadowWindowProc) (ScreenPtr pScreen,
CARD32 row,
CARD32 offset,
int mode, CARD32 *size, void *closure);
typedef struct _shadowBuf {
DamagePtr pDamage;
ShadowUpdateProc update;
ShadowWindowProc window;