mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed several off-by-one errors and some compiler warnings
svn path=/trunk/; revision=4229
This commit is contained in:
parent
8690cad211
commit
1b1e741e1b
9 changed files with 113 additions and 115 deletions
|
@ -17,87 +17,86 @@ DrvLineTo(SURFOBJ *Surface,
|
|||
// FIXME: Use Mix to perform ROPs
|
||||
|
||||
{
|
||||
ULONG x, y, d, i, length, xchange, ychange, error,
|
||||
iSolidColor, hx, vy;
|
||||
LONG deltax, deltay;
|
||||
ULONG x, y, d, i, xchange, ychange, error,
|
||||
iSolidColor, hx, vy;
|
||||
LONG deltax, deltay;
|
||||
|
||||
iSolidColor = Brush->iSolidColor; // FIXME: Brush Realization...
|
||||
iSolidColor = Brush->iSolidColor; // FIXME: Brush Realization...
|
||||
|
||||
// FIXME: Implement clipping
|
||||
// FIXME: Implement clipping
|
||||
|
||||
x=x1;
|
||||
y=y1;
|
||||
deltax=x2-x1;
|
||||
deltay=y2-y1;
|
||||
x = x1;
|
||||
y = y1;
|
||||
deltax = x2 - x1;
|
||||
deltay = y2 - y1;
|
||||
|
||||
if(deltax<0)
|
||||
{
|
||||
xchange=-1;
|
||||
deltax=-deltax;
|
||||
hx = x2;
|
||||
} else
|
||||
{
|
||||
xchange=1;
|
||||
hx = x1;
|
||||
}
|
||||
if (deltax < 0)
|
||||
{
|
||||
xchange = -1;
|
||||
deltax = - deltax;
|
||||
hx = x2;
|
||||
x--;
|
||||
}
|
||||
else
|
||||
{
|
||||
xchange = 1;
|
||||
hx = x1;
|
||||
}
|
||||
|
||||
if(deltay<0)
|
||||
{
|
||||
ychange=-1;
|
||||
deltay=-deltay;
|
||||
vy = y2;
|
||||
} else
|
||||
{
|
||||
ychange=1;
|
||||
vy = y1;
|
||||
};
|
||||
if (deltay < 0)
|
||||
{
|
||||
ychange = -1;
|
||||
deltay = - deltay;
|
||||
vy = y2;
|
||||
y--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ychange = 1;
|
||||
vy = y1;
|
||||
};
|
||||
|
||||
if(y1==y2)
|
||||
{
|
||||
return vgaHLine(hx, y1, deltax, iSolidColor);
|
||||
}
|
||||
if(x1==x2)
|
||||
{
|
||||
return vgaVLine(x1, vy, deltay, iSolidColor);
|
||||
}
|
||||
if (y1 == y2)
|
||||
{
|
||||
return vgaHLine(hx, y1, deltax, iSolidColor);
|
||||
}
|
||||
if (x1 == x2)
|
||||
{
|
||||
return vgaVLine(x1, vy, deltay, iSolidColor);
|
||||
}
|
||||
|
||||
// Using individual pixels to draw a line neither horizontal or vertical
|
||||
// Set up the VGA masking for individual pixels
|
||||
|
||||
error = 0;
|
||||
|
||||
error=0;
|
||||
i=0;
|
||||
|
||||
if(deltax<deltay)
|
||||
{
|
||||
length=deltay+1;
|
||||
while(i<length)
|
||||
{
|
||||
vgaPutPixel(x, y, iSolidColor);
|
||||
y=y+ychange;
|
||||
error=error+deltax;
|
||||
|
||||
if(error>deltay)
|
||||
{
|
||||
x=x+xchange;
|
||||
error=error-deltay;
|
||||
}
|
||||
i=i+1;
|
||||
}
|
||||
} else
|
||||
{
|
||||
length=deltax+1;
|
||||
while(i<length)
|
||||
if (deltax < deltay)
|
||||
{
|
||||
vgaPutPixel(x, y, iSolidColor);
|
||||
x=x+xchange;
|
||||
error=error+deltay;
|
||||
if(error>deltax)
|
||||
{
|
||||
y=y+ychange;
|
||||
error=error-deltax;
|
||||
}
|
||||
i=i+1;
|
||||
for (i = 0; i < deltay; i++)
|
||||
{
|
||||
vgaPutPixel(x, y, iSolidColor);
|
||||
y = y + ychange;
|
||||
error = error + deltax;
|
||||
|
||||
if (deltay <= error)
|
||||
{
|
||||
x = x + xchange;
|
||||
error = error - deltay;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < deltax; i++)
|
||||
{
|
||||
vgaPutPixel(x, y, iSolidColor);
|
||||
x = x + xchange;
|
||||
error = error + deltay;
|
||||
if (deltax <= error)
|
||||
{
|
||||
y = y + ychange;
|
||||
error = error - deltax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ BOOL vgaHLine(INT x, INT y, INT len, UCHAR c)
|
|||
|
||||
// Calculate the left mask pixels, middle bytes and right mask pixel
|
||||
ileftpix = 8-mod(x, 8);
|
||||
irightpix = mod(x+len, 8);
|
||||
irightpix = mod(x+len-1, 8);
|
||||
imidpix = (len-ileftpix-irightpix) / 8;
|
||||
|
||||
pre1=xconv[x-(8-ileftpix)]+y80[y];
|
||||
|
@ -324,8 +324,6 @@ BOOL vgaVLine(INT x, INT y, INT len, UCHAR c)
|
|||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf,maskbit[x]);
|
||||
|
||||
len++;
|
||||
|
||||
for(i=y; i<y+len; i++)
|
||||
{
|
||||
a = READ_REGISTER_UCHAR(vidmem + offset);
|
||||
|
|
5
reactos/subsys/win32k/dib/dib.c
Normal file
5
reactos/subsys/win32k/dib/dib.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
/* Static data */
|
||||
|
||||
unsigned char notmask[2] = { 0x0f, 0xf0 };
|
||||
unsigned char altnotmask[2] = { 0xf0, 0x0f };
|
||||
unsigned char mask1Bpp[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
|
|
@ -1,25 +1,25 @@
|
|||
static unsigned char notmask[2] = { 0x0f, 0xf0 };
|
||||
static unsigned char altnotmask[2] = { 0xf0, 0x0f };
|
||||
static unsigned char mask1Bpp[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
|
||||
extern unsigned char notmask[2];
|
||||
extern unsigned char altnotmask[2];
|
||||
extern unsigned char mask1Bpp[8];
|
||||
|
||||
typedef VOID (*PFN_DIB_PutPixel)(PSURFOBJ, LONG, LONG, ULONG);
|
||||
typedef ULONG (*PFN_DIB_GetPixel)(PSURFOBJ, LONG, LONG);
|
||||
typedef VOID (*PFN_DIB_HLine) (PSURFOBJ, LONG, LONG, LONG, ULONG);
|
||||
typedef VOID (*PFN_DIB_VLine) (PSURFOBJ, LONG, LONG, LONG, ULONG);
|
||||
|
||||
PFN_DIB_PutPixel DIB_1BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
|
||||
PFN_DIB_GetPixel DIB_1BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
|
||||
PFN_DIB_HLine DIB_1BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c);
|
||||
PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c);
|
||||
VOID DIB_1BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
|
||||
ULONG DIB_1BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
|
||||
VOID DIB_1BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c);
|
||||
VOID DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c);
|
||||
BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
SURFGDI *DestGDI, SURFGDI *SourceGDI,
|
||||
PRECTL DestRect, POINTL *SourcePoint,
|
||||
LONG Delta, XLATEOBJ *ColorTranslation);
|
||||
|
||||
PFN_DIB_PutPixel DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
|
||||
PFN_DIB_GetPixel DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
|
||||
PFN_DIB_HLine DIB_4BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c);
|
||||
PFN_DIB_VLine DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c);
|
||||
VOID DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
|
||||
ULONG DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
|
||||
VOID DIB_4BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c);
|
||||
VOID DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c);
|
||||
BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
SURFGDI *DestGDI, SURFGDI *SourceGDI,
|
||||
PRECTL DestRect, POINTL *SourcePoint,
|
||||
|
@ -34,10 +34,10 @@ BOOL DIB_To_16BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|||
PRECTL DestRect, POINTL *SourcePoint,
|
||||
LONG Delta, XLATEOBJ *ColorTranslation);
|
||||
|
||||
PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
|
||||
PFN_DIB_GetPixel DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
|
||||
PFN_DIB_HLine DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c);
|
||||
PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c);
|
||||
VOID DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
|
||||
ULONG DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
|
||||
VOID DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c);
|
||||
VOID DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c);
|
||||
BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
SURFGDI *DestGDI, SURFGDI *SourceGDI,
|
||||
PRECTL DestRect, POINTL *SourcePoint,
|
||||
|
|
|
@ -30,7 +30,7 @@ VOID DIB_16BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
|
|||
PWORD addr = (PWORD)byteaddr + x1;
|
||||
LONG cx = x1;
|
||||
|
||||
while(cx <= x2) {
|
||||
while(cx < x2) {
|
||||
*addr = (WORD)c;
|
||||
++addr;
|
||||
++cx;
|
||||
|
@ -44,7 +44,7 @@ VOID DIB_16BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
|
|||
LONG lDelta = SurfObj->lDelta;
|
||||
|
||||
byteaddr = (PBYTE)addr;
|
||||
while(y1++ <= y2) {
|
||||
while(y1++ < y2) {
|
||||
*addr = (WORD)c;
|
||||
|
||||
byteaddr += lDelta;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "../eng/objects.h"
|
||||
#include "dib.h"
|
||||
|
||||
PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
|
||||
VOID DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
|
||||
{
|
||||
PBYTE byteaddr = SurfObj->pvBits + y * SurfObj->lDelta;
|
||||
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
|
||||
|
@ -16,35 +16,35 @@ PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
|
|||
*(PULONG)(addr) = c;
|
||||
}
|
||||
|
||||
PFN_DIB_GetPixel DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
|
||||
ULONG DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
|
||||
{
|
||||
PBYTE byteaddr = SurfObj->pvBits + y * SurfObj->lDelta;
|
||||
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
|
||||
|
||||
return (PFN_DIB_GetPixel)(*(PULONG)(addr));
|
||||
return *(PULONG)(addr) & 0x00ffffff;
|
||||
}
|
||||
|
||||
PFN_DIB_HLine DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
|
||||
VOID DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
|
||||
{
|
||||
PBYTE byteaddr = SurfObj->pvBits + y * SurfObj->lDelta;
|
||||
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x1;
|
||||
LONG cx = x1;
|
||||
|
||||
while(cx <= x2) {
|
||||
while(cx < x2) {
|
||||
*(PULONG)(addr) = c;
|
||||
++addr;
|
||||
++cx;
|
||||
}
|
||||
}
|
||||
|
||||
PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
|
||||
VOID DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
|
||||
{
|
||||
PBYTE byteaddr = SurfObj->pvBits + y1 * SurfObj->lDelta;
|
||||
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
|
||||
LONG lDelta = SurfObj->lDelta;
|
||||
|
||||
byteaddr = (PBYTE)addr;
|
||||
while(y1++ <= y2) {
|
||||
while(y1++ < y2) {
|
||||
*(PULONG)(addr) = c;
|
||||
|
||||
byteaddr += lDelta;
|
||||
|
@ -89,11 +89,9 @@ BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|||
LONG Delta, XLATEOBJ *ColorTranslation)
|
||||
{
|
||||
LONG i, j, sx, sy, xColor, f1;
|
||||
PBYTE DestBits, SourceBits_24BPP, DestLine, SourceLine_24BPP;
|
||||
PRGBTRIPLE SPDestBits, SPSourceBits_24BPP, SPDestLine, SPSourceLine_24BPP; // specially for 24-to-24 blit
|
||||
PBYTE SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;
|
||||
PBYTE DestBits, DestLine;
|
||||
PBYTE SourceBits_4BPP, SourceLine_4BPP;
|
||||
PWORD SourceBits_16BPP, SourceLine_16BPP;
|
||||
PDWORD SourceBits_32BPP, SourceLine_32BPP;
|
||||
|
||||
DestBits = DestSurf->pvBits + (DestRect->top * DestSurf->lDelta) + DestRect->left * 3;
|
||||
|
||||
|
|
|
@ -8,24 +8,22 @@
|
|||
#include "../eng/objects.h"
|
||||
#include "dib.h"
|
||||
|
||||
PFN_DIB_PutPixel DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
|
||||
VOID DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
|
||||
{
|
||||
unsigned char *vp;
|
||||
unsigned char mask;
|
||||
PBYTE addr = SurfObj->pvBits;
|
||||
|
||||
addr += (x>>1) + y * SurfObj->lDelta;
|
||||
*addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
|
||||
}
|
||||
|
||||
PFN_DIB_GetPixel DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
|
||||
ULONG DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
|
||||
{
|
||||
PBYTE addr = SurfObj->pvBits;
|
||||
|
||||
return (PFN_DIB_GetPixel)((addr[(x>>1) + y * SurfObj->lDelta] >> ((1-(x&1))<<2) ) & 0x0f);
|
||||
return (addr[(x>>1) + y * SurfObj->lDelta] >> ((1-(x&1))<<2) ) & 0x0f;
|
||||
}
|
||||
|
||||
PFN_DIB_HLine DIB_4BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
|
||||
VOID DIB_4BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
|
||||
{
|
||||
PBYTE addr = SurfObj->pvBits + (x1>>1) + y * SurfObj->lDelta;
|
||||
LONG cx = x1;
|
||||
|
@ -38,7 +36,7 @@ PFN_DIB_HLine DIB_4BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c
|
|||
}
|
||||
}
|
||||
|
||||
PFN_DIB_VLine DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
|
||||
VOID DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
|
||||
{
|
||||
PBYTE addr = SurfObj->pvBits;
|
||||
int lDelta = SurfObj->lDelta;
|
||||
|
@ -57,9 +55,7 @@ BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
|||
{
|
||||
LONG i, j, sx, sy, f1, f2, xColor;
|
||||
PBYTE SourceBits_24BPP, SourceLine_24BPP;
|
||||
PBYTE DestBits, DestLine, SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;
|
||||
PWORD SourceBits_16BPP, SourceLine_16BPP;
|
||||
PDWORD SourceBits_32BPP, SourceLine_32BPP;
|
||||
PBYTE DestBits, DestLine, SourceBits_8BPP, SourceLine_8BPP;
|
||||
|
||||
DestBits = DestSurf->pvBits + (DestRect->left>>1) + DestRect->top * DestSurf->lDelta;
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ EngLineTo(SURFOBJ *DestObj,
|
|||
xchange = -1;
|
||||
deltax = - deltax;
|
||||
hx = x2;
|
||||
x--;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -118,6 +119,7 @@ EngLineTo(SURFOBJ *DestObj,
|
|||
ychange = -1;
|
||||
deltay = - deltay;
|
||||
vy = y2;
|
||||
y--;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -129,7 +131,7 @@ EngLineTo(SURFOBJ *DestObj,
|
|||
{
|
||||
DIB_HLine(OutputObj, hx, hx + deltax, y1, Pixel);
|
||||
}
|
||||
else if(x1==x2)
|
||||
else if (x1 == x2)
|
||||
{
|
||||
DIB_VLine(OutputObj, x1, vy, vy + deltay, Pixel);
|
||||
}
|
||||
|
@ -145,7 +147,7 @@ EngLineTo(SURFOBJ *DestObj,
|
|||
y = y + ychange;
|
||||
error = error + deltax;
|
||||
|
||||
if (deltay < error)
|
||||
if (deltay <= error)
|
||||
{
|
||||
x = x + xchange;
|
||||
error = error - deltay;
|
||||
|
@ -159,7 +161,7 @@ EngLineTo(SURFOBJ *DestObj,
|
|||
DIB_PutPixel(OutputObj, x, y, Pixel);
|
||||
x = x + xchange;
|
||||
error = error + deltay;
|
||||
if (error > deltax)
|
||||
if (deltax <= error)
|
||||
{
|
||||
y = y + ychange;
|
||||
error = error - deltax;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.56 2003/02/25 23:08:52 gvg Exp $
|
||||
# $Id: makefile,v 1.57 2003/03/02 12:03:59 gvg Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -41,7 +41,7 @@ OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
|
|||
objects/region.o objects/text.o objects/wingl.o \
|
||||
objects/bezier.o objects/objconv.o objects/dib.o \
|
||||
objects/palette.o objects/rect.o
|
||||
DIB_OBJECTS = dib/dib1bpp.o dib/dib4bpp.o dib/dib16bpp.o dib/dib24bpp.o
|
||||
DIB_OBJECTS = dib/dib.o dib/dib1bpp.o dib/dib4bpp.o dib/dib16bpp.o dib/dib24bpp.o
|
||||
FREETYPE_OBJECTS = freetype/ctype.o freetype/grfont.o \
|
||||
freetype/src/base/ftsystem.o freetype/src/base/ftdebug.o \
|
||||
freetype/src/base/ftinit.o freetype/src/base/ftbase.o \
|
||||
|
|
Loading…
Reference in a new issue