📄 lineto.c
字号:
/*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: lineto.c 21292 2006-03-11 23:50:04Z jimtabor $
*/
#include <w32k.h>
#define NDEBUG
#include <debug.h>
static void FASTCALL
TranslateRects(RECT_ENUM *RectEnum, POINTL* Translate)
{
RECTL* CurrentRect;
if (0 != Translate->x || 0 != Translate->y)
{
for (CurrentRect = RectEnum->arcl; CurrentRect < RectEnum->arcl + RectEnum->c; CurrentRect++)
{
CurrentRect->left += Translate->x;
CurrentRect->right += Translate->x;
CurrentRect->top += Translate->y;
CurrentRect->bottom += Translate->y;
}
}
}
/*
* Draw a line from top-left to bottom-right
*/
void FASTCALL
NWtoSE(SURFOBJ* OutputObj, CLIPOBJ* Clip,
BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay,
POINTL* Translate)
{
int i;
int error;
BOOLEAN EnumMore;
RECTL* ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta >> 1;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c /* there's still a current clip rect */
&& (ClipRect->bottom <= y /* but it's above us */
|| (ClipRect->top <= y && ClipRect->right <= x))) /* or to the left of us */
|| EnumMore) /* no current clip rect, but rects left */
{
/* Skip to the next clip rect */
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c) /* If there's no current clip rect we're done */
{
if (ClipRect->left <= x && ClipRect->top <= y)
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
}
if (deltax < deltay)
{
y++;
error = error + deltax;
if (deltay <= error)
{
x++;
error = error - deltay;
}
}
else
{
x++;
error = error + deltay;
if (deltax <= error)
{
y++;
error = error - deltax;
}
}
i++;
}
}
}
void FASTCALL
SWtoNE(SURFOBJ* OutputObj, CLIPOBJ* Clip,
BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay,
POINTL* Translate)
{
int i;
int error;
BOOLEAN EnumMore;
RECTL* ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta >> 1;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (y < ClipRect->top
|| (y < ClipRect->bottom && ClipRect->right <= x)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (ClipRect->left <= x && y < ClipRect->bottom)
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
}
if (deltax < deltay)
{
y--;
error = error + deltax;
if (deltay <= error)
{
x++;
error = error - deltay;
}
}
else
{
x++;
error = error + deltay;
if (deltax <= error)
{
y--;
error = error - deltax;
}
}
i++;
}
}
}
void FASTCALL
NEtoSW(SURFOBJ* OutputObj, CLIPOBJ* Clip,
BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay,
POINTL* Translate)
{
int i;
int error;
BOOLEAN EnumMore;
RECTL* ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta >> 1;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (ClipRect->bottom <= y
|| (ClipRect->top <= y && x < ClipRect->left)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (x < ClipRect->right && ClipRect->top <= y)
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
}
if (deltax < deltay)
{
y++;
error = error + deltax;
if (deltay <= error)
{
x--;
error = error - deltay;
}
}
else
{
x--;
error = error + deltay;
if (deltax <= error)
{
y++;
error = error - deltax;
}
}
i++;
}
}
}
void FASTCALL
SEtoNW(SURFOBJ* OutputObj, CLIPOBJ* Clip,
BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay,
POINTL* Translate)
{
int i;
int error;
BOOLEAN EnumMore;
RECTL* ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta >> 1;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (y < ClipRect->top
|| (y < ClipRect->bottom && x < ClipRect->left)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
TranslateRects(&RectEnum, Translate);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (x < ClipRect->right && y < ClipRect->bottom)
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
}
if (deltax < deltay)
{
y--;
error = error + deltax;
if (deltay <= error)
{
x--;
error = error - deltay;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -