cirrus: stop passing around dst pointers in the blitter

Instead pass around the address (aka offset into vga memory).  Calculate
the pointer in the rop_* functions, after applying the mask to the
address, to make sure the address stays within the valid range.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1489574872-8679-1-git-send-email-kraxel@redhat.com
master
Gerd Hoffmann 2017-03-15 11:47:52 +01:00
parent e048dac616
commit 026aeffcb4
3 changed files with 153 additions and 125 deletions

View File

@ -178,11 +178,12 @@
struct CirrusVGAState; struct CirrusVGAState;
typedef void (*cirrus_bitblt_rop_t) (struct CirrusVGAState *s, typedef void (*cirrus_bitblt_rop_t) (struct CirrusVGAState *s,
uint8_t * dst, const uint8_t * src, uint32_t dstaddr, const uint8_t *src,
int dstpitch, int srcpitch, int dstpitch, int srcpitch,
int bltwidth, int bltheight); int bltwidth, int bltheight);
typedef void (*cirrus_fill_t)(struct CirrusVGAState *s, typedef void (*cirrus_fill_t)(struct CirrusVGAState *s,
uint8_t *dst, int dst_pitch, int width, int height); uint32_t dstaddr, int dst_pitch,
int width, int height);
typedef struct CirrusVGAState { typedef struct CirrusVGAState {
VGACommonState vga; VGACommonState vga;
@ -321,14 +322,14 @@ static bool blit_is_unsafe(struct CirrusVGAState *s, bool dst_only)
} }
static void cirrus_bitblt_rop_nop(CirrusVGAState *s, static void cirrus_bitblt_rop_nop(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr, const uint8_t *src,
int dstpitch,int srcpitch, int dstpitch,int srcpitch,
int bltwidth,int bltheight) int bltwidth,int bltheight)
{ {
} }
static void cirrus_bitblt_fill_nop(CirrusVGAState *s, static void cirrus_bitblt_fill_nop(CirrusVGAState *s,
uint8_t *dst, uint32_t dstaddr,
int dstpitch, int bltwidth,int bltheight) int dstpitch, int bltwidth,int bltheight)
{ {
} }
@ -678,11 +679,8 @@ static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin,
static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s, bool videosrc) static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s, bool videosrc)
{ {
uint32_t patternsize; uint32_t patternsize;
uint8_t *dst;
uint8_t *src; uint8_t *src;
dst = s->vga.vram_ptr + s->cirrus_blt_dstaddr;
if (videosrc) { if (videosrc) {
switch (s->vga.get_bpp(&s->vga)) { switch (s->vga.get_bpp(&s->vga)) {
case 8: case 8:
@ -711,7 +709,7 @@ static int cirrus_bitblt_common_patterncopy(CirrusVGAState *s, bool videosrc)
return 0; return 0;
} }
(*s->cirrus_rop) (s, dst, src, (*s->cirrus_rop) (s, s->cirrus_blt_dstaddr, src,
s->cirrus_blt_dstpitch, 0, s->cirrus_blt_dstpitch, 0,
s->cirrus_blt_width, s->cirrus_blt_height); s->cirrus_blt_width, s->cirrus_blt_height);
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
@ -730,7 +728,7 @@ static int cirrus_bitblt_solidfill(CirrusVGAState *s, int blt_rop)
return 0; return 0;
} }
rop_func = cirrus_fill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; rop_func = cirrus_fill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
rop_func(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, rop_func(s, s->cirrus_blt_dstaddr,
s->cirrus_blt_dstpitch, s->cirrus_blt_dstpitch,
s->cirrus_blt_width, s->cirrus_blt_height); s->cirrus_blt_width, s->cirrus_blt_height);
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
@ -797,7 +795,7 @@ static int cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
} }
} }
(*s->cirrus_rop) (s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, (*s->cirrus_rop) (s, s->cirrus_blt_dstaddr,
s->vga.vram_ptr + s->cirrus_blt_srcaddr, s->vga.vram_ptr + s->cirrus_blt_srcaddr,
s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch, s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch,
s->cirrus_blt_width, s->cirrus_blt_height); s->cirrus_blt_width, s->cirrus_blt_height);
@ -848,7 +846,7 @@ static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s)
} else { } else {
/* at least one scan line */ /* at least one scan line */
do { do {
(*s->cirrus_rop)(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, (*s->cirrus_rop)(s, s->cirrus_blt_dstaddr,
s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1); s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1);
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0, cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0,
s->cirrus_blt_width, 1); s->cirrus_blt_width, 1);

View File

@ -22,31 +22,65 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
static inline void glue(rop_8_,ROP_NAME)(uint8_t *dst, uint8_t src) static inline void glue(rop_8_, ROP_NAME)(CirrusVGAState *s,
uint32_t dstaddr, uint8_t src)
{ {
uint8_t *dst = &s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask];
*dst = ROP_FN(*dst, src); *dst = ROP_FN(*dst, src);
} }
static inline void glue(rop_16_,ROP_NAME)(uint16_t *dst, uint16_t src) static inline void glue(rop_tr_8_, ROP_NAME)(CirrusVGAState *s,
uint32_t dstaddr, uint8_t src,
uint8_t transp)
{ {
uint8_t *dst = &s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask];
uint8_t pixel = ROP_FN(*dst, src);
if (pixel != transp) {
*dst = pixel;
}
}
static inline void glue(rop_16_, ROP_NAME)(CirrusVGAState *s,
uint32_t dstaddr, uint16_t src)
{
uint16_t *dst = (uint16_t *)
(&s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask & ~1]);
*dst = ROP_FN(*dst, src); *dst = ROP_FN(*dst, src);
} }
static inline void glue(rop_32_,ROP_NAME)(uint32_t *dst, uint32_t src) static inline void glue(rop_tr_16_, ROP_NAME)(CirrusVGAState *s,
uint32_t dstaddr, uint16_t src,
uint16_t transp)
{ {
uint16_t *dst = (uint16_t *)
(&s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask & ~1]);
uint16_t pixel = ROP_FN(*dst, src);
if (pixel != transp) {
*dst = pixel;
}
}
static inline void glue(rop_32_, ROP_NAME)(CirrusVGAState *s,
uint32_t dstaddr, uint32_t src)
{
uint32_t *dst = (uint32_t *)
(&s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask & ~3]);
*dst = ROP_FN(*dst, src); *dst = ROP_FN(*dst, src);
} }
#define ROP_OP(d, s) glue(rop_8_,ROP_NAME)(d, s) #define ROP_OP(st, d, s) glue(rop_8_, ROP_NAME)(st, d, s)
#define ROP_OP_16(d, s) glue(rop_16_,ROP_NAME)(d, s) #define ROP_OP_TR(st, d, s, t) glue(rop_tr_8_, ROP_NAME)(st, d, s, t)
#define ROP_OP_32(d, s) glue(rop_32_,ROP_NAME)(d, s) #define ROP_OP_16(st, d, s) glue(rop_16_, ROP_NAME)(st, d, s)
#define ROP_OP_TR_16(st, d, s, t) glue(rop_tr_16_, ROP_NAME)(st, d, s, t)
#define ROP_OP_32(st, d, s) glue(rop_32_, ROP_NAME)(st, d, s)
#undef ROP_FN #undef ROP_FN
static void static void
glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s, glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr,
int dstpitch,int srcpitch, const uint8_t *src,
int bltwidth,int bltheight) int dstpitch, int srcpitch,
int bltwidth, int bltheight)
{ {
int x,y; int x,y;
dstpitch -= bltwidth; dstpitch -= bltwidth;
@ -58,43 +92,47 @@ glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
for (y = 0; y < bltheight; y++) { for (y = 0; y < bltheight; y++) {
for (x = 0; x < bltwidth; x++) { for (x = 0; x < bltwidth; x++) {
ROP_OP(dst, *src); ROP_OP(s, dstaddr, *src);
dst++; dstaddr++;
src++; src++;
} }
dst += dstpitch; dstaddr += dstpitch;
src += srcpitch; src += srcpitch;
} }
} }
static void static void
glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s, glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr,
int dstpitch,int srcpitch, const uint8_t *src,
int bltwidth,int bltheight) int dstpitch, int srcpitch,
int bltwidth, int bltheight)
{ {
int x,y; int x,y;
dstpitch += bltwidth; dstpitch += bltwidth;
srcpitch += bltwidth; srcpitch += bltwidth;
for (y = 0; y < bltheight; y++) { for (y = 0; y < bltheight; y++) {
for (x = 0; x < bltwidth; x++) { for (x = 0; x < bltwidth; x++) {
ROP_OP(dst, *src); ROP_OP(s, dstaddr, *src);
dst--; dstaddr--;
src--; src--;
} }
dst += dstpitch; dstaddr += dstpitch;
src += srcpitch; src += srcpitch;
} }
} }
static void static void
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s, glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr,
int dstpitch,int srcpitch, const uint8_t *src,
int bltwidth,int bltheight) int dstpitch,
int srcpitch,
int bltwidth,
int bltheight)
{ {
int x,y; int x,y;
uint8_t p; uint8_t transp = s->vga.gr[0x34];
dstpitch -= bltwidth; dstpitch -= bltwidth;
srcpitch -= bltwidth; srcpitch -= bltwidth;
@ -104,48 +142,50 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
for (y = 0; y < bltheight; y++) { for (y = 0; y < bltheight; y++) {
for (x = 0; x < bltwidth; x++) { for (x = 0; x < bltwidth; x++) {
p = *dst; ROP_OP_TR(s, dstaddr, *src, transp);
ROP_OP(&p, *src); dstaddr++;
if (p != s->vga.gr[0x34]) *dst = p;
dst++;
src++; src++;
} }
dst += dstpitch; dstaddr += dstpitch;
src += srcpitch; src += srcpitch;
} }
} }
static void static void
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s, glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr,
int dstpitch,int srcpitch, const uint8_t *src,
int bltwidth,int bltheight) int dstpitch,
int srcpitch,
int bltwidth,
int bltheight)
{ {
int x,y; int x,y;
uint8_t p; uint8_t transp = s->vga.gr[0x34];
dstpitch += bltwidth; dstpitch += bltwidth;
srcpitch += bltwidth; srcpitch += bltwidth;
for (y = 0; y < bltheight; y++) { for (y = 0; y < bltheight; y++) {
for (x = 0; x < bltwidth; x++) { for (x = 0; x < bltwidth; x++) {
p = *dst; ROP_OP_TR(s, dstaddr, *src, transp);
ROP_OP(&p, *src); dstaddr--;
if (p != s->vga.gr[0x34]) *dst = p;
dst--;
src--; src--;
} }
dst += dstpitch; dstaddr += dstpitch;
src += srcpitch; src += srcpitch;
} }
} }
static void static void
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s, glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr,
int dstpitch,int srcpitch, const uint8_t *src,
int bltwidth,int bltheight) int dstpitch,
int srcpitch,
int bltwidth,
int bltheight)
{ {
int x,y; int x,y;
uint8_t p1, p2; uint16_t transp = s->vga.gr[0x34] | (uint16_t)s->vga.gr[0x35] << 8;
dstpitch -= bltwidth; dstpitch -= bltwidth;
srcpitch -= bltwidth; srcpitch -= bltwidth;
@ -155,46 +195,35 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
for (y = 0; y < bltheight; y++) { for (y = 0; y < bltheight; y++) {
for (x = 0; x < bltwidth; x+=2) { for (x = 0; x < bltwidth; x+=2) {
p1 = *dst; ROP_OP_TR_16(s, dstaddr, *(uint16_t *)src, transp);
p2 = *(dst+1); dstaddr += 2;
ROP_OP(&p1, *src); src += 2;
ROP_OP(&p2, *(src + 1));
if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
*dst = p1;
*(dst+1) = p2;
}
dst+=2;
src+=2;
} }
dst += dstpitch; dstaddr += dstpitch;
src += srcpitch; src += srcpitch;
} }
} }
static void static void
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s, glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
uint8_t *dst,const uint8_t *src, uint32_t dstaddr,
int dstpitch,int srcpitch, const uint8_t *src,
int bltwidth,int bltheight) int dstpitch,
int srcpitch,
int bltwidth,
int bltheight)
{ {
int x,y; int x,y;
uint8_t p1, p2; uint16_t transp = s->vga.gr[0x34] | (uint16_t)s->vga.gr[0x35] << 8;
dstpitch += bltwidth; dstpitch += bltwidth;
srcpitch += bltwidth; srcpitch += bltwidth;
for (y = 0; y < bltheight; y++) { for (y = 0; y < bltheight; y++) {
for (x = 0; x < bltwidth; x+=2) { for (x = 0; x < bltwidth; x+=2) {
p1 = *(dst-1); ROP_OP_TR_16(s, dstaddr, *(uint16_t *)src, transp);
p2 = *dst; dstaddr -= 2;
ROP_OP(&p1, *(src - 1)); src -= 2;
ROP_OP(&p2, *src);
if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
*(dst-1) = p1;
*dst = p2;
}
dst-=2;
src-=2;
} }
dst += dstpitch; dstaddr += dstpitch;
src += srcpitch; src += srcpitch;
} }
} }

View File

@ -23,27 +23,29 @@
*/ */
#if DEPTH == 8 #if DEPTH == 8
#define PUTPIXEL() ROP_OP(&d[0], col) #define PUTPIXEL(s, a, c) ROP_OP(s, a, c)
#elif DEPTH == 16 #elif DEPTH == 16
#define PUTPIXEL() ROP_OP_16((uint16_t *)&d[0], col) #define PUTPIXEL(s, a, c) ROP_OP_16(s, a, c)
#elif DEPTH == 24 #elif DEPTH == 24
#define PUTPIXEL() ROP_OP(&d[0], col); \ #define PUTPIXEL(s, a, c) do { \
ROP_OP(&d[1], (col >> 8)); \ ROP_OP(s, a, c); \
ROP_OP(&d[2], (col >> 16)) ROP_OP(s, a + 1, (col >> 8)); \
ROP_OP(s, a + 2, (col >> 16)); \
} while (0)
#elif DEPTH == 32 #elif DEPTH == 32
#define PUTPIXEL() ROP_OP_32(((uint32_t *)&d[0]), col) #define PUTPIXEL(s, a, c) ROP_OP_32(s, a, c)
#else #else
#error unsupported DEPTH #error unsupported DEPTH
#endif #endif
static void static void
glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH) glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH)
(CirrusVGAState * s, uint8_t * dst, (CirrusVGAState *s, uint32_t dstaddr,
const uint8_t * src, const uint8_t *src,
int dstpitch, int srcpitch, int dstpitch, int srcpitch,
int bltwidth, int bltheight) int bltwidth, int bltheight)
{ {
uint8_t *d; uint32_t addr;
int x, y, pattern_y, pattern_pitch, pattern_x; int x, y, pattern_y, pattern_pitch, pattern_x;
unsigned int col; unsigned int col;
const uint8_t *src1; const uint8_t *src1;
@ -63,7 +65,7 @@ glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH)
pattern_y = s->cirrus_blt_srcaddr & 7; pattern_y = s->cirrus_blt_srcaddr & 7;
for(y = 0; y < bltheight; y++) { for(y = 0; y < bltheight; y++) {
pattern_x = skipleft; pattern_x = skipleft;
d = dst + skipleft; addr = dstaddr + skipleft;
src1 = src + pattern_y * pattern_pitch; src1 = src + pattern_y * pattern_pitch;
for (x = skipleft; x < bltwidth; x += (DEPTH / 8)) { for (x = skipleft; x < bltwidth; x += (DEPTH / 8)) {
#if DEPTH == 8 #if DEPTH == 8
@ -82,23 +84,23 @@ glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH)
col = ((uint32_t *)(src1 + pattern_x))[0]; col = ((uint32_t *)(src1 + pattern_x))[0];
pattern_x = (pattern_x + 4) & 31; pattern_x = (pattern_x + 4) & 31;
#endif #endif
PUTPIXEL(); PUTPIXEL(s, addr, col);
d += (DEPTH / 8); addr += (DEPTH / 8);
} }
pattern_y = (pattern_y + 1) & 7; pattern_y = (pattern_y + 1) & 7;
dst += dstpitch; dstaddr += dstpitch;
} }
} }
/* NOTE: srcpitch is ignored */ /* NOTE: srcpitch is ignored */
static void static void
glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH) glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH)
(CirrusVGAState * s, uint8_t * dst, (CirrusVGAState *s, uint32_t dstaddr,
const uint8_t * src, const uint8_t *src,
int dstpitch, int srcpitch, int dstpitch, int srcpitch,
int bltwidth, int bltheight) int bltwidth, int bltheight)
{ {
uint8_t *d; uint32_t addr;
int x, y; int x, y;
unsigned bits, bits_xor; unsigned bits, bits_xor;
unsigned int col; unsigned int col;
@ -123,7 +125,7 @@ glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) { for(y = 0; y < bltheight; y++) {
bitmask = 0x80 >> srcskipleft; bitmask = 0x80 >> srcskipleft;
bits = *src++ ^ bits_xor; bits = *src++ ^ bits_xor;
d = dst + dstskipleft; addr = dstaddr + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) { for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
if ((bitmask & 0xff) == 0) { if ((bitmask & 0xff) == 0) {
bitmask = 0x80; bitmask = 0x80;
@ -131,24 +133,24 @@ glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH)
} }
index = (bits & bitmask); index = (bits & bitmask);
if (index) { if (index) {
PUTPIXEL(); PUTPIXEL(s, addr, col);
} }
d += (DEPTH / 8); addr += (DEPTH / 8);
bitmask >>= 1; bitmask >>= 1;
} }
dst += dstpitch; dstaddr += dstpitch;
} }
} }
static void static void
glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH) glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH)
(CirrusVGAState * s, uint8_t * dst, (CirrusVGAState *s, uint32_t dstaddr,
const uint8_t * src, const uint8_t *src,
int dstpitch, int srcpitch, int dstpitch, int srcpitch,
int bltwidth, int bltheight) int bltwidth, int bltheight)
{ {
uint32_t colors[2]; uint32_t colors[2];
uint8_t *d; uint32_t addr;
int x, y; int x, y;
unsigned bits; unsigned bits;
unsigned int col; unsigned int col;
@ -161,29 +163,29 @@ glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) { for(y = 0; y < bltheight; y++) {
bitmask = 0x80 >> srcskipleft; bitmask = 0x80 >> srcskipleft;
bits = *src++; bits = *src++;
d = dst + dstskipleft; addr = dstaddr + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) { for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
if ((bitmask & 0xff) == 0) { if ((bitmask & 0xff) == 0) {
bitmask = 0x80; bitmask = 0x80;
bits = *src++; bits = *src++;
} }
col = colors[!!(bits & bitmask)]; col = colors[!!(bits & bitmask)];
PUTPIXEL(); PUTPIXEL(s, addr, col);
d += (DEPTH / 8); addr += (DEPTH / 8);
bitmask >>= 1; bitmask >>= 1;
} }
dst += dstpitch; dstaddr += dstpitch;
} }
} }
static void static void
glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH) glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH)
(CirrusVGAState * s, uint8_t * dst, (CirrusVGAState *s, uint32_t dstaddr,
const uint8_t * src, const uint8_t *src,
int dstpitch, int srcpitch, int dstpitch, int srcpitch,
int bltwidth, int bltheight) int bltwidth, int bltheight)
{ {
uint8_t *d; uint32_t addr;
int x, y, bitpos, pattern_y; int x, y, bitpos, pattern_y;
unsigned int bits, bits_xor; unsigned int bits, bits_xor;
unsigned int col; unsigned int col;
@ -207,28 +209,28 @@ glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) { for(y = 0; y < bltheight; y++) {
bits = src[pattern_y] ^ bits_xor; bits = src[pattern_y] ^ bits_xor;
bitpos = 7 - srcskipleft; bitpos = 7 - srcskipleft;
d = dst + dstskipleft; addr = dstaddr + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) { for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
if ((bits >> bitpos) & 1) { if ((bits >> bitpos) & 1) {
PUTPIXEL(); PUTPIXEL(s, addr, col);
} }
d += (DEPTH / 8); addr += (DEPTH / 8);
bitpos = (bitpos - 1) & 7; bitpos = (bitpos - 1) & 7;
} }
pattern_y = (pattern_y + 1) & 7; pattern_y = (pattern_y + 1) & 7;
dst += dstpitch; dstaddr += dstpitch;
} }
} }
static void static void
glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH) glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH)
(CirrusVGAState * s, uint8_t * dst, (CirrusVGAState *s, uint32_t dstaddr,
const uint8_t * src, const uint8_t *src,
int dstpitch, int srcpitch, int dstpitch, int srcpitch,
int bltwidth, int bltheight) int bltwidth, int bltheight)
{ {
uint32_t colors[2]; uint32_t colors[2];
uint8_t *d; uint32_t addr;
int x, y, bitpos, pattern_y; int x, y, bitpos, pattern_y;
unsigned int bits; unsigned int bits;
unsigned int col; unsigned int col;
@ -242,38 +244,37 @@ glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) { for(y = 0; y < bltheight; y++) {
bits = src[pattern_y]; bits = src[pattern_y];
bitpos = 7 - srcskipleft; bitpos = 7 - srcskipleft;
d = dst + dstskipleft; addr = dstaddr + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) { for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
col = colors[(bits >> bitpos) & 1]; col = colors[(bits >> bitpos) & 1];
PUTPIXEL(); PUTPIXEL(s, addr, col);
d += (DEPTH / 8); addr += (DEPTH / 8);
bitpos = (bitpos - 1) & 7; bitpos = (bitpos - 1) & 7;
} }
pattern_y = (pattern_y + 1) & 7; pattern_y = (pattern_y + 1) & 7;
dst += dstpitch; dstaddr += dstpitch;
} }
} }
static void static void
glue(glue(glue(cirrus_fill_, ROP_NAME), _),DEPTH) glue(glue(glue(cirrus_fill_, ROP_NAME), _),DEPTH)
(CirrusVGAState *s, (CirrusVGAState *s,
uint8_t *dst, int dst_pitch, uint32_t dstaddr, int dst_pitch,
int width, int height) int width, int height)
{ {
uint8_t *d, *d1; uint32_t addr;
uint32_t col; uint32_t col;
int x, y; int x, y;
col = s->cirrus_blt_fgcol; col = s->cirrus_blt_fgcol;
d1 = dst;
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
d = d1; addr = dstaddr;
for(x = 0; x < width; x += (DEPTH / 8)) { for(x = 0; x < width; x += (DEPTH / 8)) {
PUTPIXEL(); PUTPIXEL(s, addr, col);
d += (DEPTH / 8); addr += (DEPTH / 8);
} }
d1 += dst_pitch; dstaddr += dst_pitch;
} }
} }