FREERDP_API UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel, BOOL vFlip);
FREERDP_API BOOL gdi_decode_color(rdpGdi* gdi, const UINT32 srcColor,
UINT32* color, UINT32* format);
-FREERDP_API BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y);
-FREERDP_API BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y);
FREERDP_API BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height);
FREERDP_API BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
UINT32 stride, UINT32 format, BYTE* buffer,
#include "brush.h"
#include "clipping.h"
+#include "../gdi/gdi.h"
#define TAG FREERDP_TAG("gdi.bitmap")
hBrush->pattern = hbmp;
return hBrush;
}
-UINT32 gdi_GetBrushStyle(HGDI_DC hdc)
-{
- if (!hdc || !hdc->brush)
- return GDI_BS_NULL;
- return hdc->brush->style;
-}
FREERDP_LOCAL HGDI_BRUSH gdi_CreateSolidBrush(UINT32 crColor);
FREERDP_LOCAL HGDI_BRUSH gdi_CreatePatternBrush(HGDI_BITMAP hbmp);
FREERDP_LOCAL HGDI_BRUSH gdi_CreateHatchBrush(HGDI_BITMAP hbmp);
-FREERDP_LOCAL UINT32 gdi_GetBrushStyle(HGDI_DC hdc);
+
+static INLINE UINT32 gdi_GetBrushStyle(HGDI_DC hdc)
+{
+ if (!hdc || !hdc->brush)
+ return GDI_BS_NULL;
+
+ return hdc->brush->style;
+}
#ifdef __cplusplus
}
return format;
}
-BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y)
-{
- BYTE* p;
- HGDI_BITMAP hBmp = (HGDI_BITMAP) hdcBmp->selectedObject;
-
- if (x < hBmp->width && y < hBmp->height)
- {
- p = hBmp->data + (y * hBmp->scanline) + (x * GetBytesPerPixel(hdcBmp->format));
- return p;
- }
- else
- {
- WLog_ERR(TAG,
- "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
- x, y, hBmp->width, hBmp->height);
- return 0;
- }
-}
-
-/**
- * Get current color in brush bitmap according to dest coordinates.\n
- * @msdn{dd183396}
- * @param x dest x-coordinate
- * @param y dest y-coordinate
- * @return color
- */
-BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
-{
- BYTE* p;
- UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);
-
- switch (brushStyle)
- {
- case GDI_BS_PATTERN:
- case GDI_BS_HATCHED:
- {
- HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;
- /* According to @msdn{dd183396}, the system always positions a brush bitmap
- * at the brush origin and copy across the client area.
- * Calculate the offset of the mapped pixel in the brush bitmap according to
- * brush origin and dest coordinates */
- x = (x + hBmpBrush->width - (hdcBrush->brush->nXOrg % hBmpBrush->width)) %
- hBmpBrush->width;
- y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
- hBmpBrush->height;
- p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * GetBytesPerPixel(
- hBmpBrush->format));
- return p;
- }
- break;
-
- default:
- break;
- }
-
- p = (BYTE*) & (hdcBrush->textColor);
- return p;
-}
-
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
BYTE* data)
{
#define __GDI_CORE_H
#include "graphics.h"
+#include "brush.h"
#include <freerdp/api.h>
BYTE* data);
FREERDP_LOCAL void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);
+static INLINE BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, UINT32 x, UINT32 y)
+{
+ BYTE* p;
+ HGDI_BITMAP hBmp = (HGDI_BITMAP) hdcBmp->selectedObject;
+
+ if (x < hBmp->width && y < hBmp->height)
+ {
+ p = hBmp->data + (y * hBmp->scanline) + (x * GetBytesPerPixel(hdcBmp->format));
+ return p;
+ }
+ else
+ {
+ WLog_ERR(FREERDP_TAG("gdi"),
+ "gdi_get_bitmap_pointer: requesting invalid pointer: (%d,%d) in %dx%d",
+ x, y, hBmp->width, hBmp->height);
+ return 0;
+ }
+}
+
+/**
+ * Get current color in brush bitmap according to dest coordinates.\n
+ * @msdn{dd183396}
+ * @param x dest x-coordinate
+ * @param y dest y-coordinate
+ * @return color
+ */
+static INLINE BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, UINT32 x, UINT32 y)
+{
+ BYTE* p;
+ UINT32 brushStyle = gdi_GetBrushStyle(hdcBrush);
+
+ switch (brushStyle)
+ {
+ case GDI_BS_PATTERN:
+ case GDI_BS_HATCHED:
+ {
+ HGDI_BITMAP hBmpBrush = hdcBrush->brush->pattern;
+ /* According to @msdn{dd183396}, the system always positions a brush bitmap
+ * at the brush origin and copy across the client area.
+ * Calculate the offset of the mapped pixel in the brush bitmap according to
+ * brush origin and dest coordinates */
+ x = (x + hBmpBrush->width - (hdcBrush->brush->nXOrg % hBmpBrush->width)) %
+ hBmpBrush->width;
+ y = (y + hBmpBrush->height - (hdcBrush->brush->nYOrg % hBmpBrush->height)) %
+ hBmpBrush->height;
+ p = hBmpBrush->data + (y * hBmpBrush->scanline) + (x * GetBytesPerPixel(
+ hBmpBrush->format));
+ return p;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ p = (BYTE*) & (hdcBrush->textColor);
+ return p;
+}
+
#endif /* __GDI_CORE_H */
#include <freerdp/log.h>
#include "clipping.h"
+#include "../gdi/gdi.h"
#define TAG FREERDP_TAG("gdi.shape")
* @return nonzero if successful, 0 otherwise
*/
BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect,
- int nBottomRect)
+ int nBottomRect)
{
Ellipse_Bresenham(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
return TRUE;
if (!gdi_ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL))
return TRUE;
- switch(hbr->style)
+ switch (hbr->style)
{
- case GDI_BS_SOLID:
- color = hbr->color;
+ case GDI_BS_SOLID:
+ color = hbr->color;
- for (y = 0; y < nHeight; y++)
- {
- for (x = 0; x < nWidth; x++)
- {
- BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x,
- nYDest + y);
+ for (y = 0; y < nHeight; y++)
+ {
+ for (x = 0; x < nWidth; x++)
+ {
+ BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x,
+ nYDest + y);
- if (dstp)
- WriteColor(dstp, hdc->format, color);
- }
- }
+ if (dstp)
+ WriteColor(dstp, hdc->format, color);
+ }
+ }
- break;
- case GDI_BS_HATCHED:
- case GDI_BS_PATTERN:
- monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
- for (y = 0; y < nHeight; y++)
- {
- for (x = 0; x < nWidth; x++)
+ break;
+
+ case GDI_BS_HATCHED:
+ case GDI_BS_PATTERN:
+ monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
+
+ for (y = 0; y < nHeight; y++)
{
- const UINT32 yOffset = ((nYDest + y) * hbr->pattern->width % hbr->pattern->height) * GetBytesPerPixel(hbr->pattern->format);
- const UINT32 xOffset = ((nXDest + x) % hbr->pattern->width) * GetBytesPerPixel(hbr->pattern->format);
- const BYTE* patp = &hbr->pattern->data[yOffset + xOffset];
- BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x,
- nYDest + y);
-
- if (!patp)
- return FALSE;
- if (monochrome)
+ for (x = 0; x < nWidth; x++)
{
- if (*patp == 0)
- dstColor = hdc->bkColor;
+ const UINT32 yOffset = ((nYDest + y) * hbr->pattern->width %
+ hbr->pattern->height) * GetBytesPerPixel(hbr->pattern->format);
+ const UINT32 xOffset = ((nXDest + x) % hbr->pattern->width) * GetBytesPerPixel(
+ hbr->pattern->format);
+ const BYTE* patp = &hbr->pattern->data[yOffset + xOffset];
+ BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x,
+ nYDest + y);
+
+ if (!patp)
+ return FALSE;
+
+ if (monochrome)
+ {
+ if (*patp == 0)
+ dstColor = hdc->bkColor;
+ else
+ dstColor = hdc->textColor;
+ }
else
- dstColor = hdc->textColor;
- }
- else
- {
- dstColor = ReadColor(patp, hbr->pattern->format);
- dstColor = ConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL);
- }
+ {
+ dstColor = ReadColor(patp, hbr->pattern->format);
+ dstColor = ConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL);
+ }
- if (dstp)
- WriteColor(dstp, hdc->format, dstColor);
+ if (dstp)
+ WriteColor(dstp, hdc->format, dstColor);
+ }
}
- }
- break;
- default:
- break;
+
+ break;
+
+ default:
+ break;
}
+
if (!gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight))
return FALSE;
* @return nonzero if successful, 0 otherwise
*/
BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT* lpPoints, int* lpPolyCounts,
- int nCount)
+ int nCount)
{
WLog_ERR(TAG, "Not implemented!");
return FALSE;
}
BOOL gdi_Rectangle(HGDI_DC hdc, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
- UINT32 nHeight)
+ UINT32 nHeight)
{
UINT32 x, y;
UINT32 color;
for (y = 0; y < nHeight; y++)
{
BYTE* dstLeft = gdi_get_bitmap_pointer(hdc, nXDst,
- nYDst + y);
+ nYDst + y);
BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1,
- nYDst + y);
+ nYDst + y);
if (dstLeft)
WriteColor(dstLeft, hdc->format, color);
for (x = 0; x < nWidth; x++)
{
BYTE* dstTop = gdi_get_bitmap_pointer(hdc, nXDst + x,
- nYDst);
+ nYDst);
BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x,
- nYDst + nHeight - 1);
+ nYDst + nHeight - 1);
if (dstTop)
WriteColor(dstTop, hdc->format, color);