[gdi,line] clean up line functions
* Simplify CMake source detection * Clean up code in line.c, add assertions
This commit is contained in:
parent
e5ad90627b
commit
a546388063
@ -20,22 +20,12 @@ set(MODULE_PREFIX "FREERDP_GDI")
|
|||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
set(${MODULE_PREFIX}_SRCS
|
file(GLOB ${MODULE_PREFIX}_SRCS
|
||||||
bitmap.c
|
LIST_DIRECTORIES false
|
||||||
brush.c
|
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
clipping.c
|
CONFIGURE_DEPENDS
|
||||||
dc.c
|
"*.[ch]"
|
||||||
drawing.c
|
)
|
||||||
line.c
|
|
||||||
pen.c
|
|
||||||
region.c
|
|
||||||
shape.c
|
|
||||||
graphics.c
|
|
||||||
graphics.h
|
|
||||||
gfx.c
|
|
||||||
video.c
|
|
||||||
gdi.c
|
|
||||||
gdi.h)
|
|
||||||
|
|
||||||
freerdp_module_add(${${MODULE_PREFIX}_SRCS})
|
freerdp_module_add(${${MODULE_PREFIX}_SRCS})
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <winpr/assert.h>
|
||||||
|
|
||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
#include <freerdp/gdi/gdi.h>
|
#include <freerdp/gdi/gdi.h>
|
||||||
#include <freerdp/gdi/pen.h>
|
#include <freerdp/gdi/pen.h>
|
||||||
@ -37,6 +39,7 @@
|
|||||||
|
|
||||||
static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
|
static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(pixelPtr);
|
||||||
const UINT32 srcPixel = FreeRDPReadColor(pixelPtr, format);
|
const UINT32 srcPixel = FreeRDPReadColor(pixelPtr, format);
|
||||||
UINT32 dstPixel;
|
UINT32 dstPixel;
|
||||||
|
|
||||||
@ -115,30 +118,26 @@ static BOOL gdi_rop_color(UINT32 rop, BYTE* pixelPtr, UINT32 pen, UINT32 format)
|
|||||||
|
|
||||||
BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
|
BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
|
||||||
{
|
{
|
||||||
INT32 x, y;
|
INT32 e2;
|
||||||
INT32 x1, y1;
|
|
||||||
INT32 x2, y2;
|
|
||||||
INT32 e, e2;
|
|
||||||
INT32 dx, dy;
|
|
||||||
INT32 sx, sy;
|
|
||||||
INT32 bx1, by1;
|
|
||||||
INT32 bx2, by2;
|
|
||||||
HGDI_BITMAP bmp;
|
|
||||||
UINT32 pen;
|
UINT32 pen;
|
||||||
INT32 rop2 = gdi_GetROP2(hdc);
|
|
||||||
x1 = hdc->pen->posX;
|
|
||||||
y1 = hdc->pen->posY;
|
|
||||||
x2 = nXEnd;
|
|
||||||
y2 = nYEnd;
|
|
||||||
dx = (x1 > x2) ? x1 - x2 : x2 - x1;
|
|
||||||
dy = (y1 > y2) ? y1 - y2 : y2 - y1;
|
|
||||||
sx = (x1 < x2) ? 1 : -1;
|
|
||||||
sy = (y1 < y2) ? 1 : -1;
|
|
||||||
e = dx - dy;
|
|
||||||
x = x1;
|
|
||||||
y = y1;
|
|
||||||
bmp = (HGDI_BITMAP)hdc->selectedObject;
|
|
||||||
|
|
||||||
|
WINPR_ASSERT(hdc);
|
||||||
|
const INT32 rop2 = gdi_GetROP2(hdc);
|
||||||
|
|
||||||
|
const INT32 x1 = hdc->pen->posX;
|
||||||
|
const INT32 y1 = hdc->pen->posY;
|
||||||
|
const INT32 x2 = nXEnd;
|
||||||
|
const INT32 y2 = nYEnd;
|
||||||
|
const INT32 dx = (x1 > x2) ? x1 - x2 : x2 - x1;
|
||||||
|
const INT32 dy = (y1 > y2) ? y1 - y2 : y2 - y1;
|
||||||
|
const INT32 sx = (x1 < x2) ? 1 : -1;
|
||||||
|
const INT32 sy = (y1 < y2) ? 1 : -1;
|
||||||
|
INT32 e = dx - dy;
|
||||||
|
INT32 x = x1;
|
||||||
|
INT32 y = y1;
|
||||||
|
|
||||||
|
WINPR_ASSERT(hdc->clip);
|
||||||
|
INT32 bx1, by1, bx2, by2;
|
||||||
if (hdc->clip->null)
|
if (hdc->clip->null)
|
||||||
{
|
{
|
||||||
bx1 = (x1 < x2) ? x1 : x2;
|
bx1 = (x1 < x2) ? x1 : x2;
|
||||||
@ -154,6 +153,9 @@ BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
|
|||||||
by2 = by1 + hdc->clip->h - 1;
|
by2 = by1 + hdc->clip->h - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HGDI_BITMAP bmp = (HGDI_BITMAP)hdc->selectedObject;
|
||||||
|
WINPR_ASSERT(bmp);
|
||||||
|
|
||||||
bx1 = MAX(bx1, 0);
|
bx1 = MAX(bx1, 0);
|
||||||
by1 = MAX(by1, 0);
|
by1 = MAX(by1, 0);
|
||||||
bx2 = MIN(bx2, bmp->width - 1);
|
bx2 = MIN(bx2, bmp->width - 1);
|
||||||
@ -171,6 +173,7 @@ BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
|
|||||||
if ((x >= bx1 && x <= bx2) && (y >= by1 && y <= by2))
|
if ((x >= bx1 && x <= bx2) && (y >= by1 && y <= by2))
|
||||||
{
|
{
|
||||||
BYTE* pixel = gdi_GetPointer(bmp, x, y);
|
BYTE* pixel = gdi_GetPointer(bmp, x, y);
|
||||||
|
WINPR_ASSERT(pixel);
|
||||||
gdi_rop_color(rop2, pixel, pen, bmp->format);
|
gdi_rop_color(rop2, pixel, pen, bmp->format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,9 +209,10 @@ BOOL gdi_LineTo(HGDI_DC hdc, UINT32 nXEnd, UINT32 nYEnd)
|
|||||||
*/
|
*/
|
||||||
BOOL gdi_PolylineTo(HGDI_DC hdc, GDI_POINT* lppt, DWORD cCount)
|
BOOL gdi_PolylineTo(HGDI_DC hdc, GDI_POINT* lppt, DWORD cCount)
|
||||||
{
|
{
|
||||||
DWORD i;
|
WINPR_ASSERT(hdc);
|
||||||
|
WINPR_ASSERT(lppt || (cCount == 0));
|
||||||
|
|
||||||
for (i = 0; i < cCount; i++)
|
for (DWORD i = 0; i < cCount; i++)
|
||||||
{
|
{
|
||||||
if (!gdi_LineTo(hdc, lppt[i].x, lppt[i].y))
|
if (!gdi_LineTo(hdc, lppt[i].x, lppt[i].y))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -229,15 +233,17 @@ BOOL gdi_PolylineTo(HGDI_DC hdc, GDI_POINT* lppt, DWORD cCount)
|
|||||||
*/
|
*/
|
||||||
BOOL gdi_Polyline(HGDI_DC hdc, GDI_POINT* lppt, UINT32 cPoints)
|
BOOL gdi_Polyline(HGDI_DC hdc, GDI_POINT* lppt, UINT32 cPoints)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(hdc);
|
||||||
|
WINPR_ASSERT(lppt || (cPoints == 0));
|
||||||
|
|
||||||
if (cPoints > 0)
|
if (cPoints > 0)
|
||||||
{
|
{
|
||||||
UINT32 i;
|
GDI_POINT pt = { 0 };
|
||||||
GDI_POINT pt;
|
|
||||||
|
|
||||||
if (!gdi_MoveToEx(hdc, lppt[0].x, lppt[0].y, &pt))
|
if (!gdi_MoveToEx(hdc, lppt[0].x, lppt[0].y, &pt))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < cPoints; i++)
|
for (UINT32 i = 0; i < cPoints; i++)
|
||||||
{
|
{
|
||||||
if (!gdi_LineTo(hdc, lppt[i].x, lppt[i].y))
|
if (!gdi_LineTo(hdc, lppt[i].x, lppt[i].y))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -263,12 +269,15 @@ BOOL gdi_Polyline(HGDI_DC hdc, GDI_POINT* lppt, UINT32 cPoints)
|
|||||||
*/
|
*/
|
||||||
BOOL gdi_PolyPolyline(HGDI_DC hdc, GDI_POINT* lppt, UINT32* lpdwPolyPoints, DWORD cCount)
|
BOOL gdi_PolyPolyline(HGDI_DC hdc, GDI_POINT* lppt, UINT32* lpdwPolyPoints, DWORD cCount)
|
||||||
{
|
{
|
||||||
UINT32 cPoints;
|
DWORD j = 0;
|
||||||
DWORD i, j = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < cCount; i++)
|
WINPR_ASSERT(hdc);
|
||||||
|
WINPR_ASSERT(lppt || (cCount == 0));
|
||||||
|
WINPR_ASSERT(lpdwPolyPoints || (cCount == 0));
|
||||||
|
|
||||||
|
for (DWORD i = 0; i < cCount; i++)
|
||||||
{
|
{
|
||||||
cPoints = lpdwPolyPoints[i];
|
const UINT32 cPoints = lpdwPolyPoints[i];
|
||||||
|
|
||||||
if (!gdi_Polyline(hdc, &lppt[j], cPoints))
|
if (!gdi_Polyline(hdc, &lppt[j], cPoints))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -289,6 +298,8 @@ BOOL gdi_PolyPolyline(HGDI_DC hdc, GDI_POINT* lppt, UINT32* lpdwPolyPoints, DWOR
|
|||||||
|
|
||||||
BOOL gdi_MoveToEx(HGDI_DC hdc, UINT32 X, UINT32 Y, HGDI_POINT lpPoint)
|
BOOL gdi_MoveToEx(HGDI_DC hdc, UINT32 X, UINT32 Y, HGDI_POINT lpPoint)
|
||||||
{
|
{
|
||||||
|
WINPR_ASSERT(hdc);
|
||||||
|
|
||||||
if (lpPoint != NULL)
|
if (lpPoint != NULL)
|
||||||
{
|
{
|
||||||
lpPoint->x = hdc->pen->posX;
|
lpPoint->x = hdc->pen->posX;
|
||||||
|
Loading…
Reference in New Issue
Block a user