FREERDP_API UINT32 gdi_GetPixel(HGDI_DC hdc, UINT32 nXPos, UINT32 nYPos);
FREERDP_API UINT32 gdi_SetPixel(HGDI_DC hdc, UINT32 X, UINT32 Y,
- UINT32 crColor);
+ UINT32 crColor);
FREERDP_API BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y);
FREERDP_API HGDI_BITMAP gdi_CreateBitmap(UINT32 nWidth, UINT32 nHeight,
- UINT32 format, BYTE* data);
+ UINT32 format, BYTE* data);
FREERDP_API HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight,
- UINT32 format, UINT32 stride,
- BYTE* data, void (*fkt_free)(void*));
+ UINT32 format, UINT32 stride,
+ BYTE* data, void (*fkt_free)(void*));
FREERDP_API HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc,
- UINT32 nWidth, UINT32 nHeight);
+ UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc, DWORD rop);
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, DWORD rop,
+ const gdiPalette* palette);
typedef BOOL (*p_BitBlt)(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc, DWORD rop);
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, DWORD rop);
#ifdef __cplusplus
}
#define TAG FREERDP_TAG("cache.glyph")
+static rdpGlyph* glyph_cache_get(rdpGlyphCache* glyph_cache, UINT32 id,
+ UINT32 index);
+static void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index,
+ rdpGlyph* entry);
-static rdpGlyph* glyph_cache_get(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index);
-static void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGlyph* entry);
-
-static void* glyph_cache_fragment_get(rdpGlyphCache* glyph, UINT32 index, UINT32* count);
-static void glyph_cache_fragment_put(rdpGlyphCache* glyph, UINT32 index, UINT32 count, void* entry);
+static void* glyph_cache_fragment_get(rdpGlyphCache* glyph, UINT32 index,
+ UINT32* count);
+static void glyph_cache_fragment_put(rdpGlyphCache* glyph, UINT32 index,
+ UINT32 count, void* entry);
static void update_process_glyph(rdpContext* context, const BYTE* data,
- UINT32* index, UINT32* x, UINT32* y,
- UINT32 cacheId, UINT32 ulCharInc, UINT32 flAccel)
+ UINT32* index, UINT32* x, UINT32* y,
+ UINT32 cacheId, UINT32 ulCharInc, UINT32 flAccel)
{
UINT32 offset;
rdpGlyph* glyph;
UINT32 cacheIndex;
rdpGraphics* graphics;
rdpGlyphCache* glyph_cache;
-
graphics = context->graphics;
glyph_cache = context->cache->glyph;
-
cacheIndex = data[*index];
-
glyph = glyph_cache_get(glyph_cache, cacheId, cacheIndex);
if ((ulCharInc == 0) && (!(flAccel & SO_CHAR_INC_EQUAL_BM_BASE)))
}
}
-static BOOL update_process_glyph_fragments(rdpContext* context, const BYTE* data,
- UINT32 length, UINT32 cacheId,
- UINT32 ulCharInc, UINT32 flAccel,
- UINT32 bgcolor, UINT32 fgcolor,
- UINT32 x, UINT32 y,
- UINT32 bkX, UINT32 bkY,
- UINT32 bkWidth, UINT32 bkHeight,
- UINT32 opX, UINT32 opY,
- UINT32 opWidth, UINT32 opHeight,
- BOOL fOpRedundant)
+static BOOL update_process_glyph_fragments(rdpContext* context,
+ const BYTE* data,
+ UINT32 length, UINT32 cacheId,
+ UINT32 ulCharInc, UINT32 flAccel,
+ UINT32 bgcolor, UINT32 fgcolor,
+ UINT32 x, UINT32 y,
+ UINT32 bkX, UINT32 bkY,
+ UINT32 bkWidth, UINT32 bkHeight,
+ UINT32 opX, UINT32 opY,
+ UINT32 opWidth, UINT32 opHeight,
+ BOOL fOpRedundant)
{
UINT32 n;
UINT32 id;
BYTE* fragments;
rdpGraphics* graphics;
rdpGlyphCache* glyph_cache;
-
graphics = context->graphics;
glyph_cache = context->cache->glyph;
if (opWidth > 0 && opHeight > 0)
{
- if (!Glyph_BeginDraw(context, opX, opY, opWidth, opHeight, bgcolor, fgcolor, fOpRedundant))
+ if (!Glyph_BeginDraw(context, opX, opY, opWidth, opHeight, bgcolor, fgcolor,
+ fOpRedundant))
return FALSE;
}
else
{
if (fOpRedundant)
{
- if (!Glyph_BeginDraw(context, bkX, bkY, bkWidth, bkHeight, bgcolor, fgcolor, fOpRedundant))
+ if (!Glyph_BeginDraw(context, bkX, bkY, bkWidth, bkHeight, bgcolor, fgcolor,
+ fOpRedundant))
return FALSE;
}
else
switch (data[index])
{
case GLYPH_FRAGMENT_USE:
-
if (index + 2 > (int) length)
{
/* at least one byte need to follow */
{
for (n = 0; n < (int) size; n++)
{
- update_process_glyph(context, fragments, &n, &x, &y, cacheId, ulCharInc, flAccel);
+ update_process_glyph(context, fragments, &n, &x, &y, cacheId, ulCharInc,
+ flAccel);
}
/* Contrary to glyphs, the offset is added after the fragment. */
length -= index;
data = &(data[index]);
index = 0;
-
break;
case GLYPH_FRAGMENT_ADD:
-
if (index + 3 > (int) length)
{
/* at least two bytes need to follow */
id = data[index + 1];
size = data[index + 2];
-
fragments = (BYTE*) malloc(size);
+
if (!fragments)
return FALSE;
- CopyMemory(fragments, data, size);
+ CopyMemory(fragments, data, size);
glyph_cache_fragment_put(glyph_cache, id, size, fragments);
-
index += 3;
length -= index;
data = &(data[index]);
index = 0;
-
break;
default:
- update_process_glyph(context, data, &index, &x, &y, cacheId, ulCharInc, flAccel);
+ update_process_glyph(context, data, &index, &x, &y, cacheId, ulCharInc,
+ flAccel);
index++;
break;
}
}
static BOOL update_gdi_glyph_index(rdpContext* context,
- GLYPH_INDEX_ORDER* glyphIndex)
+ GLYPH_INDEX_ORDER* glyphIndex)
{
rdpGlyphCache* glyph_cache;
int bkWidth, bkHeight, opWidth, opHeight;
-
glyph_cache = context->cache->glyph;
-
bkWidth = glyphIndex->bkRight - glyphIndex->bkLeft;
opWidth = glyphIndex->opRight - glyphIndex->opLeft;
bkHeight = glyphIndex->bkBottom - glyphIndex->bkTop;
opHeight = glyphIndex->opBottom - glyphIndex->opTop;
-
- return update_process_glyph_fragments(context, glyphIndex->data, glyphIndex->cbData,
- glyphIndex->cacheId, glyphIndex->ulCharInc, glyphIndex->flAccel,
- glyphIndex->backColor, glyphIndex->foreColor, glyphIndex->x, glyphIndex->y,
- glyphIndex->bkLeft, glyphIndex->bkTop, bkWidth, bkHeight,
- glyphIndex->opLeft, glyphIndex->opTop, opWidth, opHeight,
- glyphIndex->fOpRedundant);
+ return update_process_glyph_fragments(context, glyphIndex->data,
+ glyphIndex->cbData,
+ glyphIndex->cacheId, glyphIndex->ulCharInc, glyphIndex->flAccel,
+ glyphIndex->backColor, glyphIndex->foreColor, glyphIndex->x, glyphIndex->y,
+ glyphIndex->bkLeft, glyphIndex->bkTop, bkWidth, bkHeight,
+ glyphIndex->opLeft, glyphIndex->opTop, opWidth, opHeight,
+ glyphIndex->fOpRedundant);
}
static BOOL update_gdi_fast_index(rdpContext* context,
- const FAST_INDEX_ORDER* fastIndex)
+ const FAST_INDEX_ORDER* fastIndex)
{
INT32 x, y;
INT32 opLeft, opTop;
INT32 opRight, opBottom;
rdpGlyphCache* glyph_cache;
-
glyph_cache = context->cache->glyph;
-
opLeft = fastIndex->opLeft;
opTop = fastIndex->opTop;
opRight = fastIndex->opRight;
if (opBottom == -32768)
{
- BYTE flags = (BYTE) (opTop & 0x0F);
+ BYTE flags = (BYTE)(opTop & 0x0F);
if (flags & 0x01)
opBottom = fastIndex->bkBottom;
+
if (flags & 0x02)
opRight = fastIndex->bkRight;
+
if (flags & 0x04)
opTop = fastIndex->bkTop;
+
if (flags & 0x08)
opLeft = fastIndex->bkLeft;
}
if (y == -32768)
y = fastIndex->bkTop;
- return update_process_glyph_fragments(context, fastIndex->data, fastIndex->cbData,
- fastIndex->cacheId, fastIndex->ulCharInc, fastIndex->flAccel,
- fastIndex->backColor, fastIndex->foreColor, x, y,
- fastIndex->bkLeft, fastIndex->bkTop,
- fastIndex->bkRight - fastIndex->bkLeft, fastIndex->bkBottom - fastIndex->bkTop,
- opLeft, opTop,
- opRight - opLeft, opBottom - opTop,
- FALSE);
+ return update_process_glyph_fragments(context, fastIndex->data,
+ fastIndex->cbData,
+ fastIndex->cacheId, fastIndex->ulCharInc, fastIndex->flAccel,
+ fastIndex->backColor, fastIndex->foreColor, x, y,
+ fastIndex->bkLeft, fastIndex->bkTop,
+ fastIndex->bkRight - fastIndex->bkLeft, fastIndex->bkBottom - fastIndex->bkTop,
+ opLeft, opTop,
+ opRight - opLeft, opBottom - opTop,
+ FALSE);
}
static BOOL update_gdi_fast_glyph(rdpContext* context,
- const FAST_GLYPH_ORDER* fastGlyph)
+ const FAST_GLYPH_ORDER* fastGlyph)
{
INT32 x, y;
rdpGlyph* glyph;
INT32 opRight, opBottom;
const GLYPH_DATA_V2* glyphData;
rdpCache* cache = context->cache;
-
opLeft = fastGlyph->opLeft;
opTop = fastGlyph->opTop;
opRight = fastGlyph->opRight;
if (opBottom == -32768)
{
- BYTE flags = (BYTE) (opTop & 0x0F);
+ BYTE flags = (BYTE)(opTop & 0x0F);
if (flags & 0x01)
opBottom = fastGlyph->bkBottom;
+
if (flags & 0x02)
opRight = fastGlyph->bkRight;
+
if (flags & 0x04)
opTop = fastGlyph->bkTop;
+
if (flags & 0x08)
opLeft = fastGlyph->bkLeft;
}
{
/* got option font that needs to go into cache */
glyphData = &fastGlyph->glyphData;
-
glyph = Glyph_Alloc(context);
+
if (!glyph)
return FALSE;
+
glyph->x = glyphData->x;
glyph->y = glyphData->y;
glyph->cx = glyphData->cx;
glyph->cy = glyphData->cy;
glyph->cb = glyphData->cb;
glyph->aj = malloc(glyphData->cb);
+
if (!glyph->aj)
goto error_aj;
+
CopyMemory(glyph->aj, glyphData->aj, glyph->cb);
if (!Glyph_New(context, glyph))
text_data[0] = fastGlyph->data[0];
text_data[1] = 0;
-
return update_process_glyph_fragments(context, text_data, 1,
- fastGlyph->cacheId, fastGlyph->ulCharInc, fastGlyph->flAccel,
- fastGlyph->backColor, fastGlyph->foreColor, x, y,
- fastGlyph->bkLeft, fastGlyph->bkTop,
- fastGlyph->bkRight - fastGlyph->bkLeft, fastGlyph->bkBottom - fastGlyph->bkTop,
- opLeft, opTop,
- opRight - opLeft, opBottom - opTop,
- FALSE);
-
+ fastGlyph->cacheId, fastGlyph->ulCharInc, fastGlyph->flAccel,
+ fastGlyph->backColor, fastGlyph->foreColor, x, y,
+ fastGlyph->bkLeft, fastGlyph->bkTop,
+ fastGlyph->bkRight - fastGlyph->bkLeft, fastGlyph->bkBottom - fastGlyph->bkTop,
+ opLeft, opTop,
+ opRight - opLeft, opBottom - opTop,
+ FALSE);
error_glyph_new:
free(glyph->aj);
glyph->aj = NULL;
}
static BOOL update_gdi_cache_glyph(rdpContext* context,
- const CACHE_GLYPH_ORDER* cacheGlyph)
+ const CACHE_GLYPH_ORDER* cacheGlyph)
{
UINT32 i;
rdpGlyph* glyph;
for (i = 0; i < cacheGlyph->cGlyphs; i++)
{
glyph_data = &cacheGlyph->glyphData[i];
-
glyph = Glyph_Alloc(context);
+
if (!glyph)
return FALSE;
glyph->cy = glyph_data->cy;
glyph->cb = glyph_data->cb;
glyph->aj = glyph_data->aj;
+
if (!Glyph_New(context, glyph))
{
Glyph_Free(context, glyph);
return FALSE;
}
- glyph_cache_put(cache->glyph, cacheGlyph->cacheId, glyph_data->cacheIndex, glyph);
+ glyph_cache_put(cache->glyph, cacheGlyph->cacheId, glyph_data->cacheIndex,
+ glyph);
}
+
return TRUE;
}
static BOOL update_gdi_cache_glyph_v2(rdpContext* context,
- const CACHE_GLYPH_V2_ORDER* cacheGlyphV2)
+ const CACHE_GLYPH_V2_ORDER* cacheGlyphV2)
{
UINT32 i;
rdpGlyph* glyph;
for (i = 0; i < cacheGlyphV2->cGlyphs; i++)
{
glyphData = &cacheGlyphV2->glyphData[i];
-
glyph = Glyph_Alloc(context);
+
if (!glyph)
{
/* TODO: cleanup perviosly allocated glyph memory in error case */
glyph->cb = glyphData->cb;
glyph->aj = glyphData->aj;
Glyph_New(context, glyph);
-
- glyph_cache_put(cache->glyph, cacheGlyphV2->cacheId, glyphData->cacheIndex, glyph);
+ glyph_cache_put(cache->glyph, cacheGlyphV2->cacheId, glyphData->cacheIndex,
+ glyph);
}
+
return TRUE;
}
rdpGlyph* glyph_cache_get(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index)
{
rdpGlyph* glyph;
-
WLog_DBG(TAG, "GlyphCacheGet: id: %d index: %d", id, index);
if (id > 9)
return glyph;
}
-void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyph* glyph)
+void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index,
+ rdpGlyph* glyph)
{
rdpGlyph* prevGlyph;
}
WLog_DBG(TAG, "GlyphCachePut: id: %d index: %d", id, index);
-
prevGlyph = glyphCache->glyphCache[id].entries[index];
if (prevGlyph)
glyphCache->glyphCache[id].entries[index] = glyph;
}
-void* glyph_cache_fragment_get(rdpGlyphCache* glyphCache, UINT32 index, UINT32* size)
+void* glyph_cache_fragment_get(rdpGlyphCache* glyphCache, UINT32 index,
+ UINT32* size)
{
void* fragment;
fragment = glyphCache->fragCache.entries[index].fragment;
*size = (BYTE) glyphCache->fragCache.entries[index].size;
-
WLog_DBG(TAG, "GlyphCacheFragmentGet: index: %d size: %d", index, *size);
if (!fragment)
return fragment;
}
-void glyph_cache_fragment_put(rdpGlyphCache* glyphCache, UINT32 index, UINT32 size, void* fragment)
+void glyph_cache_fragment_put(rdpGlyphCache* glyphCache, UINT32 index,
+ UINT32 size, void* fragment)
{
void* prevFragment;
}
WLog_DBG(TAG, "GlyphCacheFragmentPut: index: %d size: %d", index, size);
-
prevFragment = glyphCache->fragCache.entries[index].fragment;
-
glyphCache->fragCache.entries[index].fragment = fragment;
glyphCache->fragCache.entries[index].size = size;
-
free(prevFragment);
}
rdpGlyphCache* glyph_cache_new(rdpSettings* settings)
{
rdpGlyphCache* glyphCache;
-
glyphCache = (rdpGlyphCache*) calloc(1, sizeof(rdpGlyphCache));
if (glyphCache)
{
int i;
-
WLog_Init();
glyphCache->log = WLog_Get("com.freerdp.cache.glyph");
-
glyphCache->settings = settings;
glyphCache->context = ((freerdp*) settings->instance)->update->context;
for (i = 0; i < 10; i++)
{
glyphCache->glyphCache[i].number = settings->GlyphCache[i].cacheEntries;
- glyphCache->glyphCache[i].maxCellSize = settings->GlyphCache[i].cacheMaximumCellSize;
- glyphCache->glyphCache[i].entries = (rdpGlyph**) calloc(glyphCache->glyphCache[i].number, sizeof(rdpGlyph*));
+ glyphCache->glyphCache[i].maxCellSize =
+ settings->GlyphCache[i].cacheMaximumCellSize;
+ glyphCache->glyphCache[i].entries = (rdpGlyph**) calloc(
+ glyphCache->glyphCache[i].number, sizeof(rdpGlyph*));
}
glyphCache->fragCache.entries = calloc(256, sizeof(FRAGMENT_CACHE_ENTRY));
for (j = 0; j < (int) glyphCache->glyphCache[i].number; j++)
{
rdpGlyph* glyph;
-
glyph = glyphCache->glyphCache[i].entries[j];
if (glyph)
glyphCache->glyphCache[i].entries[j] = NULL;
}
}
+
free(glyphCache->glyphCache[i].entries);
glyphCache->glyphCache[i].entries = NULL;
}
}
BOOL freerdp_image_copy_from_monochrome(BYTE* pDstData, UINT32 DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight,
- const BYTE* pSrcData,
- UINT32 backColor, UINT32 foreColor,
- const gdiPalette* palette)
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight,
+ const BYTE* pSrcData,
+ UINT32 backColor, UINT32 foreColor,
+ const gdiPalette* palette)
{
UINT32 x, y;
BOOL vFlip;
*/
BOOL freerdp_image_copy_from_pointer_data(
- BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
- UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
- const BYTE* xorMask, UINT32 xorMaskLength,
- const BYTE* andMask, UINT32 andMaskLength,
- UINT32 xorBpp, const gdiPalette* palette)
+ BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
+ UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
+ const BYTE* xorMask, UINT32 xorMaskLength,
+ const BYTE* andMask, UINT32 andMaskLength,
+ UINT32 xorBpp, const gdiPalette* palette)
{
UINT32 x, y;
BOOL vFlip;
for (y = 0; y < nHeight; y++)
{
BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) +
- (nXDst * GetBytesPerPixel(DstFormat))];
+ (nXDst * GetBytesPerPixel(DstFormat))];
xorBit = andBit = 0x80;
if (!vFlip)
color = freerdp_image_inverted_pointer_color(x, y); /* inverted */
color = ConvertColor(color, PIXEL_FORMAT_ABGR32,
- DstFormat, palette);
+ DstFormat, palette);
WriteColor(pDstPixel, DstFormat, color);
pDstPixel += GetBytesPerPixel(DstFormat);
}
if (xorBpp == 8 && !palette)
{
WLog_ERR(TAG, "null palette in convertion from %d bpp to %d bpp",
- xorBpp, dstBitsPerPixel);
+ xorBpp, dstBitsPerPixel);
return -1;
}
for (y = 0; y < nHeight; y++)
{
BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) +
- (nXDst * GetBytesPerPixel(DstFormat))];
+ (nXDst * GetBytesPerPixel(DstFormat))];
andBit = 0x80;
if (!vFlip)
else if (xorBpp == 16)
{
xorPixel = ConvertColor(*(UINT16*)xorBits,
- PIXEL_FORMAT_RGB16,
- PIXEL_FORMAT_ARGB32,
- palette);
+ PIXEL_FORMAT_RGB16,
+ PIXEL_FORMAT_ARGB32,
+ palette);
}
else if (xorBpp == 8)
{
color = xorPixel;
color = ConvertColor(color, PIXEL_FORMAT_ARGB32, DstFormat,
- palette);
+ palette);
}
else
{
color = ConvertColor(xorPixel, PIXEL_FORMAT_ARGB32,
- DstFormat, palette);
+ DstFormat, palette);
}
WriteColor(pDstPixel, DstFormat, color);
}
WLog_ERR(TAG, "failed to convert from %d bpp to %d bpp",
- xorBpp, dstBitsPerPixel);
+ xorBpp, dstBitsPerPixel);
return -1;
}
+static BOOL overlapping(const BYTE* pDstData, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nDstStep, UINT32 dstBytesPerPixel,
+ const BYTE* pSrcData, UINT32 nXSrc, UINT32 nYSrc,
+ UINT32 nSrcStep, UINT32 srcBytesPerPixel,
+ UINT32 nWidth, UINT32 nHeight)
+{
+ const BYTE* pDstStart = &pDstData[nXDst * dstBytesPerPixel + nYDst * nDstStep];
+ const BYTE* pDstEnd = pDstStart + nHeight * nDstStep;
+ const BYTE* pSrcStart = &pSrcData[nXSrc * srcBytesPerPixel + nYSrc * nSrcStep];
+ const BYTE* pSrcEnd = pSrcStart + nHeight * nSrcStep;
+
+ if ((pDstStart >= pSrcStart) && (pDstStart <= pSrcEnd))
+ return TRUE;
+
+ if ((pDstEnd >= pSrcStart) && (pDstEnd <= pSrcEnd))
+ return TRUE;
+
+ return FALSE;
+}
BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
- INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight,
- const BYTE* pSrcData, DWORD SrcFormat,
- INT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
- const gdiPalette* palette)
+ INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight,
+ const BYTE* pSrcData, DWORD SrcFormat,
+ INT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
+ const gdiPalette* palette)
{
const UINT32 dstByte = GetBytesPerPixel(DstFormat);
const UINT32 srcByte = GetBytesPerPixel(SrcFormat);
if (vSrcHFlip || vDstHFlip)
{
WLog_ERR(TAG, "Horizontal flipping not supported! %s %s",
- GetColorFormatName(SrcFormat), GetColorFormatName(DstFormat));
+ GetColorFormatName(SrcFormat), GetColorFormatName(DstFormat));
return FALSE;
}
if (FREERDP_PIXEL_FORMAT_FLIP_MASKED(SrcFormat) ==
- FREERDP_PIXEL_FORMAT_FLIP_MASKED(DstFormat))
+ FREERDP_PIXEL_FORMAT_FLIP_MASKED(DstFormat))
{
INT32 y;
- if (pDstData == pSrcData)
+ if (overlapping(pDstData, nXDst, nYDst, nDstStep, dstByte,
+ pSrcData, nXSrc, nYSrc, nSrcStep, srcByte,
+ nWidth, nHeight))
{
/* Copy down */
- if (nYDst > nYSrc)
+ if (nYDst < nYSrc)
{
for (y = 0; y < nHeight; y++)
{
const BYTE* srcLine = &pSrcData[(y + nYSrc) *
- nSrcStep * srcVMultiplier +
- srcVOffset];
+ nSrcStep * srcVMultiplier +
+ srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) *
- nDstStep * dstVMultiplier +
- dstVOffset];
-
+ nDstStep * dstVMultiplier +
+ dstVOffset];
memcpy(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth);
}
}
/* Copy up */
- else if (nYDst < nYSrc)
+ else if (nYDst > nYSrc)
{
for (y = nHeight - 1; y >= 0; y--)
{
const BYTE* srcLine = &pSrcData[(y + nYSrc) *
- nSrcStep * srcVMultiplier +
- srcVOffset];
+ nSrcStep * srcVMultiplier +
+ srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) *
- nDstStep * dstVMultiplier +
- dstVOffset];
-
+ nDstStep * dstVMultiplier +
+ dstVOffset];
memcpy(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth);
}
for (y = 0; y < nHeight; y++)
{
const BYTE* srcLine = &pSrcData[(y + nYSrc) *
- nSrcStep * srcVMultiplier +
- srcVOffset];
+ nSrcStep * srcVMultiplier +
+ srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) *
- nDstStep * dstVMultiplier +
- dstVOffset];
-
+ nDstStep * dstVMultiplier +
+ dstVOffset];
memmove(&dstLine[xDstOffset],
- &srcLine[xSrcOffset], copyDstWidth);
+ &srcLine[xSrcOffset], copyDstWidth);
}
}
/* Copy right */
for (y = nHeight - 1; y >= 0; y--)
{
const BYTE* srcLine = &pSrcData[(y + nYSrc) *
- nSrcStep * srcVMultiplier +
- srcVOffset];
+ nSrcStep * srcVMultiplier +
+ srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) *
- nDstStep * dstVMultiplier +
- dstVOffset];
-
- memove(&dstLine[xDstOffset],
- &srcLine[xSrcOffset], copyDstWidth);
+ nDstStep * dstVMultiplier +
+ dstVOffset];
+ memmove(&dstLine[xDstOffset],
+ &srcLine[xSrcOffset], copyDstWidth);
}
}
/* Source and destination are equal... */
else
{
-
}
}
- else if (nYDst < nYSrc)
+ else
{
for (y = 0; y < nHeight; y++)
{
const BYTE* srcLine = &pSrcData[(y + nYSrc) *
- nSrcStep * srcVMultiplier +
- srcVOffset];
+ nSrcStep * srcVMultiplier +
+ srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) *
- nDstStep * dstVMultiplier +
- dstVOffset];
-
+ nDstStep * dstVMultiplier +
+ dstVOffset];
memcpy(&dstLine[xDstOffset],
&srcLine[xSrcOffset], copyDstWidth);
}
for (y = 0; y < nHeight; y++)
{
const BYTE* srcLine = &pSrcData[(y + nYSrc) *
- nSrcStep * srcVMultiplier +
- srcVOffset];
+ nSrcStep * srcVMultiplier +
+ srcVOffset];
BYTE* dstLine = &pDstData[(y + nYDst) *
- nDstStep * dstVMultiplier + dstVOffset];
+ nDstStep * dstVMultiplier + dstVOffset];
for (x = 0; x < nWidth; x++)
{
UINT32 dstColor;
UINT32 color = ReadColor(&srcLine[(x + nXSrc) * srcByte],
- SrcFormat);
+ SrcFormat);
dstColor = ConvertColor(color, SrcFormat, DstFormat, palette);
WriteColor(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor);
}
}
BOOL freerdp_image_fill(BYTE* pDstData, DWORD DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, UINT32 color)
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight, UINT32 color)
{
UINT32 x, y;
#define TAG FREERDP_TAG("codec")
static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
- int nWidth, int nHeight)
+ int nWidth, int nHeight)
{
int x, y;
int cRawBytes;
}
static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
- BYTE* pDstData, INT32 nDstStep,
- UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight,
- UINT32 nChannel, BOOL vFlip)
+ BYTE* pDstData, INT32 nDstStep,
+ UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight,
+ UINT32 nChannel, BOOL vFlip)
{
UINT32 x, y;
BYTE* dstp;
}
static BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4],
- BYTE* pDstData, UINT32 DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
- BOOL alpha, BOOL vFlip)
+ BYTE* pDstData, UINT32 DstFormat,
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
+ BOOL alpha, BOOL vFlip)
{
INT32 x, y;
INT32 beg, end, inc;
for (y = beg; y != end; y += inc)
{
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
- DstFormat))];
+ DstFormat))];
for (x = 0; x < nWidth; x++)
{
for (y = beg; y != end; y += inc)
{
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
- DstFormat))];
+ DstFormat))];
for (x = 0; x < nWidth; x++)
{
}
INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
- const BYTE* pSrcData, UINT32 SrcSize,
- BYTE* pDstData, UINT32 DstFormat,
- UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
- UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
+ const BYTE* pSrcData, UINT32 SrcSize,
+ BYTE* pDstData, UINT32 DstFormat,
+ UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
+ UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
{
BOOL cs;
BOOL rle;
{
planes[3] = srcp;
rleSizes[3] = planar_skip_plane_rle(planes[3], SrcSize - (planes[3] - pSrcData),
- rawWidths[3], rawHeights[3]); /* AlphaPlane */
+ rawWidths[3], rawHeights[3]); /* AlphaPlane */
if (rleSizes[3] < 0)
return -1;
planes[0] = planes[3] + rleSizes[3];
rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData),
- rawWidths[0], rawHeights[0]); /* RedPlane */
+ rawWidths[0], rawHeights[0]); /* RedPlane */
if (rleSizes[0] < 0)
return -1;
planes[1] = planes[0] + rleSizes[0];
rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData),
- rawWidths[1], rawHeights[1]); /* GreenPlane */
+ rawWidths[1], rawHeights[1]); /* GreenPlane */
if (rleSizes[1] < 1)
return -1;
planes[2] = planes[1] + rleSizes[1];
rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData),
- rawWidths[2], rawHeights[2]); /* BluePlane */
+ rawWidths[2], rawHeights[2]); /* BluePlane */
if (rleSizes[2] < 1)
return -1;
{
planes[0] = srcp;
rleSizes[0] = planar_skip_plane_rle(planes[0], SrcSize - (planes[0] - pSrcData),
- rawWidths[0], rawHeights[0]); /* RedPlane */
+ rawWidths[0], rawHeights[0]); /* RedPlane */
if (rleSizes[0] < 0)
return -1;
planes[1] = planes[0] + rleSizes[0];
rleSizes[1] = planar_skip_plane_rle(planes[1], SrcSize - (planes[1] - pSrcData),
- rawWidths[1], rawHeights[1]); /* GreenPlane */
+ rawWidths[1], rawHeights[1]); /* GreenPlane */
if (rleSizes[1] < 1)
return -1;
planes[2] = planes[1] + rleSizes[1];
rleSizes[2] = planar_skip_plane_rle(planes[2], SrcSize - (planes[2] - pSrcData),
- rawWidths[2], rawHeights[2]); /* BluePlane */
+ rawWidths[2], rawHeights[2]); /* BluePlane */
if (rleSizes[2] < 1)
return -1;
if (alpha)
{
planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
+ nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
}
else /* NoAlpha */
{
planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
+ nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
}
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
- vFlip); /* AlphaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+ vFlip); /* AlphaPlane */
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* RedPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* RedPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* GreenPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* GreenPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* BluePlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* BluePlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
}
else /* NoAlpha */
{
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* RedPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* RedPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* GreenPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* GreenPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* BluePlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* BluePlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
}
if (pTempData != pDstData)
{
- freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight,
- pTempData,
- TempFormat, nTempStep, nXDst, nYDst, NULL);
+ if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth,
+ nHeight,
+ pTempData,
+ TempFormat, nTempStep, nXDst, nYDst, NULL))
+ return -1;
}
}
}
if (alpha)
{
planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
+ nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
}
else /* NoAlpha */
{
planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
- nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
+ nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
}
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
- vFlip); /* AlphaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 3,
+ vFlip); /* AlphaPlane */
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* LumaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* LumaPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* OrangeChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* OrangeChromaPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* GreenChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* GreenChromaPlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2] + rleSizes[3];
}
else /* NoAlpha */
{
status = planar_decompress_plane_rle(planes[0], rleSizes[0],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
- vFlip); /* LumaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 2,
+ vFlip); /* LumaPlane */
status = planar_decompress_plane_rle(planes[1], rleSizes[1],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
- vFlip); /* OrangeChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 1,
+ vFlip); /* OrangeChromaPlane */
status = planar_decompress_plane_rle(planes[2], rleSizes[2],
- pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
- vFlip); /* GreenChromaPlane */
+ pTempData, nTempStep, nXDst, nYDst, nWidth, nHeight, 0,
+ vFlip); /* GreenChromaPlane */
srcp += rleSizes[0] + rleSizes[1] + rleSizes[2];
}
}
prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, nDstStep,
- nWidth, nHeight, cll, alpha);
+ nWidth, nHeight, cll, alpha);
}
status = (SrcSize == (srcp - pSrcData)) ? 1 : -1;
}
static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
- UINT32 width, UINT32 height,
- UINT32 scanline, BYTE** planes)
+ UINT32 width, UINT32 height,
+ UINT32 scanline, BYTE** planes)
{
INT32 i, j, k;
UINT32* pixel;
for (j = 0; j < width; j++)
{
*pixel = GetColor(format, planes[1][k], planes[2][k],
- planes[3][k], planes[0][k]);
+ planes[3][k], planes[0][k]);
pixel++;
k++;
}
}
static UINT32 freerdp_bitmap_planar_write_rle_bytes(
- const BYTE* pInBuffer, UINT32 cRawBytes, UINT32 nRunLength,
- BYTE* pOutBuffer, UINT32 outBufferSize)
+ const BYTE* pInBuffer, UINT32 cRawBytes, UINT32 nRunLength,
+ BYTE* pOutBuffer, UINT32 outBufferSize)
{
const BYTE* pInput;
BYTE* pOutput;
}
static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
- UINT32 inBufferSize,
- BYTE* pOutBuffer,
- UINT32 outBufferSize)
+ UINT32 inBufferSize,
+ BYTE* pOutBuffer,
+ UINT32 outBufferSize)
{
BYTE symbol;
const BYTE* pInput;
{
pBytes = pInput - (cRawBytes + nRunLength + 1);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(
- pBytes, cRawBytes,
- nRunLength, pOutput,
- outBufferSize);
+ pBytes, cRawBytes,
+ nRunLength, pOutput,
+ outBufferSize);
nRunLength = 0;
if (!nBytesWritten || (nBytesWritten > outBufferSize))
{
pBytes = pInput - (cRawBytes + nRunLength);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes,
- cRawBytes, nRunLength, pOutput, outBufferSize);
+ cRawBytes, nRunLength, pOutput, outBufferSize);
if (!nBytesWritten)
return 0;
}
BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
- UINT32 width, UINT32 height,
- BYTE* outPlane, UINT32* dstSize)
+ UINT32 width, UINT32 height,
+ BYTE* outPlane, UINT32* dstSize)
{
UINT32 index;
const BYTE* pInput;
while (outBufferSize)
{
nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes(
- pInput, width, pOutput, outBufferSize);
+ pInput, width, pOutput, outBufferSize);
if ((!nBytesWritten) || (nBytesWritten > outBufferSize))
return NULL;
}
static UINT32 freerdp_bitmap_planar_compress_planes_rle(
- const BYTE** inPlanes, UINT32 width, UINT32 height,
- BYTE* outPlanes, UINT32* dstSizes, BOOL skipAlpha)
+ const BYTE** inPlanes, UINT32 width, UINT32 height,
+ BYTE* outPlanes, UINT32* dstSizes, BOOL skipAlpha)
{
UINT32 outPlanesSize = width * height * 4;
dstSizes[0] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(
- inPlanes[0], width, height, outPlanes, &dstSizes[0]))
+ inPlanes[0], width, height, outPlanes, &dstSizes[0]))
return 0;
outPlanes += dstSizes[0];
dstSizes[1] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height,
- outPlanes, &dstSizes[1]))
+ outPlanes, &dstSizes[1]))
return 0;
outPlanes += dstSizes[1];
dstSizes[2] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height,
- outPlanes, &dstSizes[2]))
+ outPlanes, &dstSizes[2]))
return 0;
outPlanes += dstSizes[2];
dstSizes[3] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height,
- outPlanes, &dstSizes[3]))
+ outPlanes, &dstSizes[3]))
return 0;
outPlanes += dstSizes[3];
}
BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
- UINT32 width, UINT32 height,
- BYTE* outPlane)
+ UINT32 width, UINT32 height,
+ BYTE* outPlane)
{
char s2c;
INT32 delta;
}
BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
- UINT32 width, UINT32 height,
- BYTE* outPlanes[4])
+ UINT32 width, UINT32 height,
+ BYTE* outPlanes[4])
{
UINT32 i;
for (i = 0; i < 4; i++)
{
outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(
- inPlanes[i], width, height, outPlanes[i]);
+ inPlanes[i], width, height, outPlanes[i]);
if (!outPlanes[i])
return FALSE;
}
BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
- const BYTE* data, UINT32 format,
- UINT32 width, UINT32 height, UINT32 scanline,
- BYTE* dstData, UINT32* pDstSize)
+ const BYTE* data, UINT32 format,
+ UINT32 width, UINT32 height, UINT32 scanline,
+ BYTE* dstData, UINT32* pDstSize)
{
UINT32 size;
BYTE* dstp;
planeSize = width * height;
if (!freerdp_split_color_planes(data, format, width, height, scanline,
- context->planes))
+ context->planes))
return NULL;
if (context->AllowRunLengthEncoding)
{
if (!freerdp_bitmap_planar_delta_encode_planes(
- (const BYTE**)context->planes, width, height,
- context->deltaPlanes))
+ (const BYTE**)context->planes, width, height,
+ context->deltaPlanes))
return NULL;;
if (freerdp_bitmap_planar_compress_planes_rle(
- (const BYTE**)context->deltaPlanes, width, height,
- context->rlePlanesBuffer, dstSizes,
- context->AllowSkipAlpha) > 0)
+ (const BYTE**)context->deltaPlanes, width, height,
+ context->rlePlanesBuffer, dstSizes,
+ context->AllowSkipAlpha) > 0)
{
int offset = 0;
FormatHeader |= PLANAR_FORMAT_HEADER_RLE;
}
BOOL freerdp_bitmap_planar_context_reset(
- BITMAP_PLANAR_CONTEXT* context, UINT32 width, UINT32 height)
+ BITMAP_PLANAR_CONTEXT* context, UINT32 width, UINT32 height)
{
if (!context)
return FALSE;
context->maxHeight = height;
context->maxPlaneSize = context->maxWidth * context->maxHeight;
context->nTempStep = context->maxWidth * 4;
-
context->planesBuffer = malloc(context->maxPlaneSize * 4);
context->pTempData = malloc(context->maxPlaneSize * 4);
context->deltaPlanesBuffer = malloc(context->maxPlaneSize * 4);
context->rlePlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->planesBuffer || !context->pTempData ||
- !context->deltaPlanesBuffer || !context->rlePlanesBuffer)
+ !context->deltaPlanesBuffer || !context->rlePlanesBuffer)
return FALSE;
context->planes[0] = &context->planesBuffer[context->maxPlaneSize * 0];
context->planes[1] = &context->planesBuffer[context->maxPlaneSize * 1];
context->planes[2] = &context->planesBuffer[context->maxPlaneSize * 2];
context->planes[3] = &context->planesBuffer[context->maxPlaneSize * 3];
-
-
context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 0];
+ 0];
context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 1];
+ 1];
context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 2];
+ 2];
context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize *
- 3];
-
+ 3];
return TRUE;
}
BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(
- DWORD flags, UINT32 maxWidth, UINT32 maxHeight)
+ DWORD flags, UINT32 maxWidth, UINT32 maxHeight)
{
BITMAP_PLANAR_CONTEXT* context;
context = (BITMAP_PLANAR_CONTEXT*) calloc(1, sizeof(BITMAP_PLANAR_CONTEXT));
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId)
{
+ INT32 rc = 1;
UINT status;
const BYTE* block;
const BYTE* blocks;
nHeight = updateRects[j].bottom - updateRects[j].top;
nXSrc = updateRects[j].left - (nXDst + tile->x);
nYSrc = updateRects[j].top - (nYDst + tile->y);
- freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
- nWidth, nHeight, tile->data, PIXEL_FORMAT_XRGB32,
- 64 * 4, nXSrc, nYSrc, NULL);
+
+ if (!freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
+ nWidth, nHeight, tile->data, PIXEL_FORMAT_XRGB32,
+ 64 * 4, nXSrc, nYSrc, NULL))
+ {
+ rc = -42;
+ break;
+ }
}
region16_uninit(&updateRegion);
}
region16_uninit(&clippingRects);
- return 1;
+ return rc;
}
int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData,
{
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
BYTE* data = &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * GetBytesPerPixel(
- hBmp->format)]);
+ hBmp->format)]);
return ReadColor(data, hBmp->format);
}
*/
static INLINE UINT32 gdi_SetPixelBmp(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y,
- UINT32 crColor)
+ UINT32 crColor)
{
BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * GetBytesPerPixel(
- hBmp->format)];
+ hBmp->format)];
WriteColor(p, hBmp->format, crColor);
return crColor;
}
*/
HGDI_BITMAP gdi_CreateBitmap(UINT32 nWidth, UINT32 nHeight, UINT32 format,
- BYTE* data)
+ BYTE* data)
{
return gdi_CreateBitmapEx(nWidth, nHeight, format, 0, data, _aligned_free);
}
HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight, UINT32 format,
- UINT32 stride, BYTE* data, void (*fkt_free)(void*))
+ UINT32 stride, BYTE* data, void (*fkt_free)(void*))
{
HGDI_BITMAP hBitmap = (HGDI_BITMAP) calloc(1, sizeof(GDI_BITMAP));
*/
HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, UINT32 nWidth,
- UINT32 nHeight)
+ UINT32 nHeight)
{
HGDI_BITMAP hBitmap = (HGDI_BITMAP) calloc(1, sizeof(GDI_BITMAP));
hBitmap->width = nWidth;
hBitmap->height = nHeight;
hBitmap->data = _aligned_malloc(nWidth * nHeight * GetBytesPerPixel(
- hBitmap->format), 16);
+ hBitmap->format), 16);
hBitmap->free = _aligned_free;
if (!hBitmap->data)
}
static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
- INT32 y;
- BYTE* srcp;
- BYTE* dstp;
+ HGDI_BITMAP hSrcBmp;
+ HGDI_BITMAP hDstBmp;
if (!hdcDest || !hdcSrc)
return FALSE;
- if (hdcDest->format != hdcSrc->format)
- {
- WLog_ERR(TAG, "Function does not support color conversion!");
- return FALSE;
- }
-
if ((nHeight == 0) || (nWidth == 0))
return TRUE;
- if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
- !gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc))
- {
- for (y = 0; y < nHeight; y++)
- {
- srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
- dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
-
- if (srcp != 0 && dstp != 0)
- memmove(dstp, srcp, nWidth * GetBytesPerPixel(hdcDest->format));
- }
-
- return TRUE;
- }
-
- if (nYSrc < nYDest)
- {
- /* copy down (bottom to top) */
- for (y = nHeight - 1; y >= 0; y--)
- {
- srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
- dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
+ hSrcBmp = (HGDI_BITMAP) hdcSrc->selectedObject;
+ hDstBmp = (HGDI_BITMAP) hdcDest->selectedObject;
- if (srcp != 0 && dstp != 0)
- memmove(dstp, srcp, nWidth * GetBytesPerPixel(hdcDest->format));
- }
- }
- else
- {
- /* copy straight right */
- for (y = 0; y < nHeight; y++)
- {
- srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
- dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
-
- if (srcp != 0 && dstp != 0)
- memmove(dstp, srcp, nWidth * GetBytesPerPixel(hdcDest->format));
- }
- }
+ if (!freerdp_image_copy(hDstBmp->data, hDstBmp->format, hDstBmp->scanline,
+ nXDest, nYDest, nWidth, nHeight,
+ hSrcBmp->data, hSrcBmp->format, hSrcBmp->scanline,
+ nXSrc, nYSrc, palette))
+ return FALSE;
return TRUE;
}
static BOOL BitBlt_NOTSRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color = ReadColor(srcp, hdcSrc->format);
- color = ConvertColor(color, hdcSrc->format, hdcDest->format, NULL);
+ color = ConvertColor(color, hdcSrc->format, hdcDest->format,
+ palette);
color = ~color;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
UINT32 color;
-
- colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, NULL);
+ colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format,
+ palette);
color = colorA & ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = ~colorA & ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = colorA ^ colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = colorA & colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_SRCPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = colorA | colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
UINT32 color;
for (y = 0; y < nHeight; y++)
{
- for (x = 0; x<nWidth; x++)
+ for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = (colorA & color) | (~colorA & colorB);
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (y = 0; y < nHeight; y++)
{
- for (x = 0; x<nWidth; x++)
+ for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = (colorA & colorB) | (~colorA & colorC);
WriteColor(dstp, hdcDest->format, color);
}
{
for (y = 0; y < nHeight; y++)
{
- for (x = 0; x<nWidth; x++)
+ for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
UINT32 colorC = ReadColor(patp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = (colorA & colorB) | (~colorA & colorC);
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (y = 0; y < nHeight; y++)
{
- for (x = 0; x<nWidth; x++)
+ for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 colorD;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
colorD = colorA ^ (color & (colorB ^ colorA));
WriteColor(dstp, hdcDest->format, color);
}
{
for (y = 0; y < nHeight; y++)
{
- for (x = 0; x<nWidth; x++)
+ for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
UINT32 color = ReadColor(patp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
colorD = colorA ^ (color & (colorB ^ colorA));
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_SPna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(patp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
+ hdcDest->format, palette);
color = colorA & ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
+
if (srcp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
-
+ hdcDest->format, palette);
color = ~colorA & colorB;
WriteColor(dstp, hdcDest->format, color);
}
static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
- hdcSrc, nXSrc + x, nYSrc + y);
+ hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(
- hdcDest, nXDest + x, nYDest + y);
+ hdcDest, nXDest + x, nYDest + y);
if (srcp && patp && dstp)
{
UINT32 color;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(patp, hdcDest->format);
-
colorA = ConvertColor(colorA, hdcSrc->format,
- hdcDest->format, NULL);
+ hdcDest->format, palette);
color = colorA & colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
static BOOL BitBlt_MERGEPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette)
{
UINT32 x, y;
UINT32 colorA = ReadColor(srcp, hdcSrc->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
UINT32 color;
-
- colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format, NULL);
+ colorA = ConvertColor(colorA, hdcSrc->format, hdcDest->format,
+ palette);
color = ~colorA | colorB;
WriteColor(dstp, hdcDest->format, color);
}
* @return 0 on failure, non-zero otherwise
*/
BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc, DWORD rop)
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc, DWORD rop, const gdiPalette* palette)
{
if (!hdcDest)
return FALSE;
+ if (gdi_PatBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, rop))
+ return TRUE;
+
if (hdcSrc != NULL)
{
- if (!gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc))
+ if (!gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc,
+ &nYSrc))
return TRUE;
}
else
switch (rop)
{
- case GDI_BLACKNESS:
- return BitBlt_BLACKNESS(hdcDest, nXDest, nYDest, nWidth, nHeight);
-
- case GDI_WHITENESS:
- return BitBlt_WHITENESS(hdcDest, nXDest, nYDest, nWidth, nHeight);
-
case GDI_SRCCOPY:
- return BitBlt_SRCCOPY(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SRCCOPY(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_SPna:
- return BitBlt_SPna(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SPna(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_DSna:
- return BitBlt_DSna(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_DSna(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_DSPDxax:
- return BitBlt_DSPDxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_DSPDxax(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_PSDPxax:
- return BitBlt_PSDPxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_PSDPxax(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_SPDSxax:
- return BitBlt_SPDSxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SPDSxax(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_NOTSRCCOPY:
- return BitBlt_NOTSRCCOPY(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
-
- case GDI_DSTINVERT:
- return BitBlt_DSTINVERT(hdcDest, nXDest, nYDest, nWidth, nHeight);
+ return BitBlt_NOTSRCCOPY(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_SRCERASE:
- return BitBlt_SRCERASE(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SRCERASE(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_NOTSRCERASE:
- return BitBlt_NOTSRCERASE(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_NOTSRCERASE(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_SRCINVERT:
- return BitBlt_SRCINVERT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SRCINVERT(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_SRCAND:
- return BitBlt_SRCAND(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SRCAND(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_SRCPAINT:
- return BitBlt_SRCPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_SRCPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_MERGECOPY:
- return BitBlt_MERGECOPY(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ return BitBlt_MERGECOPY(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
case GDI_MERGEPAINT:
- return BitBlt_MERGEPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
-
- case GDI_PATCOPY:
- return BitBlt_PATCOPY(hdcDest, nXDest, nYDest, nWidth, nHeight);
-
- case GDI_PATINVERT:
- return BitBlt_PATINVERT(hdcDest, nXDest, nYDest, nWidth, nHeight);
+ return BitBlt_MERGEPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight,
+ hdcSrc, nXSrc, nYSrc, palette);
- case GDI_PATPAINT:
- return BitBlt_PATPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
+ default:
+ break;
}
WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop);
return TRUE;
}
-BOOL BitBlt_PATINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight)
+static BOOL BitBlt_PATINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+ UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
return TRUE;
}
-BOOL BitBlt_PATPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc)
+static BOOL BitBlt_PATPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+ UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
+ UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
return TRUE;
}
-BOOL BitBlt_PATCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight)
+static BOOL BitBlt_PATCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+ UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y, xOffset, yOffset;
return TRUE;
}
-BOOL BitBlt_DSTINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight)
+static BOOL BitBlt_DSTINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+ UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
return TRUE;
}
-BOOL BitBlt_BLACKNESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight)
+static BOOL BitBlt_BLACKNESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+ UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
UINT32 color = GetColor(hdcDest->format, 0, 0, 0, 0xFF);
return TRUE;
}
-BOOL BitBlt_WHITENESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight)
+static BOOL BitBlt_WHITENESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
+ UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
UINT32 color = GetColor(hdcDest->format, 0, 0, 0, 0);
break;
}
- WLog_ERR(TAG, "PatBlt: unknown rop: 0x%08X", rop);
return FALSE;
}
HGDI_BRUSH gdi_CreatePatternBrush(HGDI_BITMAP hbmp);
HGDI_BRUSH gdi_CreateHatchBrush(HGDI_BITMAP hbmp);
BOOL gdi_PatBlt(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft,
- UINT32 nWidth, UINT32 nHeight, DWORD rop);
-
-BOOL BitBlt_PATPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
- UINT32 nXSrc, UINT32 nYSrc);
-BOOL BitBlt_PATINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight);
-BOOL BitBlt_BLACKNESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight);
-BOOL BitBlt_WHITENESS(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight);
-BOOL BitBlt_PATCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight);
-BOOL BitBlt_DSTINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
- UINT32 nWidth, UINT32 nHeight);
+ UINT32 nWidth, UINT32 nHeight, DWORD rop);
#ifdef __cplusplus
}
#endif
typedef BOOL (*p_PatBlt)(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft,
- UINT32 nWidth, UINT32 nHeight, DWORD rop);
+ UINT32 nWidth, UINT32 nHeight, DWORD rop);
#endif /* FREERDP_GDI_BRUSH_H */
if (bitsPerPixel < 32)
{
status = interleaved_decompress(codecs->interleaved,
- pSrcData, SrcSize,
- bitsPerPixel,
- gdi->primary_buffer,
- gdi->dstFormat,
- gdi->stride, nXDst, nYDst,
- nWidth, nHeight,
- gdi->palette);
+ pSrcData, SrcSize,
+ bitsPerPixel,
+ gdi->primary_buffer,
+ gdi->dstFormat,
+ gdi->stride, nXDst, nYDst,
+ nWidth, nHeight,
+ &gdi->palette);
}
else
{
gdi->height - 1) - bitmap->destTop + 1; /* clip height */
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
- nXDst, nYDst, nWidth, nHeight,
- pSrcData, SrcFormat, nSrcStep,
- nXSrc, nYSrc, gdi->palette))
- return FALSE;
+ nXDst, nYDst, nWidth, nHeight,
+ pSrcData, SrcFormat, nSrcStep,
+ nXSrc, nYSrc, &gdi->palette))
+ return FALSE;
}
if (!gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst,
{
int index;
const PALETTE_ENTRY* pe;
- UINT32* palette32;
rdpGdi* gdi = context->gdi;
- palette32 = (UINT32*) gdi->palette;
+ gdi->palette.format = gdi->dstFormat;
+ gdi->palette.format = gdi->dstFormat;
for (index = 0; index < (int) palette->number; index++)
{
pe = &(palette->entries[index]);
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
brush = &patblt->brush;
foreColor = ConvertColor(patblt->foreColor, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
backColor = ConvertColor(patblt->backColor, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
if (brush->style == GDI_BS_SOLID)
hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch);
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
- hatched, backColor, foreColor, gdi->palette);
+ hatched, backColor, foreColor, &gdi->palette);
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
if (!hBmp)
goto out_error;
}
- freerdp_image_copy(data, gdi->dstFormat, -1, 0, 0,
- 8, 8, brush->data, brushFormat, -1, 0, 0, gdi->palette);
+ if (!freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0,
+ 8, 8, brush->data, brushFormat, 0, 0, 0,
+ &gdi->palette))
+ {
+ ret = FALSE;
+ goto out_error;
+ }
}
else
{
}
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
- brush->data, backColor, foreColor, gdi->palette);
+ brush->data, backColor, foreColor, &gdi->palette);
}
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect,
opaque_rect->nWidth, opaque_rect->nHeight, &rect);
brush_color = ConvertColor(opaque_rect->color, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
if (!(hBrush = gdi_CreateSolidBrush(brush_color)))
return FALSE;
gdi_CRgnToRect(rectangle->left, rectangle->top,
rectangle->width, rectangle->height, &rect);
brush_color = ConvertColor(multi_opaque_rect->color, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
hBrush = gdi_CreateSolidBrush(brush_color);
if (!hBrush)
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
if (!(hPen = gdi_CreatePen(lineTo->penStyle, lineTo->penWidth, color,
- SrcFormat)))
+ SrcFormat, &gdi->palette)))
return FALSE;
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
color = polyline->penColor;
- if (!(hPen = gdi_CreatePen(GDI_PS_SOLID, 1, color, SrcFormat)))
+ if (!(hPen = gdi_CreatePen(GDI_PS_SOLID, 1, color, SrcFormat, &gdi->palette)))
return FALSE;
gdi_SelectObject(gdi->drawing->hdc, (HGDIOBJECT) hPen);
brush = &mem3blt->brush;
bitmap = (gdiBitmap*) mem3blt->bitmap;
foreColor = ConvertColor(mem3blt->foreColor, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
backColor = ConvertColor(mem3blt->backColor, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
originalColor = gdi_SetTextColor(gdi->drawing->hdc, foreColor);
if (brush->style == GDI_BS_SOLID)
}
freerdp_image_copy_from_monochrome(data, gdi->dstFormat, 0, 0, 0, 8, 8,
- brush->data, backColor, foreColor, gdi->palette);
+ brush->data, backColor, foreColor, &gdi->palette);
}
hBmp = gdi_CreateBitmap(8, 8, gdi->drawing->hdc->format, data);
r = solidFill->fillPixel.R;
a = solidFill->fillPixel.XA;
color = GetColor(PIXEL_FORMAT_ARGB32, r, g, b, a);
- color = ConvertColor(color, PIXEL_FORMAT_ARGB32, surface->format, NULL);
+ color = ConvertColor(color, PIXEL_FORMAT_ARGB32, surface->format,
+ &gdi->palette);
for (index = 0; index < solidFill->fillRectCount; index++)
{
pSrcData = data;
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
- freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
- nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, gdi->palette);
+
+ if (!freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
+ nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0,
+ &gdi->palette))
+ {
+ _aligned_free(pDstData);
+ return NULL;
+ }
+
bitmap = gdi_CreateBitmap(nWidth, nHeight, gdi->dstFormat, pDstData);
return bitmap;
}
if (bpp < 32)
{
status = interleaved_decompress(gdi->codecs->interleaved,
- pSrcData, SrcSize,
- bpp,
- pDstData, gdi->dstFormat,
- 0, 0, 0, width, height,
- gdi->palette);
+ pSrcData, SrcSize,
+ bpp,
+ pDstData, gdi->dstFormat,
+ 0, 0, 0, width, height,
+ &gdi->palette);
}
else
{
{
SrcFormat = gdi_get_pixel_format(bpp, FALSE);
status = freerdp_image_copy(pDstData, gdi->dstFormat, 0, 0, 0,
- width, height, pSrcData, SrcFormat,
- 0, 0, 0, gdi->palette);
+ width, height, pSrcData, SrcFormat,
+ 0, 0, 0, &gdi->palette);
}
bitmap->compressed = FALSE;
BOOL ret = FALSE;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
/* TODO: handle fOpRedundant! See xf_Glyph_BeginDraw() */
- bgcolor = ConvertColor(bgcolor, SrcFormat, gdi->dstFormat, gdi->palette);
- fgcolor = ConvertColor(fgcolor, SrcFormat, gdi->dstFormat, gdi->palette);
+ bgcolor = ConvertColor(bgcolor, SrcFormat, gdi->dstFormat, &gdi->palette);
+ fgcolor = ConvertColor(fgcolor, SrcFormat, gdi->dstFormat, &gdi->palette);
if (!(brush = gdi_CreateSolidBrush(fgcolor)))
goto out;
rdpGdi* gdi = context->gdi;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
bgcolor = ConvertColor(bgcolor, SrcFormat,
- gdi->dstFormat, gdi->palette);
+ gdi->dstFormat, &gdi->palette);
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
return TRUE;
}