mirror of https://github.com/FreeRDP/FreeRDP
Simplified bitmap drawing.
This commit is contained in:
parent
ec0d68bf4c
commit
867528015a
|
@ -124,63 +124,6 @@ static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
const BYTE* data, UINT32 width, UINT32 height, UINT32 bpp, UINT32 length,
|
||||
BOOL compressed, UINT32 codecId)
|
||||
{
|
||||
UINT16 size;
|
||||
const BYTE* pSrcData;
|
||||
BYTE* pDstData;
|
||||
UINT32 SrcSize;
|
||||
UINT32 SrcFormat;
|
||||
UINT32 bytesPerPixel;
|
||||
xfContext* xfc = (xfContext*) context;
|
||||
bytesPerPixel = (bpp + 7) / 8;
|
||||
size = width * height * 4;
|
||||
bitmap->data = (BYTE*) _aligned_malloc(size, 16);
|
||||
|
||||
if (!bitmap->data)
|
||||
return FALSE;
|
||||
|
||||
pSrcData = data;
|
||||
SrcSize = (UINT32) length;
|
||||
pDstData = bitmap->data;
|
||||
|
||||
if (compressed)
|
||||
{
|
||||
if (bpp < 32)
|
||||
{
|
||||
if (!interleaved_decompress(context->codecs->interleaved,
|
||||
pSrcData, SrcSize, width, height, bpp,
|
||||
pDstData, xfc->format,
|
||||
0, 0, 0, bitmap->width, bitmap->height,
|
||||
&context->gdi->palette))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,
|
||||
width, height,
|
||||
pDstData, xfc->format, 0, 0, 0, bitmap->width, bitmap->height, TRUE))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SrcFormat = gdi_get_pixel_format(bpp, TRUE);
|
||||
|
||||
if (!freerdp_image_copy(pDstData, xfc->format, 0, 0, 0,
|
||||
width, height, pSrcData,
|
||||
SrcFormat, 0, 0, 0, &context->gdi->palette))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bitmap->compressed = FALSE;
|
||||
bitmap->length = size;
|
||||
bitmap->format = xfc->format;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
|
||||
BOOL primary)
|
||||
{
|
||||
|
@ -461,33 +404,26 @@ BOOL xf_register_pointer(rdpGraphics* graphics)
|
|||
|
||||
BOOL xf_register_graphics(rdpGraphics* graphics)
|
||||
{
|
||||
rdpBitmap* bitmap = NULL;
|
||||
rdpGlyph* glyph = NULL;
|
||||
BOOL ret = FALSE;
|
||||
rdpBitmap bitmap;
|
||||
rdpGlyph glyph;
|
||||
|
||||
if (!(bitmap = (rdpBitmap*) calloc(1, sizeof(rdpBitmap))))
|
||||
goto out;
|
||||
if (!graphics || !graphics->Bitmap_Prototype || !graphics->Glyph_Prototype)
|
||||
return FALSE;
|
||||
|
||||
if (!(glyph = (rdpGlyph*) calloc(1, sizeof(rdpGlyph))))
|
||||
goto out;
|
||||
|
||||
bitmap->size = sizeof(xfBitmap);
|
||||
bitmap->New = xf_Bitmap_New;
|
||||
bitmap->Free = xf_Bitmap_Free;
|
||||
bitmap->Paint = xf_Bitmap_Paint;
|
||||
bitmap->Decompress = xf_Bitmap_Decompress;
|
||||
bitmap->SetSurface = xf_Bitmap_SetSurface;
|
||||
graphics_register_bitmap(graphics, bitmap);
|
||||
glyph->size = sizeof(xfGlyph);
|
||||
glyph->New = xf_Glyph_New;
|
||||
glyph->Free = xf_Glyph_Free;
|
||||
glyph->Draw = xf_Glyph_Draw;
|
||||
glyph->BeginDraw = xf_Glyph_BeginDraw;
|
||||
glyph->EndDraw = xf_Glyph_EndDraw;
|
||||
graphics_register_glyph(graphics, glyph);
|
||||
ret = TRUE;
|
||||
out:
|
||||
free(bitmap);
|
||||
free(glyph);
|
||||
return ret;
|
||||
bitmap = *graphics->Bitmap_Prototype;
|
||||
glyph = *graphics->Glyph_Prototype;
|
||||
bitmap.size = sizeof(xfBitmap);
|
||||
bitmap.New = xf_Bitmap_New;
|
||||
bitmap.Free = xf_Bitmap_Free;
|
||||
bitmap.Paint = xf_Bitmap_Paint;
|
||||
bitmap.SetSurface = xf_Bitmap_SetSurface;
|
||||
graphics_register_bitmap(graphics, &bitmap);
|
||||
glyph.size = sizeof(xfGlyph);
|
||||
glyph.New = xf_Glyph_New;
|
||||
glyph.Free = xf_Glyph_Free;
|
||||
glyph.Draw = xf_Glyph_Draw;
|
||||
glyph.BeginDraw = xf_Glyph_BeginDraw;
|
||||
glyph.EndDraw = xf_Glyph_EndDraw;
|
||||
graphics_register_glyph(graphics, &glyph);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <freerdp/cache/bitmap.h>
|
||||
#include <freerdp/gdi/bitmap.h>
|
||||
|
||||
#include "../gdi/gdi.h"
|
||||
|
||||
#define TAG FREERDP_TAG("cache.bitmap")
|
||||
|
||||
static rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
|
||||
|
@ -236,53 +238,6 @@ static BOOL update_gdi_cache_bitmap_v3(rdpContext* context,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL update_gdi_bitmap_update(rdpContext* context,
|
||||
const BITMAP_UPDATE* bitmapUpdate)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
for (i = 0; i < bitmapUpdate->number; i++)
|
||||
{
|
||||
const BITMAP_DATA* bitmapData = &bitmapUpdate->rectangles[i];
|
||||
rdpBitmap* bitmap = Bitmap_Alloc(context);
|
||||
|
||||
if (!bitmap)
|
||||
return FALSE;
|
||||
|
||||
bitmap->format = gdi_get_pixel_format(bitmapData->bitsPerPixel, FALSE);
|
||||
bitmap->length = bitmapData->bitmapLength;
|
||||
bitmap->compressed = bitmapData->compressed;
|
||||
Bitmap_SetRectangle(bitmap,
|
||||
bitmapData->destLeft, bitmapData->destTop,
|
||||
bitmapData->destRight, bitmapData->destBottom);
|
||||
|
||||
if (!bitmap->Decompress(context, bitmap,
|
||||
bitmapData->bitmapDataStream, bitmapData->width, bitmapData->height,
|
||||
bitmapData->bitsPerPixel, bitmapData->bitmapLength,
|
||||
bitmapData->compressed, RDP_CODEC_ID_NONE))
|
||||
{
|
||||
bitmap->Free(context, bitmap);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!bitmap->New(context, bitmap))
|
||||
{
|
||||
bitmap->Free(context, bitmap);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!bitmap->Paint(context, bitmap))
|
||||
{
|
||||
bitmap->Free(context, bitmap);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bitmap->Free(context, bitmap);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
|
||||
UINT32 index)
|
||||
{
|
||||
|
@ -340,7 +295,7 @@ void bitmap_cache_register_callbacks(rdpUpdate* update)
|
|||
update->secondary->CacheBitmap = update_gdi_cache_bitmap;
|
||||
update->secondary->CacheBitmapV2 = update_gdi_cache_bitmap_v2;
|
||||
update->secondary->CacheBitmapV3 = update_gdi_cache_bitmap_v3;
|
||||
update->BitmapUpdate = update_gdi_bitmap_update;
|
||||
update->BitmapUpdate = gdi_bitmap_update;
|
||||
}
|
||||
|
||||
rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
|
||||
|
|
|
@ -48,8 +48,8 @@ static BOOL update_gdi_create_offscreen_bitmap(rdpContext* context,
|
|||
if (!bitmap)
|
||||
return FALSE;
|
||||
|
||||
bitmap->width = createOffscreenBitmap->cx;
|
||||
bitmap->height = createOffscreenBitmap->cy;
|
||||
Bitmap_SetDimensions(bitmap, createOffscreenBitmap->cx,
|
||||
createOffscreenBitmap->cy);
|
||||
|
||||
if (!bitmap->New(context, bitmap))
|
||||
{
|
||||
|
|
|
@ -76,8 +76,6 @@ BOOL Bitmap_SetRectangle(rdpBitmap* bitmap,
|
|||
bitmap->top = top;
|
||||
bitmap->right = right;
|
||||
bitmap->bottom = bottom;
|
||||
bitmap->width = bitmap->right - bitmap->left + 1;
|
||||
bitmap->height = bitmap->bottom - bitmap->top + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -471,8 +471,8 @@ void gdi_bitmap_free_ex(gdiBitmap* bitmap)
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL gdi_bitmap_update(rdpContext* context,
|
||||
const BITMAP_UPDATE* bitmapUpdate)
|
||||
BOOL gdi_bitmap_update(rdpContext* context,
|
||||
const BITMAP_UPDATE* bitmapUpdate)
|
||||
{
|
||||
UINT32 index;
|
||||
rdpGdi* gdi;
|
||||
|
@ -487,16 +487,14 @@ static BOOL gdi_bitmap_update(rdpContext* context,
|
|||
for (index = 0; index < bitmapUpdate->number; index++)
|
||||
{
|
||||
const BITMAP_DATA* bitmap = &(bitmapUpdate->rectangles[index]);
|
||||
const UINT32 nWidth = MIN(bitmap->destRight,
|
||||
gdi->width - 1) - bitmap->destLeft + 1; /* clip width */
|
||||
const UINT32 nHeight = MIN(bitmap->destBottom,
|
||||
gdi->height - 1) - bitmap->destTop + 1; /* clip height */
|
||||
rdpBitmap* bmp = Bitmap_Alloc(context);
|
||||
|
||||
if (!bmp)
|
||||
return FALSE;
|
||||
|
||||
Bitmap_SetDimensions(bmp, bitmap->width, bitmap->height);
|
||||
Bitmap_SetRectangle(bmp, bitmap->destLeft, bitmap->destTop, bitmap->destRight,
|
||||
bitmap->destBottom);
|
||||
|
||||
if (!bmp->Decompress(context, bmp, bitmap->bitmapDataStream,
|
||||
bitmap->width, bitmap->height, bitmap->bitsPerPixel,
|
||||
|
@ -513,20 +511,13 @@ static BOOL gdi_bitmap_update(rdpContext* context,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!freerdp_image_copy(gdi->primary_buffer, gdi->dstFormat, gdi->stride,
|
||||
bitmap->destLeft, bitmap->destTop, nWidth, nHeight,
|
||||
bmp->data, bmp->format, bmp->width * GetBytesPerPixel(bmp->format),
|
||||
0, 0, &gdi->palette))
|
||||
if (!bmp->Paint(context, bmp))
|
||||
{
|
||||
bmp->Free(context, bmp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bmp->Free(context, bmp);
|
||||
|
||||
if (!gdi_InvalidateRegion(gdi->primary->hdc, bitmap->destLeft, bitmap->destTop,
|
||||
nWidth, nHeight))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -22,7 +22,11 @@
|
|||
|
||||
#include "graphics.h"
|
||||
|
||||
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp, BYTE* data);
|
||||
BOOL gdi_bitmap_update(rdpContext* context,
|
||||
const BITMAP_UPDATE* bitmapUpdate);
|
||||
|
||||
gdiBitmap* gdi_bitmap_new_ex(rdpGdi* gdi, int width, int height, int bpp,
|
||||
BYTE* data);
|
||||
void gdi_bitmap_free_ex(gdiBitmap* gdi_bmp);
|
||||
|
||||
#endif /* __GDI_CORE_H */
|
||||
|
|
|
@ -313,7 +313,7 @@ static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
|
|||
if (!gdi->drawing || !gdi->drawing->hdc)
|
||||
return FALSE;
|
||||
|
||||
gdi_DeleteObject(gdi->drawing->hdc->brush);
|
||||
gdi_DeleteObject((HGDIOBJECT)gdi->drawing->hdc->brush);
|
||||
gdi_SetNullClipRgn(gdi->drawing->hdc);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -321,33 +321,21 @@ static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
|
|||
/* Graphics Module */
|
||||
BOOL gdi_register_graphics(rdpGraphics* graphics)
|
||||
{
|
||||
rdpBitmap* bitmap;
|
||||
rdpGlyph* glyph;
|
||||
bitmap = (rdpBitmap*) calloc(1, sizeof(rdpBitmap));
|
||||
|
||||
if (!bitmap)
|
||||
return FALSE;
|
||||
|
||||
bitmap->size = sizeof(gdiBitmap);
|
||||
bitmap->New = gdi_Bitmap_New;
|
||||
bitmap->Free = gdi_Bitmap_Free;
|
||||
bitmap->Paint = gdi_Bitmap_Paint;
|
||||
bitmap->Decompress = gdi_Bitmap_Decompress;
|
||||
bitmap->SetSurface = gdi_Bitmap_SetSurface;
|
||||
graphics_register_bitmap(graphics, bitmap);
|
||||
free(bitmap);
|
||||
glyph = (rdpGlyph*) calloc(1, sizeof(rdpGlyph));
|
||||
|
||||
if (!glyph)
|
||||
return FALSE;
|
||||
|
||||
glyph->size = sizeof(gdiGlyph);
|
||||
glyph->New = gdi_Glyph_New;
|
||||
glyph->Free = gdi_Glyph_Free;
|
||||
glyph->Draw = gdi_Glyph_Draw;
|
||||
glyph->BeginDraw = gdi_Glyph_BeginDraw;
|
||||
glyph->EndDraw = gdi_Glyph_EndDraw;
|
||||
graphics_register_glyph(graphics, glyph);
|
||||
free(glyph);
|
||||
rdpBitmap bitmap;
|
||||
rdpGlyph glyph;
|
||||
bitmap.size = sizeof(gdiBitmap);
|
||||
bitmap.New = gdi_Bitmap_New;
|
||||
bitmap.Free = gdi_Bitmap_Free;
|
||||
bitmap.Paint = gdi_Bitmap_Paint;
|
||||
bitmap.Decompress = gdi_Bitmap_Decompress;
|
||||
bitmap.SetSurface = gdi_Bitmap_SetSurface;
|
||||
graphics_register_bitmap(graphics, &bitmap);
|
||||
glyph.size = sizeof(gdiGlyph);
|
||||
glyph.New = gdi_Glyph_New;
|
||||
glyph.Free = gdi_Glyph_Free;
|
||||
glyph.Draw = gdi_Glyph_Draw;
|
||||
glyph.BeginDraw = gdi_Glyph_BeginDraw;
|
||||
glyph.EndDraw = gdi_Glyph_EndDraw;
|
||||
graphics_register_glyph(graphics, &glyph);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue