Fixed color conversion, unified GFX and updated API.

This commit is contained in:
Armin Novak 2016-04-05 17:07:45 +02:00
parent bfdab0ed4a
commit df35c135d1
170 changed files with 9779 additions and 17874 deletions

View File

@ -5,6 +5,8 @@
* Copyright 2013-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2015 Thincast Technologies GmbH
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -586,7 +588,18 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
cmd.surfaceId = pdu.surfaceId;
cmd.codecId = pdu.codecId;
cmd.contextId = 0;
cmd.format = pdu.pixelFormat;
switch(pdu.pixelFormat)
{
case PIXEL_FORMAT_XRGB_8888:
cmd.format = PIXEL_FORMAT_BGRX32;
break;
case PIXEL_FORMAT_ARGB_8888:
cmd.format = PIXEL_FORMAT_BGRA32;
break;
default:
return ERROR_INVALID_DATA;
}
cmd.left = pdu.destRect.left;
cmd.top = pdu.destRect.top;
cmd.right = pdu.destRect.right;

View File

@ -1124,7 +1124,7 @@ public class SessionActivity extends ActionBarActivity implements
}
@Override
public int OnVerifiyChangedCertificate(String commonName, String subject, String issuer, String fingerprint, String oldSubject, String oldIssuer, String oldFingerprint) {
public int OnVerifyChangedCertificate(String commonName, String subject, String issuer, String fingerprint, String oldSubject, String oldIssuer, String oldFingerprint) {
// see if global settings says accept all
if (GlobalSettings.getAcceptAllCertificates())
return 0;

View File

@ -93,7 +93,7 @@ public class LibFreeRDP {
int OnVerifiyCertificate(String commonName, String subject,
String issuer, String fingerprint, boolean mismatch);
int OnVerifiyChangedCertificate(String commonName, String subject,
int OnVerifyChangedCertificate(String commonName, String subject,
String issuer, String fingerprint, String oldSubject,
String oldIssuer, String oldFingerprint);
@ -403,7 +403,7 @@ public class LibFreeRDP {
return 0;
}
private static int OnVerifyCertificate(int inst, String commonName, String subject,
private static int OnVerifyChangedCertificate(int inst, String commonName, String subject,
String issuer, String fingerprint, String oldSubject,
String oldIssuer, String oldFingerprint) {
SessionState s = GlobalApp.getSession(inst);
@ -411,7 +411,7 @@ public class LibFreeRDP {
return 0;
UIEventListener uiEventListener = s.getUIEventListener();
if (uiEventListener != null)
return uiEventListener.OnVerifiyChangedCertificate(commonName, subject, issuer,
return uiEventListener.OnVerifyChangedCertificate(commonName, subject, issuer,
fingerprint, oldSubject, oldIssuer, oldFingerprint);
return 0;
}

View File

@ -334,7 +334,7 @@ static BOOL android_pre_connect(freerdp* instance)
static BOOL android_post_connect(freerdp* instance)
{
UINT32 gdi_flags;
UINT32 gdi_format;
rdpSettings *settings;
if (!instance || !instance->settings || !instance->context || !instance->update)
@ -346,11 +346,11 @@ static BOOL android_post_connect(freerdp* instance)
return FALSE;
if (instance->settings->ColorDepth > 16)
gdi_flags = CLRBUF_32BPP | CLRCONV_ALPHA | CLRCONV_INVERT;
gdi_format = PIXEL_FORMAT_ARGB32;
else
gdi_flags = CLRBUF_16BPP;
gdi_format = PIXEL_FORMAT_RGB16;
if (!gdi_init(instance, gdi_flags, NULL))
if (!gdi_init(instance, gdi_format))
return FALSE;
instance->update->BeginPaint = android_begin_paint;
@ -916,7 +916,7 @@ static jboolean JNICALL jni_freerdp_update_graphics(
}
copy_pixel_buffer(pixels, gdi->primary_buffer, x, y, width, height,
gdi->width, gdi->height, gdi->bytesPerPixel);
gdi->width, gdi->height, GetBytesPerPixel(gdi->dstFormat));
if ((ret = AndroidBitmap_unlockPixels(env, bitmap)) < 0)
{

View File

@ -3,6 +3,8 @@
* FreeRDP Test UI
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -117,7 +119,7 @@ static BOOL tf_pre_connect(freerdp* instance)
static BOOL tf_post_connect(freerdp* instance)
{
if (!gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_16BPP | CLRBUF_32BPP, NULL))
if (!gdi_init(instance, PIXEL_FORMAT_XRGB32))
return FALSE;
instance->update->BeginPaint = tf_begin_paint;

View File

@ -3,6 +3,8 @@
* Wayland Client
*
* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -97,9 +99,9 @@ static BOOL wl_end_paint(rdpContext* context)
for (i = 0; i < h; i++)
{
memcpy(data + ((i+y)*(gdi->width*4)) + x*4,
gdi->primary_buffer + ((i+y)*(gdi->width*4)) + x*4,
w*4);
memcpy(data + ((i+y)*(gdi->width*GetBytesPerPixel(gdi->dstFormat))) + x*GetBytesPerPixel(gdi->dstFormat),
gdi->primary_buffer + ((i+y)*(gdi->width*GetBytesPerPixel(gdi->dstFormat))) + x*GetBytesPerPixel(gdi->dstFormat),
w*GetBytesPerPixel(gdi->dstFormat));
}
if (UwacWindowAddDamage(context_w->window, x, y, w, h) != UWAC_SUCCESS)
@ -132,7 +134,7 @@ static BOOL wl_post_connect(freerdp* instance)
UwacWindow* window;
wlfContext* context;
if (!gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, NULL))
if (!gdi_init(instance, PIXEL_FORMAT_ARGB32))
return FALSE;
gdi = instance->context->gdi;
@ -241,8 +243,8 @@ static int wlfreerdp_run(freerdp* instance)
if (!freerdp_connect(instance))
{
printf("Failed to connect\n");
return -1;
printf("Failed to connect\n");
return -1;
}
handle_uwac_events(instance, g_display);
@ -271,11 +273,11 @@ static int wlfreerdp_run(freerdp* instance)
}
//if (WaitForMultipleObjects(count, &handles[1], FALSE, INFINITE)) {
if (freerdp_check_event_handles(instance->context) != TRUE)
{
printf("Failed to check FreeRDP file descriptor\n");
break;
}
if (freerdp_check_event_handles(instance->context) != TRUE)
{
printf("Failed to check FreeRDP file descriptor\n");
break;
}
//}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@
* X11 GDI
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +28,7 @@
#include "xfreerdp.h"
void xf_gdi_register_update_callbacks(rdpUpdate* update);
BOOL xf_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate);
BOOL xf_gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate);
UINT32 xf_convert_rdp_order_color(xfContext* xfc, UINT32 color);
#endif /* __XF_GDI_H */

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@
* X11 Graphics Pipeline
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,21 +29,10 @@
struct xf_gfx_surface
{
UINT16 surfaceId;
rdpCodecs* codecs;
UINT32 width;
UINT32 height;
BOOL alpha;
BYTE* data;
gdiGfxSurface gdi;
BYTE* stage;
UINT32 stageScanline;
XImage* image;
int scanline;
int stageStep;
UINT32 format;
BOOL outputMapped;
UINT32 outputOriginX;
UINT32 outputOriginY;
REGION16 invalidRegion;
};
typedef struct xf_gfx_surface xfGfxSurface;
@ -50,14 +41,14 @@ struct xf_gfx_cache_entry
UINT64 cacheKey;
UINT32 width;
UINT32 height;
BOOL alpha;
BYTE* data;
int scanline;
UINT32 scanline;
UINT32 format;
};
typedef struct xf_gfx_cache_entry xfGfxCacheEntry;
int xf_OutputExpose(xfContext* xfc, int x, int y, int width, int height);
UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y,
UINT32 width, UINT32 height);
void xf_graphics_pipeline_init(xfContext* xfc, RdpgfxClientContext* gfx);
void xf_graphics_pipeline_uninit(xfContext* xfc, RdpgfxClientContext* gfx);

View File

@ -3,6 +3,8 @@
* X11 Graphical Objects
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,8 +43,7 @@
#define TAG CLIENT_TAG("x11")
/* Bitmap Class */
BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
int depth;
BYTE* data;
@ -73,7 +74,9 @@ BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
SrcFormat = gdi_get_pixel_format(bitmap->bpp, TRUE);
freerdp_image_copy(data, xfc->format, -1, 0, 0,
bitmap->width, bitmap->height, bitmap->data, SrcFormat, -1, 0, 0, xfc->palette);
bitmap->width, bitmap->height,
bitmap->data, SrcFormat,
-1, 0, 0, xfc->palette);
_aligned_free(bitmap->data);
bitmap->data = data;
@ -82,7 +85,7 @@ BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
}
image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfc->scanline_pad, 0);
ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfc->scanline_pad, 0);
XPutImage(xfc->display, pixmap, xfc->gc, image, 0, 0, 0, 0, bitmap->width, bitmap->height);
@ -95,7 +98,7 @@ BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
return TRUE;
}
void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
static void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
{
xfContext* xfc = (xfContext*) context;
@ -107,7 +110,7 @@ void xf_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
xf_unlock_x11(xfc, FALSE);
}
BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
XImage* image;
int width, height;
@ -122,10 +125,10 @@ BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
XSetFunction(xfc->display, xfc->gc, GXcopy);
image = XCreateImage(xfc->display, xfc->visual, xfc->depth,
ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfc->scanline_pad, 0);
ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, xfc->scanline_pad, 0);
XPutImage(xfc->display, xfc->primary, xfc->gc,
image, 0, 0, bitmap->left, bitmap->top, width, height);
image, 0, 0, bitmap->left, bitmap->top, width, height);
XFree(image);
@ -135,13 +138,13 @@ BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
return TRUE;
}
BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
BYTE* data, int width, int height, int bpp, int length,
BOOL compressed, int codecId)
static BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
const BYTE* data, UINT32 width, UINT32 height, UINT32 bpp, UINT32 length,
BOOL compressed, UINT32 codecId)
{
int status;
UINT16 size;
BYTE* pSrcData;
const BYTE* pSrcData;
BYTE* pDstData;
UINT32 SrcSize;
UINT32 SrcFormat;
@ -168,8 +171,11 @@ BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
xfc->settings->DesktopHeight))
return FALSE;
status = interleaved_decompress(xfc->codecs->interleaved, pSrcData, SrcSize, bpp,
&pDstData, xfc->format, -1, 0, 0, width, height, xfc->palette);
status = interleaved_decompress(xfc->codecs->interleaved,
pSrcData, SrcSize, bpp,
pDstData, xfc->format,
-1, 0, 0, width, height,
xfc->palette);
}
else
{
@ -179,7 +185,7 @@ BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
return FALSE;
status = planar_decompress(xfc->codecs->planar, pSrcData, SrcSize,
&pDstData, xfc->format, -1, 0, 0, width, height, TRUE);
&pDstData, xfc->format, -1, 0, 0, width, height, TRUE);
}
if (status < 0)
@ -193,7 +199,8 @@ BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
SrcFormat = gdi_get_pixel_format(bpp, TRUE);
status = freerdp_image_copy(pDstData, xfc->format, -1, 0, 0,
width, height, pSrcData, SrcFormat, -1, 0, 0, xfc->palette);
width, height, pSrcData,
SrcFormat, -1, 0, 0, xfc->palette);
}
bitmap->compressed = FALSE;
@ -202,7 +209,7 @@ BOOL xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
return TRUE;
}
BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
{
xfContext* xfc = (xfContext*) context;
@ -218,8 +225,7 @@ BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
}
/* Pointer Class */
BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
XcursorImage ci;
@ -242,11 +248,11 @@ BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
}
if (freerdp_image_copy_from_pointer_data(
(BYTE*) ci.pixels, PIXEL_FORMAT_ARGB32,
pointer->width * 4, 0, 0, pointer->width, pointer->height,
pointer->xorMaskData, pointer->lengthXorMask,
pointer->andMaskData, pointer->lengthAndMask,
pointer->xorBpp, xfc->palette) < 0)
(BYTE*) ci.pixels, xfc->format,
pointer->width * 4, 0, 0, pointer->width, pointer->height,
pointer->xorMaskData, pointer->lengthXorMask,
pointer->andMaskData, pointer->lengthAndMask,
pointer->xorBpp, xfc->palette) < 0)
{
free(ci.pixels);
xf_unlock_x11(xfc, FALSE);
@ -262,7 +268,7 @@ BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer)
return TRUE;
}
void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*) context;
@ -276,7 +282,8 @@ void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
#endif
}
BOOL xf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
static BOOL xf_Pointer_Set(rdpContext* context,
const rdpPointer* pointer)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*) context;
@ -295,7 +302,7 @@ BOOL xf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
return TRUE;
}
BOOL xf_Pointer_SetNull(rdpContext* context)
static BOOL xf_Pointer_SetNull(rdpContext* context)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*) context;
@ -326,7 +333,7 @@ BOOL xf_Pointer_SetNull(rdpContext* context)
return TRUE;
}
BOOL xf_Pointer_SetDefault(rdpContext* context)
static BOOL xf_Pointer_SetDefault(rdpContext* context)
{
#ifdef WITH_XCURSOR
xfContext* xfc = (xfContext*) context;
@ -343,7 +350,7 @@ BOOL xf_Pointer_SetDefault(rdpContext* context)
return TRUE;
}
BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
{
xfContext* xfc = (xfContext*) context;
XWindowAttributes current;
@ -375,8 +382,7 @@ out:
}
/* Glyph Class */
BOOL xf_Glyph_New(rdpContext* context, rdpGlyph* glyph)
static BOOL xf_Glyph_New(rdpContext* context, rdpGlyph* glyph)
{
int scanline;
XImage* image;
@ -392,7 +398,7 @@ BOOL xf_Glyph_New(rdpContext* context, rdpGlyph* glyph)
xf_glyph->pixmap = XCreatePixmap(xfc->display, xfc->drawing, glyph->cx, glyph->cy, 1);
image = XCreateImage(xfc->display, xfc->visual, 1,
ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline);
ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline);
image->byte_order = MSBFirst;
image->bitmap_bit_order = MSBFirst;
@ -405,7 +411,7 @@ BOOL xf_Glyph_New(rdpContext* context, rdpGlyph* glyph)
return TRUE;
}
void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
{
xfContext* xfc = (xfContext*) context;
@ -417,7 +423,7 @@ void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
xf_unlock_x11(xfc, FALSE);
}
BOOL xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
static BOOL xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x, UINT32 y)
{
xfGlyph* xf_glyph;
xfContext* xfc = (xfContext*) context;
@ -435,7 +441,9 @@ BOOL xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
return TRUE;
}
BOOL xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
static BOOL xf_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant)
{
xfContext* xfc = (xfContext*) context;
@ -462,7 +470,9 @@ BOOL xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height
return TRUE;
}
BOOL xf_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor)
static BOOL xf_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height,
UINT32 bgcolor, UINT32 fgcolor)
{
xfContext* xfc = (xfContext*) context;
BOOL ret = TRUE;

View File

@ -4,6 +4,8 @@
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2012 HP Development Company, LLC
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -590,7 +592,7 @@ void xf_SetWindowText(xfContext* xfc, xfAppWindow* appWindow, char* name)
Atom utf8Str = xfc->UTF8_STRING;
XChangeProperty(xfc->display, appWindow->handle, wm_Name, utf8Str, 8,
PropModeReplace, (unsigned char *)name, i);
PropModeReplace, (unsigned char *)name, i);
}
void xf_FixWindowCoordinates(xfContext* xfc, int* x, int* y, int* width, int* height)
@ -959,7 +961,8 @@ void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow, UINT32
}
void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, int width, int height)
void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y,
int width, int height)
{
int ax, ay;

View File

@ -3,6 +3,8 @@
* X11 Client
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Thincast Technologies GmbH
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -97,7 +99,6 @@ struct xf_context
rdpCodecs* codecs;
GC gc;
int bpp;
int xfds;
int depth;
int sessionWidth;
@ -135,15 +136,12 @@ struct xf_context
HANDLE mutex;
BOOL UseXThreads;
BOOL cursorHidden;
BYTE* palette;
BYTE palette_hwgdi[256 * 4];
UINT32* palette;
UINT32 palette_hwgdi[256];
HGDI_DC hdc;
UINT32 bitmap_size;
BYTE* bitmap_buffer;
BYTE* primary_buffer;
BOOL inGfxFrame;
BOOL graphicsReset;
BOOL frame_begin;
UINT16 frame_x1;

View File

@ -165,18 +165,30 @@ struct _DRAW_GDIPLUS_CACHE_END_ORDER
};
typedef struct _DRAW_GDIPLUS_CACHE_END_ORDER DRAW_GDIPLUS_CACHE_END_ORDER;
typedef BOOL (*pCreateOffscreenBitmap)(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
typedef BOOL (*pSwitchSurface)(rdpContext* context, SWITCH_SURFACE_ORDER* switch_surface);
typedef BOOL (*pCreateNineGridBitmap)(rdpContext* context, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap);
typedef BOOL (*pFrameMarker)(rdpContext* context, FRAME_MARKER_ORDER* frame_marker);
typedef BOOL (*pStreamBitmapFirst)(rdpContext* context, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first);
typedef BOOL (*pStreamBitmapNext)(rdpContext* context, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next);
typedef BOOL (*pDrawGdiPlusFirst)(rdpContext* context, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first);
typedef BOOL (*pDrawGdiPlusNext)(rdpContext* context, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next);
typedef BOOL (*pDrawGdiPlusEnd)(rdpContext* context, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end);
typedef BOOL (*pDrawGdiPlusCacheFirst)(rdpContext* context, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first);
typedef BOOL (*pDrawGdiPlusCacheNext)(rdpContext* context, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next);
typedef BOOL (*pDrawGdiPlusCacheEnd)(rdpContext* context, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end);
typedef BOOL (*pCreateOffscreenBitmap)(rdpContext* context,
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
typedef BOOL (*pSwitchSurface)(rdpContext* context,
const SWITCH_SURFACE_ORDER* switch_surface);
typedef BOOL (*pCreateNineGridBitmap)(rdpContext* context,
const CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap);
typedef BOOL (*pFrameMarker)(rdpContext* context,
const FRAME_MARKER_ORDER* frame_marker);
typedef BOOL (*pStreamBitmapFirst)(rdpContext* context,
const STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first);
typedef BOOL (*pStreamBitmapNext)(rdpContext* context,
const STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next);
typedef BOOL (*pDrawGdiPlusFirst)(rdpContext* context,
const DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first);
typedef BOOL (*pDrawGdiPlusNext)(rdpContext* context,
const DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next);
typedef BOOL (*pDrawGdiPlusEnd)(rdpContext* context,
const DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end);
typedef BOOL (*pDrawGdiPlusCacheFirst)(rdpContext* context,
const DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first);
typedef BOOL (*pDrawGdiPlusCacheNext)(rdpContext* context,
const DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next);
typedef BOOL (*pDrawGdiPlusCacheEnd)(rdpContext* context,
const DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end);
struct rdp_altsec_update
{

View File

@ -64,9 +64,6 @@ struct rdp_bitmap_cache
extern "C" {
#endif
FREERDP_API rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 index);
FREERDP_API void bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 index, rdpBitmap* bitmap);
FREERDP_API void bitmap_cache_register_callbacks(rdpUpdate* update);
FREERDP_API rdpBitmapCache* bitmap_cache_new(rdpSettings* settings);

View File

@ -61,8 +61,10 @@ struct rdp_brush_cache
extern "C" {
#endif
FREERDP_API void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp);
FREERDP_API void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp);
FREERDP_API void* brush_cache_get(rdpBrushCache* brush, UINT32 index,
UINT32* bpp);
FREERDP_API void brush_cache_put(rdpBrushCache* brush, UINT32 index,
void* entry, UINT32 bpp);
FREERDP_API void brush_cache_register_callbacks(rdpUpdate* update);

View File

@ -66,12 +66,6 @@ struct rdp_glyph_cache
extern "C" {
#endif
FREERDP_API rdpGlyph* glyph_cache_get(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index);
FREERDP_API void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGlyph* entry);
FREERDP_API void* glyph_cache_fragment_get(rdpGlyphCache* glyph, UINT32 index, UINT32* count);
FREERDP_API void glyph_cache_fragment_put(rdpGlyphCache* glyph, UINT32 index, UINT32 count, void* entry);
FREERDP_API void glyph_cache_register_callbacks(rdpUpdate* update);
FREERDP_API rdpGlyphCache* glyph_cache_new(rdpSettings* settings);

View File

@ -57,9 +57,6 @@ struct rdp_nine_grid_cache
extern "C" {
#endif
FREERDP_API void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index);
FREERDP_API void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index, void* entry);
FREERDP_API void nine_grid_cache_register_callbacks(rdpUpdate* update);
FREERDP_API rdpNineGridCache* nine_grid_cache_new(rdpSettings* settings);

View File

@ -49,8 +49,6 @@ extern "C" {
#endif
FREERDP_API rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreen_cache, UINT32 index);
FREERDP_API void offscreen_cache_put(rdpOffscreenCache* offscreen_cache, UINT32 index, rdpBitmap* bitmap);
FREERDP_API void offscreen_cache_delete(rdpOffscreenCache* offscreen, UINT32 index);
FREERDP_API void offscreen_cache_register_callbacks(rdpUpdate* update);

View File

@ -51,9 +51,6 @@ struct rdp_palette_cache
extern "C" {
#endif
FREERDP_API void* palette_cache_get(rdpPaletteCache* palette, UINT32 index);
FREERDP_API void palette_cache_put(rdpPaletteCache* palette, UINT32 index, void* entry);
FREERDP_API void palette_cache_register_callbacks(rdpUpdate* update);
FREERDP_API rdpPaletteCache* palette_cache_new(rdpSettings* settings);

View File

@ -35,7 +35,7 @@ typedef struct rdp_pointer_cache rdpPointerCache;
struct rdp_pointer_cache
{
UINT32 cacheSize; /* 0 */
rdpPointer** entries; /* 1 */
rdpPointer** entries; /* 1 */
/* internal */
@ -47,9 +47,6 @@ struct rdp_pointer_cache
extern "C" {
#endif
FREERDP_API rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index);
FREERDP_API void pointer_cache_put(rdpPointerCache* pointer_cache, UINT32 index, rdpPointer* pointer);
FREERDP_API void pointer_cache_register_callbacks(rdpUpdate* update);
FREERDP_API rdpPointerCache* pointer_cache_new(rdpSettings* settings);

View File

@ -30,22 +30,38 @@
typedef struct _rdpgfx_client_context RdpgfxClientContext;
typedef UINT (*pcRdpgfxResetGraphics)(RdpgfxClientContext* context, RDPGFX_RESET_GRAPHICS_PDU* resetGraphics);
typedef UINT (*pcRdpgfxStartFrame)(RdpgfxClientContext* context, RDPGFX_START_FRAME_PDU* startFrame);
typedef UINT (*pcRdpgfxEndFrame)(RdpgfxClientContext* context, RDPGFX_END_FRAME_PDU* endFrame);
typedef UINT (*pcRdpgfxSurfaceCommand)(RdpgfxClientContext* context, RDPGFX_SURFACE_COMMAND* cmd);
typedef UINT (*pcRdpgfxDeleteEncodingContext)(RdpgfxClientContext* context, RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext);
typedef UINT (*pcRdpgfxCreateSurface)(RdpgfxClientContext* context, RDPGFX_CREATE_SURFACE_PDU* createSurface);
typedef UINT (*pcRdpgfxDeleteSurface)(RdpgfxClientContext* context, RDPGFX_DELETE_SURFACE_PDU* deleteSurface);
typedef UINT (*pcRdpgfxSolidFill)(RdpgfxClientContext* context, RDPGFX_SOLID_FILL_PDU* solidFill);
typedef UINT (*pcRdpgfxSurfaceToSurface)(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface);
typedef UINT (*pcRdpgfxSurfaceToCache)(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache);
typedef UINT (*pcRdpgfxCacheToSurface)(RdpgfxClientContext* context, RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface);
typedef UINT (*pcRdpgfxCacheImportOffer)(RdpgfxClientContext* context, RDPGFX_CACHE_IMPORT_OFFER_PDU* cacheImportOffer);
typedef UINT (*pcRdpgfxCacheImportReply)(RdpgfxClientContext* context, RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply);
typedef UINT (*pcRdpgfxEvictCacheEntry)(RdpgfxClientContext* context, RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry);
typedef UINT (*pcRdpgfxMapSurfaceToOutput)(RdpgfxClientContext* context, RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput);
typedef UINT (*pcRdpgfxMapSurfaceToWindow)(RdpgfxClientContext* context, RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow);
typedef UINT (*pcRdpgfxResetGraphics)(RdpgfxClientContext* context,
const RDPGFX_RESET_GRAPHICS_PDU* resetGraphics);
typedef UINT (*pcRdpgfxStartFrame)(RdpgfxClientContext* context,
const RDPGFX_START_FRAME_PDU* startFrame);
typedef UINT (*pcRdpgfxEndFrame)(RdpgfxClientContext* context,
const RDPGFX_END_FRAME_PDU* endFrame);
typedef UINT (*pcRdpgfxSurfaceCommand)(RdpgfxClientContext* context,
const RDPGFX_SURFACE_COMMAND* cmd);
typedef UINT (*pcRdpgfxDeleteEncodingContext)(RdpgfxClientContext* context,
const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext);
typedef UINT (*pcRdpgfxCreateSurface)(RdpgfxClientContext* context,
const RDPGFX_CREATE_SURFACE_PDU* createSurface);
typedef UINT (*pcRdpgfxDeleteSurface)(RdpgfxClientContext* context,
const RDPGFX_DELETE_SURFACE_PDU* deleteSurface);
typedef UINT (*pcRdpgfxSolidFill)(RdpgfxClientContext* context,
const RDPGFX_SOLID_FILL_PDU* solidFill);
typedef UINT (*pcRdpgfxSurfaceToSurface)(RdpgfxClientContext* context,
const RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface);
typedef UINT (*pcRdpgfxSurfaceToCache)(RdpgfxClientContext* context,
const RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache);
typedef UINT (*pcRdpgfxCacheToSurface)(RdpgfxClientContext* context,
const RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface);
typedef UINT (*pcRdpgfxCacheImportOffer)(RdpgfxClientContext* context,
const RDPGFX_CACHE_IMPORT_OFFER_PDU* cacheImportOffer);
typedef UINT (*pcRdpgfxCacheImportReply)(RdpgfxClientContext* context,
const RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply);
typedef UINT (*pcRdpgfxEvictCacheEntry)(RdpgfxClientContext* context,
const RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry);
typedef UINT (*pcRdpgfxMapSurfaceToOutput)(RdpgfxClientContext* context,
const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput);
typedef UINT (*pcRdpgfxMapSurfaceToWindow)(RdpgfxClientContext* context,
const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow);
typedef UINT (*pcRdpgfxSetSurfaceData)(RdpgfxClientContext* context, UINT16 surfaceId, void* pData);
typedef void* (*pcRdpgfxGetSurfaceData)(RdpgfxClientContext* context, UINT16 surfaceId);
@ -53,6 +69,8 @@ typedef UINT (*pcRdpgfxGetSurfaceIds)(RdpgfxClientContext* context, UINT16** ppS
typedef UINT (*pcRdpgfxSetCacheSlotData)(RdpgfxClientContext* context, UINT16 cacheSlot, void* pData);
typedef void* (*pcRdpgfxGetCacheSlotData)(RdpgfxClientContext* context, UINT16 cacheSlot);
typedef UINT (*pcRdpgfxUpdateSurfaces)(RdpgfxClientContext* context);
struct _rdpgfx_client_context
{
void* handle;
@ -80,6 +98,8 @@ struct _rdpgfx_client_context
pcRdpgfxGetSurfaceData GetSurfaceData;
pcRdpgfxSetCacheSlotData SetCacheSlotData;
pcRdpgfxGetCacheSlotData GetCacheSlotData;
pcRdpgfxUpdateSurfaces UpdateSurfaces;
};
#endif /* FREERDP_CHANNEL_CLIENT_RDPGFX_H */

View File

@ -44,7 +44,7 @@ struct _CLEAR_VBAR_ENTRY
{
UINT32 size;
UINT32 count;
UINT32* pixels;
BYTE* pixels;
};
typedef struct _CLEAR_VBAR_ENTRY CLEAR_VBAR_ENTRY;
@ -55,6 +55,7 @@ struct _CLEAR_CONTEXT
UINT32 seqNumber;
BYTE* TempBuffer;
UINT32 TempSize;
UINT32 format;
CLEAR_GLYPH_ENTRY GlyphCache[4000];
UINT32 VBarStorageCursor;
CLEAR_VBAR_ENTRY VBarStorage[32768];
@ -68,8 +69,10 @@ extern "C" {
FREERDP_API int clear_compress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize);
FREERDP_API int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight);
FREERDP_API INT32 clear_decompress(CLEAR_CONTEXT* clear, const BYTE* pSrcData,
UINT32 SrcSize,
BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL clear_context_reset(CLEAR_CONTEXT* clear);

File diff suppressed because it is too large Load Diff

View File

@ -42,11 +42,20 @@ struct _BITMAP_INTERLEAVED_CONTEXT
extern "C" {
#endif
FREERDP_API int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcData, UINT32 SrcSize, int bpp,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BYTE* palette);
FREERDP_API INT32 interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
const BYTE* pSrcData, UINT32 SrcSize,
UINT32 bpp,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight,
const UINT32* palette);
FREERDP_API int interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pDstData, UINT32* pDstSize,
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette, int bpp);
FREERDP_API BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
BYTE* pDstData, UINT32* pDstSize,
UINT32 nWidth, UINT32 nHeight,
const BYTE* pSrcData, UINT32 SrcFormat,
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
const UINT32* palette, UINT32 bpp);
FREERDP_API BOOL bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT* interleaved);

View File

@ -4,6 +4,8 @@
*
* Copyright 2011 Samsung, Author Jiten Pathy
* Copyright 2012 Vic Lee
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,12 +35,12 @@ extern "C" {
struct _NSC_MESSAGE
{
int x;
int y;
UINT32 x;
UINT32 y;
UINT32 width;
UINT32 height;
BYTE* data;
int scanline;
const BYTE* data;
UINT32 scanline;
BYTE* PlaneBuffer;
UINT32 MaxPlaneSize;
BYTE* PlaneBuffers[5];
@ -60,12 +62,12 @@ typedef struct _NSC_CONTEXT NSC_CONTEXT;
struct _NSC_CONTEXT
{
UINT32 OrgByteCount[4];
UINT16 bpp;
UINT32 format;
UINT16 width;
UINT16 height;
BYTE* BitmapData;
UINT32 BitmapDataLength;
RDP_PIXEL_FORMAT pixel_format;
UINT32 pixel_format;
BYTE* Planes;
UINT32 PlaneByteCount[4];
@ -77,23 +79,32 @@ struct _NSC_CONTEXT
const BYTE* palette;
void (*decode)(NSC_CONTEXT* context);
void (*encode)(NSC_CONTEXT* context, BYTE* BitmapData, int rowstride);
void (*encode)(NSC_CONTEXT* context, const BYTE* BitmapData,
UINT32 rowstride);
NSC_CONTEXT_PRIV* priv;
};
FREERDP_API void nsc_context_set_pixel_format(NSC_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format);
FREERDP_API int nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
UINT16 width, UINT16 height, BYTE* data, UINT32 length);
FREERDP_API void nsc_compose_message(NSC_CONTEXT* context, wStream* s,
BYTE* bmpdata, int width, int height, int rowstride);
FREERDP_API BOOL nsc_context_set_pixel_format(NSC_CONTEXT* context,
UINT32 pixel_format);
FREERDP_API BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
UINT32 width, UINT32 height,
const BYTE* data, UINT32 length);
FREERDP_API BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s,
const BYTE* bmpdata,
UINT32 width, UINT32 height, UINT32 rowstride);
FREERDP_API NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, BYTE* data, int x, int y,
int width, int height, int scanline, int* numMessages, int maxDataSize);
FREERDP_API int nsc_write_message(NSC_CONTEXT* context, wStream* s, NSC_MESSAGE* message);
FREERDP_API int nsc_message_free(NSC_CONTEXT* context, NSC_MESSAGE* message);
FREERDP_API NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context,
const BYTE* data,
UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 scanline,
UINT32* numMessages, UINT32 maxDataSize);
FREERDP_API BOOL nsc_write_message(NSC_CONTEXT* context, wStream* s,
NSC_MESSAGE* message);
FREERDP_API void nsc_message_free(NSC_CONTEXT* context, NSC_MESSAGE* message);
FREERDP_API BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width, UINT32 height);
FREERDP_API BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width,
UINT32 height);
FREERDP_API NSC_CONTEXT* nsc_context_new(void);
FREERDP_API void nsc_context_free(NSC_CONTEXT* context);

View File

@ -3,6 +3,8 @@
* RDP6 Planar Codec
*
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -73,16 +75,16 @@ typedef struct _RDP6_BITMAP_STREAM RDP6_BITMAP_STREAM;
struct _BITMAP_PLANAR_CONTEXT
{
int maxWidth;
int maxHeight;
int maxPlaneSize;
UINT32 maxWidth;
UINT32 maxHeight;
UINT32 maxPlaneSize;
BOOL AllowSkipAlpha;
BOOL AllowRunLengthEncoding;
BOOL AllowColorSubsampling;
BOOL AllowDynamicColorFidelity;
int ColorLossLevel;
UINT32 ColorLossLevel;
BYTE* planes[4];
BYTE* planesBuffer;
@ -92,33 +94,43 @@ struct _BITMAP_PLANAR_CONTEXT
BYTE* rlePlanes[4];
BYTE* rlePlanesBuffer;
UINT32 TempSize;
BYTE* TempBuffer;
};
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
FREERDP_API int freerdp_split_color_planes(BYTE* data, UINT32 format, int width, int height, int scanline, BYTE* planes[4]);
FREERDP_API BYTE* freerdp_bitmap_planar_compress_plane_rle(BYTE* plane, int width, int height, BYTE* outPlane, int* dstSize);
FREERDP_API BYTE* freerdp_bitmap_planar_delta_encode_plane(BYTE* inPlane, int width, int height, BYTE* outPlane);
FREERDP_API BOOL freerdp_bitmap_planar_delta_encode_planes(BYTE* inPlanes[4], int width, int height, BYTE* outPlanes[4]);
FREERDP_API BYTE* freerdp_bitmap_planar_compress_plane_rle(
const BYTE* plane, UINT32 width, UINT32 height,
BYTE* outPlane, UINT32* dstSize);
FREERDP_API BYTE* freerdp_bitmap_planar_delta_encode_plane(
const BYTE* inPlane, UINT32 width, UINT32 height, BYTE* outPlane);
FREERDP_API BOOL freerdp_bitmap_planar_delta_encode_planes(
const BYTE* inPlanes[4], UINT32 width, UINT32 height,
BYTE* outPlanes[4]);
FREERDP_API BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data, UINT32 format,
int width, int height, int scanline, BYTE* dstData, int* pDstSize);
FREERDP_API BYTE* freerdp_bitmap_compress_planar(
BITMAP_PLANAR_CONTEXT* context,
const BYTE* data, UINT32 format,
UINT32 width, UINT32 height, UINT32 scanline,
BYTE* dstData, UINT32* pDstSize);
FREERDP_API BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context);
FREERDP_API BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT*
context);
FREERDP_API BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, int maxWidth, int maxHeight);
FREERDP_API void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context);
FREERDP_API BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(
DWORD flags, UINT32 maxWidth, UINT32 maxHeight);
FREERDP_API void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT*
context);
FREERDP_API int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BOOL vFlip);
FREERDP_API INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
const BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, UINT32 DstFormat,
INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, BOOL vFlip);
#ifdef __cplusplus
}
}
#endif
#endif /* FREERDP_CODEC_PLANAR_H */

View File

@ -116,10 +116,10 @@ struct _RFX_PROGRESSIVE_TILE
UINT16 cbLen;
UINT16 crLen;
UINT16 tailLen;
BYTE* yData;
BYTE* cbData;
BYTE* crData;
BYTE* tailData;
const BYTE* yData;
const BYTE* cbData;
const BYTE* crData;
const BYTE* tailData;
UINT16 ySrlLen;
UINT16 yRawLen;
@ -127,21 +127,21 @@ struct _RFX_PROGRESSIVE_TILE
UINT16 cbRawLen;
UINT16 crSrlLen;
UINT16 crRawLen;
BYTE* ySrlData;
BYTE* yRawData;
BYTE* cbSrlData;
BYTE* cbRawData;
BYTE* crSrlData;
BYTE* crRawData;
const BYTE* ySrlData;
const BYTE* yRawData;
const BYTE* cbSrlData;
const BYTE* cbRawData;
const BYTE* crSrlData;
const BYTE* crRawData;
int x;
int y;
int width;
int height;
UINT32 x;
UINT32 y;
UINT32 width;
UINT32 height;
BYTE* data;
BYTE* current;
int pass;
UINT16 pass;
BYTE* sign;
RFX_COMPONENT_CODEC_QUANT yBitPos;
RFX_COMPONENT_CODEC_QUANT cbBitPos;
@ -236,8 +236,11 @@ extern "C" {
FREERDP_API int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize);
FREERDP_API int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, UINT16 surfaceId);
FREERDP_API UINT progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
const BYTE* pSrcData, UINT32 SrcSize,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId);
FREERDP_API int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, UINT32 width, UINT32 height);
FREERDP_API int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId);

View File

@ -79,7 +79,7 @@ FREERDP_API int region16_n_rects(const REGION16 *region);
* @param nbRects if non-NULL returns the number of rectangles
* @return a pointer on the rectangles
*/
FREERDP_API const RECTANGLE_16 *region16_rects(const REGION16 *region, int *nbRects);
FREERDP_API const RECTANGLE_16 *region16_rects(const REGION16 *region, UINT32 *nbRects);
/** @return the extents rectangle of this region */
FREERDP_API const RECTANGLE_16 *region16_extents(const REGION16 *region);

View File

@ -3,6 +3,8 @@
* RemoteFX Codec
*
* Copyright 2011 Vic Lee
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,6 +31,7 @@ typedef struct _RFX_CONTEXT RFX_CONTEXT;
#include <freerdp/types.h>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/codec/region.h>
#include <winpr/stream.h>
@ -55,10 +58,10 @@ struct _RFX_TILE
{
UINT16 x;
UINT16 y;
int width;
int height;
UINT32 width;
UINT32 height;
BYTE* data;
int scanline;
UINT32 scanline;
BOOL allocated;
BYTE quantIdxY;
BYTE quantIdxCb;
@ -136,7 +139,7 @@ struct _RFX_CONTEXT
UINT32 version;
UINT32 codec_id;
UINT32 codec_version;
RDP_PIXEL_FORMAT pixel_format;
UINT32 pixel_format;
BYTE bits_per_pixel;
/* color palette allocated by the application */
@ -163,11 +166,18 @@ struct _RFX_CONTEXT
RFX_CONTEXT_PRIV* priv;
};
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format);
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context,
UINT32 pixel_format);
FREERDP_API int rfx_rlgr_decode(const BYTE* pSrcData, UINT32 SrcSize, INT16* pDstData, UINT32 DstSize, int mode);
FREERDP_API int rfx_rlgr_decode(const BYTE* pSrcData, UINT32 SrcSize,
INT16* pDstData, UINT32 DstSize, int mode);
FREERDP_API RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length);
FREERDP_API BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data,
UINT32 format, UINT32 length,
UINT32 left, UINT32 top,
BYTE* dst, UINT32 dstFormat,
UINT32 dstStride, UINT32 dstHeight,
REGION16* invalidRegion);
FREERDP_API UINT16 rfx_message_get_tile_count(RFX_MESSAGE* message);
FREERDP_API RFX_TILE* rfx_message_get_tile(RFX_MESSAGE* message, int index);
FREERDP_API UINT16 rfx_message_get_rect_count(RFX_MESSAGE* message);
@ -175,15 +185,21 @@ FREERDP_API RFX_RECT* rfx_message_get_rect(RFX_MESSAGE* message, int index);
FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message);
FREERDP_API BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s,
const RFX_RECT* rects, int num_rects, BYTE* image_data, int width, int height, int rowstride);
const RFX_RECT* rects, int num_rects, BYTE* image_data, int width, int height,
int rowstride);
FREERDP_API RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
int numRects, BYTE* data, int width, int height, int scanline);
FREERDP_API RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects, int numRects,
BYTE* data, int width, int height, int scanline, int* numMessages, int maxDataSize);
FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message);
FREERDP_API RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context,
const RFX_RECT* rects,
int numRects, BYTE* data, int width, int height, int scanline);
FREERDP_API RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context,
const RFX_RECT* rects, int numRects,
BYTE* data, int width, int height, int scanline, int* numMessages,
int maxDataSize);
FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s,
RFX_MESSAGE* message);
FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height);
FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width,
UINT32 height);
FREERDP_API RFX_CONTEXT* rfx_context_new(BOOL encoder);
FREERDP_API void rfx_context_free(RFX_CONTEXT* context);

View File

@ -32,22 +32,6 @@ enum RDP_CODEC_ID
RDP_CODEC_ID_IMAGE_REMOTEFX = 0x04
};
/**
* Pixel format
*/
enum RDP_PIXEL_FORMAT
{
RDP_PIXEL_FORMAT_B8G8R8A8,
RDP_PIXEL_FORMAT_R8G8B8A8,
RDP_PIXEL_FORMAT_B8G8R8,
RDP_PIXEL_FORMAT_R8G8B8,
RDP_PIXEL_FORMAT_B5G6R5_LE,
RDP_PIXEL_FORMAT_R5G6B5_LE,
RDP_PIXEL_FORMAT_P4_PLANER,
RDP_PIXEL_FORMAT_P8
};
typedef enum RDP_PIXEL_FORMAT RDP_PIXEL_FORMAT;
/**
* CPU Optimization flags
*/

View File

@ -1,44 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* GDI 16bpp Internal Buffer Routines
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_GDI_16BPP_H
#define FREERDP_GDI_16BPP_H
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
typedef BOOL (*pLineTo_16bpp)(HGDI_DC hdc, int nXEnd, int nYEnd);
#ifdef __cplusplus
extern "C" {
#endif
FREERDP_API UINT16 gdi_get_color_16bpp(HGDI_DC hdc, GDI_COLOR color);
FREERDP_API BOOL FillRect_16bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr);
FREERDP_API BOOL BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, DWORD rop);
FREERDP_API BOOL PatBlt_16bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD rop);
FREERDP_API BOOL LineTo_16bpp(HGDI_DC hdc, int nXEnd, int nYEnd);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_GDI_16BPP_H */

View File

@ -1,44 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* GDI 32bpp Internal Buffer Routines
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_GDI_32BPP_H
#define FREERDP_GDI_32BPP_H
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
typedef BOOL (*pLineTo_32bpp)(HGDI_DC hdc, int nXEnd, int nYEnd);
#ifdef __cplusplus
extern "C" {
#endif
FREERDP_API UINT32 gdi_get_color_32bpp(HGDI_DC hdc, GDI_COLOR color);
FREERDP_API BOOL FillRect_32bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr);
FREERDP_API BOOL BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, DWORD rop);
FREERDP_API BOOL PatBlt_32bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD rop);
FREERDP_API BOOL LineTo_32bpp(HGDI_DC hdc, int nXEnd, int nYEnd);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_GDI_32BPP_H */

View File

@ -1,44 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* GDI 8bpp Internal Buffer Routines
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_GDI_8BPP_H
#define FREERDP_GDI_8BPP_H
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
typedef BOOL (*pLineTo_8bpp)(HGDI_DC hdc, int nXEnd, int nYEnd);
#ifdef __cplusplus
extern "C" {
#endif
FREERDP_API BYTE gdi_get_color_8bpp(HGDI_DC hdc, GDI_COLOR color);
FREERDP_API BOOL FillRect_8bpp(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr);
FREERDP_API BOOL BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, DWORD rop);
FREERDP_API BOOL PatBlt_8bpp(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD rop);
FREERDP_API BOOL LineTo_8bpp(HGDI_DC hdc, int nXEnd, int nYEnd);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_GDI_8BPP_H */

View File

@ -3,6 +3,8 @@
* GDI Bitmap Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,31 +26,32 @@
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
FREERDP_API GDI_COLOR gdi_GetPixel(HGDI_DC hdc, int nXPos, int nYPos);
FREERDP_API GDI_COLOR gdi_SetPixel(HGDI_DC hdc, int X, int Y, GDI_COLOR crColor);
FREERDP_API BYTE gdi_GetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y);
FREERDP_API UINT16 gdi_GetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y);
FREERDP_API UINT32 gdi_GetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y);
FREERDP_API BYTE* gdi_GetPointer_8bpp(HGDI_BITMAP hBmp, int X, int Y);
FREERDP_API UINT16* gdi_GetPointer_16bpp(HGDI_BITMAP hBmp, int X, int Y);
FREERDP_API UINT32* gdi_GetPointer_32bpp(HGDI_BITMAP hBmp, int X, int Y);
FREERDP_API void gdi_SetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y, BYTE pixel);
FREERDP_API void gdi_SetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y, UINT16 pixel);
FREERDP_API void gdi_SetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y, UINT32 pixel);
FREERDP_API HGDI_BITMAP gdi_CreateBitmap(int nWidth, int nHeight, int cBitsPerPixel,
BYTE* data);
FREERDP_API HGDI_BITMAP gdi_CreateBitmapEx(int nWidth, int nHeight, int cBitsPerPixel,
BYTE* data, void (*fkt_free)(void*));
FREERDP_API HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, int nWidth, int nHeight);
FREERDP_API BOOL gdi_BitBlt(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, DWORD rop);
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);
FREERDP_API BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y);
typedef BOOL (*p_BitBlt)(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, DWORD rop);
FREERDP_API HGDI_BITMAP gdi_CreateBitmap(UINT32 nWidth, UINT32 nHeight,
UINT32 format, BYTE* data);
FREERDP_API HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight,
UINT32 format, UINT32 stride,
BYTE* data, void (*fkt_free)(void*));
FREERDP_API HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc,
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);
typedef BOOL (*p_BitBlt)(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc, DWORD rop);
#ifdef __cplusplus
}
}
#endif
#endif /* FREERDP_GDI_BITMAP_H */

View File

@ -1,41 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* GDI Brush Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_GDI_BRUSH_H
#define FREERDP_GDI_BRUSH_H
#include <freerdp/api.h>
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
extern "C" {
#endif
FREERDP_API HGDI_BRUSH gdi_CreateSolidBrush(GDI_COLOR crColor);
FREERDP_API HGDI_BRUSH gdi_CreatePatternBrush(HGDI_BITMAP hbmp);
FREERDP_API HGDI_BRUSH gdi_CreateHatchBrush(HGDI_BITMAP hbmp);
FREERDP_API BOOL gdi_PatBlt(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD rop);
#ifdef __cplusplus
}
#endif
typedef BOOL (*p_PatBlt)(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD rop);
#endif /* FREERDP_GDI_BRUSH_H */

View File

@ -3,6 +3,8 @@
* GDI Device Context Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,7 +30,7 @@
#endif
FREERDP_API HGDI_DC gdi_GetDC(void);
FREERDP_API HGDI_DC gdi_CreateDC(UINT32 flags, int bpp);
FREERDP_API HGDI_DC gdi_CreateDC(UINT32 format);
FREERDP_API HGDI_DC gdi_CreateCompatibleDC(HGDI_DC hdc);
FREERDP_API HGDIOBJECT gdi_SelectObject(HGDI_DC hdc, HGDIOBJECT hgdiobject);
FREERDP_API BOOL gdi_DeleteObject(HGDIOBJECT hgdiobject);

View File

@ -3,6 +3,8 @@
* GDI Library
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -142,17 +144,13 @@ struct _GDIOBJECT
typedef struct _GDIOBJECT GDIOBJECT;
typedef GDIOBJECT* HGDIOBJECT;
/* RGB encoded as 0x00BBGGRR */
typedef unsigned int GDI_COLOR;
typedef GDI_COLOR* LPGDI_COLOR;
struct _GDI_RECT
{
BYTE objectType;
int left;
int top;
int right;
int bottom;
UINT32 left;
UINT32 top;
UINT32 right;
UINT32 bottom;
};
typedef struct _GDI_RECT GDI_RECT;
typedef GDI_RECT* HGDI_RECT;
@ -160,11 +158,11 @@ typedef GDI_RECT* HGDI_RECT;
struct _GDI_RGN
{
BYTE objectType;
int x; /* left */
int y; /* top */
int w; /* width */
int h; /* height */
int null; /* null region */
UINT32 x; /* left */
UINT32 y; /* top */
UINT32 w; /* width */
UINT32 h; /* height */
BOOL null; /* null region */
};
typedef struct _GDI_RGN GDI_RGN;
typedef GDI_RGN* HGDI_RGN;
@ -172,13 +170,12 @@ typedef GDI_RGN* HGDI_RGN;
struct _GDI_BITMAP
{
BYTE objectType;
int bytesPerPixel;
int bitsPerPixel;
int width;
int height;
int scanline;
UINT32 format;
UINT32 width;
UINT32 height;
UINT32 scanline;
BYTE* data;
void (*free)(void *);
void (*free)(void*);
};
typedef struct _GDI_BITMAP GDI_BITMAP;
typedef GDI_BITMAP* HGDI_BITMAP;
@ -186,11 +183,12 @@ typedef GDI_BITMAP* HGDI_BITMAP;
struct _GDI_PEN
{
BYTE objectType;
int style;
int width;
int posX;
int posY;
GDI_COLOR color;
UINT32 style;
UINT32 width;
UINT32 posX;
UINT32 posY;
UINT32 color;
UINT32 format;
};
typedef struct _GDI_PEN GDI_PEN;
typedef GDI_PEN* HGDI_PEN;
@ -206,15 +204,15 @@ typedef struct _GDI_PALETTEENTRY GDI_PALETTEENTRY;
struct _GDI_PALETTE
{
UINT16 count;
GDI_PALETTEENTRY *entries;
GDI_PALETTEENTRY* entries;
};
typedef struct _GDI_PALETTE GDI_PALETTE;
typedef GDI_PALETTE* HGDI_PALETTE;
struct _GDI_POINT
{
int x;
int y;
UINT32 x;
UINT32 y;
};
typedef struct _GDI_POINT GDI_POINT;
typedef GDI_POINT* HGDI_POINT;
@ -224,17 +222,17 @@ struct _GDI_BRUSH
BYTE objectType;
int style;
HGDI_BITMAP pattern;
GDI_COLOR color;
int nXOrg;
int nYOrg;
UINT32 color;
UINT32 nXOrg;
UINT32 nYOrg;
};
typedef struct _GDI_BRUSH GDI_BRUSH;
typedef GDI_BRUSH* HGDI_BRUSH;
struct _GDI_WND
{
int count;
int ninvalid;
UINT32 count;
INT32 ninvalid;
HGDI_RGN invalid;
HGDI_RGN cinvalid;
};
@ -244,19 +242,15 @@ typedef GDI_WND* HGDI_WND;
struct _GDI_DC
{
HGDIOBJECT selectedObject;
int bytesPerPixel;
int bitsPerPixel;
GDI_COLOR bkColor;
GDI_COLOR textColor;
UINT32 format;
UINT32 bkColor;
UINT32 textColor;
HGDI_BRUSH brush;
HGDI_RGN clip;
HGDI_PEN pen;
HGDI_WND hwnd;
int drawMode;
int bkMode;
int alpha;
int invert;
int rgb555;
UINT32 drawMode;
UINT32 bkMode;
};
typedef struct _GDI_DC GDI_DC;
typedef GDI_DC* HGDI_DC;
@ -285,27 +279,24 @@ struct rdp_gdi
{
rdpContext* context;
int width;
int height;
int dstBpp;
int srcBpp;
int cursor_x;
int cursor_y;
int bytesPerPixel;
UINT32 width;
UINT32 height;
UINT32 stride;
UINT32 dstFormat;
UINT32 cursor_x;
UINT32 cursor_y;
rdpCodecs* codecs;
BOOL invert;
HGDI_DC hdc;
UINT32 format;
gdiBitmap* primary;
gdiBitmap* drawing;
UINT32 bitmap_size;
BYTE* bitmap_buffer;
BYTE* primary_buffer;
GDI_COLOR textColor;
BYTE palette[256 * 4];
gdiBitmap* tile;
UINT32 textColor;
UINT32 palette[256];
gdiBitmap* image;
void (*free)(void*);
BOOL inGfxFrame;
BOOL graphicsReset;
@ -322,9 +313,14 @@ FREERDP_API DWORD gdi_rop3_code(BYTE code);
FREERDP_API UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel, BOOL vFlip);
FREERDP_API BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y);
FREERDP_API BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y);
FREERDP_API BOOL gdi_resize(rdpGdi* gdi, int width, int height);
FREERDP_API BOOL gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer);
FREERDP_API BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height);
FREERDP_API BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
INT32 stride, INT32 format, BYTE* buffer,
void (*pfree)(void*));
FREERDP_API BOOL gdi_init(freerdp* instance, UINT32 format);
FREERDP_API BOOL gdi_init_ex(freerdp* instance, UINT32 format,
UINT32 stride, BYTE* buffer,
void (*pfree)(void*));
FREERDP_API void gdi_free(freerdp* instance);
#ifdef __cplusplus

View File

@ -29,9 +29,8 @@ struct gdi_gfx_surface
rdpCodecs* codecs;
UINT32 width;
UINT32 height;
BOOL alpha;
BYTE* data;
int scanline;
UINT32 scanline;
UINT32 format;
BOOL outputMapped;
UINT32 outputOriginX;
@ -45,9 +44,8 @@ struct gdi_gfx_cache_entry
UINT64 cacheKey;
UINT32 width;
UINT32 height;
BOOL alpha;
BYTE* data;
int scanline;
UINT32 scanline;
UINT32 format;
};
typedef struct gdi_gfx_cache_entry gdiGfxCacheEntry;

View File

@ -1,37 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* GDI Palette Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_GDI_PALETTE_H
#define FREERDP_GDI_PALETTE_H
#include <freerdp/api.h>
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
extern "C" {
#endif
FREERDP_API HGDI_PALETTE gdi_CreatePalette(HGDI_PALETTE palette);
FREERDP_API HGDI_PALETTE gdi_GetSystemPalette(void);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_GDI_PALETTE_H */

View File

@ -27,10 +27,9 @@
extern "C" {
#endif
FREERDP_API HGDI_PEN gdi_CreatePen(int fnPenStyle, int nWidth, int crColor);
FREERDP_API BYTE gdi_GetPenColor_8bpp(HGDI_PEN pen);
FREERDP_API UINT16 gdi_GetPenColor_16bpp(HGDI_PEN pen);
FREERDP_API UINT32 gdi_GetPenColor_32bpp(HGDI_PEN pen);
FREERDP_API HGDI_PEN gdi_CreatePen(UINT32 fnPenStyle, UINT32 nWidth,
UINT32 crColor, UINT32 format);
FREERDP_API UINT32 gdi_GetPenColor(HGDI_PEN pen, UINT32 format);
#ifdef __cplusplus
}

View File

@ -3,6 +3,8 @@
* GDI Region Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,24 +29,37 @@
extern "C" {
#endif
FREERDP_API HGDI_RGN gdi_CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
FREERDP_API HGDI_RECT gdi_CreateRect(int xLeft, int yTop, int xRight, int yBottom);
FREERDP_API HGDI_RGN gdi_CreateRectRgn(UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect);
FREERDP_API HGDI_RECT gdi_CreateRect(UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom);
FREERDP_API void gdi_RectToRgn(HGDI_RECT rect, HGDI_RGN rgn);
FREERDP_API void gdi_CRectToRgn(int left, int top, int right, int bottom, HGDI_RGN rgn);
FREERDP_API void gdi_RectToCRgn(HGDI_RECT rect, int *x, int *y, int *w, int *h);
FREERDP_API void gdi_CRectToCRgn(int left, int top, int right, int bottom, int *x, int *y, int *w, int *h);
FREERDP_API void gdi_CRectToRgn(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom, HGDI_RGN rgn);
FREERDP_API void gdi_RectToCRgn(const HGDI_RECT rect, UINT32 *x, UINT32 *y,
UINT32 *w, UINT32 *h);
FREERDP_API void gdi_CRectToCRgn(UINT32 left, UINT32 top,
UINT32 right, UINT32 bottom,
UINT32 *x, UINT32 *y, UINT32 *w, UINT32 *h);
FREERDP_API void gdi_RgnToRect(HGDI_RGN rgn, HGDI_RECT rect);
FREERDP_API void gdi_CRgnToRect(int x, int y, int w, int h, HGDI_RECT rect);
FREERDP_API void gdi_RgnToCRect(HGDI_RGN rgn, int *left, int *top, int *right, int *bottom);
FREERDP_API void gdi_CRgnToCRect(int x, int y, int w, int h, int *left, int *top, int *right, int *bottom);
FREERDP_API BOOL gdi_CopyOverlap(int x, int y, int width, int height, int srcx, int srcy);
FREERDP_API BOOL gdi_SetRect(HGDI_RECT rc, int xLeft, int yTop, int xRight, int yBottom);
FREERDP_API BOOL gdi_SetRgn(HGDI_RGN hRgn, int nXLeft, int nYLeft, int nWidth, int nHeight);
FREERDP_API BOOL gdi_SetRectRgn(HGDI_RGN hRgn, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
FREERDP_API void gdi_CRgnToRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h, HGDI_RECT rect);
FREERDP_API void gdi_RgnToCRect(HGDI_RGN rgn, UINT32 *left,
UINT32 *top, UINT32 *right, UINT32 *bottom);
FREERDP_API void gdi_CRgnToCRect(UINT32 x, UINT32 y, UINT32 w, UINT32 h,
UINT32 *left, UINT32 *top, UINT32 *right, UINT32 *bottom);
FREERDP_API BOOL gdi_CopyOverlap(UINT32 x, UINT32 y, UINT32 width, UINT32 height,
UINT32 srcx, UINT32 srcy);
FREERDP_API BOOL gdi_SetRect(HGDI_RECT rc, UINT32 xLeft, UINT32 yTop,
UINT32 xRight, UINT32 yBottom);
FREERDP_API BOOL gdi_SetRgn(HGDI_RGN hRgn, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight);
FREERDP_API BOOL gdi_SetRectRgn(HGDI_RGN hRgn, UINT32 nLeftRect, UINT32 nTopRect,
UINT32 nRightRect, UINT32 nBottomRect);
FREERDP_API BOOL gdi_EqualRgn(HGDI_RGN hSrcRgn1, HGDI_RGN hSrcRgn2);
FREERDP_API BOOL gdi_CopyRect(HGDI_RECT dst, HGDI_RECT src);
FREERDP_API BOOL gdi_PtInRect(HGDI_RECT rc, int x, int y);
FREERDP_API BOOL gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h);
FREERDP_API BOOL gdi_PtInRect(HGDI_RECT rc, UINT32 x, UINT32 y);
FREERDP_API BOOL gdi_InvalidateRegion(HGDI_DC hdc, UINT32 x, UINT32 y,
UINT32 w, UINT32 h);
#ifdef __cplusplus
}

View File

@ -28,7 +28,7 @@
#endif
FREERDP_API BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
FREERDP_API BOOL gdi_FillRect(HGDI_DC hdc, HGDI_RECT rect, HGDI_BRUSH hbr);
FREERDP_API BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr);
FREERDP_API BOOL gdi_Polygon(HGDI_DC hdc, GDI_POINT *lpPoints, int nCount);
FREERDP_API BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT *lpPoints, int *lpPolyCounts, int nCount);
FREERDP_API BOOL gdi_Rectangle(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);

View File

@ -3,6 +3,8 @@
* Graphical Objects
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,40 +36,40 @@ extern "C" {
#endif
/* Bitmap Class */
typedef BOOL (*pBitmap_New)(rdpContext* context, rdpBitmap* bitmap);
typedef void (*pBitmap_Free)(rdpContext* context, rdpBitmap* bitmap);
typedef BOOL (*pBitmap_Paint)(rdpContext* context, rdpBitmap* bitmap);
typedef BOOL (*pBitmap_Decompress)(rdpContext* context, rdpBitmap* bitmap,
BYTE* data, int width, int height, int bpp, int length,
BOOL compressed, int codec_id);
const BYTE* data, UINT32 width, UINT32 height,
UINT32 bpp, UINT32 length, BOOL compressed,
UINT32 codec_id);
typedef BOOL (*pBitmap_SetSurface)(rdpContext* context, rdpBitmap* bitmap, BOOL primary);
struct rdp_bitmap
{
size_t size; /* 0 */
pBitmap_New New; /* 1 */
pBitmap_Free Free; /* 2 */
pBitmap_Paint Paint; /* 3 */
pBitmap_Decompress Decompress; /* 4 */
pBitmap_SetSurface SetSurface; /* 5 */
UINT32 paddingA[16 - 6]; /* 6 */
size_t size; /* 0 */
pBitmap_New New; /* 1 */
pBitmap_Free Free; /* 2 */
pBitmap_Paint Paint; /* 3 */
pBitmap_Decompress Decompress; /* 4 */
pBitmap_SetSurface SetSurface; /* 5 */
UINT32 paddingA[16 - 6]; /* 6 */
UINT32 left; /* 16 */
UINT32 top; /* 17 */
UINT32 right; /* 18 */
UINT32 bottom; /* 19 */
UINT32 width; /* 20 */
UINT32 height; /* 21 */
UINT32 bpp; /* 22 */
UINT32 flags; /* 23 */
UINT32 length; /* 24 */
BYTE* data; /* 25 */
UINT32 paddingB[32 - 26]; /* 26 */
UINT32 left; /* 16 */
UINT32 top; /* 17 */
UINT32 right; /* 18 */
UINT32 bottom; /* 19 */
UINT32 width; /* 20 */
UINT32 height; /* 21 */
UINT32 bpp; /* 22 */
UINT32 flags; /* 23 */
UINT32 length; /* 24 */
BYTE* data; /* 25 */
UINT32 paddingB[32 - 26]; /* 26 */
BOOL compressed; /* 32 */
BOOL ephemeral; /* 33 */
UINT32 paddingC[64 - 34]; /* 34 */
BOOL compressed; /* 32 */
BOOL ephemeral; /* 33 */
UINT32 paddingC[64 - 34]; /* 34 */
};
FREERDP_API rdpBitmap* Bitmap_Alloc(rdpContext* context);
@ -75,9 +77,9 @@ FREERDP_API BOOL Bitmap_New(rdpContext* context, rdpBitmap* bitmap);
FREERDP_API void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap);
FREERDP_API BOOL Bitmap_Register(rdpContext* context, rdpBitmap* bitmap);
FREERDP_API BOOL Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
BYTE* data, int width, int height, int bpp, int length, BOOL compressed);
BYTE* data, int width, int height, int bpp, int length, BOOL compressed);
FREERDP_API void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap,
UINT16 left, UINT16 top, UINT16 right, UINT16 bottom);
UINT16 left, UINT16 top, UINT16 right, UINT16 bottom);
FREERDP_API void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, UINT16 width, UINT16 height);
FREERDP_API BOOL Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary);
@ -85,67 +87,69 @@ FREERDP_API BOOL Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL
typedef BOOL (*pPointer_New)(rdpContext* context, rdpPointer* pointer);
typedef void (*pPointer_Free)(rdpContext* context, rdpPointer* pointer);
typedef BOOL (*pPointer_Set)(rdpContext* context, rdpPointer* pointer);
typedef BOOL (*pPointer_Set)(rdpContext* context, const rdpPointer* pointer);
typedef BOOL (*pPointer_SetNull)(rdpContext* context);
typedef BOOL (*pPointer_SetDefault)(rdpContext* context);
typedef BOOL (*pPointer_SetPosition)(rdpContext* context, UINT32 x, UINT32 y);
struct rdp_pointer
{
size_t size; /* 0 */
pPointer_New New; /* 1 */
pPointer_Free Free; /* 2 */
pPointer_Set Set; /* 3 */
pPointer_SetNull SetNull; /* 4*/
pPointer_SetDefault SetDefault; /* 5 */
pPointer_SetPosition SetPosition; /* 6 */
UINT32 paddingA[16 - 7]; /* 7 */
size_t size; /* 0 */
pPointer_New New; /* 1 */
pPointer_Free Free; /* 2 */
pPointer_Set Set; /* 3 */
pPointer_SetNull SetNull; /* 4*/
pPointer_SetDefault SetDefault; /* 5 */
pPointer_SetPosition SetPosition; /* 6 */
UINT32 paddingA[16 - 7]; /* 7 */
UINT32 xPos; /* 16 */
UINT32 yPos; /* 17 */
UINT32 width; /* 18 */
UINT32 height; /* 19 */
UINT32 xorBpp; /* 20 */
UINT32 lengthAndMask; /* 21 */
UINT32 lengthXorMask; /* 22 */
BYTE* xorMaskData; /* 23 */
BYTE* andMaskData; /* 24 */
UINT32 paddingB[32 - 25]; /* 25 */
UINT32 xPos; /* 16 */
UINT32 yPos; /* 17 */
UINT32 width; /* 18 */
UINT32 height; /* 19 */
UINT32 xorBpp; /* 20 */
UINT32 lengthAndMask; /* 21 */
UINT32 lengthXorMask; /* 22 */
BYTE* xorMaskData; /* 23 */
BYTE* andMaskData; /* 24 */
UINT32 paddingB[32 - 25]; /* 25 */
};
FREERDP_API rdpPointer* Pointer_Alloc(rdpContext* context);
FREERDP_API BOOL Pointer_New(rdpContext* context, rdpPointer* pointer);
FREERDP_API void Pointer_Free(rdpContext* context, rdpPointer* pointer);
FREERDP_API BOOL Pointer_Set(rdpContext* context, rdpPointer* pointer);
FREERDP_API BOOL Pointer_Set(rdpContext* context, const rdpPointer* pointer);
FREERDP_API BOOL Pointer_SetNull(rdpContext* context);
FREERDP_API BOOL Pointer_SetDefault(rdpContext* context);
FREERDP_API BOOL Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y);
/* Glyph Class */
typedef BOOL (*pGlyph_New)(rdpContext* context, rdpGlyph* glyph);
typedef void (*pGlyph_Free)(rdpContext* context, rdpGlyph* glyph);
typedef BOOL (*pGlyph_Draw)(rdpContext* context, rdpGlyph* glyph, int x, int y);
typedef BOOL (*pGlyph_BeginDraw)(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant);
typedef BOOL (*pGlyph_EndDraw)(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor);
typedef BOOL (*pGlyph_Draw)(rdpContext* context, rdpGlyph* glyph, UINT32 x, UINT32 y);
typedef BOOL (*pGlyph_BeginDraw)(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant);
typedef BOOL (*pGlyph_EndDraw)(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor);
struct rdp_glyph
{
size_t size; /* 0 */
pGlyph_New New; /* 1 */
pGlyph_Free Free; /* 2 */
pGlyph_Draw Draw; /* 3 */
pGlyph_BeginDraw BeginDraw; /* 4 */
pGlyph_EndDraw EndDraw; /* 5 */
UINT32 paddingA[16 - 6]; /* 6 */
size_t size; /* 0 */
pGlyph_New New; /* 1 */
pGlyph_Free Free; /* 2 */
pGlyph_Draw Draw; /* 3 */
pGlyph_BeginDraw BeginDraw; /* 4 */
pGlyph_EndDraw EndDraw; /* 5 */
UINT32 paddingA[16 - 6]; /* 6 */
INT32 x; /* 16 */
INT32 y; /* 17 */
UINT32 cx; /* 18 */
UINT32 cy; /* 19 */
UINT32 cb; /* 20 */
BYTE* aj; /* 21 */
UINT32 paddingB[32 - 22]; /* 22 */
INT32 x; /* 16 */
INT32 y; /* 17 */
UINT32 cx; /* 18 */
UINT32 cy; /* 19 */
UINT32 cb; /* 20 */
BYTE* aj; /* 21 */
UINT32 paddingB[32 - 22]; /* 22 */
};
FREERDP_API rdpGlyph* Glyph_Alloc(rdpContext* context);
@ -159,11 +163,11 @@ FREERDP_API BOOL Glyph_EndDraw(rdpContext* context, int x, int y, int width, int
struct rdp_graphics
{
rdpContext* context; /* 0 */
rdpBitmap* Bitmap_Prototype; /* 1 */
rdpPointer* Pointer_Prototype; /* 2 */
rdpGlyph* Glyph_Prototype; /* 3 */
UINT32 paddingA[16 - 4]; /* 4 */
rdpContext* context; /* 0 */
rdpBitmap* Bitmap_Prototype; /* 1 */
rdpPointer* Pointer_Prototype; /* 2 */
rdpGlyph* Glyph_Prototype; /* 3 */
UINT32 paddingA[16 - 4]; /* 4 */
};
FREERDP_API void graphics_register_bitmap(rdpGraphics* graphics, rdpBitmap* bitmap);

View File

@ -71,11 +71,16 @@ struct _POINTER_CACHED_UPDATE
};
typedef struct _POINTER_CACHED_UPDATE POINTER_CACHED_UPDATE;
typedef BOOL (*pPointerPosition)(rdpContext* context, POINTER_POSITION_UPDATE* pointer_position);
typedef BOOL (*pPointerSystem)(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system);
typedef BOOL (*pPointerColor)(rdpContext* context, POINTER_COLOR_UPDATE* pointer_color);
typedef BOOL (*pPointerNew)(rdpContext* context, POINTER_NEW_UPDATE* pointer_new);
typedef BOOL (*pPointerCached)(rdpContext* context, POINTER_CACHED_UPDATE* pointer_cached);
typedef BOOL (*pPointerPosition)(rdpContext* context,
const POINTER_POSITION_UPDATE* pointer_position);
typedef BOOL (*pPointerSystem)(rdpContext* context,
const POINTER_SYSTEM_UPDATE* pointer_system);
typedef BOOL (*pPointerColor)(rdpContext* context,
const POINTER_COLOR_UPDATE* pointer_color);
typedef BOOL (*pPointerNew)(rdpContext* context,
const POINTER_NEW_UPDATE* pointer_new);
typedef BOOL (*pPointerCached)(rdpContext* context,
const POINTER_CACHED_UPDATE* pointer_cached);
struct rdp_pointer_update
{

View File

@ -438,28 +438,35 @@ struct _ELLIPSE_CB_ORDER
};
typedef struct _ELLIPSE_CB_ORDER ELLIPSE_CB_ORDER;
typedef BOOL (*pDstBlt)(rdpContext* context, DSTBLT_ORDER* dstblt);
typedef BOOL (*pDstBlt)(rdpContext* context, const DSTBLT_ORDER* dstblt);
typedef BOOL (*pPatBlt)(rdpContext* context, PATBLT_ORDER* patblt);
typedef BOOL (*pScrBlt)(rdpContext* context, SCRBLT_ORDER* scrblt);
typedef BOOL (*pOpaqueRect)(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect);
typedef BOOL (*pDrawNineGrid)(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid);
typedef BOOL (*pMultiDstBlt)(rdpContext* context, MULTI_DSTBLT_ORDER* multi_dstblt);
typedef BOOL (*pMultiPatBlt)(rdpContext* context, MULTI_PATBLT_ORDER* multi_patblt);
typedef BOOL (*pMultiScrBlt)(rdpContext* context, MULTI_SCRBLT_ORDER* multi_scrblt);
typedef BOOL (*pMultiOpaqueRect)(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect);
typedef BOOL (*pMultiDrawNineGrid)(rdpContext* context, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid);
typedef BOOL (*pLineTo)(rdpContext* context, LINE_TO_ORDER* line_to);
typedef BOOL (*pPolyline)(rdpContext* context, POLYLINE_ORDER* polyline);
typedef BOOL (*pScrBlt)(rdpContext* context, const SCRBLT_ORDER* scrblt);
typedef BOOL (*pOpaqueRect)(rdpContext* context,
const OPAQUE_RECT_ORDER* opaque_rect);
typedef BOOL (*pDrawNineGrid)(rdpContext* context,
const DRAW_NINE_GRID_ORDER* draw_nine_grid);
typedef BOOL (*pMultiDstBlt)(rdpContext* context,
const MULTI_DSTBLT_ORDER* multi_dstblt);
typedef BOOL (*pMultiPatBlt)(rdpContext* context,
const MULTI_PATBLT_ORDER* multi_patblt);
typedef BOOL (*pMultiScrBlt)(rdpContext* context,
const MULTI_SCRBLT_ORDER* multi_scrblt);
typedef BOOL (*pMultiOpaqueRect)(rdpContext* context,
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect);
typedef BOOL (*pMultiDrawNineGrid)(rdpContext* context,
const MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid);
typedef BOOL (*pLineTo)(rdpContext* context, const LINE_TO_ORDER* line_to);
typedef BOOL (*pPolyline)(rdpContext* context, const POLYLINE_ORDER* polyline);
typedef BOOL (*pMemBlt)(rdpContext* context, MEMBLT_ORDER* memblt);
typedef BOOL (*pMem3Blt)(rdpContext* context, MEM3BLT_ORDER* memblt);
typedef BOOL (*pSaveBitmap)(rdpContext* context, SAVE_BITMAP_ORDER* save_bitmap);
typedef BOOL (*pSaveBitmap)(rdpContext* context, const SAVE_BITMAP_ORDER* save_bitmap);
typedef BOOL (*pGlyphIndex)(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index);
typedef BOOL (*pFastIndex)(rdpContext* context, FAST_INDEX_ORDER* fast_index);
typedef BOOL (*pFastGlyph)(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph);
typedef BOOL (*pPolygonSC)(rdpContext* context, POLYGON_SC_ORDER* polygon_sc);
typedef BOOL (*pFastIndex)(rdpContext* context, const FAST_INDEX_ORDER* fast_index);
typedef BOOL (*pFastGlyph)(rdpContext* context, const FAST_GLYPH_ORDER* fast_glyph);
typedef BOOL (*pPolygonSC)(rdpContext* context, const POLYGON_SC_ORDER* polygon_sc);
typedef BOOL (*pPolygonCB)(rdpContext* context, POLYGON_CB_ORDER* polygon_cb);
typedef BOOL (*pEllipseSC)(rdpContext* context, ELLIPSE_SC_ORDER* ellipse_sc);
typedef BOOL (*pEllipseCB)(rdpContext* context, ELLIPSE_CB_ORDER* ellipse_cb);
typedef BOOL (*pEllipseSC)(rdpContext* context, const ELLIPSE_SC_ORDER* ellipse_sc);
typedef BOOL (*pEllipseCB)(rdpContext* context, const ELLIPSE_CB_ORDER* ellipse_cb);
struct rdp_primary_update
{

View File

@ -22,6 +22,7 @@
#include <freerdp/api.h>
#include <freerdp/types.h>
#include <freerdp/codec/color.h>
#include <winpr/platform.h>
@ -64,146 +65,145 @@ typedef struct
/* Function prototypes for all of the supported primitives. */
typedef pstatus_t (*__copy_t)(
const void *pSrc,
void *pDst,
INT32 bytes);
const void* pSrc,
void* pDst,
INT32 bytes);
typedef pstatus_t (*__copy_8u_t)(
const BYTE *pSrc,
BYTE *pDst,
INT32 len);
const BYTE* pSrc,
BYTE* pDst,
INT32 len);
typedef pstatus_t (*__copy_8u_AC4r_t)(
const BYTE *pSrc,
INT32 srcStep, /* bytes */
BYTE *pDst,
INT32 dstStep, /* bytes */
INT32 width, INT32 height); /* pixels */
const BYTE* pSrc,
INT32 srcStep, /* bytes */
BYTE* pDst,
INT32 dstStep, /* bytes */
INT32 width, INT32 height); /* pixels */
typedef pstatus_t (*__set_8u_t)(
BYTE val,
BYTE *pDst,
INT32 len);
BYTE val,
BYTE* pDst,
INT32 len);
typedef pstatus_t (*__set_32s_t)(
INT32 val,
INT32 *pDst,
INT32 len);
INT32 val,
INT32* pDst,
INT32 len);
typedef pstatus_t (*__set_32u_t)(
UINT32 val,
UINT32 *pDst,
INT32 len);
UINT32 val,
UINT32* pDst,
INT32 len);
typedef pstatus_t (*__zero_t)(
void *pDst,
size_t bytes);
void* pDst,
size_t bytes);
typedef pstatus_t (*__alphaComp_argb_t)(
const BYTE *pSrc1, INT32 src1Step,
const BYTE *pSrc2, INT32 src2Step,
BYTE *pDst, INT32 dstStep,
INT32 width, INT32 height);
const BYTE* pSrc1, INT32 src1Step,
const BYTE* pSrc2, INT32 src2Step,
BYTE* pDst, INT32 dstStep,
INT32 width, INT32 height);
typedef pstatus_t (*__add_16s_t)(
const INT16 *pSrc1,
const INT16 *pSrc2,
INT16 *pDst,
INT32 len);
const INT16* pSrc1,
const INT16* pSrc2,
INT16* pDst,
INT32 len);
typedef pstatus_t (*__lShiftC_16s_t)(
const INT16 *pSrc,
INT32 val,
INT16 *pSrcDst,
INT32 len);
const INT16* pSrc,
INT32 val,
INT16* pSrcDst,
INT32 len);
typedef pstatus_t (*__lShiftC_16u_t)(
const UINT16 *pSrc,
INT32 val,
UINT16 *pSrcDst,
INT32 len);
const UINT16* pSrc,
INT32 val,
UINT16* pSrcDst,
INT32 len);
typedef pstatus_t (*__rShiftC_16s_t)(
const INT16 *pSrc,
INT32 val,
INT16 *pSrcDst,
INT32 len);
const INT16* pSrc,
INT32 val,
INT16* pSrcDst,
INT32 len);
typedef pstatus_t (*__rShiftC_16u_t)(
const UINT16 *pSrc,
INT32 val,
UINT16 *pSrcDst,
INT32 len);
const UINT16* pSrc,
INT32 val,
UINT16* pSrcDst,
INT32 len);
typedef pstatus_t (*__shiftC_16s_t)(
const INT16 *pSrc,
INT32 val,
INT16 *pSrcDst,
INT32 len);
const INT16* pSrc,
INT32 val,
INT16* pSrcDst,
INT32 len);
typedef pstatus_t (*__shiftC_16u_t)(
const UINT16 *pSrc,
INT32 val,
UINT16 *pSrcDst,
INT32 len);
const UINT16* pSrc,
INT32 val,
UINT16* pSrcDst,
INT32 len);
typedef pstatus_t (*__sign_16s_t)(
const INT16 *pSrc,
INT16 *pDst,
INT32 len);
const INT16* pSrc,
INT16* pDst,
INT32 len);
typedef pstatus_t (*__yCbCrToRGB_16s8u_P3AC4R_t)(
const INT16* pSrc[3], INT32 srcStep,
BYTE* pDst, INT32 dstStep,
const prim_size_t* roi);
const INT16* pSrc[3], INT32 srcStep,
BYTE* pDst, INT32 dstStep, UINT32 DstFormat,
const prim_size_t* roi);
typedef pstatus_t (*__yCbCrToBGR_16s8u_P3AC4R_t)(
const INT16* pSrc[3], INT32 srcStep,
BYTE* pDst, INT32 dstStep,
const prim_size_t* roi);
const INT16* pSrc[3], INT32 srcStep,
BYTE* pDst, INT32 dstStep, UINT32 DstFormat,
const prim_size_t* roi);
typedef pstatus_t (*__yCbCrToRGB_16s16s_P3P3_t)(
const INT16 *pSrc[3], INT32 srcStep,
INT16 *pDst[3], INT32 dstStep,
const prim_size_t *roi);
const INT16* pSrc[3], INT32 srcStep,
INT16* pDst[3], INT32 dstStep,
const prim_size_t* roi);
typedef pstatus_t (*__RGBToYCbCr_16s16s_P3P3_t)(
const INT16 *pSrc[3], INT32 srcStep,
INT16 *pDst[3], INT32 dstStep,
const prim_size_t *roi);
const INT16* pSrc[3], INT32 srcStep,
INT16* pDst[3], INT32 dstStep,
const prim_size_t* roi);
typedef pstatus_t (*__RGBToRGB_16s8u_P3AC4R_t)(
const INT16 *pSrc[3], INT32 srcStep,
BYTE *pDst, INT32 dstStep,
const prim_size_t *roi);
const INT16* pSrc[3], INT32 srcStep,
BYTE* pDst, INT32 dstStep, UINT32 DstFormat,
const prim_size_t* roi);
typedef pstatus_t (*__YCoCgToRGB_8u_AC4R_t)(
const BYTE *pSrc, INT32 srcStep,
BYTE *pDst, INT32 dstStep,
UINT32 width, UINT32 height,
UINT8 shift,
BOOL withAlpha,
BOOL invert);
const BYTE* pSrc, INT32 srcStep,
BYTE* pDst, UINT32 DstFormat, INT32 dstStep,
UINT32 width, UINT32 height,
UINT8 shift,
BOOL withAlpha);
typedef pstatus_t (*__RGB565ToARGB_16u32u_C3C4_t)(
const UINT16* pSrc, INT32 srcStep,
UINT32* pDst, INT32 dstStep,
UINT32 width, UINT32 height,
BOOL alpha, BOOL invert);
const UINT16* pSrc, INT32 srcStep,
UINT32* pDst, INT32 dstStep,
UINT32 width, UINT32 height,
UINT32 format);
typedef pstatus_t (*__YUV420ToRGB_8u_P3AC4R_t)(
const BYTE* pSrc[3], const UINT32 srcStep[3],
BYTE* pDst, UINT32 dstStep,
const prim_size_t* roi);
const BYTE* pSrc[3], const UINT32 srcStep[3],
BYTE* pDst, UINT32 dstStep, UINT32 DstFormat,
const prim_size_t* roi);
typedef pstatus_t (*__YUV444ToRGB_8u_P3AC4R_t)(
const BYTE* pSrc[3], const UINT32 srcStep[3],
BYTE* pDst, UINT32 dstStep,
const prim_size_t* roi);
const BYTE* pSrc[3], const UINT32 srcStep[3],
BYTE* pDst, UINT32 dstStep, UINT32 DstFormat,
const prim_size_t* roi);
typedef pstatus_t (*__RGBToYUV420_8u_P3AC4R_t)(
const BYTE* pSrc, UINT32 srcStep,
BYTE* pDst[3], UINT32 dstStep[3],
const prim_size_t* roi);
const BYTE* pSrc, UINT32 srcStep,
BYTE* pDst[3], UINT32 dstStep[3],
const prim_size_t* roi);
typedef pstatus_t (*__RGBToYUV444_8u_P3AC4R_t)(
const BYTE* pSrc, UINT32 srcStep,
BYTE* pDst[3], UINT32 dstStep[3],
const prim_size_t* roi);
const BYTE* pSrc, UINT32 srcStep,
BYTE* pDst[3], UINT32 dstStep[3],
const prim_size_t* roi);
typedef pstatus_t (*__YUV420CombineToYUV444_t)(
const BYTE* pMainSrc[3], const UINT32 srcMainStep[3],
const BYTE* pAuxSrc[3], const UINT32 srcAuxStep[3],
BYTE* pDst[3], const UINT32 dstStep[3],
const prim_size_t* roi);
const BYTE* pMainSrc[3], const UINT32 srcMainStep[3],
const BYTE* pAuxSrc[3], const UINT32 srcAuxStep[3],
BYTE* pDst[3], const UINT32 dstStep[3],
const prim_size_t* roi);
typedef pstatus_t (*__YUV444SplitToYUV420_t)(
const BYTE* pSrc[3], const UINT32 srcStep[3],
BYTE* pMainDst[3], const UINT32 dstMainStep[3],
BYTE* pAuxDst[3], const UINT32 srcAuxStep[3],
const prim_size_t* roi);
const BYTE* pSrc[3], const UINT32 srcStep[3],
BYTE* pMainDst[3], const UINT32 dstMainStep[3],
BYTE* pAuxDst[3], const UINT32 srcAuxStep[3],
const prim_size_t* roi);
typedef pstatus_t (*__andC_32u_t)(
const UINT32 *pSrc,
UINT32 val,
UINT32 *pDst,
INT32 len);
const UINT32* pSrc,
UINT32 val,
UINT32* pDst,
INT32 len);
typedef pstatus_t (*__orC_32u_t)(
const UINT32 *pSrc,
UINT32 val,
UINT32 *pDst,
INT32 len);
const UINT32* pSrc,
UINT32 val,
UINT32* pDst,
INT32 len);
typedef struct
{
@ -239,23 +239,20 @@ typedef struct
__RGBToYCbCr_16s16s_P3P3_t RGBToYCbCr_16s16s_P3P3;
__RGBToRGB_16s8u_P3AC4R_t RGBToRGB_16s8u_P3AC4R;
__YCoCgToRGB_8u_AC4R_t YCoCgToRGB_8u_AC4R;
__RGB565ToARGB_16u32u_C3C4_t RGB565ToARGB_16u32u_C3C4;
__YUV420ToRGB_8u_P3AC4R_t YUV420ToRGB_8u_P3AC4R;
__RGBToYUV420_8u_P3AC4R_t RGBToYUV420_8u_P3AC4R;
__RGBToYUV444_8u_P3AC4R_t RGBToYUV444_8u_P3AC4R;
__YUV420CombineToYUV444_t YUV420CombineToYUV444;
__YUV444SplitToYUV420_t YUV444SplitToYUV420;
__YUV420ToRGB_8u_P3AC4R_t YUV444ToRGB_8u_P3AC4R;
__YUV444ToRGB_8u_P3AC4R_t YUV444ToRGB_8u_P3AC4R;
} primitives_t;
#ifdef __cplusplus
extern "C" {
#endif
/* Prototypes for the externally-visible entrypoints. */
FREERDP_API void primitives_init(void);
FREERDP_API primitives_t *primitives_get(void);
FREERDP_API void primitives_deinit(void);
FREERDP_API primitives_t* primitives_get(void);
FREERDP_API primitives_t* primitives_get_generic(void);
#ifdef __cplusplus
}

View File

@ -163,13 +163,20 @@ struct _CACHE_BRUSH_ORDER
};
typedef struct _CACHE_BRUSH_ORDER CACHE_BRUSH_ORDER;
typedef BOOL (*pCacheBitmap)(rdpContext* context, CACHE_BITMAP_ORDER* cache_bitmap_order);
typedef BOOL (*pCacheBitmapV2)(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order);
typedef BOOL (*pCacheBitmapV3)(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order);
typedef BOOL (*pCacheColorTable)(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cache_color_table_order);
typedef BOOL (*pCacheGlyph)(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph_order);
typedef BOOL (*pCacheGlyphV2)(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order);
typedef BOOL (*pCacheBrush)(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush_order);
typedef BOOL (*pCacheBitmap)(rdpContext* context,
const CACHE_BITMAP_ORDER* cache_bitmap_order);
typedef BOOL (*pCacheBitmapV2)(rdpContext* context,
CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order);
typedef BOOL (*pCacheBitmapV3)(rdpContext* context,
CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order);
typedef BOOL (*pCacheColorTable)(rdpContext* context,
const CACHE_COLOR_TABLE_ORDER* cache_color_table_order);
typedef BOOL (*pCacheGlyph)(rdpContext* context,
const CACHE_GLYPH_ORDER* cache_glyph_order);
typedef BOOL (*pCacheGlyphV2)(rdpContext* context,
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order);
typedef BOOL (*pCacheBrush)(rdpContext* context,
const CACHE_BRUSH_ORDER* cache_brush_order);
struct rdp_secondary_update
{

View File

@ -137,23 +137,27 @@ typedef struct rdp_update_proxy rdpUpdateProxy;
typedef BOOL (*pBeginPaint)(rdpContext* context);
typedef BOOL (*pEndPaint)(rdpContext* context);
typedef BOOL (*pSetBounds)(rdpContext* context, rdpBounds* bounds);
typedef BOOL (*pSetBounds)(rdpContext* context, const rdpBounds* bounds);
typedef BOOL (*pSynchronize)(rdpContext* context);
typedef BOOL (*pDesktopResize)(rdpContext* context);
typedef BOOL (*pBitmapUpdate)(rdpContext* context, BITMAP_UPDATE* bitmap);
typedef BOOL (*pPalette)(rdpContext* context, PALETTE_UPDATE* palette);
typedef BOOL (*pPlaySound)(rdpContext* context, PLAY_SOUND_UPDATE* play_sound);
typedef BOOL (*pBitmapUpdate)(rdpContext* context, const BITMAP_UPDATE* bitmap);
typedef BOOL (*pPalette)(rdpContext* context, const PALETTE_UPDATE* palette);
typedef BOOL (*pPlaySound)(rdpContext* context, const PLAY_SOUND_UPDATE* play_sound);
typedef BOOL (*pSetKeyboardIndicators)(rdpContext* context, UINT16 led_flags);
typedef BOOL (*pRefreshRect)(rdpContext* context, BYTE count, RECTANGLE_16* areas);
typedef BOOL (*pSuppressOutput)(rdpContext* context, BYTE allow, RECTANGLE_16* area);
typedef BOOL (*pRefreshRect)(rdpContext* context, BYTE count, const RECTANGLE_16* areas);
typedef BOOL (*pSuppressOutput)(rdpContext* context, BYTE allow, const RECTANGLE_16* area);
typedef BOOL (*pRemoteMonitors)(rdpContext* context, UINT32 count, const MONITOR_DEF *monitors);
typedef BOOL (*pSurfaceCommand)(rdpContext* context, wStream* s);
typedef BOOL (*pSurfaceBits)(rdpContext* context, SURFACE_BITS_COMMAND* surfaceBitsCommand);
typedef BOOL (*pSurfaceFrameMarker)(rdpContext* context, SURFACE_FRAME_MARKER* surfaceFrameMarker);
typedef BOOL (*pSurfaceFrameBits)(rdpContext* context, SURFACE_BITS_COMMAND* cmd, BOOL first, BOOL last, UINT32 frameId);
typedef BOOL (*pSurfaceBits)(rdpContext* context,
const SURFACE_BITS_COMMAND* surfaceBitsCommand);
typedef BOOL (*pSurfaceFrameMarker)(rdpContext* context,
const SURFACE_FRAME_MARKER* surfaceFrameMarker);
typedef BOOL (*pSurfaceFrameBits)(rdpContext* context,
const SURFACE_BITS_COMMAND* cmd, BOOL first,
BOOL last, UINT32 frameId);
typedef BOOL (*pSurfaceFrameAcknowledge)(rdpContext* context, UINT32 frameId);
typedef BOOL (*pSaveSessionInfo)(rdpContext *context, UINT32 type, void *data);

View File

@ -195,7 +195,6 @@ endif()
# primitives
set(PRIMITIVES_SRCS
primitives/prim_16to32bpp.c
primitives/prim_add.c
primitives/prim_andor.c
primitives/prim_alphaComp.c
@ -210,7 +209,6 @@ set(PRIMITIVES_SRCS
primitives/prim_internal.h)
set(PRIMITIVES_OPT_SRCS
primitives/prim_16to32bpp_opt.c
primitives/prim_add_opt.c
primitives/prim_andor_opt.c
primitives/prim_alphaComp_opt.c

View File

@ -34,7 +34,11 @@
#define TAG FREERDP_TAG("cache.bitmap")
BOOL update_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
static rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index);
static void bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 index, rdpBitmap* bitmap);
static BOOL update_gdi_memblt(rdpContext* context,
MEMBLT_ORDER* memblt)
{
rdpBitmap* bitmap;
rdpCache* cache = context->cache;
@ -51,7 +55,8 @@ BOOL update_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
return IFCALLRESULT(TRUE, cache->bitmap->MemBlt, context, memblt);
}
BOOL update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
static BOOL update_gdi_mem3blt(rdpContext* context,
MEM3BLT_ORDER* mem3blt)
{
BYTE style;
rdpBitmap* bitmap;
@ -84,7 +89,8 @@ BOOL update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
return ret;
}
BOOL update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cacheBitmap)
static BOOL update_gdi_cache_bitmap(rdpContext* context,
const CACHE_BITMAP_ORDER* cacheBitmap)
{
rdpBitmap* bitmap;
rdpBitmap* prevBitmap;
@ -117,7 +123,8 @@ BOOL update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cacheBitma
return TRUE;
}
BOOL update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cacheBitmapV2)
static BOOL update_gdi_cache_bitmap_v2(rdpContext* context,
CACHE_BITMAP_V2_ORDER* cacheBitmapV2)
{
rdpBitmap* bitmap;
@ -138,9 +145,13 @@ BOOL update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cach
cacheBitmapV2->bitmapBpp = settings->ColorDepth;
if (!bitmap->Decompress(context, bitmap,
cacheBitmapV2->bitmapDataStream, cacheBitmapV2->bitmapWidth, cacheBitmapV2->bitmapHeight,
cacheBitmapV2->bitmapBpp, cacheBitmapV2->bitmapLength,
cacheBitmapV2->compressed, RDP_CODEC_ID_NONE))
cacheBitmapV2->bitmapDataStream,
cacheBitmapV2->bitmapWidth,
cacheBitmapV2->bitmapHeight,
cacheBitmapV2->bitmapBpp,
cacheBitmapV2->bitmapLength,
cacheBitmapV2->compressed,
RDP_CODEC_ID_NONE))
{
Bitmap_Free(context, bitmap);
return FALSE;
@ -157,7 +168,8 @@ BOOL update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cach
return TRUE;
}
BOOL update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cacheBitmapV3)
static BOOL update_gdi_cache_bitmap_v3(rdpContext* context,
CACHE_BITMAP_V3_ORDER* cacheBitmapV3)
{
rdpBitmap* bitmap;
rdpBitmap* prevBitmap;
@ -193,9 +205,10 @@ BOOL update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cach
return TRUE;
}
BOOL update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
static BOOL update_gdi_bitmap_update(rdpContext* context,
const BITMAP_UPDATE* bitmapUpdate)
{
int i;
UINT32 i;
BOOL reused = TRUE;
rdpBitmap* bitmap;
BITMAP_DATA* bitmapData;

View File

@ -34,12 +34,13 @@
#define TAG FREERDP_TAG("cache.brush")
BOOL update_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
static BOOL update_gdi_patblt(rdpContext* context,
PATBLT_ORDER* patblt)
{
BYTE style;
BOOL ret = TRUE;
rdpBrush* brush = &patblt->brush;
rdpCache* cache = context->cache;
const rdpCache* cache = context->cache;
style = brush->style;
@ -54,13 +55,15 @@ BOOL update_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
return ret;
}
BOOL update_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
static BOOL update_gdi_polygon_sc(rdpContext* context,
const POLYGON_SC_ORDER* polygon_sc)
{
rdpCache* cache = context->cache;
return IFCALLRESULT(TRUE, cache->brush->PolygonSC, context, polygon_sc);
}
BOOL update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
static BOOL update_gdi_polygon_cb(rdpContext* context,
POLYGON_CB_ORDER* polygon_cb)
{
BYTE style;
rdpBrush* brush = &polygon_cb->brush;
@ -77,12 +80,14 @@ BOOL update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
IFCALLRET(cache->brush->PolygonCB, ret, context, polygon_cb);
brush->style = style;
return ret;
}
static BOOL update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cacheBrush)
static BOOL update_gdi_cache_brush(rdpContext* context,
const CACHE_BRUSH_ORDER* cacheBrush)
{
int length;
UINT32 length;
void* data = NULL;
rdpCache* cache = context->cache;

View File

@ -33,10 +33,18 @@
#define TAG FREERDP_TAG("cache.glyph")
void update_process_glyph(rdpContext* context, BYTE* data, int* index,
int* x, int* y, UINT32 cacheId, UINT32 ulCharInc, UINT32 flAccel)
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 update_process_glyph(rdpContext* context, const BYTE* data,
UINT32* index, UINT32* x, UINT32* y,
UINT32 cacheId, UINT32 ulCharInc, UINT32 flAccel)
{
int offset;
UINT32 offset;
rdpGlyph* glyph;
UINT32 cacheIndex;
rdpGraphics* graphics;
@ -77,14 +85,21 @@ void update_process_glyph(rdpContext* context, BYTE* data, int* index,
}
}
BOOL update_process_glyph_fragments(rdpContext* context, BYTE* data, UINT32 length,
UINT32 cacheId, UINT32 ulCharInc, UINT32 flAccel, UINT32 bgcolor, UINT32 fgcolor, int x, int y,
int bkX, int bkY, int bkWidth, int bkHeight, int opX, int opY, int opWidth, int 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)
{
int n;
UINT32 n;
UINT32 id;
UINT32 size;
int index = 0;
UINT32 index = 0;
BYTE* fragments;
rdpGraphics* graphics;
rdpGlyphCache* glyph_cache;
@ -204,7 +219,8 @@ BOOL update_process_glyph_fragments(rdpContext* context, BYTE* data, UINT32 leng
return Glyph_EndDraw(context, bkX, bkY, bkWidth, bkHeight, bgcolor, fgcolor);
}
BOOL update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyphIndex)
static BOOL update_gdi_glyph_index(rdpContext* context,
GLYPH_INDEX_ORDER* glyphIndex)
{
rdpGlyphCache* glyph_cache;
int bkWidth, bkHeight, opWidth, opHeight;
@ -224,7 +240,8 @@ BOOL update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyphIndex)
glyphIndex->fOpRedundant);
}
BOOL update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fastIndex)
static BOOL update_gdi_fast_index(rdpContext* context,
const FAST_INDEX_ORDER* fastIndex)
{
INT32 x, y;
INT32 opLeft, opTop;
@ -282,14 +299,15 @@ BOOL update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fastIndex)
FALSE);
}
BOOL update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fastGlyph)
static BOOL update_gdi_fast_glyph(rdpContext* context,
const FAST_GLYPH_ORDER* fastGlyph)
{
INT32 x, y;
rdpGlyph* glyph;
BYTE text_data[2];
INT32 opLeft, opTop;
INT32 opRight, opBottom;
GLYPH_DATA_V2* glyphData;
const GLYPH_DATA_V2* glyphData;
rdpCache* cache = context->cache;
opLeft = fastGlyph->opLeft;
@ -373,14 +391,15 @@ error_aj:
return FALSE;
}
BOOL update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyph)
static BOOL update_gdi_cache_glyph(rdpContext* context,
const CACHE_GLYPH_ORDER* cacheGlyph)
{
int i;
UINT32 i;
rdpGlyph* glyph;
GLYPH_DATA* glyph_data;
const GLYPH_DATA* glyph_data;
rdpCache* cache = context->cache;
for (i = 0; i < (int) cacheGlyph->cGlyphs; i++)
for (i = 0; i < cacheGlyph->cGlyphs; i++)
{
glyph_data = &cacheGlyph->glyphData[i];
@ -405,14 +424,15 @@ BOOL update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyph)
return TRUE;
}
BOOL update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cacheGlyphV2)
static BOOL update_gdi_cache_glyph_v2(rdpContext* context,
const CACHE_GLYPH_V2_ORDER* cacheGlyphV2)
{
int i;
UINT32 i;
rdpGlyph* glyph;
GLYPH_DATA_V2* glyphData;
const GLYPH_DATA_V2* glyphData;
rdpCache* cache = context->cache;
for (i = 0; i < (int) cacheGlyphV2->cGlyphs; i++)
for (i = 0; i < cacheGlyphV2->cGlyphs; i++)
{
glyphData = &cacheGlyphV2->glyphData[i];

View File

@ -35,13 +35,19 @@
#define TAG FREERDP_TAG("cache.nine_grid")
BOOL update_gdi_draw_nine_grid(rdpContext* context, DRAW_NINE_GRID_ORDER* draw_nine_grid)
static void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index);
static void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index, void* entry);
static BOOL update_gdi_draw_nine_grid(rdpContext* context,
const DRAW_NINE_GRID_ORDER* draw_nine_grid)
{
rdpCache* cache = context->cache;
return IFCALLRESULT(TRUE, cache->nine_grid->DrawNineGrid, context, draw_nine_grid);
}
BOOL update_gdi_multi_draw_nine_grid(rdpContext* context, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
static BOOL update_gdi_multi_draw_nine_grid(rdpContext* context,
const MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
{
rdpCache* cache = context->cache;
return IFCALLRESULT(TRUE, cache->nine_grid->MultiDrawNineGrid, context, multi_draw_nine_grid);

View File

@ -32,7 +32,11 @@
#define TAG FREERDP_TAG("cache.offscreen")
BOOL update_gdi_create_offscreen_bitmap(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
static void offscreen_cache_put(rdpOffscreenCache* offscreen_cache, UINT32 index, rdpBitmap* bitmap);
static void offscreen_cache_delete(rdpOffscreenCache* offscreen, UINT32 index);
static BOOL update_gdi_create_offscreen_bitmap(rdpContext* context,
const CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
{
int i;
UINT16 index;
@ -66,7 +70,8 @@ BOOL update_gdi_create_offscreen_bitmap(rdpContext* context, CREATE_OFFSCREEN_BI
return TRUE;
}
BOOL update_gdi_switch_surface(rdpContext* context, SWITCH_SURFACE_ORDER* switchSurface)
static BOOL update_gdi_switch_surface(rdpContext* context,
const SWITCH_SURFACE_ORDER* switchSurface)
{
rdpCache* cache = context->cache;

View File

@ -30,7 +30,11 @@
#define TAG FREERDP_TAG("cache.palette")
static BOOL update_gdi_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cacheColorTable)
static void* palette_cache_get(rdpPaletteCache* palette, UINT32 index);
static void palette_cache_put(rdpPaletteCache* palette, UINT32 index, void* entry);
static BOOL update_gdi_cache_color_table(rdpContext* context,
const CACHE_COLOR_TABLE_ORDER* cacheColorTable)
{
UINT32* colorTable;
rdpCache* cache = context->cache;

View File

@ -33,12 +33,18 @@
#define TAG FREERDP_TAG("cache.pointer")
BOOL update_pointer_position(rdpContext* context, POINTER_POSITION_UPDATE* pointer_position)
static void pointer_cache_put(rdpPointerCache* pointer_cache, UINT32 index,
rdpPointer* pointer);
static const rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index);
static BOOL update_pointer_position(rdpContext* context,
const POINTER_POSITION_UPDATE* pointer_position)
{
return Pointer_SetPosition(context, pointer_position->xPos, pointer_position->yPos);
}
BOOL update_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system)
static BOOL update_pointer_system(rdpContext* context,
const POINTER_SYSTEM_UPDATE* pointer_system)
{
switch (pointer_system->type)
{
@ -56,7 +62,8 @@ BOOL update_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_s
return TRUE;
}
BOOL update_pointer_color(rdpContext* context, POINTER_COLOR_UPDATE* pointer_color)
static BOOL update_pointer_color(rdpContext* context,
const POINTER_COLOR_UPDATE* pointer_color)
{
rdpPointer* pointer;
rdpCache* cache = context->cache;
@ -103,7 +110,8 @@ out_fail:
return FALSE;
}
BOOL update_pointer_new(rdpContext* context, POINTER_NEW_UPDATE* pointer_new)
static BOOL update_pointer_new(rdpContext* context,
const POINTER_NEW_UPDATE* pointer_new)
{
rdpPointer* pointer;
rdpCache* cache = context->cache;
@ -148,9 +156,10 @@ out_fail:
return FALSE;
}
BOOL update_pointer_cached(rdpContext* context, POINTER_CACHED_UPDATE* pointer_cached)
static BOOL update_pointer_cached(rdpContext* context,
const POINTER_CACHED_UPDATE* pointer_cached)
{
rdpPointer* pointer;
const rdpPointer* pointer;
rdpCache* cache = context->cache;
pointer = pointer_cache_get(cache->pointer, pointer_cached->cacheIndex);
@ -163,9 +172,9 @@ BOOL update_pointer_cached(rdpContext* context, POINTER_CACHED_UPDATE* pointer_c
return FALSE;
}
rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index)
const rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index)
{
rdpPointer* pointer;
const rdpPointer* pointer;
if (index >= pointer_cache->cacheSize)
{
@ -178,7 +187,8 @@ rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, UINT32 index)
return pointer;
}
void pointer_cache_put(rdpPointerCache* pointer_cache, UINT32 index, rdpPointer* pointer)
void pointer_cache_put(rdpPointerCache* pointer_cache, UINT32 index,
rdpPointer* pointer)
{
rdpPointer* prevPointer;
@ -233,10 +243,10 @@ void pointer_cache_free(rdpPointerCache* pointer_cache)
{
if (pointer_cache != NULL)
{
int i;
UINT32 i;
rdpPointer* pointer;
for (i = 0; i < (int) pointer_cache->cacheSize; i++)
for (i = 0; i < pointer_cache->cacheSize; i++)
{
pointer = pointer_cache->entries[i];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1483,19 +1483,21 @@ static BOOL avc_yuv_to_rgb(H264_CONTEXT* h264, const RECTANGLE_16* regionRects,
roi.width = width;
roi.height = height;
// TODO: Color format converstion support!!!
if (use444)
{
if (prims->YUV444ToRGB_8u_P3AC4R(
pYUVPoint, iStride, pDstPoint,
nDstStep, &roi) != PRIMITIVES_SUCCESS)
pYUVPoint, iStride, pDstPoint, nDstStep,
DstFormat, &roi) != PRIMITIVES_SUCCESS)
{
return FALSE;
}
}
else
{
if (prims->YUV420ToRGB_8u_P3AC4R(pYUVPoint, iStride, pDstPoint,
nDstStep, &roi) != PRIMITIVES_SUCCESS)
if (prims->YUV420ToRGB_8u_P3AC4R(
pYUVPoint, iStride, pDstPoint, nDstStep,
DstFormat, &roi) != PRIMITIVES_SUCCESS)
return FALSE;
}
}

View File

@ -3,6 +3,8 @@
* RLE Compressed Bitmap Stream
*
* Copyright 2011 Jay Sorg <jay.sorg@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -251,11 +253,11 @@ static BYTE* WRITEFIRSTLINEFGBGIMAGE(BYTE* pbDest, BYTE bitmask,
/**
* Decompress an RLE compressed bitmap.
*/
void RLEDECOMPRESS(BYTE* pbSrcBuffer, UINT32 cbSrcBuffer, BYTE* pbDestBuffer,
UINT32 rowDelta, UINT32 width, UINT32 height)
void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer, BYTE* pbDestBuffer,
UINT32 rowDelta, UINT32 width, UINT32 height)
{
BYTE* pbSrc = pbSrcBuffer;
BYTE* pbEnd = pbSrcBuffer + cbSrcBuffer;
const BYTE* pbSrc = pbSrcBuffer;
const BYTE* pbEnd = pbSrcBuffer + cbSrcBuffer;
BYTE* pbDest = pbDestBuffer;
PIXEL temp;
@ -354,214 +356,214 @@ void RLEDECOMPRESS(BYTE* pbSrcBuffer, UINT32 cbSrcBuffer, BYTE* pbDestBuffer,
switch (code)
{
/* Handle Foreground Run Orders. */
case REGULAR_FG_RUN:
case MEGA_MEGA_FG_RUN:
case LITE_SET_FG_FG_RUN:
case MEGA_MEGA_SET_FG_RUN:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
if (code == LITE_SET_FG_FG_RUN || code == MEGA_MEGA_SET_FG_RUN)
/* Handle Foreground Run Orders. */
case REGULAR_FG_RUN:
case MEGA_MEGA_FG_RUN:
case LITE_SET_FG_FG_RUN:
case MEGA_MEGA_SET_FG_RUN:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
if (code == LITE_SET_FG_FG_RUN || code == MEGA_MEGA_SET_FG_RUN)
{
SRCREADPIXEL(fgPel, pbSrc);
SRCNEXTPIXEL(pbSrc);
}
if (fFirstLine)
{
while (runLength >= UNROLL_COUNT)
{
SRCREADPIXEL(fgPel, pbSrc);
SRCNEXTPIXEL(pbSrc);
}
if (fFirstLine)
{
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTWRITEPIXEL(pbDest, fgPel);
UNROLL(
DESTWRITEPIXEL(pbDest, fgPel);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
DESTWRITEPIXEL(pbDest, fgPel);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
runLength = runLength - UNROLL_COUNT;
}
else
while (runLength > 0)
{
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTREADPIXEL(temp, pbDest - rowDelta);
DESTWRITEPIXEL(pbDest, fgPel);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
}
else
{
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTREADPIXEL(temp, pbDest - rowDelta);
DESTWRITEPIXEL(pbDest, temp ^ fgPel);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
DESTREADPIXEL(temp, pbDest - rowDelta);
DESTWRITEPIXEL(pbDest, temp ^ fgPel);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
break;
while (runLength > 0)
{
DESTREADPIXEL(temp, pbDest - rowDelta);
DESTWRITEPIXEL(pbDest, temp ^ fgPel);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
}
break;
/* Handle Dithered Run Orders. */
case LITE_DITHERED_RUN:
case MEGA_MEGA_DITHERED_RUN:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
SRCREADPIXEL(pixelA, pbSrc);
SRCNEXTPIXEL(pbSrc);
SRCREADPIXEL(pixelB, pbSrc);
SRCNEXTPIXEL(pbSrc);
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTWRITEPIXEL(pbDest, pixelA);
case LITE_DITHERED_RUN:
case MEGA_MEGA_DITHERED_RUN:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
SRCREADPIXEL(pixelA, pbSrc);
SRCNEXTPIXEL(pbSrc);
SRCREADPIXEL(pixelB, pbSrc);
SRCNEXTPIXEL(pbSrc);
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTWRITEPIXEL(pbDest, pixelA);
DESTNEXTPIXEL(pbDest);
DESTWRITEPIXEL(pbDest, pixelB);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
DESTWRITEPIXEL(pbDest, pixelA);
DESTNEXTPIXEL(pbDest);
DESTWRITEPIXEL(pbDest, pixelB);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
break;
DESTWRITEPIXEL(pbDest, pixelB);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
DESTWRITEPIXEL(pbDest, pixelA);
DESTNEXTPIXEL(pbDest);
DESTWRITEPIXEL(pbDest, pixelB);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
break;
/* Handle Color Run Orders. */
case REGULAR_COLOR_RUN:
case MEGA_MEGA_COLOR_RUN:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
SRCREADPIXEL(pixelA, pbSrc);
SRCNEXTPIXEL(pbSrc);
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTWRITEPIXEL(pbDest, pixelA);
case REGULAR_COLOR_RUN:
case MEGA_MEGA_COLOR_RUN:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
SRCREADPIXEL(pixelA, pbSrc);
SRCNEXTPIXEL(pbSrc);
while (runLength >= UNROLL_COUNT)
{
UNROLL(
DESTWRITEPIXEL(pbDest, pixelA);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
DESTWRITEPIXEL(pbDest, pixelA);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
break;
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
DESTWRITEPIXEL(pbDest, pixelA);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
break;
/* Handle Foreground/Background Image Orders. */
case REGULAR_FGBG_IMAGE:
case MEGA_MEGA_FGBG_IMAGE:
case LITE_SET_FG_FGBG_IMAGE:
case MEGA_MEGA_SET_FGBG_IMAGE:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
if (code == LITE_SET_FG_FGBG_IMAGE || code == MEGA_MEGA_SET_FGBG_IMAGE)
{
SRCREADPIXEL(fgPel, pbSrc);
SRCNEXTPIXEL(pbSrc);
}
if (fFirstLine)
{
while (runLength > 8)
{
bitmask = *pbSrc;
pbSrc = pbSrc + 1;
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, bitmask, fgPel, 8);
runLength = runLength - 8;
}
}
else
{
while (runLength > 8)
{
bitmask = *pbSrc;
pbSrc = pbSrc + 1;
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, bitmask, fgPel, 8);
runLength = runLength - 8;
}
}
if (runLength > 0)
case REGULAR_FGBG_IMAGE:
case MEGA_MEGA_FGBG_IMAGE:
case LITE_SET_FG_FGBG_IMAGE:
case MEGA_MEGA_SET_FGBG_IMAGE:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
if (code == LITE_SET_FG_FGBG_IMAGE || code == MEGA_MEGA_SET_FGBG_IMAGE)
{
SRCREADPIXEL(fgPel, pbSrc);
SRCNEXTPIXEL(pbSrc);
}
if (fFirstLine)
{
while (runLength > 8)
{
bitmask = *pbSrc;
pbSrc = pbSrc + 1;
if (fFirstLine)
{
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, bitmask, fgPel, runLength);
}
else
{
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, bitmask, fgPel, runLength);
}
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, bitmask, fgPel, 8);
runLength = runLength - 8;
}
break;
}
else
{
while (runLength > 8)
{
bitmask = *pbSrc;
pbSrc = pbSrc + 1;
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, bitmask, fgPel, 8);
runLength = runLength - 8;
}
}
if (runLength > 0)
{
bitmask = *pbSrc;
pbSrc = pbSrc + 1;
if (fFirstLine)
{
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, bitmask, fgPel, runLength);
}
else
{
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, bitmask, fgPel, runLength);
}
}
break;
/* Handle Color Image Orders. */
case REGULAR_COLOR_IMAGE:
case MEGA_MEGA_COLOR_IMAGE:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
while (runLength >= UNROLL_COUNT)
{
UNROLL(
SRCREADPIXEL(temp, pbSrc);
case REGULAR_COLOR_IMAGE:
case MEGA_MEGA_COLOR_IMAGE:
runLength = ExtractRunLength(code, pbSrc, &advance);
pbSrc = pbSrc + advance;
while (runLength >= UNROLL_COUNT)
{
UNROLL(
SRCREADPIXEL(temp, pbSrc);
SRCNEXTPIXEL(pbSrc);
DESTWRITEPIXEL(pbDest, temp);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
SRCREADPIXEL(temp, pbSrc);
SRCNEXTPIXEL(pbSrc);
DESTWRITEPIXEL(pbDest, temp);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
break;
DESTWRITEPIXEL(pbDest, temp);
DESTNEXTPIXEL(pbDest); );
runLength = runLength - UNROLL_COUNT;
}
while (runLength > 0)
{
SRCREADPIXEL(temp, pbSrc);
SRCNEXTPIXEL(pbSrc);
DESTWRITEPIXEL(pbDest, temp);
DESTNEXTPIXEL(pbDest);
runLength = runLength - 1;
}
break;
/* Handle Special Order 1. */
case SPECIAL_FGBG_1:
pbSrc = pbSrc + 1;
if (fFirstLine)
{
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, g_MaskSpecialFgBg1, fgPel, 8);
}
else
{
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, g_MaskSpecialFgBg1, fgPel, 8);
}
break;
case SPECIAL_FGBG_1:
pbSrc = pbSrc + 1;
if (fFirstLine)
{
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, g_MaskSpecialFgBg1, fgPel, 8);
}
else
{
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, g_MaskSpecialFgBg1, fgPel, 8);
}
break;
/* Handle Special Order 2. */
case SPECIAL_FGBG_2:
pbSrc = pbSrc + 1;
if (fFirstLine)
{
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, g_MaskSpecialFgBg2, fgPel, 8);
}
else
{
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, g_MaskSpecialFgBg2, fgPel, 8);
}
break;
case SPECIAL_FGBG_2:
pbSrc = pbSrc + 1;
if (fFirstLine)
{
pbDest = WRITEFIRSTLINEFGBGIMAGE(pbDest, g_MaskSpecialFgBg2, fgPel, 8);
}
else
{
pbDest = WRITEFGBGIMAGE(pbDest, rowDelta, g_MaskSpecialFgBg2, fgPel, 8);
}
break;
/* Handle White Order. */
case SPECIAL_WHITE:
pbSrc = pbSrc + 1;
DESTWRITEPIXEL(pbDest, WHITE_PIXEL);
DESTNEXTPIXEL(pbDest);
break;
/* Handle White Order. */
case SPECIAL_WHITE:
pbSrc = pbSrc + 1;
DESTWRITEPIXEL(pbDest, WHITE_PIXEL);
DESTNEXTPIXEL(pbDest);
break;
/* Handle Black Order. */
case SPECIAL_BLACK:
pbSrc = pbSrc + 1;
DESTWRITEPIXEL(pbDest, BLACK_PIXEL);
DESTNEXTPIXEL(pbDest);
break;
case SPECIAL_BLACK:
pbSrc = pbSrc + 1;
DESTWRITEPIXEL(pbDest, BLACK_PIXEL);
DESTNEXTPIXEL(pbDest);
break;
}
}
}

View File

@ -5,6 +5,8 @@
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2015 Thincast Technologies GmbH
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -103,7 +105,7 @@ static INLINE UINT32 ExtractCodeId(BYTE bOrderHdr)
/**
* Extract the run length of a compression order.
*/
static INLINE UINT32 ExtractRunLength(UINT32 code, BYTE* pbOrderHdr, UINT32* advance)
static INLINE UINT32 ExtractRunLength(UINT32 code, const BYTE* pbOrderHdr, UINT32* advance)
{
UINT32 runLength;
UINT32 ladvance;
@ -112,63 +114,63 @@ static INLINE UINT32 ExtractRunLength(UINT32 code, BYTE* pbOrderHdr, UINT32* adv
runLength = 0;
switch (code)
{
case REGULAR_FGBG_IMAGE:
runLength = (*pbOrderHdr) & g_MaskRegularRunLength;
if (runLength == 0)
{
runLength = (*(pbOrderHdr + 1)) + 1;
ladvance += 1;
}
else
{
runLength = runLength * 8;
}
break;
case LITE_SET_FG_FGBG_IMAGE:
runLength = (*pbOrderHdr) & g_MaskLiteRunLength;
if (runLength == 0)
{
runLength = (*(pbOrderHdr + 1)) + 1;
ladvance += 1;
}
else
{
runLength = runLength * 8;
}
break;
case REGULAR_BG_RUN:
case REGULAR_FG_RUN:
case REGULAR_COLOR_RUN:
case REGULAR_COLOR_IMAGE:
runLength = (*pbOrderHdr) & g_MaskRegularRunLength;
if (runLength == 0)
{
/* An extended (MEGA) run. */
runLength = (*(pbOrderHdr + 1)) + 32;
ladvance += 1;
}
break;
case LITE_SET_FG_FG_RUN:
case LITE_DITHERED_RUN:
runLength = (*pbOrderHdr) & g_MaskLiteRunLength;
if (runLength == 0)
{
/* An extended (MEGA) run. */
runLength = (*(pbOrderHdr + 1)) + 16;
ladvance += 1;
}
break;
case MEGA_MEGA_BG_RUN:
case MEGA_MEGA_FG_RUN:
case MEGA_MEGA_SET_FG_RUN:
case MEGA_MEGA_DITHERED_RUN:
case MEGA_MEGA_COLOR_RUN:
case MEGA_MEGA_FGBG_IMAGE:
case MEGA_MEGA_SET_FGBG_IMAGE:
case MEGA_MEGA_COLOR_IMAGE:
runLength = ((UINT16) pbOrderHdr[1]) | ((UINT16) (pbOrderHdr[2] << 8));
ladvance += 2;
break;
case REGULAR_FGBG_IMAGE:
runLength = (*pbOrderHdr) & g_MaskRegularRunLength;
if (runLength == 0)
{
runLength = (*(pbOrderHdr + 1)) + 1;
ladvance += 1;
}
else
{
runLength = runLength * 8;
}
break;
case LITE_SET_FG_FGBG_IMAGE:
runLength = (*pbOrderHdr) & g_MaskLiteRunLength;
if (runLength == 0)
{
runLength = (*(pbOrderHdr + 1)) + 1;
ladvance += 1;
}
else
{
runLength = runLength * 8;
}
break;
case REGULAR_BG_RUN:
case REGULAR_FG_RUN:
case REGULAR_COLOR_RUN:
case REGULAR_COLOR_IMAGE:
runLength = (*pbOrderHdr) & g_MaskRegularRunLength;
if (runLength == 0)
{
/* An extended (MEGA) run. */
runLength = (*(pbOrderHdr + 1)) + 32;
ladvance += 1;
}
break;
case LITE_SET_FG_FG_RUN:
case LITE_DITHERED_RUN:
runLength = (*pbOrderHdr) & g_MaskLiteRunLength;
if (runLength == 0)
{
/* An extended (MEGA) run. */
runLength = (*(pbOrderHdr + 1)) + 16;
ladvance += 1;
}
break;
case MEGA_MEGA_BG_RUN:
case MEGA_MEGA_FG_RUN:
case MEGA_MEGA_SET_FG_RUN:
case MEGA_MEGA_DITHERED_RUN:
case MEGA_MEGA_COLOR_RUN:
case MEGA_MEGA_FGBG_IMAGE:
case MEGA_MEGA_SET_FGBG_IMAGE:
case MEGA_MEGA_COLOR_IMAGE:
runLength = ((UINT16) pbOrderHdr[1]) | ((UINT16) (pbOrderHdr[2] << 8));
ladvance += 2;
break;
}
*advance = ladvance;
return runLength;
@ -231,11 +233,11 @@ static INLINE UINT32 ExtractRunLength(UINT32 code, BYTE* pbOrderHdr, UINT32* adv
#undef RLEDECOMPRESS
#undef RLEEXTRA
#define DESTWRITEPIXEL(_buf, _pix) do { (_buf)[0] = (BYTE)(_pix); \
(_buf)[1] = (BYTE)((_pix) >> 8); (_buf)[2] = (BYTE)((_pix) >> 16); } while (0)
(_buf)[1] = (BYTE)((_pix) >> 8); (_buf)[2] = (BYTE)((_pix) >> 16); } while (0)
#define DESTREADPIXEL(_pix, _buf) _pix = (_buf)[0] | ((_buf)[1] << 8) | \
((_buf)[2] << 16)
((_buf)[2] << 16)
#define SRCREADPIXEL(_pix, _buf) _pix = (_buf)[0] | ((_buf)[1] << 8) | \
((_buf)[2] << 16)
((_buf)[2] << 16)
#define DESTNEXTPIXEL(_buf) _buf += 3
#define SRCNEXTPIXEL(_buf) _buf += 3
#define WRITEFGBGIMAGE WriteFgBgImage24to24
@ -244,22 +246,23 @@ static INLINE UINT32 ExtractRunLength(UINT32 code, BYTE* pbOrderHdr, UINT32* adv
#define RLEEXTRA
#include "include/bitmap.c"
int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcData, UINT32 SrcSize, int bpp,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BYTE* palette)
INT32 interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
const BYTE* pSrcData, UINT32 SrcSize,
UINT32 bpp,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight,
const UINT32* palette)
{
int status;
BOOL vFlip;
int scanline;
BYTE* pDstData;
INT32 status;
UINT32 scanline;
UINT32 SrcFormat;
UINT32 BufferSize;
int dstBitsPerPixel;
int dstBytesPerPixel;
UINT32 dstBitsPerPixel;
UINT32 dstBytesPerPixel;
pDstData = *ppDstData;
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
vFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat) ? TRUE : FALSE;
dstBitsPerPixel = GetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat);
if (!interleaved)
return -1;
@ -274,14 +277,6 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
SrcFormat = PIXEL_FORMAT_RGB24_VF;
#if 0
if ((SrcFormat == DstFormat) && !nXDst && !nYDst && (scanline == nDstStep))
{
RleDecompress24to24(pSrcData, SrcSize, pDstData, scanline, nWidth, nHeight);
return 1;
}
#endif
if (BufferSize > interleaved->TempSize)
{
interleaved->TempBuffer = _aligned_realloc(interleaved->TempBuffer, BufferSize, 16);
@ -294,7 +289,8 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight);
status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0, palette);
nWidth, nHeight, interleaved->TempBuffer,
SrcFormat, scanline, 0, 0, palette);
}
else if ((bpp == 16) || (bpp == 15))
{
@ -303,14 +299,6 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
SrcFormat = (bpp == 16) ? PIXEL_FORMAT_RGB16_VF : PIXEL_FORMAT_RGB15_VF;
#if 0
if ((SrcFormat == DstFormat) && !nXDst && !nYDst && (scanline == nDstStep))
{
RleDecompress16to16(pSrcData, SrcSize, pDstData, scanline, nWidth, nHeight);
return 1;
}
#endif
if (BufferSize > interleaved->TempSize)
{
interleaved->TempBuffer = _aligned_realloc(interleaved->TempBuffer, BufferSize, 16);
@ -322,8 +310,10 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight);
status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0, palette);
status = freerdp_image_copy(pDstData, DstFormat, nDstStep,
nXDst, nYDst, nWidth, nHeight,
interleaved->TempBuffer, SrcFormat,
scanline, 0, 0, palette);
}
else if (bpp == 8)
{
@ -332,14 +322,6 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
SrcFormat = PIXEL_FORMAT_RGB8_VF;
#if 0
if ((SrcFormat == DstFormat) && !nXDst && !nYDst && (scanline == nDstStep))
{
RleDecompress8to8(pSrcData, SrcSize, pDstData, scanline, nWidth, nHeight);
return 1;
}
#endif
if (BufferSize > interleaved->TempSize)
{
interleaved->TempBuffer = _aligned_realloc(interleaved->TempBuffer, BufferSize, 16);
@ -352,7 +334,8 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight);
status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
nWidth, nHeight, interleaved->TempBuffer, SrcFormat, scanline, 0, 0, palette);
nWidth, nHeight, interleaved->TempBuffer,
SrcFormat, scanline, 0, 0, palette);
}
else
{
@ -362,8 +345,12 @@ int interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pSrcDa
return 1;
}
int interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pDstData, UINT32* pDstSize,
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette, int bpp)
BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
BYTE* pDstData, UINT32* pDstSize,
UINT32 nWidth, UINT32 nHeight,
const BYTE* pSrcData, UINT32 SrcFormat,
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
const UINT32* palette, UINT32 bpp)
{
int status;
wStream* s;
@ -373,13 +360,13 @@ int interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pDstData
if (nWidth % 4)
{
WLog_ERR(TAG, "interleaved_compress: width is not a multiple of 4");
return -1;
return FALSE;
}
if ((nWidth > 64) || (nHeight > 64))
{
WLog_ERR(TAG, "interleaved_compress: width (%d) or height (%d) is greater than 64", nWidth, nHeight);
return -1;
return FALSE;
}
if (bpp == 24)
@ -392,18 +379,18 @@ int interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pDstData
DstFormat = PIXEL_FORMAT_RGB8;
if (!DstFormat)
return -1;
return FALSE;
status = freerdp_image_copy(interleaved->TempBuffer, DstFormat, -1, 0, 0, nWidth, nHeight,
pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette);
s = Stream_New(pDstData, maxSize);
if (!s)
return -1;
return FALSE;
status = freerdp_bitmap_compress((char*) interleaved->TempBuffer, nWidth, nHeight,
s, bpp, maxSize, nHeight - 1, interleaved->bts, 0);
s, bpp, maxSize, nHeight - 1, interleaved->bts, 0);
Stream_SealLength(s);
*pDstSize = (UINT32) Stream_Length(s);

View File

@ -4,6 +4,8 @@
*
* Copyright 2011 Samsung, Author Jiten Pathy
* Copyright 2012 Vic Lee
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,6 +31,7 @@
#include <winpr/crt.h>
#include <freerdp/codec/nsc.h>
#include <freerdp/codec/color.h>
#include "nsc_types.h"
#include "nsc_encode.h"
@ -56,21 +59,22 @@ static void nsc_decode(NSC_CONTEXT* context)
INT16 g_val;
INT16 b_val;
BYTE* bmpdata;
bmpdata = context->BitmapData;
rw = ROUND_UP_TO(context->width, 8);
shift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */
WLog_Print(context->priv->log, WLOG_DEBUG, "NscDecode: width: %d height: %d ChromaSubsamplingLevel: %d",
context->width, context->height, context->ChromaSubsamplingLevel);
WLog_Print(context->priv->log, WLOG_DEBUG,
"NscDecode: width: %d height: %d ChromaSubsamplingLevel: %d",
context->width, context->height, context->ChromaSubsamplingLevel);
for (y = 0; y < context->height; y++)
{
if (context->ChromaSubsamplingLevel)
{
yplane = context->priv->PlaneBuffers[0] + y * rw; /* Y */
coplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >> 1); /* Co, supersampled */
cgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >> 1); /* Cg, supersampled */
coplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>
1); /* Co, supersampled */
cgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>
1); /* Cg, supersampled */
}
else
{
@ -83,9 +87,9 @@ static void nsc_decode(NSC_CONTEXT* context)
for (x = 0; x < context->width; x++)
{
y_val = (INT16) *yplane;
co_val = (INT16) (INT8) (*coplane << shift);
cg_val = (INT16) (INT8) (*cgplane << shift);
y_val = (INT16) * yplane;
co_val = (INT16)(INT8)(*coplane << shift);
cg_val = (INT16)(INT8)(*cgplane << shift);
r_val = y_val + co_val - cg_val;
g_val = y_val + cg_val;
b_val = y_val - co_val - cg_val;
@ -106,7 +110,6 @@ static void nsc_rle_decode(BYTE* in, BYTE* out, UINT32 originalSize)
UINT32 len;
UINT32 left;
BYTE value;
left = originalSize;
while (left > 4)
@ -124,7 +127,7 @@ static void nsc_rle_decode(BYTE* in, BYTE* out, UINT32 originalSize)
if (*in < 0xFF)
{
len = (UINT32) *in++;
len = (UINT32) * in++;
len += 2;
}
else
@ -154,7 +157,6 @@ static void nsc_rle_decompress_data(NSC_CONTEXT* context)
BYTE* rle;
UINT32 planeSize;
UINT32 originalSize;
rle = context->Planes;
for (i = 0; i < 4; i++)
@ -184,9 +186,9 @@ static BOOL nsc_stream_initialize(NSC_CONTEXT* context, wStream* s)
Stream_Read_UINT32(s, context->PlaneByteCount[i]);
Stream_Read_UINT8(s, context->ColorLossLevel); /* ColorLossLevel (1 byte) */
Stream_Read_UINT8(s, context->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
Stream_Read_UINT8(s,
context->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
Stream_Seek(s, 2); /* Reserved (2 bytes) */
context->Planes = Stream_Pointer(s);
return TRUE;
}
@ -200,11 +202,13 @@ static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
if (!nsc_stream_initialize(context, s))
return FALSE;
length = context->width * context->height * 4;
if (!context->BitmapData)
{
context->BitmapData = calloc(1, length + 16);
if (!context->BitmapData)
return FALSE;
@ -212,17 +216,18 @@ static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
}
else if (length > context->BitmapDataLength)
{
void *tmp;
void* tmp;
tmp = realloc(context->BitmapData, length + 16);
if (!tmp)
return FALSE;
context->BitmapData = tmp;
context->BitmapDataLength = length;
}
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
/* The maximum length a decoded plane can reach in all cases */
length = tempWidth * tempHeight;
@ -230,9 +235,11 @@ static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
{
for (i = 0; i < 4; i++)
{
void * tmp = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);
void* tmp = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);
if (!tmp)
return FALSE;
context->priv->PlaneBuffers[i] = tmp;
}
@ -257,12 +264,10 @@ static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
static void nsc_profiler_print(NSC_CONTEXT* context)
{
PROFILER_PRINT_HEADER;
PROFILER_PRINT(context->priv->prof_nsc_rle_decompress_data);
PROFILER_PRINT(context->priv->prof_nsc_decode);
PROFILER_PRINT(context->priv->prof_nsc_rle_compress_data);
PROFILER_PRINT(context->priv->prof_nsc_encode);
PROFILER_PRINT_FOOTER;
}
@ -273,51 +278,45 @@ BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width, UINT32 height)
context->width = width;
context->height = height;
return TRUE;
}
NSC_CONTEXT* nsc_context_new(void)
{
NSC_CONTEXT* context;
context = (NSC_CONTEXT*) calloc(1, sizeof(NSC_CONTEXT));
if (!context)
return NULL;
context->priv = (NSC_CONTEXT_PRIV*) calloc(1, sizeof(NSC_CONTEXT_PRIV));
if (!context->priv)
goto error_priv;
WLog_Init();
context->priv->log = WLog_Get("com.freerdp.codec.nsc");
WLog_OpenAppender(context->priv->log);
context->BitmapData = NULL;
context->decode = nsc_decode;
context->encode = nsc_encode;
context->priv->PlanePool = BufferPool_New(TRUE, 0, 16);
if (!context->priv->PlanePool)
goto error_PlanePool;
PROFILER_CREATE(context->priv->prof_nsc_rle_decompress_data, "nsc_rle_decompress_data");
PROFILER_CREATE(context->priv->prof_nsc_rle_decompress_data,
"nsc_rle_decompress_data");
PROFILER_CREATE(context->priv->prof_nsc_decode, "nsc_decode");
PROFILER_CREATE(context->priv->prof_nsc_rle_compress_data, "nsc_rle_compress_data");
PROFILER_CREATE(context->priv->prof_nsc_rle_compress_data,
"nsc_rle_compress_data");
PROFILER_CREATE(context->priv->prof_nsc_encode, "nsc_encode");
/* Default encoding parameters */
context->ColorLossLevel = 3;
context->ChromaSubsamplingLevel = 1;
/* init optimized methods */
NSC_INIT_SIMD(context);
return context;
error_PlanePool:
free(context->priv);
error_priv:
@ -339,83 +338,75 @@ void nsc_context_free(NSC_CONTEXT* context)
}
free(context->BitmapData);
BufferPool_Free(context->priv->PlanePool);
nsc_profiler_print(context);
PROFILER_FREE(context->priv->prof_nsc_rle_decompress_data);
PROFILER_FREE(context->priv->prof_nsc_decode);
PROFILER_FREE(context->priv->prof_nsc_rle_compress_data);
PROFILER_FREE(context->priv->prof_nsc_encode);
free(context->priv);
free(context);
}
void nsc_context_set_pixel_format(NSC_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format)
BOOL nsc_context_set_pixel_format(NSC_CONTEXT* context, UINT32 pixel_format)
{
context->pixel_format = pixel_format;
switch (pixel_format)
{
case RDP_PIXEL_FORMAT_B8G8R8A8:
case RDP_PIXEL_FORMAT_R8G8B8A8:
context->bpp = 32;
break;
case RDP_PIXEL_FORMAT_B8G8R8:
case RDP_PIXEL_FORMAT_R8G8B8:
context->bpp = 24;
break;
case RDP_PIXEL_FORMAT_B5G6R5_LE:
case RDP_PIXEL_FORMAT_R5G6B5_LE:
context->bpp = 16;
break;
case RDP_PIXEL_FORMAT_P4_PLANER:
context->bpp = 4;
break;
case RDP_PIXEL_FORMAT_P8:
context->bpp = 8;
break;
default:
context->bpp = 0;
break;
}
context->format = pixel_format;
return TRUE;
}
int nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, UINT16 width, UINT16 height, BYTE* data, UINT32 length)
BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
UINT32 width, UINT32 height, const BYTE* data,
UINT32 length)
{
wStream* s;
BOOL ret;
s = Stream_New(data, length);
s = Stream_New((BYTE*)data, length);
if (!s)
return -1;
return FALSE;
switch (bpp)
{
case 32:
context->format = PIXEL_FORMAT_BGRA32;
break;
case 24:
context->format = PIXEL_FORMAT_BGR24;
break;
case 16:
context->format = PIXEL_FORMAT_BGR16;
break;
case 8:
context->format = PIXEL_FORMAT_RGB8;
break;
case 4:
context->format = PIXEL_FORMAT_A4;
break;
default:
return FALSE;
}
context->bpp = bpp;
context->width = width;
context->height = height;
ret = nsc_context_initialize(context, s);
Stream_Free(s, FALSE);
if (!ret)
return -1;
return FALSE;
/* RLE decode */
PROFILER_ENTER(context->priv->prof_nsc_rle_decompress_data);
nsc_rle_decompress_data(context);
PROFILER_EXIT(context->priv->prof_nsc_rle_decompress_data);
/* Colorloss recover, Chroma supersample and AYCoCg to ARGB Conversion in one step */
PROFILER_ENTER(context->priv->prof_nsc_decode);
context->decode(context);
PROFILER_EXIT(context->priv->prof_nsc_decode);
return 1;
return TRUE;
}

View File

@ -3,6 +3,8 @@
* NSCodec Encoder
*
* Copyright 2012 Vic Lee
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,6 +30,7 @@
#include <winpr/crt.h>
#include <freerdp/codec/nsc.h>
#include <freerdp/codec/color.h>
#include "nsc_types.h"
#include "nsc_encode.h"
@ -38,17 +41,16 @@ static void nsc_context_initialize_encode(NSC_CONTEXT* context)
UINT32 length;
UINT32 tempWidth;
UINT32 tempHeight;
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
/* The maximum length a decoded plane can reach in all cases */
length = tempWidth * tempHeight + 16;
if (length > context->priv->PlaneBuffersLength)
{
for (i = 0; i < 5; i++)
context->priv->PlaneBuffers[i] = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);
context->priv->PlaneBuffers[i] = (BYTE*) realloc(context->priv->PlaneBuffers[i],
length);
context->priv->PlaneBuffersLength = length;
}
@ -69,13 +71,14 @@ static void nsc_context_initialize_encode(NSC_CONTEXT* context)
}
}
static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, BYTE* data, int scanline)
static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data,
UINT32 scanline)
{
UINT16 x;
UINT16 y;
UINT16 rw;
BYTE ccl;
BYTE* src;
const BYTE* src;
BYTE* yplane;
BYTE* coplane;
BYTE* cgplane;
@ -86,7 +89,6 @@ static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, BYTE* data, int scan
BYTE a_val;
UINT32 tempWidth;
UINT32 tempHeight;
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
rw = (context->ChromaSubsamplingLevel ? tempWidth : context->width);
@ -108,55 +110,54 @@ static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, BYTE* data, int scan
{
switch (context->pixel_format)
{
case RDP_PIXEL_FORMAT_B8G8R8A8:
case PIXEL_FORMAT_BGRA32:
b_val = *src++;
g_val = *src++;
r_val = *src++;
a_val = *src++;
break;
case RDP_PIXEL_FORMAT_R8G8B8A8:
case PIXEL_FORMAT_RGBA32:
r_val = *src++;
g_val = *src++;
b_val = *src++;
a_val = *src++;
break;
case RDP_PIXEL_FORMAT_B8G8R8:
case PIXEL_FORMAT_BGR24:
b_val = *src++;
g_val = *src++;
r_val = *src++;
a_val = 0xFF;
break;
case RDP_PIXEL_FORMAT_R8G8B8:
case PIXEL_FORMAT_RGB24:
r_val = *src++;
g_val = *src++;
b_val = *src++;
a_val = 0xFF;
break;
case RDP_PIXEL_FORMAT_B5G6R5_LE:
b_val = (INT16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
g_val = (INT16) ((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
r_val = (INT16) ((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
case PIXEL_FORMAT_BGR16:
b_val = (INT16)(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
g_val = (INT16)((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
r_val = (INT16)((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
a_val = 0xFF;
src += 2;
break;
case RDP_PIXEL_FORMAT_R5G6B5_LE:
r_val = (INT16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
g_val = (INT16) ((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
b_val = (INT16) ((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
case PIXEL_FORMAT_RGB16:
r_val = (INT16)(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
g_val = (INT16)((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
b_val = (INT16)((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
a_val = 0xFF;
src += 2;
break;
case RDP_PIXEL_FORMAT_P4_PLANER:
case PIXEL_FORMAT_A4:
{
int shift;
BYTE idx;
shift = (7 - (x % 8));
idx = ((*src) >> shift) & 1;
idx |= (((*(src + 1)) >> shift) & 1) << 1;
@ -166,21 +167,23 @@ static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, BYTE* data, int scan
r_val = (INT16) context->palette[idx];
g_val = (INT16) context->palette[idx + 1];
b_val = (INT16) context->palette[idx + 2];
if (shift == 0)
src += 4;
}
a_val = 0xFF;
break;
case RDP_PIXEL_FORMAT_P8:
case PIXEL_FORMAT_RGB8:
{
int idx = (*src) * 3;
r_val = (INT16) context->palette[idx];
g_val = (INT16) context->palette[idx + 1];
b_val = (INT16) context->palette[idx + 2];
src++;
}
a_val = 0xFF;
break;
@ -189,11 +192,10 @@ static void nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, BYTE* data, int scan
break;
}
*yplane++ = (BYTE) ((r_val >> 2) + (g_val >> 1) + (b_val >> 2));
*yplane++ = (BYTE)((r_val >> 2) + (g_val >> 1) + (b_val >> 2));
/* Perform color loss reduction here */
*coplane++ = (BYTE) ((r_val - b_val) >> ccl);
*cgplane++ = (BYTE) ((-(r_val >> 1) + g_val - (b_val >> 1)) >> ccl);
*coplane++ = (BYTE)((r_val - b_val) >> ccl);
*cgplane++ = (BYTE)((-(r_val >> 1) + g_val - (b_val >> 1)) >> ccl);
*aplane++ = a_val;
}
@ -225,7 +227,6 @@ static void nsc_encode_subsampling(NSC_CONTEXT* context)
INT8* cg_src1;
UINT32 tempWidth;
UINT32 tempHeight;
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
@ -240,10 +241,10 @@ static void nsc_encode_subsampling(NSC_CONTEXT* context)
for (x = 0; x < tempWidth >> 1; x++)
{
*co_dst++ = (BYTE) (((INT16) *co_src0 + (INT16) *(co_src0 + 1) +
(INT16) *co_src1 + (INT16) *(co_src1 + 1)) >> 2);
*cg_dst++ = (BYTE) (((INT16) *cg_src0 + (INT16) *(cg_src0 + 1) +
(INT16) *cg_src1 + (INT16) *(cg_src1 + 1)) >> 2);
*co_dst++ = (BYTE)(((INT16) * co_src0 + (INT16) * (co_src0 + 1) +
(INT16) * co_src1 + (INT16) * (co_src1 + 1)) >> 2);
*cg_dst++ = (BYTE)(((INT16) * cg_src0 + (INT16) * (cg_src0 + 1) +
(INT16) * cg_src1 + (INT16) * (cg_src1 + 1)) >> 2);
co_src0 += 2;
co_src1 += 2;
cg_src0 += 2;
@ -252,7 +253,7 @@ static void nsc_encode_subsampling(NSC_CONTEXT* context)
}
}
void nsc_encode(NSC_CONTEXT* context, BYTE* bmpdata, int rowstride)
void nsc_encode(NSC_CONTEXT* context, const BYTE* bmpdata, UINT32 rowstride)
{
nsc_encode_argb_to_aycocg(context, bmpdata, rowstride);
@ -267,8 +268,8 @@ static UINT32 nsc_rle_encode(BYTE* in, BYTE* out, UINT32 originalSize)
UINT32 left;
UINT32 runlength = 1;
UINT32 planeSize = 0;
left = originalSize;
/**
* We quit the loop if the running compressed size is larger than the original.
* In such cases data will be sent uncompressed.
@ -304,6 +305,7 @@ static UINT32 nsc_rle_encode(BYTE* in, BYTE* out, UINT32 originalSize)
runlength = 1;
planeSize += 7;
}
in++;
left--;
}
@ -312,7 +314,6 @@ static UINT32 nsc_rle_encode(BYTE* in, BYTE* out, UINT32 originalSize)
CopyMemory(out, in, 4);
planeSize += 4;
return planeSize;
}
@ -332,10 +333,12 @@ static void nsc_rle_compress_data(NSC_CONTEXT* context)
}
else
{
planeSize = nsc_rle_encode(context->priv->PlaneBuffers[i], context->priv->PlaneBuffers[4], originalSize);
planeSize = nsc_rle_encode(context->priv->PlaneBuffers[i],
context->priv->PlaneBuffers[4], originalSize);
if (planeSize < originalSize)
CopyMemory(context->priv->PlaneBuffers[i], context->priv->PlaneBuffers[4], planeSize);
CopyMemory(context->priv->PlaneBuffers[i], context->priv->PlaneBuffers[4],
planeSize);
else
planeSize = originalSize;
}
@ -344,15 +347,14 @@ static void nsc_rle_compress_data(NSC_CONTEXT* context)
}
}
UINT32 nsc_compute_byte_count(NSC_CONTEXT* context, UINT32* ByteCount, UINT32 width, UINT32 height)
UINT32 nsc_compute_byte_count(NSC_CONTEXT* context, UINT32* ByteCount,
UINT32 width, UINT32 height)
{
UINT32 tempWidth;
UINT32 tempHeight;
UINT32 maxPlaneSize;
tempWidth = ROUND_UP_TO(width, 8);
tempHeight = ROUND_UP_TO(height, 2);
maxPlaneSize = tempWidth * tempHeight + 16;
if (context->ChromaSubsamplingLevel)
@ -373,35 +375,34 @@ UINT32 nsc_compute_byte_count(NSC_CONTEXT* context, UINT32* ByteCount, UINT32 wi
return maxPlaneSize;
}
NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, BYTE* data, int x, int y,
int width, int height, int scanline, int* numMessages, int maxDataSize)
NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, const BYTE* data,
UINT32 x, UINT32 y, UINT32 width, UINT32 height,
UINT32 scanline, UINT32* numMessages,
UINT32 maxDataSize)
{
int i, j, k;
int dataOffset;
int rows, cols;
int BytesPerPixel;
int MaxRegionWidth;
int MaxRegionHeight;
UINT32 i, j, k;
UINT32 dataOffset;
UINT32 rows, cols;
UINT32 BytesPerPixel;
UINT32 MaxRegionWidth;
UINT32 MaxRegionHeight;
UINT32 ByteCount[4];
UINT32 MaxPlaneSize;
UINT32 MaxMessageSize;
NSC_MESSAGE* messages;
UINT32 PaddedMaxPlaneSize;
k = 0;
MaxRegionWidth = 64 * 4;
MaxRegionHeight = 64 * 2;
BytesPerPixel = (context->bpp / 8);
BytesPerPixel = GetBytesPerPixel(context->format);
rows = (width + (MaxRegionWidth - (width % MaxRegionWidth))) / MaxRegionWidth;
cols = (height + (MaxRegionHeight - (height % MaxRegionHeight))) / MaxRegionHeight;
cols = (height + (MaxRegionHeight - (height % MaxRegionHeight))) /
MaxRegionHeight;
*numMessages = rows * cols;
MaxPlaneSize = nsc_compute_byte_count(context, (UINT32*) ByteCount, width, height);
MaxPlaneSize = nsc_compute_byte_count(context, (UINT32*) ByteCount, width,
height);
MaxMessageSize = ByteCount[0] + ByteCount[1] + ByteCount[2] + ByteCount[3] + 20;
maxDataSize -= 1024; /* reserve enough space for headers */
messages = (NSC_MESSAGE*) calloc(*numMessages, sizeof(NSC_MESSAGE));
if (!messages)
@ -413,14 +414,14 @@ NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, BYTE* data, int x, int y,
{
messages[k].x = x + (i * MaxRegionWidth);
messages[k].y = y + (j * MaxRegionHeight);
messages[k].width = (i < (rows - 1)) ? MaxRegionWidth : width - (i * MaxRegionWidth);
messages[k].height = (j < (cols - 1)) ? MaxRegionHeight : height - (j * MaxRegionHeight);
messages[k].width = (i < (rows - 1)) ? MaxRegionWidth : width -
(i * MaxRegionWidth);
messages[k].height = (j < (cols - 1)) ? MaxRegionHeight : height -
(j * MaxRegionHeight);
messages[k].data = data;
messages[k].scanline = scanline;
messages[k].MaxPlaneSize = nsc_compute_byte_count(context,
(UINT32*) messages[k].OrgByteCount, messages[k].width, messages[k].height);
(UINT32*) messages[k].OrgByteCount, messages[k].width, messages[k].height);
k++;
}
}
@ -430,14 +431,18 @@ NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, BYTE* data, int x, int y,
for (i = 0; i < *numMessages; i++)
{
PaddedMaxPlaneSize = messages[i].MaxPlaneSize + 32;
messages[i].PlaneBuffer = (BYTE*) BufferPool_Take(context->priv->PlanePool, PaddedMaxPlaneSize * 5);
messages[i].PlaneBuffers[0] = (BYTE*) &(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 0) + 16]);
messages[i].PlaneBuffers[1] = (BYTE*) &(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 1) + 16]);
messages[i].PlaneBuffers[2] = (BYTE*) &(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 2) + 16]);
messages[i].PlaneBuffers[3] = (BYTE*) &(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 3) + 16]);
messages[i].PlaneBuffers[4] = (BYTE*) &(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 4) + 16]);
messages[i].PlaneBuffer = (BYTE*) BufferPool_Take(context->priv->PlanePool,
PaddedMaxPlaneSize * 5);
messages[i].PlaneBuffers[0] = (BYTE*) &
(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 0) + 16]);
messages[i].PlaneBuffers[1] = (BYTE*) &
(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 1) + 16]);
messages[i].PlaneBuffers[2] = (BYTE*) &
(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 2) + 16]);
messages[i].PlaneBuffers[3] = (BYTE*) &
(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 3) + 16]);
messages[i].PlaneBuffers[4] = (BYTE*) &
(messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 4) + 16]);
}
for (i = 0; i < *numMessages; i++)
@ -454,17 +459,14 @@ NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, BYTE* data, int x, int y,
context->priv->PlaneBuffers[2] = messages[i].PlaneBuffers[2];
context->priv->PlaneBuffers[3] = messages[i].PlaneBuffers[3];
context->priv->PlaneBuffers[4] = messages[i].PlaneBuffers[4];
dataOffset = (messages[i].y * messages[i].scanline) + (messages[i].x * BytesPerPixel);
dataOffset = (messages[i].y * messages[i].scanline) + (messages[i].x *
BytesPerPixel);
PROFILER_ENTER(context->priv->prof_nsc_encode);
context->encode(context, &data[dataOffset], scanline);
PROFILER_EXIT(context->priv->prof_nsc_encode);
PROFILER_ENTER(context->priv->prof_nsc_rle_compress_data);
nsc_rle_compress_data(context);
PROFILER_EXIT(context->priv->prof_nsc_rle_compress_data);
messages[i].LumaPlaneByteCount = context->PlaneByteCount[0];
messages[i].OrangeChromaPlaneByteCount = context->PlaneByteCount[1];
messages[i].GreenChromaPlaneByteCount = context->PlaneByteCount[2];
@ -478,78 +480,81 @@ NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, BYTE* data, int x, int y,
context->priv->PlaneBuffers[2] = NULL;
context->priv->PlaneBuffers[3] = NULL;
context->priv->PlaneBuffers[4] = NULL;
return messages;
}
int nsc_write_message(NSC_CONTEXT* context, wStream* s, NSC_MESSAGE* message)
BOOL nsc_write_message(NSC_CONTEXT* context, wStream* s, NSC_MESSAGE* message)
{
UINT32 totalPlaneByteCount;
totalPlaneByteCount = message->LumaPlaneByteCount + message->OrangeChromaPlaneByteCount +
message->GreenChromaPlaneByteCount + message->AlphaPlaneByteCount;
totalPlaneByteCount = message->LumaPlaneByteCount +
message->OrangeChromaPlaneByteCount +
message->GreenChromaPlaneByteCount + message->AlphaPlaneByteCount;
if (!Stream_EnsureRemainingCapacity(s, 20 + totalPlaneByteCount))
return -1;
Stream_Write_UINT32(s, message->LumaPlaneByteCount); /* LumaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s, message->OrangeChromaPlaneByteCount); /* OrangeChromaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s, message->GreenChromaPlaneByteCount); /* GreenChromaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s, message->AlphaPlaneByteCount); /* AlphaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s,
message->LumaPlaneByteCount); /* LumaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s,
message->OrangeChromaPlaneByteCount); /* OrangeChromaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s,
message->GreenChromaPlaneByteCount); /* GreenChromaPlaneByteCount (4 bytes) */
Stream_Write_UINT32(s,
message->AlphaPlaneByteCount); /* AlphaPlaneByteCount (4 bytes) */
Stream_Write_UINT8(s, message->ColorLossLevel); /* ColorLossLevel (1 byte) */
Stream_Write_UINT8(s, message->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
Stream_Write_UINT8(s,
message->ChromaSubsamplingLevel); /* ChromaSubsamplingLevel (1 byte) */
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
if (message->LumaPlaneByteCount)
Stream_Write(s, message->PlaneBuffers[0], message->LumaPlaneByteCount); /* LumaPlane */
Stream_Write(s, message->PlaneBuffers[0],
message->LumaPlaneByteCount); /* LumaPlane */
if (message->OrangeChromaPlaneByteCount)
Stream_Write(s, message->PlaneBuffers[1], message->OrangeChromaPlaneByteCount); /* OrangeChromaPlane */
Stream_Write(s, message->PlaneBuffers[1],
message->OrangeChromaPlaneByteCount); /* OrangeChromaPlane */
if (message->GreenChromaPlaneByteCount)
Stream_Write(s, message->PlaneBuffers[2], message->GreenChromaPlaneByteCount); /* GreenChromaPlane */
Stream_Write(s, message->PlaneBuffers[2],
message->GreenChromaPlaneByteCount); /* GreenChromaPlane */
if (message->AlphaPlaneByteCount)
Stream_Write(s, message->PlaneBuffers[3], message->AlphaPlaneByteCount); /* AlphaPlane */
Stream_Write(s, message->PlaneBuffers[3],
message->AlphaPlaneByteCount); /* AlphaPlane */
return 0;
return TRUE;
}
int nsc_message_free(NSC_CONTEXT* context, NSC_MESSAGE* message)
void nsc_message_free(NSC_CONTEXT* context, NSC_MESSAGE* message)
{
BufferPool_Return(context->priv->PlanePool, message->PlaneBuffer);
return 0;
}
void nsc_compose_message(NSC_CONTEXT* context, wStream* s, BYTE* data, int width, int height, int scanline)
BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s, const BYTE* data,
UINT32 width, UINT32 height, UINT32 scanline)
{
NSC_MESSAGE s_message = { 0 };
NSC_MESSAGE* message = &s_message;
context->width = width;
context->height = height;
nsc_context_initialize_encode(context);
/* ARGB to AYCoCg conversion, chroma subsampling and colorloss reduction */
PROFILER_ENTER(context->priv->prof_nsc_encode);
context->encode(context, data, scanline);
PROFILER_EXIT(context->priv->prof_nsc_encode);
/* RLE encode */
PROFILER_ENTER(context->priv->prof_nsc_rle_compress_data);
nsc_rle_compress_data(context);
PROFILER_EXIT(context->priv->prof_nsc_rle_compress_data);
message->PlaneBuffers[0] = context->priv->PlaneBuffers[0];
message->PlaneBuffers[1] = context->priv->PlaneBuffers[1];
message->PlaneBuffers[2] = context->priv->PlaneBuffers[2];
message->PlaneBuffers[3] = context->priv->PlaneBuffers[3];
message->LumaPlaneByteCount = context->PlaneByteCount[0];
message->OrangeChromaPlaneByteCount = context->PlaneByteCount[1];
message->GreenChromaPlaneByteCount = context->PlaneByteCount[2];
message->AlphaPlaneByteCount = context->PlaneByteCount[3];
message->ColorLossLevel = context->ColorLossLevel;
message->ChromaSubsamplingLevel = context->ChromaSubsamplingLevel;
nsc_write_message(context, s, message);
return nsc_write_message(context, s, message);
}

View File

@ -3,6 +3,8 @@
* NSCodec Encoder
*
* Copyright 2012 Vic Lee
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +22,6 @@
#ifndef __NSC_ENCODE_H
#define __NSC_ENCODE_H
void nsc_encode(NSC_CONTEXT* context, BYTE* bmpdata, int rowstride);
void nsc_encode(NSC_CONTEXT* context, const BYTE* bmpdata, UINT32 rowstride);
#endif

View File

@ -28,18 +28,20 @@
#include <xmmintrin.h>
#include <emmintrin.h>
#include <freerdp/codec/color.h>
#include <winpr/crt.h>
#include "nsc_types.h"
#include "nsc_sse2.h"
static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, BYTE* data, int scanline)
static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context,
const BYTE* data, UINT32 scanline)
{
UINT16 x;
UINT16 y;
UINT16 rw;
BYTE ccl;
BYTE* src;
const BYTE* src;
BYTE* yplane;
BYTE* coplane;
BYTE* cgplane;
@ -53,7 +55,6 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, BYTE* data, int
__m128i cg_val;
UINT32 tempWidth;
UINT32 tempHeight;
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
rw = (context->ChromaSubsamplingLevel > 0 ? tempWidth : context->width);
@ -75,103 +76,117 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, BYTE* data, int
{
switch (context->pixel_format)
{
case RDP_PIXEL_FORMAT_B8G8R8A8:
b_val = _mm_set_epi16(*(src + 28), *(src + 24), *(src + 20), *(src + 16), *(src + 12), *(src + 8), *(src + 4), *src);
g_val = _mm_set_epi16(*(src + 29), *(src + 25), *(src + 21), *(src + 17), *(src + 13), *(src + 9), *(src + 5), *(src + 1));
r_val = _mm_set_epi16(*(src + 30), *(src + 26), *(src + 22), *(src + 18), *(src + 14), *(src + 10), *(src + 6), *(src + 2));
a_val = _mm_set_epi16(*(src + 31), *(src + 27), *(src + 23), *(src + 19), *(src + 15), *(src + 11), *(src + 7), *(src + 3));
case PIXEL_FORMAT_BGRA32:
b_val = _mm_set_epi16(*(src + 28), *(src + 24), *(src + 20), *(src + 16),
*(src + 12), *(src + 8), *(src + 4), *src);
g_val = _mm_set_epi16(*(src + 29), *(src + 25), *(src + 21), *(src + 17),
*(src + 13), *(src + 9), *(src + 5), *(src + 1));
r_val = _mm_set_epi16(*(src + 30), *(src + 26), *(src + 22), *(src + 18),
*(src + 14), *(src + 10), *(src + 6), *(src + 2));
a_val = _mm_set_epi16(*(src + 31), *(src + 27), *(src + 23), *(src + 19),
*(src + 15), *(src + 11), *(src + 7), *(src + 3));
src += 32;
break;
case RDP_PIXEL_FORMAT_R8G8B8A8:
r_val = _mm_set_epi16(*(src + 28), *(src + 24), *(src + 20), *(src + 16), *(src + 12), *(src + 8), *(src + 4), *src);
g_val = _mm_set_epi16(*(src + 29), *(src + 25), *(src + 21), *(src + 17), *(src + 13), *(src + 9), *(src + 5), *(src + 1));
b_val = _mm_set_epi16(*(src + 30), *(src + 26), *(src + 22), *(src + 18), *(src + 14), *(src + 10), *(src + 6), *(src + 2));
a_val = _mm_set_epi16(*(src + 31), *(src + 27), *(src + 23), *(src + 19), *(src + 15), *(src + 11), *(src + 7), *(src + 3));
case PIXEL_FORMAT_RGBA32:
r_val = _mm_set_epi16(*(src + 28), *(src + 24), *(src + 20), *(src + 16),
*(src + 12), *(src + 8), *(src + 4), *src);
g_val = _mm_set_epi16(*(src + 29), *(src + 25), *(src + 21), *(src + 17),
*(src + 13), *(src + 9), *(src + 5), *(src + 1));
b_val = _mm_set_epi16(*(src + 30), *(src + 26), *(src + 22), *(src + 18),
*(src + 14), *(src + 10), *(src + 6), *(src + 2));
a_val = _mm_set_epi16(*(src + 31), *(src + 27), *(src + 23), *(src + 19),
*(src + 15), *(src + 11), *(src + 7), *(src + 3));
src += 32;
break;
case RDP_PIXEL_FORMAT_B8G8R8:
b_val = _mm_set_epi16(*(src + 21), *(src + 18), *(src + 15), *(src + 12), *(src + 9), *(src + 6), *(src + 3), *src);
g_val = _mm_set_epi16(*(src + 22), *(src + 19), *(src + 16), *(src + 13), *(src + 10), *(src + 7), *(src + 4), *(src + 1));
r_val = _mm_set_epi16(*(src + 23), *(src + 20), *(src + 17), *(src + 14), *(src + 11), *(src + 8), *(src + 5), *(src + 2));
case PIXEL_FORMAT_BGR24:
b_val = _mm_set_epi16(*(src + 21), *(src + 18), *(src + 15), *(src + 12),
*(src + 9), *(src + 6), *(src + 3), *src);
g_val = _mm_set_epi16(*(src + 22), *(src + 19), *(src + 16), *(src + 13),
*(src + 10), *(src + 7), *(src + 4), *(src + 1));
r_val = _mm_set_epi16(*(src + 23), *(src + 20), *(src + 17), *(src + 14),
*(src + 11), *(src + 8), *(src + 5), *(src + 2));
a_val = _mm_set1_epi16(0xFF);
src += 24;
break;
case RDP_PIXEL_FORMAT_R8G8B8:
r_val = _mm_set_epi16(*(src + 21), *(src + 18), *(src + 15), *(src + 12), *(src + 9), *(src + 6), *(src + 3), *src);
g_val = _mm_set_epi16(*(src + 22), *(src + 19), *(src + 16), *(src + 13), *(src + 10), *(src + 7), *(src + 4), *(src + 1));
b_val = _mm_set_epi16(*(src + 23), *(src + 20), *(src + 17), *(src + 14), *(src + 11), *(src + 8), *(src + 5), *(src + 2));
case PIXEL_FORMAT_RGB24:
r_val = _mm_set_epi16(*(src + 21), *(src + 18), *(src + 15), *(src + 12),
*(src + 9), *(src + 6), *(src + 3), *src);
g_val = _mm_set_epi16(*(src + 22), *(src + 19), *(src + 16), *(src + 13),
*(src + 10), *(src + 7), *(src + 4), *(src + 1));
b_val = _mm_set_epi16(*(src + 23), *(src + 20), *(src + 17), *(src + 14),
*(src + 11), *(src + 8), *(src + 5), *(src + 2));
a_val = _mm_set1_epi16(0xFF);
src += 24;
break;
case RDP_PIXEL_FORMAT_B5G6R5_LE:
case PIXEL_FORMAT_BGR16:
b_val = _mm_set_epi16(
(((*(src + 15)) & 0xF8) | ((*(src + 15)) >> 5)),
(((*(src + 13)) & 0xF8) | ((*(src + 13)) >> 5)),
(((*(src + 11)) & 0xF8) | ((*(src + 11)) >> 5)),
(((*(src + 9)) & 0xF8) | ((*(src + 9)) >> 5)),
(((*(src + 7)) & 0xF8) | ((*(src + 7)) >> 5)),
(((*(src + 5)) & 0xF8) | ((*(src + 5)) >> 5)),
(((*(src + 3)) & 0xF8) | ((*(src + 3)) >> 5)),
(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5)));
(((*(src + 15)) & 0xF8) | ((*(src + 15)) >> 5)),
(((*(src + 13)) & 0xF8) | ((*(src + 13)) >> 5)),
(((*(src + 11)) & 0xF8) | ((*(src + 11)) >> 5)),
(((*(src + 9)) & 0xF8) | ((*(src + 9)) >> 5)),
(((*(src + 7)) & 0xF8) | ((*(src + 7)) >> 5)),
(((*(src + 5)) & 0xF8) | ((*(src + 5)) >> 5)),
(((*(src + 3)) & 0xF8) | ((*(src + 3)) >> 5)),
(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5)));
g_val = _mm_set_epi16(
((((*(src + 15)) & 0x07) << 5) | (((*(src + 14)) & 0xE0) >> 3)),
((((*(src + 13)) & 0x07) << 5) | (((*(src + 12)) & 0xE0) >> 3)),
((((*(src + 11)) & 0x07) << 5) | (((*(src + 10)) & 0xE0) >> 3)),
((((*(src + 9)) & 0x07) << 5) | (((*(src + 8)) & 0xE0) >> 3)),
((((*(src + 7)) & 0x07) << 5) | (((*(src + 6)) & 0xE0) >> 3)),
((((*(src + 5)) & 0x07) << 5) | (((*(src + 4)) & 0xE0) >> 3)),
((((*(src + 3)) & 0x07) << 5) | (((*(src + 2)) & 0xE0) >> 3)),
((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3)));
((((*(src + 15)) & 0x07) << 5) | (((*(src + 14)) & 0xE0) >> 3)),
((((*(src + 13)) & 0x07) << 5) | (((*(src + 12)) & 0xE0) >> 3)),
((((*(src + 11)) & 0x07) << 5) | (((*(src + 10)) & 0xE0) >> 3)),
((((*(src + 9)) & 0x07) << 5) | (((*(src + 8)) & 0xE0) >> 3)),
((((*(src + 7)) & 0x07) << 5) | (((*(src + 6)) & 0xE0) >> 3)),
((((*(src + 5)) & 0x07) << 5) | (((*(src + 4)) & 0xE0) >> 3)),
((((*(src + 3)) & 0x07) << 5) | (((*(src + 2)) & 0xE0) >> 3)),
((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3)));
r_val = _mm_set_epi16(
((((*(src + 14)) & 0x1F) << 3) | (((*(src + 14)) >> 2) & 0x07)),
((((*(src + 12)) & 0x1F) << 3) | (((*(src + 12)) >> 2) & 0x07)),
((((*(src + 10)) & 0x1F) << 3) | (((*(src + 10)) >> 2) & 0x07)),
((((*(src + 8)) & 0x1F) << 3) | (((*(src + 8)) >> 2) & 0x07)),
((((*(src + 6)) & 0x1F) << 3) | (((*(src + 6)) >> 2) & 0x07)),
((((*(src + 4)) & 0x1F) << 3) | (((*(src + 4)) >> 2) & 0x07)),
((((*(src + 2)) & 0x1F) << 3) | (((*(src + 2)) >> 2) & 0x07)),
((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07)));
((((*(src + 14)) & 0x1F) << 3) | (((*(src + 14)) >> 2) & 0x07)),
((((*(src + 12)) & 0x1F) << 3) | (((*(src + 12)) >> 2) & 0x07)),
((((*(src + 10)) & 0x1F) << 3) | (((*(src + 10)) >> 2) & 0x07)),
((((*(src + 8)) & 0x1F) << 3) | (((*(src + 8)) >> 2) & 0x07)),
((((*(src + 6)) & 0x1F) << 3) | (((*(src + 6)) >> 2) & 0x07)),
((((*(src + 4)) & 0x1F) << 3) | (((*(src + 4)) >> 2) & 0x07)),
((((*(src + 2)) & 0x1F) << 3) | (((*(src + 2)) >> 2) & 0x07)),
((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07)));
a_val = _mm_set1_epi16(0xFF);
src += 16;
break;
case RDP_PIXEL_FORMAT_R5G6B5_LE:
case PIXEL_FORMAT_RGB16:
r_val = _mm_set_epi16(
(((*(src + 15)) & 0xF8) | ((*(src + 15)) >> 5)),
(((*(src + 13)) & 0xF8) | ((*(src + 13)) >> 5)),
(((*(src + 11)) & 0xF8) | ((*(src + 11)) >> 5)),
(((*(src + 9)) & 0xF8) | ((*(src + 9)) >> 5)),
(((*(src + 7)) & 0xF8) | ((*(src + 7)) >> 5)),
(((*(src + 5)) & 0xF8) | ((*(src + 5)) >> 5)),
(((*(src + 3)) & 0xF8) | ((*(src + 3)) >> 5)),
(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5)));
(((*(src + 15)) & 0xF8) | ((*(src + 15)) >> 5)),
(((*(src + 13)) & 0xF8) | ((*(src + 13)) >> 5)),
(((*(src + 11)) & 0xF8) | ((*(src + 11)) >> 5)),
(((*(src + 9)) & 0xF8) | ((*(src + 9)) >> 5)),
(((*(src + 7)) & 0xF8) | ((*(src + 7)) >> 5)),
(((*(src + 5)) & 0xF8) | ((*(src + 5)) >> 5)),
(((*(src + 3)) & 0xF8) | ((*(src + 3)) >> 5)),
(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5)));
g_val = _mm_set_epi16(
((((*(src + 15)) & 0x07) << 5) | (((*(src + 14)) & 0xE0) >> 3)),
((((*(src + 13)) & 0x07) << 5) | (((*(src + 12)) & 0xE0) >> 3)),
((((*(src + 11)) & 0x07) << 5) | (((*(src + 10)) & 0xE0) >> 3)),
((((*(src + 9)) & 0x07) << 5) | (((*(src + 8)) & 0xE0) >> 3)),
((((*(src + 7)) & 0x07) << 5) | (((*(src + 6)) & 0xE0) >> 3)),
((((*(src + 5)) & 0x07) << 5) | (((*(src + 4)) & 0xE0) >> 3)),
((((*(src + 3)) & 0x07) << 5) | (((*(src + 2)) & 0xE0) >> 3)),
((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3)));
((((*(src + 15)) & 0x07) << 5) | (((*(src + 14)) & 0xE0) >> 3)),
((((*(src + 13)) & 0x07) << 5) | (((*(src + 12)) & 0xE0) >> 3)),
((((*(src + 11)) & 0x07) << 5) | (((*(src + 10)) & 0xE0) >> 3)),
((((*(src + 9)) & 0x07) << 5) | (((*(src + 8)) & 0xE0) >> 3)),
((((*(src + 7)) & 0x07) << 5) | (((*(src + 6)) & 0xE0) >> 3)),
((((*(src + 5)) & 0x07) << 5) | (((*(src + 4)) & 0xE0) >> 3)),
((((*(src + 3)) & 0x07) << 5) | (((*(src + 2)) & 0xE0) >> 3)),
((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3)));
b_val = _mm_set_epi16(
((((*(src + 14)) & 0x1F) << 3) | (((*(src + 14)) >> 2) & 0x07)),
((((*(src + 12)) & 0x1F) << 3) | (((*(src + 12)) >> 2) & 0x07)),
((((*(src + 10)) & 0x1F) << 3) | (((*(src + 10)) >> 2) & 0x07)),
((((*(src + 8)) & 0x1F) << 3) | (((*(src + 8)) >> 2) & 0x07)),
((((*(src + 6)) & 0x1F) << 3) | (((*(src + 6)) >> 2) & 0x07)),
((((*(src + 4)) & 0x1F) << 3) | (((*(src + 4)) >> 2) & 0x07)),
((((*(src + 2)) & 0x1F) << 3) | (((*(src + 2)) >> 2) & 0x07)),
((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07)));
((((*(src + 14)) & 0x1F) << 3) | (((*(src + 14)) >> 2) & 0x07)),
((((*(src + 12)) & 0x1F) << 3) | (((*(src + 12)) >> 2) & 0x07)),
((((*(src + 10)) & 0x1F) << 3) | (((*(src + 10)) >> 2) & 0x07)),
((((*(src + 8)) & 0x1F) << 3) | (((*(src + 8)) >> 2) & 0x07)),
((((*(src + 6)) & 0x1F) << 3) | (((*(src + 6)) >> 2) & 0x07)),
((((*(src + 4)) & 0x1F) << 3) | (((*(src + 4)) >> 2) & 0x07)),
((((*(src + 2)) & 0x1F) << 3) | (((*(src + 2)) >> 2) & 0x07)),
((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07)));
a_val = _mm_set1_epi16(0xFF);
src += 16;
break;
case RDP_PIXEL_FORMAT_P4_PLANER:
case PIXEL_FORMAT_A4:
{
int shift;
BYTE idx[8];
@ -184,69 +199,72 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, BYTE* data, int
idx[shift] |= (((*(src + 3)) >> shift) & 1) << 3;
idx[shift] *= 3;
}
r_val = _mm_set_epi16(
context->palette[idx[0]],
context->palette[idx[1]],
context->palette[idx[2]],
context->palette[idx[3]],
context->palette[idx[4]],
context->palette[idx[5]],
context->palette[idx[6]],
context->palette[idx[7]]);
context->palette[idx[0]],
context->palette[idx[1]],
context->palette[idx[2]],
context->palette[idx[3]],
context->palette[idx[4]],
context->palette[idx[5]],
context->palette[idx[6]],
context->palette[idx[7]]);
g_val = _mm_set_epi16(
context->palette[idx[0] + 1],
context->palette[idx[1] + 1],
context->palette[idx[2] + 1],
context->palette[idx[3] + 1],
context->palette[idx[4] + 1],
context->palette[idx[5] + 1],
context->palette[idx[6] + 1],
context->palette[idx[7] + 1]);
context->palette[idx[0] + 1],
context->palette[idx[1] + 1],
context->palette[idx[2] + 1],
context->palette[idx[3] + 1],
context->palette[idx[4] + 1],
context->palette[idx[5] + 1],
context->palette[idx[6] + 1],
context->palette[idx[7] + 1]);
b_val = _mm_set_epi16(
context->palette[idx[0] + 2],
context->palette[idx[1] + 2],
context->palette[idx[2] + 2],
context->palette[idx[3] + 2],
context->palette[idx[4] + 2],
context->palette[idx[5] + 2],
context->palette[idx[6] + 2],
context->palette[idx[7] + 2]);
context->palette[idx[0] + 2],
context->palette[idx[1] + 2],
context->palette[idx[2] + 2],
context->palette[idx[3] + 2],
context->palette[idx[4] + 2],
context->palette[idx[5] + 2],
context->palette[idx[6] + 2],
context->palette[idx[7] + 2]);
src += 4;
}
a_val = _mm_set1_epi16(0xFF);
break;
case RDP_PIXEL_FORMAT_P8:
case PIXEL_FORMAT_RGB8:
{
r_val = _mm_set_epi16(
context->palette[(*(src + 7)) * 3],
context->palette[(*(src + 6)) * 3],
context->palette[(*(src + 5)) * 3],
context->palette[(*(src + 4)) * 3],
context->palette[(*(src + 3)) * 3],
context->palette[(*(src + 2)) * 3],
context->palette[(*(src + 1)) * 3],
context->palette[(*src) * 3]);
context->palette[(*(src + 7)) * 3],
context->palette[(*(src + 6)) * 3],
context->palette[(*(src + 5)) * 3],
context->palette[(*(src + 4)) * 3],
context->palette[(*(src + 3)) * 3],
context->palette[(*(src + 2)) * 3],
context->palette[(*(src + 1)) * 3],
context->palette[(*src) * 3]);
g_val = _mm_set_epi16(
context->palette[(*(src + 7)) * 3 + 1],
context->palette[(*(src + 6)) * 3 + 1],
context->palette[(*(src + 5)) * 3 + 1],
context->palette[(*(src + 4)) * 3 + 1],
context->palette[(*(src + 3)) * 3 + 1],
context->palette[(*(src + 2)) * 3 + 1],
context->palette[(*(src + 1)) * 3 + 1],
context->palette[(*src) * 3 + 1]);
context->palette[(*(src + 7)) * 3 + 1],
context->palette[(*(src + 6)) * 3 + 1],
context->palette[(*(src + 5)) * 3 + 1],
context->palette[(*(src + 4)) * 3 + 1],
context->palette[(*(src + 3)) * 3 + 1],
context->palette[(*(src + 2)) * 3 + 1],
context->palette[(*(src + 1)) * 3 + 1],
context->palette[(*src) * 3 + 1]);
b_val = _mm_set_epi16(
context->palette[(*(src + 7)) * 3 + 2],
context->palette[(*(src + 6)) * 3 + 2],
context->palette[(*(src + 5)) * 3 + 2],
context->palette[(*(src + 4)) * 3 + 2],
context->palette[(*(src + 3)) * 3 + 2],
context->palette[(*(src + 2)) * 3 + 2],
context->palette[(*(src + 1)) * 3 + 2],
context->palette[(*src) * 3 + 2]);
context->palette[(*(src + 7)) * 3 + 2],
context->palette[(*(src + 6)) * 3 + 2],
context->palette[(*(src + 5)) * 3 + 2],
context->palette[(*(src + 4)) * 3 + 2],
context->palette[(*(src + 3)) * 3 + 2],
context->palette[(*(src + 2)) * 3 + 2],
context->palette[(*(src + 1)) * 3 + 2],
context->palette[(*src) * 3 + 2]);
src += 8;
}
a_val = _mm_set1_epi16(0xFF);
break;
@ -263,7 +281,6 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, BYTE* data, int
cg_val = _mm_sub_epi16(g_val, _mm_srai_epi16(r_val, 1));
cg_val = _mm_sub_epi16(cg_val, _mm_srai_epi16(b_val, 1));
cg_val = _mm_srai_epi16(cg_val, ccl);
y_val = _mm_packus_epi16(y_val, y_val);
_mm_storeu_si128((__m128i*) yplane, y_val);
co_val = _mm_packs_epi16(co_val, co_val);
@ -280,9 +297,12 @@ static void nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, BYTE* data, int
if (context->ChromaSubsamplingLevel > 0 && (context->width % 2) == 1)
{
context->priv->PlaneBuffers[0][y * rw + context->width] = context->priv->PlaneBuffers[0][y * rw + context->width - 1];
context->priv->PlaneBuffers[1][y * rw + context->width] = context->priv->PlaneBuffers[1][y * rw + context->width - 1];
context->priv->PlaneBuffers[2][y * rw + context->width] = context->priv->PlaneBuffers[2][y * rw + context->width - 1];
context->priv->PlaneBuffers[0][y * rw + context->width] =
context->priv->PlaneBuffers[0][y * rw + context->width - 1];
context->priv->PlaneBuffers[1][y * rw + context->width] =
context->priv->PlaneBuffers[1][y * rw + context->width - 1];
context->priv->PlaneBuffers[2][y * rw + context->width] =
context->priv->PlaneBuffers[2][y * rw + context->width - 1];
}
}
@ -309,7 +329,6 @@ static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context)
__m128i t;
__m128i val;
__m128i mask = _mm_set1_epi16(0xFF);
tempWidth = ROUND_UP_TO(context->width, 8);
tempHeight = ROUND_UP_TO(context->height, 2);
@ -333,7 +352,6 @@ static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context)
co_dst += 8;
co_src0 += 16;
co_src1 += 16;
t = _mm_loadu_si128((__m128i*) cg_src0);
t = _mm_avg_epu8(t, _mm_loadu_si128((__m128i*) cg_src1));
val = _mm_and_si128(_mm_srli_si128(t, 1), mask);
@ -347,7 +365,8 @@ static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context)
}
}
static void nsc_encode_sse2(NSC_CONTEXT* context, BYTE* data, int scanline)
static void nsc_encode_sse2(NSC_CONTEXT* context, const BYTE* data,
UINT32 scanline)
{
nsc_encode_argb_to_aycocg_sse2(context, data, scanline);
@ -360,6 +379,5 @@ static void nsc_encode_sse2(NSC_CONTEXT* context, BYTE* data, int scanline)
void nsc_init_sse2(NSC_CONTEXT* context)
{
IF_PROFILER(context->priv->prof_nsc_encode->name = "nsc_encode_sse2");
context->encode = nsc_encode_sse2;
}

View File

@ -3,6 +3,8 @@
* RDP6 Planar Codec
*
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +33,8 @@
#define TAG FREERDP_TAG("codec")
static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, int nWidth, int nHeight)
static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize,
int nWidth, int nHeight)
{
int x, y;
int cRawBytes;
@ -42,13 +45,12 @@ static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, int nWidt
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; )
for (x = 0; x < nWidth;)
{
if (pRLE >= pEnd)
return -1;
controlByte = *pRLE++;
nRunLength = PLANAR_CONTROL_BYTE_RUN_LENGTH(controlByte);
cRawBytes = PLANAR_CONTROL_BYTE_RAW_BYTES(controlByte);
@ -66,7 +68,6 @@ static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, int nWidt
pRLE += cRawBytes;
x += cRawBytes;
cRawBytes = 0;
x += nRunLength;
nRunLength = 0;
@ -78,24 +79,26 @@ static int planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, int nWidt
}
}
return (int) (pRLE - pSrcData);
return (int)(pRLE - pSrcData);
}
static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYTE* pDstData,
int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, int nChannel, BOOL vFlip)
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)
{
int x, y;
UINT32 x, y;
BYTE* dstp;
UINT32 pixel;
int cRawBytes;
int nRunLength;
int deltaValue;
int beg, end, inc;
UINT32 cRawBytes;
UINT32 nRunLength;
INT32 deltaValue;
UINT32 beg, end, inc;
BYTE controlByte;
BYTE* currentScanline;
BYTE* previousScanline;
const BYTE* srcp = pSrcData;
dstp = pDstData;
previousScanline = NULL;
@ -115,11 +118,10 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYT
for (y = beg; y != end; y += inc)
{
dstp = &pDstData[((nYDst + y) * nDstStep) + (nXDst * 4) + nChannel];
pixel = 0;
currentScanline = dstp;
for (x = 0; x < nWidth; )
for (x = 0; x < nWidth;)
{
controlByte = *srcp;
srcp++;
@ -153,12 +155,10 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYT
if (!previousScanline)
{
/* first scanline, absolute values */
while (cRawBytes > 0)
{
pixel = *srcp;
srcp++;
*dstp = pixel;
dstp += 4;
x++;
@ -176,7 +176,6 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYT
else
{
/* delta values relative to previous scanline */
while (cRawBytes > 0)
{
deltaValue = *srcp;
@ -215,15 +214,16 @@ static int planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, BYT
previousScanline = currentScanline;
}
return (int) (srcp - pSrcData);
return (int)(srcp - pSrcData);
}
static int planar_decompress_planes_raw(const BYTE* pSrcData[4], int nSrcStep, BYTE* pDstData,
int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BOOL alpha, BOOL vFlip)
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)
{
int x, y;
int beg, end, inc;
BYTE* pRGB = pDstData;
INT32 x, y;
INT32 beg, end, inc;
const BYTE* pR = pSrcData[0];
const BYTE* pG = pSrcData[1];
const BYTE* pB = pSrcData[2];
@ -246,14 +246,14 @@ static int planar_decompress_planes_raw(const BYTE* pSrcData[4], int nSrcStep, B
{
for (y = beg; y != end; y += inc)
{
pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * 4)];
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))];
for (x = 0; x < nWidth; x++)
{
*pRGB++ = *pB++;
*pRGB++ = *pG++;
*pRGB++ = *pR++;
*pRGB++ = *pA++;
UINT32 color = GetColor(DstFormat, *pR++, *pG++, *pB++, *pA++);
WriteColor(pRGB, DstFormat, color);
pRGB += GetBytesPerPixel(DstFormat);
}
}
}
@ -261,43 +261,45 @@ static int planar_decompress_planes_raw(const BYTE* pSrcData[4], int nSrcStep, B
{
for (y = beg; y != end; y += inc)
{
pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * 4)];
BYTE* pRGB = &pDstData[((nYDst + y) * nDstStep) + (nXDst * GetBytesPerPixel(
DstFormat))];
for (x = 0; x < nWidth; x++)
{
*pRGB++ = *pB++;
*pRGB++ = *pG++;
*pRGB++ = *pR++;
*pRGB++ = 0xFF;
UINT32 color = GetColor(DstFormat, *pR++, *pG++, *pB++, 0xFF);
WriteColor(pRGB, DstFormat, color);
pRGB += GetBytesPerPixel(DstFormat);
}
}
}
return 1;
return TRUE;
}
int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, BOOL vFlip)
INT32 planar_decompress(BITMAP_PLANAR_CONTEXT* planar,
const BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, UINT32 DstFormat,
INT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, BOOL vFlip)
{
BOOL cs;
BOOL rle;
UINT32 cll;
BOOL alpha;
int status;
BYTE* srcp;
int subSize;
int subWidth;
int subHeight;
int planeSize;
INT32 status;
const BYTE* srcp;
UINT32 subSize;
UINT32 subWidth;
UINT32 subHeight;
UINT32 planeSize;
BYTE* pDstData;
int rleSizes[4];
int rawSizes[4];
int rawWidths[4];
int rawHeights[4];
UINT32 rleSizes[4];
UINT32 rawSizes[4];
UINT32 rawWidths[4];
UINT32 rawHeights[4];
BYTE FormatHeader;
BOOL useTempBuffer;
int dstBitsPerPixel;
int dstBytesPerPixel;
UINT32 dstBitsPerPixel;
UINT32 dstBytesPerPixel;
const BYTE* planes[4];
UINT32 UncompressedSize;
const primitives_t* prims = primitives_get();
@ -305,15 +307,14 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
if ((nWidth < 0) || (nHeight < 0))
return -1;
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
dstBitsPerPixel = GetBitsPerPixel(DstFormat);
dstBytesPerPixel = GetBytesPerPixel(DstFormat);
if (nDstStep < 0)
nDstStep = nWidth * 4;
nDstStep = nWidth * GetBytesPerPixel(DstFormat);
srcp = pSrcData;
UncompressedSize = nWidth * nHeight * 4;
UncompressedSize = nWidth * nHeight * GetBytesPerPixel(DstFormat);
pDstData = *ppDstData;
if (!pDstData)
@ -326,24 +327,7 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
*ppDstData = pDstData;
}
useTempBuffer = (dstBytesPerPixel != 4) ? TRUE : FALSE;
if (useTempBuffer)
{
if (UncompressedSize > planar->TempSize)
{
planar->TempBuffer = _aligned_realloc(planar->TempBuffer, UncompressedSize, 16);
planar->TempSize = UncompressedSize;
}
if (!planar->TempBuffer)
return -1;
pDstData = planar->TempBuffer;
}
FormatHeader = *srcp++;
cll = (FormatHeader & PLANAR_FORMAT_HEADER_CLL_MASK);
cs = (FormatHeader & PLANAR_FORMAT_HEADER_CS) ? TRUE : FALSE;
rle = (FormatHeader & PLANAR_FORMAT_HEADER_RLE) ? TRUE : FALSE;
@ -356,7 +340,6 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
subWidth = (nWidth / 2) + (nWidth % 2);
subHeight = (nHeight / 2) + (nHeight % 2);
planeSize = nWidth * nHeight;
subSize = subWidth * subHeight;
@ -365,15 +348,12 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
rawSizes[0] = planeSize; /* LumaOrRedPlane */
rawWidths[0] = nWidth;
rawHeights[0] = nHeight;
rawSizes[1] = planeSize; /* OrangeChromaOrGreenPlane */
rawWidths[1] = nWidth;
rawHeights[1] = nHeight;
rawSizes[2] = planeSize; /* GreenChromaOrBluePlane */
rawWidths[2] = nWidth;
rawHeights[2] = nHeight;
rawSizes[3] = planeSize; /* AlphaPlane */
rawWidths[3] = nWidth;
rawHeights[3] = nHeight;
@ -383,15 +363,12 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
rawSizes[0] = planeSize; /* LumaOrRedPlane */
rawWidths[0] = nWidth;
rawHeights[0] = nHeight;
rawSizes[1] = subSize; /* OrangeChromaOrGreenPlane */
rawWidths[1] = subWidth;
rawHeights[1] = subHeight;
rawSizes[2] = subSize; /* GreenChromaOrBluePlane */
rawWidths[2] = subWidth;
rawHeights[2] = subHeight;
rawSizes[3] = planeSize; /* AlphaPlane */
rawWidths[3] = nWidth;
rawHeights[3] = nHeight;
@ -428,28 +405,28 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
{
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;
@ -458,21 +435,21 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
{
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;
@ -485,16 +462,14 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
{
if (alpha)
{
planar_decompress_planes_raw(planes, nWidth, pDstData, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
}
else /* NoAlpha */
{
planar_decompress_planes_raw(planes, nWidth, pDstData, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
planar_decompress_planes_raw(planes, pDstData, DstFormat, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
}
@ -503,42 +478,71 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
}
else /* RLE */
{
UINT32 TempFormat = PIXEL_FORMAT_ARGB32;
BYTE* pTempData = pDstData;
UINT32 nTempStep = nDstStep;
if (DstFormat != TempFormat)
{
pTempData = malloc(nWidth * nHeight * 4);
if (!pTempData)
return -1;
}
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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);
free(pTempData);
}
}
}
else /* YCoCg */
{
BYTE* pTempData;
UINT32 nTempStep = nDstStep;
UINT32 TempFormat = PIXEL_FORMAT_RGBA32;
pTempData = malloc(UncompressedSize);
if (!pTempData)
return -1;
if (cs)
{
WLog_ERR(TAG, "Chroma subsampling unimplemented");
free(pTempData);
return -1;
}
@ -546,16 +550,14 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
{
if (alpha)
{
planar_decompress_planes_raw(planes, nWidth, pDstData, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2] + rawSizes[3];
}
else /* NoAlpha */
{
planar_decompress_planes_raw(planes, nWidth, pDstData, nDstStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
planar_decompress_planes_raw(planes, pTempData, TempFormat, nTempStep,
nXDst, nYDst, nWidth, nHeight, alpha, vFlip);
srcp += rawSizes[0] + rawSizes[1] + rawSizes[2];
}
@ -567,109 +569,75 @@ int planar_decompress(BITMAP_PLANAR_CONTEXT* planar, BYTE* pSrcData, UINT32 SrcS
if (alpha)
{
status = planar_decompress_plane_rle(planes[3], rleSizes[3],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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],
pDstData, nDstStep, 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(pDstData, nDstStep, pDstData, nDstStep, nWidth, nHeight, cll, alpha, FALSE);
prims->YCoCgToRGB_8u_AC4R(pTempData, nTempStep, pDstData, DstFormat, nDstStep,
nWidth, nHeight, cll, alpha);
free(pTempData);
}
status = (SrcSize == (srcp - pSrcData)) ? 1 : -1;
if (status < 0)
return status;
if (useTempBuffer)
{
pDstData = *ppDstData;
status = freerdp_image_copy(pDstData, DstFormat, -1, 0, 0, nWidth, nHeight,
planar->TempBuffer, PIXEL_FORMAT_XRGB32, -1, 0, 0, NULL);
}
return status;
}
int freerdp_split_color_planes(BYTE* data, UINT32 format, int width, int height, int scanline, BYTE* planes[4])
static BOOL freerdp_split_color_planes(const BYTE* data, UINT32 format,
UINT32 width, UINT32 height,
UINT32 scanline, BYTE** planes)
{
int bpp;
int i, j, k;
INT32 i, j, k;
UINT32* pixel;
k = 0;
bpp = FREERDP_PIXEL_FORMAT_BPP(format);
if (bpp == 32)
for (i = height - 1; i >= 0; i--)
{
UINT32* pixel;
pixel = (UINT32*) &data[scanline * i];
for (i = height - 1; i >= 0; i--)
for (j = 0; j < width; j++)
{
pixel = (UINT32*) &data[scanline * i];
for (j = 0; j < width; j++)
{
GetARGB32(planes[0][k], planes[1][k], planes[2][k], planes[3][k], *pixel);
pixel++;
k++;
}
*pixel = GetColor(format, planes[1][k], planes[2][k],
planes[3][k], planes[0][k]);
pixel++;
k++;
}
}
else if (bpp == 24)
{
UINT32* pixel;
for (i = height - 1; i >= 0; i--)
{
pixel = (UINT32*) &data[scanline * i];
for (j = 0; j < width; j++)
{
GetRGB32(planes[1][k], planes[2][k], planes[3][k], *pixel);
planes[0][k] = 0xFF; /* A */
pixel++;
k++;
}
}
}
else
{
return -1;
}
return 0;
return TRUE;
}
int freerdp_bitmap_planar_write_rle_bytes(BYTE* pInBuffer, int cRawBytes, int nRunLength, BYTE* pOutBuffer, int outBufferSize)
static UINT32 freerdp_bitmap_planar_write_rle_bytes(
const BYTE* pInBuffer, UINT32 cRawBytes, UINT32 nRunLength,
BYTE* pOutBuffer, UINT32 outBufferSize)
{
BYTE* pInput;
const BYTE* pInput;
BYTE* pOutput;
BYTE controlByte;
int nBytesToWrite;
UINT32 nBytesToWrite;
pInput = pInBuffer;
pOutput = pOutBuffer;
@ -718,11 +686,9 @@ int freerdp_bitmap_planar_write_rle_bytes(BYTE* pInBuffer, int cRawBytes, int nR
return 0;
outBufferSize--;
*pOutput = controlByte;
pOutput++;
nBytesToWrite = (int) (controlByte >> 4);
nBytesToWrite = (int)(controlByte >> 4);
if (nBytesToWrite)
{
@ -778,18 +744,20 @@ int freerdp_bitmap_planar_write_rle_bytes(BYTE* pInBuffer, int cRawBytes, int nR
return (pOutput - pOutBuffer);
}
int freerdp_bitmap_planar_encode_rle_bytes(BYTE* pInBuffer, int inBufferSize, BYTE* pOutBuffer, int outBufferSize)
static UINT32 freerdp_bitmap_planar_encode_rle_bytes(const BYTE* pInBuffer,
UINT32 inBufferSize,
BYTE* pOutBuffer,
UINT32 outBufferSize)
{
BYTE symbol;
BYTE* pInput;
const BYTE* pInput;
BYTE* pOutput;
BYTE* pBytes;
int cRawBytes;
int nRunLength;
int bSymbolMatch;
int nBytesWritten;
int nTotalBytesWritten;
const BYTE* pBytes;
UINT32 cRawBytes;
UINT32 nRunLength;
UINT32 bSymbolMatch;
UINT32 nBytesWritten;
UINT32 nTotalBytesWritten;
symbol = 0;
cRawBytes = 0;
nRunLength = 0;
@ -820,10 +788,10 @@ int freerdp_bitmap_planar_encode_rle_bytes(BYTE* pInBuffer, int inBufferSize, BY
else
{
pBytes = pInput - (cRawBytes + nRunLength + 1);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes,
cRawBytes, nRunLength, pOutput, outBufferSize);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(
pBytes, cRawBytes,
nRunLength, pOutput,
outBufferSize);
nRunLength = 0;
if (!nBytesWritten || (nBytesWritten > outBufferSize))
@ -844,9 +812,8 @@ int freerdp_bitmap_planar_encode_rle_bytes(BYTE* pInBuffer, int inBufferSize, BY
if (cRawBytes || nRunLength)
{
pBytes = pInput - (cRawBytes + nRunLength);
nBytesWritten = freerdp_bitmap_planar_write_rle_bytes(pBytes,
cRawBytes, nRunLength, pOutput, outBufferSize);
cRawBytes, nRunLength, pOutput, outBufferSize);
if (!nBytesWritten)
return 0;
@ -860,19 +827,22 @@ int freerdp_bitmap_planar_encode_rle_bytes(BYTE* pInBuffer, int inBufferSize, BY
return nTotalBytesWritten;
}
BYTE* freerdp_bitmap_planar_compress_plane_rle(BYTE* inPlane, int width, int height, BYTE* outPlane, int* dstSize)
BYTE* freerdp_bitmap_planar_compress_plane_rle(const BYTE* inPlane,
UINT32 width, UINT32 height,
BYTE* outPlane, UINT32* dstSize)
{
int index;
BYTE* pInput;
UINT32 index;
const BYTE* pInput;
BYTE* pOutput;
int outBufferSize;
int nBytesWritten;
int nTotalBytesWritten;
UINT32 outBufferSize;
UINT32 nBytesWritten;
UINT32 nTotalBytesWritten;
if (!outPlane)
{
outBufferSize = width * height;
outPlane = malloc(outBufferSize);
if (!outPlane)
return NULL;
}
@ -888,7 +858,8 @@ BYTE* freerdp_bitmap_planar_compress_plane_rle(BYTE* inPlane, int width, int hei
while (outBufferSize)
{
nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes(pInput, width, pOutput, outBufferSize);
nBytesWritten = freerdp_bitmap_planar_encode_rle_bytes(
pInput, width, pOutput, outBufferSize);
if ((!nBytesWritten) || (nBytesWritten > outBufferSize))
return NULL;
@ -904,16 +875,16 @@ BYTE* freerdp_bitmap_planar_compress_plane_rle(BYTE* inPlane, int width, int hei
}
*dstSize = nTotalBytesWritten;
return outPlane;
}
int freerdp_bitmap_planar_compress_planes_rle(BYTE* inPlanes[4], int width, int height, BYTE* outPlanes, int* dstSizes, BOOL skipAlpha)
static UINT32 freerdp_bitmap_planar_compress_planes_rle(
const BYTE** inPlanes, UINT32 width, UINT32 height,
BYTE* outPlanes, UINT32* dstSizes, BOOL skipAlpha)
{
int outPlanesSize = width * height * 4;
UINT32 outPlanesSize = width * height * 4;
/* AlphaPlane */
if (skipAlpha)
{
dstSizes[0] = 0;
@ -922,7 +893,8 @@ int freerdp_bitmap_planar_compress_planes_rle(BYTE* inPlanes[4], int width, int
{
dstSizes[0] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[0], width, height, outPlanes, &dstSizes[0]))
if (!freerdp_bitmap_planar_compress_plane_rle(
inPlanes[0], width, height, outPlanes, &dstSizes[0]))
return 0;
outPlanes += dstSizes[0];
@ -930,44 +902,44 @@ int freerdp_bitmap_planar_compress_planes_rle(BYTE* inPlanes[4], int width, int
}
/* LumaOrRedPlane */
dstSizes[1] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height, outPlanes, &dstSizes[1]))
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[1], width, height,
outPlanes, &dstSizes[1]))
return 0;
outPlanes += dstSizes[1];
outPlanesSize -= dstSizes[1];
/* OrangeChromaOrGreenPlane */
dstSizes[2] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height, outPlanes, &dstSizes[2]))
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[2], width, height,
outPlanes, &dstSizes[2]))
return 0;
outPlanes += dstSizes[2];
outPlanesSize -= dstSizes[2];
/* GreenChromeOrBluePlane */
dstSizes[3] = outPlanesSize;
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height, outPlanes, &dstSizes[3]))
if (!freerdp_bitmap_planar_compress_plane_rle(inPlanes[3], width, height,
outPlanes, &dstSizes[3]))
return 0;
outPlanes += dstSizes[3];
outPlanesSize -= dstSizes[3];
return 1;
}
BYTE* freerdp_bitmap_planar_delta_encode_plane(BYTE* inPlane, int width, int height, BYTE* outPlane)
BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane,
UINT32 width, UINT32 height,
BYTE* outPlane)
{
char s2c;
int delta;
int y, x;
BYTE *outPtr, *srcPtr, *prevLinePtr;
INT32 delta;
UINT32 y, x;
BYTE* outPtr;
const BYTE* srcPtr, *prevLinePtr;
if (!outPlane)
{
@ -977,7 +949,6 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(BYTE* inPlane, int width, int hei
// first line is copied as is
CopyMemory(outPlane, inPlane, width);
outPtr = outPlane + width;
srcPtr = inPlane + width;
prevLinePtr = inPlane;
@ -987,11 +958,8 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(BYTE* inPlane, int width, int hei
for (x = 0; x < width; x++, outPtr++, srcPtr++, prevLinePtr++)
{
delta = *srcPtr - *prevLinePtr;
s2c = (delta >= 0) ? (char) delta : (char) (~((BYTE) (-delta)) + 1);
s2c = (s2c >= 0) ? (s2c << 1) : (char) (((~((BYTE) s2c) + 1) << 1) - 1);
s2c = (delta >= 0) ? (char) delta : (char)(~((BYTE)(-delta)) + 1);
s2c = (s2c >= 0) ? (s2c << 1) : (char)(((~((BYTE) s2c) + 1) << 1) - 1);
*outPtr = (BYTE)s2c;
}
}
@ -999,13 +967,17 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(BYTE* inPlane, int width, int hei
return outPlane;
}
BOOL freerdp_bitmap_planar_delta_encode_planes(BYTE* inPlanes[4], int width, int height, BYTE* outPlanes[4])
BOOL freerdp_bitmap_planar_delta_encode_planes(const BYTE** inPlanes,
UINT32 width, UINT32 height,
BYTE* outPlanes[4])
{
int i;
UINT32 i;
for (i = 0; i < 4; i++)
{
outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(inPlanes[i], width, height, outPlanes[i]);
outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(
inPlanes[i], width, height, outPlanes[i]);
if (!outPlanes[i])
return FALSE;
}
@ -1013,13 +985,15 @@ BOOL freerdp_bitmap_planar_delta_encode_planes(BYTE* inPlanes[4], int width, int
return TRUE;
}
BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data, UINT32 format,
int width, int height, int scanline, BYTE* dstData, int* pDstSize)
BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
const BYTE* data, UINT32 format,
UINT32 width, UINT32 height, UINT32 scanline,
BYTE* dstData, UINT32* pDstSize)
{
int size;
UINT32 size;
BYTE* dstp;
int planeSize;
int dstSizes[4];
UINT32 planeSize;
UINT32 dstSizes[4];
BYTE FormatHeader = 0;
if (context->AllowSkipAlpha)
@ -1027,32 +1001,30 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data,
planeSize = width * height;
if (freerdp_split_color_planes(data, format, width, height, scanline, context->planes) < 0)
{
if (!freerdp_split_color_planes(data, format, width, height, scanline,
context->planes))
return NULL;
}
if (context->AllowRunLengthEncoding)
{
if (!freerdp_bitmap_planar_delta_encode_planes(context->planes, width, height, context->deltaPlanes))
if (!freerdp_bitmap_planar_delta_encode_planes(
(const BYTE**)context->planes, width, height,
context->deltaPlanes))
return NULL;;
if (freerdp_bitmap_planar_compress_planes_rle(context->deltaPlanes, width, height,
context->rlePlanesBuffer, (int*) &dstSizes, context->AllowSkipAlpha) > 0)
if (freerdp_bitmap_planar_compress_planes_rle(
(const BYTE**)context->deltaPlanes, width, height,
context->rlePlanesBuffer, dstSizes,
context->AllowSkipAlpha) > 0)
{
int offset = 0;
FormatHeader |= PLANAR_FORMAT_HEADER_RLE;
context->rlePlanes[0] = &context->rlePlanesBuffer[offset];
offset += dstSizes[0];
context->rlePlanes[1] = &context->rlePlanesBuffer[offset];
offset += dstSizes[1];
context->rlePlanes[2] = &context->rlePlanesBuffer[offset];
offset += dstSizes[2];
context->rlePlanes[3] = &context->rlePlanesBuffer[offset];
offset += dstSizes[3];
//WLog_DBG(TAG, "R: [%d/%d] G: [%d/%d] B: [%d/%d]",
@ -1081,13 +1053,14 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data,
size++;
dstData = malloc(size);
if (!dstData)
return NULL;
*pDstSize = size;
}
dstp = dstData;
*dstp = FormatHeader; /* FormatHeader */
dstp++;
@ -1156,7 +1129,6 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data,
size = (dstp - dstData);
*pDstSize = size;
return dstData;
}
@ -1168,11 +1140,12 @@ BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context)
return TRUE;
}
BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, int maxWidth, int maxHeight)
BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(
DWORD flags, UINT32 maxWidth, UINT32 maxHeight)
{
BITMAP_PLANAR_CONTEXT* context;
context = (BITMAP_PLANAR_CONTEXT*) calloc(1, sizeof(BITMAP_PLANAR_CONTEXT));
if (!context)
return NULL;
@ -1193,29 +1166,34 @@ BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, int maxWid
context->maxWidth = maxWidth;
context->maxHeight = maxHeight;
context->maxPlaneSize = context->maxWidth * context->maxHeight;
context->planesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->planesBuffer)
goto error_planesBuffer;
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->deltaPlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->deltaPlanesBuffer)
goto error_deltaPlanesBuffer;
context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize * 0];
context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize * 1];
context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize * 2];
context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize * 3];
context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize *
0];
context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize *
1];
context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize *
2];
context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize *
3];
context->rlePlanesBuffer = malloc(context->maxPlaneSize * 4);
if (!context->rlePlanesBuffer)
goto error_rlePlanesBuffer;
return context;
error_rlePlanesBuffer:
free(context->deltaPlanesBuffer);
error_deltaPlanesBuffer:
@ -1233,6 +1211,5 @@ void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context)
free(context->planesBuffer);
free(context->deltaPlanesBuffer);
free(context->rlePlanesBuffer);
free(context);
}

View File

@ -28,6 +28,7 @@
#include <freerdp/primitives.h>
#include <freerdp/codec/color.h>
#include <freerdp/codec/progressive.h>
#include <freerdp/codec/region.h>
#include <freerdp/log.h>
#include "rfx_differential.h"
@ -35,7 +36,7 @@
#define TAG FREERDP_TAG("codec.progressive")
const char* progressive_get_block_type_string(UINT16 blockType)
static const char* progressive_get_block_type_string(UINT16 blockType)
{
switch (blockType)
{
@ -79,7 +80,8 @@ const char* progressive_get_block_type_string(UINT16 blockType)
return "PROGRESSIVE_WBT_UNKNOWN";
}
void progressive_component_codec_quant_read(BYTE* block, RFX_COMPONENT_CODEC_QUANT* quantVal)
static void progressive_component_codec_quant_read(const BYTE* block,
RFX_COMPONENT_CODEC_QUANT* quantVal)
{
quantVal->LL3 = block[0] & 0x0F;
quantVal->HL3 = block[0] >> 4;
@ -93,7 +95,7 @@ void progressive_component_codec_quant_read(BYTE* block, RFX_COMPONENT_CODEC_QUA
quantVal->HH1 = block[4] >> 4;
}
void progressive_rfx_quant_ladd(RFX_COMPONENT_CODEC_QUANT* q, int val)
static void progressive_rfx_quant_ladd(RFX_COMPONENT_CODEC_QUANT* q, int val)
{
q->HL1 += val; /* HL1 */
q->LH1 += val; /* LH1 */
@ -107,7 +109,9 @@ void progressive_rfx_quant_ladd(RFX_COMPONENT_CODEC_QUANT* q, int val)
q->LL3 += val; /* LL3 */
}
void progressive_rfx_quant_add(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODEC_QUANT* q2, RFX_COMPONENT_CODEC_QUANT* dst)
static void progressive_rfx_quant_add(RFX_COMPONENT_CODEC_QUANT* q1,
RFX_COMPONENT_CODEC_QUANT* q2,
RFX_COMPONENT_CODEC_QUANT* dst)
{
dst->HL1 = q1->HL1 + q2->HL1; /* HL1 */
dst->LH1 = q1->LH1 + q2->LH1; /* LH1 */
@ -121,7 +125,7 @@ void progressive_rfx_quant_add(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODE
dst->LL3 = q1->LL3 + q2->LL3; /* LL3 */
}
void progressive_rfx_quant_lsub(RFX_COMPONENT_CODEC_QUANT* q, int val)
static void progressive_rfx_quant_lsub(RFX_COMPONENT_CODEC_QUANT* q, int val)
{
q->HL1 -= val; /* HL1 */
q->LH1 -= val; /* LH1 */
@ -135,7 +139,9 @@ void progressive_rfx_quant_lsub(RFX_COMPONENT_CODEC_QUANT* q, int val)
q->LL3 -= val; /* LL3 */
}
void progressive_rfx_quant_sub(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODEC_QUANT* q2, RFX_COMPONENT_CODEC_QUANT* dst)
static void progressive_rfx_quant_sub(RFX_COMPONENT_CODEC_QUANT* q1,
RFX_COMPONENT_CODEC_QUANT* q2,
RFX_COMPONENT_CODEC_QUANT* dst)
{
dst->HL1 = q1->HL1 - q2->HL1; /* HL1 */
dst->LH1 = q1->LH1 - q2->LH1; /* LH1 */
@ -149,7 +155,8 @@ void progressive_rfx_quant_sub(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODE
dst->LL3 = q1->LL3 - q2->LL3; /* LL3 */
}
BOOL progressive_rfx_quant_lcmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q, int val)
static BOOL progressive_rfx_quant_lcmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q,
int val)
{
if (q->HL1 > val) return FALSE; /* HL1 */
if (q->LH1 > val) return FALSE; /* LH1 */
@ -164,7 +171,8 @@ BOOL progressive_rfx_quant_lcmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q, int val
return TRUE;
}
BOOL progressive_rfx_quant_cmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODEC_QUANT* q2)
static BOOL progressive_rfx_quant_cmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q1,
RFX_COMPONENT_CODEC_QUANT* q2)
{
if (q1->HL1 > q2->HL1) return FALSE; /* HL1 */
if (q1->LH1 > q2->LH1) return FALSE; /* LH1 */
@ -179,7 +187,8 @@ BOOL progressive_rfx_quant_cmp_less_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COM
return TRUE;
}
BOOL progressive_rfx_quant_lcmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q, int val)
static BOOL progressive_rfx_quant_lcmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q,
int val)
{
if (q->HL1 < val) return FALSE; /* HL1 */
if (q->LH1 < val) return FALSE; /* LH1 */
@ -194,7 +203,8 @@ BOOL progressive_rfx_quant_lcmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q, int
return TRUE;
}
BOOL progressive_rfx_quant_cmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODEC_QUANT* q2)
static BOOL progressive_rfx_quant_cmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q1,
RFX_COMPONENT_CODEC_QUANT* q2)
{
if (q1->HL1 < q2->HL1) return FALSE; /* HL1 */
if (q1->LH1 < q2->LH1) return FALSE; /* LH1 */
@ -209,7 +219,8 @@ BOOL progressive_rfx_quant_cmp_greater_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_
return TRUE;
}
BOOL progressive_rfx_quant_cmp_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONENT_CODEC_QUANT* q2)
static BOOL progressive_rfx_quant_cmp_equal(RFX_COMPONENT_CODEC_QUANT* q1,
RFX_COMPONENT_CODEC_QUANT* q2)
{
if (q1->HL1 != q2->HL1) return FALSE; /* HL1 */
if (q1->LH1 != q2->LH1) return FALSE; /* LH1 */
@ -224,13 +235,15 @@ BOOL progressive_rfx_quant_cmp_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONEN
return TRUE;
}
void progressive_rfx_quant_print(RFX_COMPONENT_CODEC_QUANT* q, const char* name)
static void progressive_rfx_quant_print(RFX_COMPONENT_CODEC_QUANT* q,
const char* name)
{
fprintf(stderr, "%s: HL1: %d LH1: %d HH1: %d HL2: %d LH2: %d HH2: %d HL3: %d LH3: %d HH3: %d LL3: %d\n",
name, q->HL1, q->LH1, q->HH1, q->HL2, q->LH2, q->HH2, q->HL3, q->LH3, q->HH3, q->LL3);
}
int progressive_set_surface_data(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, void* pData)
static int progressive_set_surface_data(PROGRESSIVE_CONTEXT* progressive,
UINT16 surfaceId, void* pData)
{
ULONG_PTR key;
@ -244,7 +257,8 @@ int progressive_set_surface_data(PROGRESSIVE_CONTEXT* progressive, UINT16 surfac
return 1;
}
void* progressive_get_surface_data(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId)
static void* progressive_get_surface_data(PROGRESSIVE_CONTEXT* progressive,
UINT16 surfaceId)
{
ULONG_PTR key;
void* pData = NULL;
@ -256,11 +270,13 @@ void* progressive_get_surface_data(PROGRESSIVE_CONTEXT* progressive, UINT16 surf
return pData;
}
PROGRESSIVE_SURFACE_CONTEXT* progressive_surface_context_new(UINT16 surfaceId, UINT32 width, UINT32 height)
static PROGRESSIVE_SURFACE_CONTEXT* progressive_surface_context_new(
UINT16 surfaceId, UINT32 width, UINT32 height)
{
PROGRESSIVE_SURFACE_CONTEXT* surface;
surface = (PROGRESSIVE_SURFACE_CONTEXT*) calloc(1, sizeof(PROGRESSIVE_SURFACE_CONTEXT));
surface = (PROGRESSIVE_SURFACE_CONTEXT*) calloc(
1, sizeof(PROGRESSIVE_SURFACE_CONTEXT));
if (!surface)
return NULL;
@ -272,7 +288,8 @@ PROGRESSIVE_SURFACE_CONTEXT* progressive_surface_context_new(UINT16 surfaceId, U
surface->gridHeight = (height + (64 - height % 64)) / 64;
surface->gridSize = surface->gridWidth * surface->gridHeight;
surface->tiles = (RFX_PROGRESSIVE_TILE*) calloc(surface->gridSize, sizeof(RFX_PROGRESSIVE_TILE));
surface->tiles = (RFX_PROGRESSIVE_TILE*) calloc(
surface->gridSize, sizeof(RFX_PROGRESSIVE_TILE));
if (!surface->tiles)
{
@ -283,7 +300,7 @@ PROGRESSIVE_SURFACE_CONTEXT* progressive_surface_context_new(UINT16 surfaceId, U
return surface;
}
void progressive_surface_context_free(PROGRESSIVE_SURFACE_CONTEXT* surface)
static void progressive_surface_context_free(PROGRESSIVE_SURFACE_CONTEXT* surface)
{
UINT32 index;
RFX_PROGRESSIVE_TILE* tile;
@ -306,11 +323,13 @@ void progressive_surface_context_free(PROGRESSIVE_SURFACE_CONTEXT* surface)
free(surface);
}
int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, UINT32 width, UINT32 height)
int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive,
UINT16 surfaceId, UINT32 width, UINT32 height)
{
PROGRESSIVE_SURFACE_CONTEXT* surface;
surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(progressive, surfaceId);
surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(
progressive, surfaceId);
if (!surface)
{
@ -329,7 +348,8 @@ int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16
{
PROGRESSIVE_SURFACE_CONTEXT* surface;
surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(progressive, surfaceId);
surface = (PROGRESSIVE_SURFACE_CONTEXT*) progressive_get_surface_data(
progressive, surfaceId);
if (surface)
{
@ -358,8 +378,9 @@ int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16
* LL3 4015 9x9 81
*/
static void progressive_rfx_idwt_x(INT16* pLowBand, int nLowStep, INT16* pHighBand, int nHighStep,
INT16* pDstBand, int nDstStep, int nLowCount, int nHighCount, int nDstCount)
static void progressive_rfx_idwt_x(INT16* pLowBand, int nLowStep, INT16* pHighBand,
int nHighStep, INT16* pDstBand, int nDstStep,
int nLowCount, int nHighCount, int nDstCount)
{
int i, j;
INT16 L0;
@ -443,8 +464,9 @@ static void progressive_rfx_idwt_x(INT16* pLowBand, int nLowStep, INT16* pHighBa
}
}
static void progressive_rfx_idwt_y(INT16* pLowBand, int nLowStep, INT16* pHighBand, int nHighStep,
INT16* pDstBand, int nDstStep, int nLowCount, int nHighCount, int nDstCount)
static void progressive_rfx_idwt_y(INT16* pLowBand, int nLowStep, INT16* pHighBand,
int nHighStep, INT16* pDstBand, int nDstStep,
int nLowCount, int nHighCount, int nDstCount)
{
int i, j;
INT16 L0;
@ -650,7 +672,8 @@ static void progressive_rfx_dwt_2d_decode_block(INT16* buffer, INT16* temp, int
progressive_rfx_idwt_y(pLowBand[2], nLowStep[2], pHighBand[2], nHighStep[2], pDstBand[2], nDstStep[2], nLowCount[2], nHighCount[2], nDstCount[2]);
}
void progressive_rfx_dwt_2d_decode(INT16* buffer, INT16* temp, INT16* current, INT16* sign, BOOL diff)
static void progressive_rfx_dwt_2d_decode(INT16* buffer, INT16* temp,
INT16* current, INT16* sign, BOOL diff)
{
const primitives_t* prims = primitives_get();
@ -664,7 +687,8 @@ void progressive_rfx_dwt_2d_decode(INT16* buffer, INT16* temp, INT16* current, I
progressive_rfx_dwt_2d_decode_block(&buffer[0], temp, 1);
}
void progressive_rfx_decode_block(const primitives_t* prims, INT16* buffer, int length, UINT32 shift)
static void progressive_rfx_decode_block(const primitives_t* prims, INT16* buffer,
int length, UINT32 shift)
{
if (!shift)
return;
@ -672,8 +696,11 @@ void progressive_rfx_decode_block(const primitives_t* prims, INT16* buffer, int
prims->lShiftC_16s(buffer, shift, buffer, length);
}
int progressive_rfx_decode_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMPONENT_CODEC_QUANT* shift,
const BYTE* data, int length, INT16* buffer, INT16* current, INT16* sign, BOOL diff)
static int progressive_rfx_decode_component(PROGRESSIVE_CONTEXT* progressive,
RFX_COMPONENT_CODEC_QUANT* shift,
const BYTE* data, int length,
INT16* buffer, INT16* current,
INT16* sign, BOOL diff)
{
int status;
INT16* temp;
@ -708,7 +735,8 @@ int progressive_rfx_decode_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMPO
return 1;
}
int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROGRESSIVE_TILE* tile)
static int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive,
RFX_PROGRESSIVE_TILE* tile)
{
BOOL diff;
BYTE* pBuffer;
@ -735,7 +763,9 @@ int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROG
WLog_DBG(TAG, "ProgressiveTile%s: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d",
(tile->blockType == PROGRESSIVE_WBT_TILE_FIRST) ? "First" : "Simple",
tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen, tile->cbLen, tile->crLen, tile->tailLen);
tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr,
tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen,
tile->cbLen, tile->crLen, tile->tailLen);
region = &(progressive->region);
@ -819,14 +849,21 @@ int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROG
pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* Cb/G buffer */
pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* Cr/B buffer */
progressive_rfx_decode_component(progressive, &shiftY, tile->yData, tile->yLen, pSrcDst[0], pCurrent[0], pSign[0], diff); /* Y */
progressive_rfx_decode_component(progressive, &shiftCb, tile->cbData, tile->cbLen, pSrcDst[1], pCurrent[1], pSign[1], diff); /* Cb */
progressive_rfx_decode_component(progressive, &shiftCr, tile->crData, tile->crLen, pSrcDst[2], pCurrent[2], pSign[2], diff); /* Cr */
progressive_rfx_decode_component(progressive, &shiftY, tile->yData, tile->yLen,
pSrcDst[0], pCurrent[0], pSign[0], diff); /* Y */
progressive_rfx_decode_component(progressive, &shiftCb, tile->cbData, tile->cbLen,
pSrcDst[1], pCurrent[1], pSign[1], diff); /* Cb */
progressive_rfx_decode_component(progressive, &shiftCr, tile->crData, tile->crLen,
pSrcDst[2], pCurrent[2], pSign[2], diff); /* Cr */
if (!progressive->invert)
prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2, tile->data, 64 * 4, &roi_64x64);
prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
tile->data, PIXEL_FORMAT_BGRX32,
64 * 4, &roi_64x64);
else
prims->yCbCrToBGR_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2, tile->data, 64 * 4, &roi_64x64);
prims->yCbCrToBGR_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
tile->data, PIXEL_FORMAT_BGRX32,
64 * 4, &roi_64x64);
BufferPool_Return(progressive->bufferPool, pBuffer);
@ -847,7 +884,8 @@ struct _RFX_PROGRESSIVE_UPGRADE_STATE
};
typedef struct _RFX_PROGRESSIVE_UPGRADE_STATE RFX_PROGRESSIVE_UPGRADE_STATE;
INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numBits)
static INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state,
UINT32 numBits)
{
int k;
UINT32 bit;
@ -941,7 +979,7 @@ INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numB
return sign ? -1 * mag : mag;
}
int progressive_rfx_upgrade_state_finish(RFX_PROGRESSIVE_UPGRADE_STATE* state)
static int progressive_rfx_upgrade_state_finish(RFX_PROGRESSIVE_UPGRADE_STATE* state)
{
int pad;
wBitStream* srl;
@ -968,8 +1006,9 @@ int progressive_rfx_upgrade_state_finish(RFX_PROGRESSIVE_UPGRADE_STATE* state)
return 1;
}
int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state, INT16* buffer,
INT16* sign, int length, UINT32 shift, UINT32 bitPos, UINT32 numBits)
static int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state,
INT16* buffer, INT16* sign, UINT32 length,
UINT32 shift, UINT32 bitPos, UINT32 numBits)
{
int index;
INT16 input;
@ -1031,13 +1070,19 @@ int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state, INT16* b
return 1;
}
int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMPONENT_CODEC_QUANT* shift,
RFX_COMPONENT_CODEC_QUANT* bitPos, RFX_COMPONENT_CODEC_QUANT* numBits, INT16* buffer,
INT16* current, INT16* sign, const BYTE* srlData, int srlLen, const BYTE* rawData, int rawLen)
static int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive,
RFX_COMPONENT_CODEC_QUANT* shift,
RFX_COMPONENT_CODEC_QUANT* bitPos,
RFX_COMPONENT_CODEC_QUANT* numBits,
INT16* buffer,
INT16* current, INT16* sign,
const BYTE* srlData,
UINT32 srlLen, const BYTE* rawData,
UINT32 rawLen)
{
INT16* temp;
int aRawLen;
int aSrlLen;
UINT32 aRawLen;
UINT32 aSrlLen;
wBitStream s_srl;
wBitStream s_raw;
RFX_PROGRESSIVE_UPGRADE_STATE state;
@ -1108,7 +1153,8 @@ int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMP
return 1;
}
int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PROGRESSIVE_TILE* tile)
static int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive,
RFX_PROGRESSIVE_TILE* tile)
{
int status;
BYTE* pBuffer;
@ -1241,19 +1287,25 @@ int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PR
return -1;
if (!progressive->invert)
prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2, tile->data, 64 * 4, &roi_64x64);
prims->yCbCrToRGB_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
tile->data, PIXEL_FORMAT_BGRX32,
64 * 4, &roi_64x64);
else
prims->yCbCrToBGR_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2, tile->data, 64 * 4, &roi_64x64);
prims->yCbCrToBGR_16s8u_P3AC4R((const INT16**) pSrcDst, 64 * 2,
tile->data, PIXEL_FORMAT_BGRX32,
64 * 4, &roi_64x64);
BufferPool_Return(progressive->bufferPool, pBuffer);
return 1;
}
int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive, BYTE* blocks, UINT32 blocksLen, PROGRESSIVE_SURFACE_CONTEXT* surface)
static int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive,
const BYTE* blocks, UINT32 blocksLen,
const PROGRESSIVE_SURFACE_CONTEXT* surface)
{
int status = -1;
BYTE* block;
const BYTE* block;
UINT16 xIdx;
UINT16 yIdx;
UINT16 zIdx;
@ -1534,12 +1586,16 @@ int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive, BYTE* blocks, UI
return (int) offset;
}
int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, UINT16 surfaceId)
UINT progressive_decompress(PROGRESSIVE_CONTEXT* progressive,
const BYTE* pSrcData, UINT32 SrcSize,
BYTE* pDstData, UINT32 DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT16 surfaceId)
{
int status;
BYTE* block;
BYTE* blocks;
UINT status;
const BYTE* block;
const BYTE* blocks;
UINT16 i, j;
UINT16 index;
UINT16 boxLeft;
UINT16 boxTop;
@ -1556,6 +1612,7 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
UINT32 count = 0;
UINT32 offset = 0;
RFX_RECT* rect = NULL;
REGION16 clippingRects, updateRegion;
PROGRESSIVE_BLOCK_SYNC sync;
PROGRESSIVE_BLOCK_REGION* region;
PROGRESSIVE_BLOCK_CONTEXT context;
@ -1872,10 +1929,64 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
if (offset != blocksLen)
return -1041;
region = &(progressive->region);
region16_init(&clippingRects);
for (i = 0; i < region->numRects; i++)
{
RECTANGLE_16 clippingRect;
RFX_RECT* rect = &(region->rects[i]);
clippingRect.left = nXDst + rect->x;
clippingRect.top = nYDst + rect->y;
clippingRect.right = clippingRect.left + rect->width;
clippingRect.bottom = clippingRect.top + rect->height;
region16_union_rect(&clippingRects, &clippingRects, &clippingRect);
}
for (i = 0; i < region->numTiles; i++)
{
UINT32 nbUpdateRects;
const RECTANGLE_16* updateRects;
RECTANGLE_16 updateRect;
RFX_PROGRESSIVE_TILE* tile = region->tiles[i];
updateRect.left = nXDst + tile->x;
updateRect.top = nYDst + tile->y;
updateRect.right = updateRect.left + 64;
updateRect.bottom = updateRect.top + 64;
region16_init(&updateRegion);
region16_intersect_rect(&updateRegion, &clippingRects, &updateRect);
updateRects = region16_rects(&updateRegion, &nbUpdateRects);
for (j = 0; j < nbUpdateRects; j++)
{
UINT32 nXSrc;
UINT32 nYSrc;
nWidth = updateRects[j].right - updateRects[j].left;
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);
}
region16_uninit(&updateRegion);
}
region16_uninit(&clippingRects);
return 1;
}
int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize)
int progressive_compress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData,
UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize)
{
return 1;
}

View File

@ -89,7 +89,7 @@ int region16_n_rects(const REGION16 *region)
return region->data->nbRects;
}
const RECTANGLE_16 *region16_rects(const REGION16 *region, int *nbRects)
const RECTANGLE_16 *region16_rects(const REGION16 *region, UINT32 *nbRects)
{
REGION16_DATA *data;
@ -232,7 +232,7 @@ BOOL region16_copy(REGION16 *dst, const REGION16 *src)
void region16_print(const REGION16 *region)
{
const RECTANGLE_16 *rects;
int nbRects, i;
UINT32 nbRects, i;
int currentBandY = -1;
rects = region16_rects(region, &nbRects);
@ -250,11 +250,11 @@ void region16_print(const REGION16 *region)
}
}
void region16_copy_band_with_union(RECTANGLE_16 *dst,
static void region16_copy_band_with_union(RECTANGLE_16 *dst,
const RECTANGLE_16 *src, const RECTANGLE_16 *end,
UINT16 newTop, UINT16 newBottom,
const RECTANGLE_16 *unionRect,
int *dstCounter,
UINT32 *dstCounter,
const RECTANGLE_16 **srcPtr, RECTANGLE_16 **dstPtr)
{
UINT16 refY = src->top;
@ -486,7 +486,7 @@ BOOL region16_union_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE_16
const RECTANGLE_16 *currentBand, *endSrcRect, *nextBand;
REGION16_DATA* newItems = NULL;
RECTANGLE_16* dstRect = NULL;
int usedRects, srcNbRects;
UINT32 usedRects, srcNbRects;
UINT16 topInterBand;
assert(src);
@ -552,7 +552,7 @@ BOOL region16_union_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE_16
+----+
=================
band of srcRect
band of srcRect
=================
+----+
| | rect (case 2)
@ -569,17 +569,17 @@ BOOL region16_union_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE_16
{
/* rect overlaps the band:
| | | |
====^=================| |==| |=========================== band
| top split | | | |
v | 1 | | 2 |
^ | | | | +----+ +----+
| merge zone | | | | | | | 4 |
v +----+ | | | | +----+
^ | | | 3 |
| bottom split | | | |
====v=========================| |==| |===================
| | | |
| | | |
====^=================| |==| |=========================== band
| top split | | | |
v | 1 | | 2 |
^ | | | | +----+ +----+
| merge zone | | | | | | | 4 |
v +----+ | | | | +----+
^ | | | 3 |
| bottom split | | | |
====v=========================| |==| |===================
| | | |
possible cases:
1) no top split, merge zone then a bottom split. The band will be splitted
@ -691,7 +691,7 @@ BOOL region16_union_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE_16
BOOL region16_intersects_rect(const REGION16 *src, const RECTANGLE_16 *arg2)
{
const RECTANGLE_16 *rect, *endPtr, *srcExtents;
int nbRects;
UINT32 nbRects;
assert(src);
assert(src->data);
@ -725,7 +725,7 @@ BOOL region16_intersect_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE
REGION16_DATA *newItems;
const RECTANGLE_16 *srcPtr, *endPtr, *srcExtents;
RECTANGLE_16 *dstPtr;
int nbRects, usedRects;
UINT32 nbRects, usedRects;
RECTANGLE_16 common, newExtents;
assert(src);
@ -775,8 +775,8 @@ BOOL region16_intersect_rect(REGION16 *dst, const REGION16 *src, const RECTANGLE
if (rectangle_is_empty(&newExtents))
{
/* Check if the existing newExtents is empty. If it is empty, use
* new common directly. We do not need to check common rectangle
/* Check if the existing newExtents is empty. If it is empty, use
* new common directly. We do not need to check common rectangle
* because the rectangles_intersection() ensures that it is not empty.
*/
newExtents = common;

File diff suppressed because it is too large Load Diff

View File

@ -38,130 +38,85 @@
#include "rfx_decode.h"
/* stride is bytes between rows in the output buffer. */
void rfx_decode_format_rgb(INT16* r_buf, INT16* g_buf, INT16* b_buf,
RDP_PIXEL_FORMAT pixel_format, BYTE* dst_buf, int stride)
static void rfx_decode_format_rgb(const INT16* r_buf, const INT16* g_buf,
const INT16* b_buf, UINT32 pixel_format,
BYTE* dst_buf, UINT32 stride)
{
primitives_t *prims = primitives_get();
INT16* r = r_buf;
INT16* g = g_buf;
INT16* b = b_buf;
INT16* pSrc[3];
primitives_t* prims = primitives_get();
const INT16* r = r_buf;
const INT16* g = g_buf;
const INT16* b = b_buf;
const INT16* pSrc[3];
static const prim_size_t roi_64x64 = { 64, 64 };
BYTE* dst = dst_buf;
int x, y;
switch (pixel_format)
{
case RDP_PIXEL_FORMAT_B8G8R8A8:
pSrc[0] = r; pSrc[1] = g; pSrc[2] = b;
prims->RGBToRGB_16s8u_P3AC4R(
(const INT16 **) pSrc, 64*sizeof(INT16),
dst, stride, &roi_64x64);
break;
case RDP_PIXEL_FORMAT_R8G8B8A8:
pSrc[0] = b; pSrc[1] = g; pSrc[2] = r;
prims->RGBToRGB_16s8u_P3AC4R(
(const INT16 **) pSrc, 64*sizeof(INT16),
dst, stride, &roi_64x64);
break;
case RDP_PIXEL_FORMAT_B8G8R8:
for (y=0; y<64; y++)
{
for (x=0; x<64; x++)
{
*dst++ = (BYTE) (*b++);
*dst++ = (BYTE) (*g++);
*dst++ = (BYTE) (*r++);
}
dst += stride - (64*3);
}
break;
case RDP_PIXEL_FORMAT_R8G8B8:
for (y=0; y<64; y++)
{
for (x=0; x<64; x++)
{
*dst++ = (BYTE) (*r++);
*dst++ = (BYTE) (*g++);
*dst++ = (BYTE) (*b++);
}
dst += stride - (64*3);
}
break;
default:
break;
}
pSrc[0] = r;
pSrc[1] = g;
pSrc[2] = b;
prims->RGBToRGB_16s8u_P3AC4R(
(const INT16**) pSrc, 64 * sizeof(INT16),
dst, stride, pixel_format, &roi_64x64);
}
static void rfx_decode_component(RFX_CONTEXT* context, const UINT32* quantization_values,
const BYTE* data, int size, INT16* buffer)
static void rfx_decode_component(RFX_CONTEXT* context,
const UINT32* quantization_values,
const BYTE* data, int size, INT16* buffer)
{
INT16* dwt_buffer;
dwt_buffer = BufferPool_Take(context->priv->BufferPool, -1); /* dwt_buffer */
PROFILER_ENTER(context->priv->prof_rfx_decode_component);
PROFILER_ENTER(context->priv->prof_rfx_rlgr_decode);
rfx_rlgr_decode(data, size, buffer, 4096, (context->mode == RLGR1) ? 1 : 3);
rfx_rlgr_decode(data, size, buffer, 4096, (context->mode == RLGR1) ? 1 : 3);
PROFILER_EXIT(context->priv->prof_rfx_rlgr_decode);
PROFILER_ENTER(context->priv->prof_rfx_differential_decode);
rfx_differential_decode(buffer + 4032, 64);
rfx_differential_decode(buffer + 4032, 64);
PROFILER_EXIT(context->priv->prof_rfx_differential_decode);
PROFILER_ENTER(context->priv->prof_rfx_quantization_decode);
context->quantization_decode(buffer, quantization_values);
context->quantization_decode(buffer, quantization_values);
PROFILER_EXIT(context->priv->prof_rfx_quantization_decode);
PROFILER_ENTER(context->priv->prof_rfx_dwt_2d_decode);
context->dwt_2d_decode(buffer, dwt_buffer);
context->dwt_2d_decode(buffer, dwt_buffer);
PROFILER_EXIT(context->priv->prof_rfx_dwt_2d_decode);
PROFILER_EXIT(context->priv->prof_rfx_decode_component);
BufferPool_Return(context->priv->BufferPool, dwt_buffer);
}
/* rfx_decode_ycbcr_to_rgb code now resides in the primitives library. */
/* stride is bytes between rows in the output buffer. */
BOOL rfx_decode_rgb(RFX_CONTEXT* context, RFX_TILE* tile, BYTE* rgb_buffer, int stride)
BOOL rfx_decode_rgb(RFX_CONTEXT* context, RFX_TILE* tile, BYTE* rgb_buffer,
int stride)
{
BYTE* pBuffer;
INT16* pSrcDst[3];
UINT32 *y_quants, *cb_quants, *cr_quants;
UINT32* y_quants, *cb_quants, *cr_quants;
static const prim_size_t roi_64x64 = { 64, 64 };
const primitives_t *prims = primitives_get();
const primitives_t* prims = primitives_get();
PROFILER_ENTER(context->priv->prof_rfx_decode_rgb);
y_quants = context->quants + (tile->quantIdxY * 10);
cb_quants = context->quants + (tile->quantIdxCb * 10);
cr_quants = context->quants + (tile->quantIdxCr * 10);
pBuffer = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */
pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */
pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */
rfx_decode_component(context, y_quants, tile->YData, tile->YLen, pSrcDst[0]); /* YData */
rfx_decode_component(context, cb_quants, tile->CbData, tile->CbLen, pSrcDst[1]); /* CbData */
rfx_decode_component(context, cr_quants, tile->CrData, tile->CrLen, pSrcDst[2]); /* CrData */
pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) +
16])); /* y_r_buffer */
pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
16])); /* cb_g_buffer */
pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
16])); /* cr_b_buffer */
rfx_decode_component(context, y_quants, tile->YData, tile->YLen,
pSrcDst[0]); /* YData */
rfx_decode_component(context, cb_quants, tile->CbData, tile->CbLen,
pSrcDst[1]); /* CbData */
rfx_decode_component(context, cr_quants, tile->CrData, tile->CrLen,
pSrcDst[2]); /* CrData */
PROFILER_ENTER(context->priv->prof_rfx_ycbcr_to_rgb);
prims->yCbCrToRGB_16s16s_P3P3((const INT16**) pSrcDst, 64 * sizeof(INT16),
pSrcDst, 64 * sizeof(INT16), &roi_64x64);
pSrcDst, 64 * sizeof(INT16), &roi_64x64);
PROFILER_EXIT(context->priv->prof_rfx_ycbcr_to_rgb);
PROFILER_ENTER(context->priv->prof_rfx_decode_format_rgb);
rfx_decode_format_rgb(pSrcDst[0], pSrcDst[1], pSrcDst[2],
context->pixel_format, rgb_buffer, stride);
rfx_decode_format_rgb(pSrcDst[0], pSrcDst[1], pSrcDst[2],
context->pixel_format, rgb_buffer, stride);
PROFILER_EXIT(context->priv->prof_rfx_decode_format_rgb);
PROFILER_EXIT(context->priv->prof_rfx_decode_rgb);
BufferPool_Return(context->priv->BufferPool, pBuffer);
return TRUE;
}

View File

@ -41,16 +41,17 @@
#define MINMAX(_v,_l,_h) ((_v) < (_l) ? (_l) : ((_v) > (_h) ? (_h) : (_v)))
static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, int rowstride,
RDP_PIXEL_FORMAT pixel_format, const BYTE* palette, INT16* r_buf, INT16* g_buf, INT16* b_buf)
static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height,
int rowstride,
UINT32 pixel_format, const BYTE* palette, INT16* r_buf, INT16* g_buf,
INT16* b_buf)
{
int x, y;
int x_exceed;
int y_exceed;
const BYTE* src;
INT16 r, g, b;
INT16 *r_last, *g_last, *b_last;
INT16* r_last, *g_last, *b_last;
x_exceed = 64 - width;
y_exceed = 64 - height;
@ -60,66 +61,78 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i
switch (pixel_format)
{
case RDP_PIXEL_FORMAT_B8G8R8A8:
case PIXEL_FORMAT_BGRA32:
for (x = 0; x < width; x++)
{
*b_buf++ = (INT16) (*src++);
*g_buf++ = (INT16) (*src++);
*r_buf++ = (INT16) (*src++);
*b_buf++ = (INT16)(*src++);
*g_buf++ = (INT16)(*src++);
*r_buf++ = (INT16)(*src++);
src++;
}
break;
case RDP_PIXEL_FORMAT_R8G8B8A8:
case PIXEL_FORMAT_RGBA32:
for (x = 0; x < width; x++)
{
*r_buf++ = (INT16) (*src++);
*g_buf++ = (INT16) (*src++);
*b_buf++ = (INT16) (*src++);
*r_buf++ = (INT16)(*src++);
*g_buf++ = (INT16)(*src++);
*b_buf++ = (INT16)(*src++);
src++;
}
break;
case RDP_PIXEL_FORMAT_B8G8R8:
case PIXEL_FORMAT_BGR24:
for (x = 0; x < width; x++)
{
*b_buf++ = (INT16) (*src++);
*g_buf++ = (INT16) (*src++);
*r_buf++ = (INT16) (*src++);
*b_buf++ = (INT16)(*src++);
*g_buf++ = (INT16)(*src++);
*r_buf++ = (INT16)(*src++);
}
break;
case RDP_PIXEL_FORMAT_R8G8B8:
case PIXEL_FORMAT_RGB24:
for (x = 0; x < width; x++)
{
*r_buf++ = (INT16) (*src++);
*g_buf++ = (INT16) (*src++);
*b_buf++ = (INT16) (*src++);
*r_buf++ = (INT16)(*src++);
*g_buf++ = (INT16)(*src++);
*b_buf++ = (INT16)(*src++);
}
break;
case RDP_PIXEL_FORMAT_B5G6R5_LE:
case PIXEL_FORMAT_BGR16:
for (x = 0; x < width; x++)
{
*b_buf++ = (INT16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
*g_buf++ = (INT16) ((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
*r_buf++ = (INT16) ((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
*b_buf++ = (INT16)(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
*g_buf++ = (INT16)((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
*r_buf++ = (INT16)((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
src += 2;
}
break;
case RDP_PIXEL_FORMAT_R5G6B5_LE:
case PIXEL_FORMAT_RGB16:
for (x = 0; x < width; x++)
{
*r_buf++ = (INT16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
*g_buf++ = (INT16) ((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
*b_buf++ = (INT16) ((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
*r_buf++ = (INT16)(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
*g_buf++ = (INT16)((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3));
*b_buf++ = (INT16)((((*src) & 0x1F) << 3) | (((*src) >> 2) & 0x07));
src += 2;
}
break;
case RDP_PIXEL_FORMAT_P4_PLANER:
case PIXEL_FORMAT_RGB8:
if (!palette)
break;
for (x = 0; x < width; x++)
{
int shift;
BYTE idx;
shift = (7 - (x % 8));
idx = ((*src) >> shift) & 1;
idx |= (((*(src + 1)) >> shift) & 1) << 1;
@ -129,26 +142,32 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i
*r_buf++ = (INT16) palette[idx];
*g_buf++ = (INT16) palette[idx + 1];
*b_buf++ = (INT16) palette[idx + 2];
if (shift == 0)
src += 4;
}
break;
case RDP_PIXEL_FORMAT_P8:
case PIXEL_FORMAT_A4:
if (!palette)
break;
for (x = 0; x < width; x++)
{
int idx = (*src) * 3;
*r_buf++ = (INT16) palette[idx];
*g_buf++ = (INT16) palette[idx + 1];
*b_buf++ = (INT16) palette[idx + 2];
src++;
}
break;
default:
break;
}
/* Fill the horizontal region outside of 64x64 tile size with the right-most pixel for best quality */
if (x_exceed > 0)
{
@ -187,33 +206,26 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i
/* rfx_encode_rgb_to_ycbcr code now resides in the primitives library. */
static void rfx_encode_component(RFX_CONTEXT* context, const UINT32* quantization_values,
INT16* data, BYTE* buffer, int buffer_size, int* size)
static void rfx_encode_component(RFX_CONTEXT* context,
const UINT32* quantization_values,
INT16* data, BYTE* buffer, int buffer_size, int* size)
{
INT16* dwt_buffer;
dwt_buffer = BufferPool_Take(context->priv->BufferPool, -1); /* dwt_buffer */
PROFILER_ENTER(context->priv->prof_rfx_encode_component);
PROFILER_ENTER(context->priv->prof_rfx_dwt_2d_encode);
context->dwt_2d_encode(data, dwt_buffer);
context->dwt_2d_encode(data, dwt_buffer);
PROFILER_EXIT(context->priv->prof_rfx_dwt_2d_encode);
PROFILER_ENTER(context->priv->prof_rfx_quantization_encode);
context->quantization_encode(data, quantization_values);
context->quantization_encode(data, quantization_values);
PROFILER_EXIT(context->priv->prof_rfx_quantization_encode);
PROFILER_ENTER(context->priv->prof_rfx_differential_encode);
rfx_differential_encode(data + 4032, 64);
rfx_differential_encode(data + 4032, 64);
PROFILER_EXIT(context->priv->prof_rfx_differential_encode);
PROFILER_ENTER(context->priv->prof_rfx_rlgr_encode);
*size = rfx_rlgr_encode(context->mode, data, 4096, buffer, buffer_size);
*size = rfx_rlgr_encode(context->mode, data, 4096, buffer, buffer_size);
PROFILER_EXIT(context->priv->prof_rfx_rlgr_encode);
PROFILER_EXIT(context->priv->prof_rfx_encode_component);
BufferPool_Return(context->priv->BufferPool, dwt_buffer);
}
@ -222,7 +234,7 @@ void rfx_encode_rgb(RFX_CONTEXT* context, RFX_TILE* tile)
BYTE* pBuffer;
INT16* pSrcDst[3];
int YLen, CbLen, CrLen;
UINT32 *YQuant, *CbQuant, *CrQuant;
UINT32* YQuant, *CbQuant, *CrQuant;
primitives_t* prims = primitives_get();
static const prim_size_t roi_64x64 = { 64, 64 };
@ -233,41 +245,34 @@ void rfx_encode_rgb(RFX_CONTEXT* context, RFX_TILE* tile)
YQuant = context->quants + (tile->quantIdxY * 10);
CbQuant = context->quants + (tile->quantIdxCb * 10);
CrQuant = context->quants + (tile->quantIdxCr * 10);
pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */
pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */
pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */
pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) +
16])); /* y_r_buffer */
pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) +
16])); /* cb_g_buffer */
pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) +
16])); /* cr_b_buffer */
PROFILER_ENTER(context->priv->prof_rfx_encode_rgb);
PROFILER_ENTER(context->priv->prof_rfx_encode_format_rgb);
rfx_encode_format_rgb(tile->data, tile->width, tile->height, tile->scanline,
context->pixel_format, context->palette, pSrcDst[0], pSrcDst[1], pSrcDst[2]);
rfx_encode_format_rgb(tile->data, tile->width, tile->height, tile->scanline,
context->pixel_format, context->palette, pSrcDst[0], pSrcDst[1], pSrcDst[2]);
PROFILER_EXIT(context->priv->prof_rfx_encode_format_rgb);
PROFILER_ENTER(context->priv->prof_rfx_rgb_to_ycbcr);
prims->RGBToYCbCr_16s16s_P3P3((const INT16**) pSrcDst, 64 * sizeof(INT16),
pSrcDst, 64 * sizeof(INT16), &roi_64x64);
prims->RGBToYCbCr_16s16s_P3P3((const INT16**) pSrcDst, 64 * sizeof(INT16),
pSrcDst, 64 * sizeof(INT16), &roi_64x64);
PROFILER_EXIT(context->priv->prof_rfx_rgb_to_ycbcr);
/**
* We need to clear the buffers as the RLGR encoder expects it to be initialized to zero.
* This allows simplifying and improving the performance of the encoding process.
*/
ZeroMemory(tile->YData, 4096);
ZeroMemory(tile->CbData, 4096);
ZeroMemory(tile->CrData, 4096);
rfx_encode_component(context, YQuant, pSrcDst[0], tile->YData, 4096, &YLen);
rfx_encode_component(context, CbQuant, pSrcDst[1], tile->CbData, 4096, &CbLen);
rfx_encode_component(context, CrQuant, pSrcDst[2], tile->CrData, 4096, &CrLen);
tile->YLen = (UINT16) YLen;
tile->CbLen = (UINT16) CbLen;
tile->CrLen = (UINT16) CrLen;
PROFILER_EXIT(context->priv->prof_rfx_encode_rgb);
BufferPool_Return(context->priv->BufferPool, pBuffer);
}

View File

@ -37,7 +37,7 @@ static BYTE TEST_CLEAR_EXAMPLE_4[] =
"\xb6\xff\xff\xff\xff\xff\xff\xff\xff\xff\x46\x91\x47\x91\x48\x91"
"\x49\x91\x4a\x91\x1b\x91";
int test_ClearDecompressExample1()
static int test_ClearDecompressExample1(void)
{
int status;
BYTE* pSrcData;
@ -50,16 +50,16 @@ int test_ClearDecompressExample1()
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_1) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_1;
status = clear_decompress(clear, pSrcData, SrcSize, &pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
status = clear_decompress(clear, pSrcData, SrcSize, pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
printf("clear_decompress example 1 status: %d\n", status);
clear_context_free(clear);
return 1;
return status;
}
int test_ClearDecompressExample2()
static int test_ClearDecompressExample2(void)
{
int status;
BYTE* pSrcData;
@ -72,16 +72,16 @@ int test_ClearDecompressExample2()
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_2) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_2;
status = clear_decompress(clear, pSrcData, SrcSize, &pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
status = clear_decompress(clear, pSrcData, SrcSize, pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
printf("clear_decompress example 2 status: %d\n", status);
clear_context_free(clear);
return 1;
return status;
}
int test_ClearDecompressExample3()
static int test_ClearDecompressExample3(void)
{
int status;
BYTE* pSrcData;
@ -94,16 +94,16 @@ int test_ClearDecompressExample3()
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_3) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_3;
status = clear_decompress(clear, pSrcData, SrcSize, &pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
status = clear_decompress(clear, pSrcData, SrcSize, pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
printf("clear_decompress example 3 status: %d\n", status);
clear_context_free(clear);
return 1;
return status;
}
int test_ClearDecompressExample4()
static int test_ClearDecompressExample4(void)
{
int status;
BYTE* pSrcData;
@ -116,24 +116,26 @@ int test_ClearDecompressExample4()
SrcSize = sizeof(TEST_CLEAR_EXAMPLE_4) - 1;
pSrcData = (BYTE*) TEST_CLEAR_EXAMPLE_4;
status = clear_decompress(clear, pSrcData, SrcSize, &pDstData, PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
status = clear_decompress(clear, pSrcData, SrcSize, pDstData,
PIXEL_FORMAT_XRGB32, 0, 0, 0, 0, 0);
printf("clear_decompress example 4 status: %d\n", status);
clear_context_free(clear);
return 1;
return status;
}
int TestFreeRDPCodecClear(int argc, char* argv[])
{
//test_ClearDecompressExample1();
//test_ClearDecompressExample2();
//test_ClearDecompressExample3();
test_ClearDecompressExample4();
if (test_ClearDecompressExample1())
return -1;
if (test_ClearDecompressExample2())
return -1;
if (test_ClearDecompressExample3())
return -1;
if (test_ClearDecompressExample4())
return -1;
return 0;
}

View File

@ -11,7 +11,7 @@
* Experimental Case 01: 64x64 (32bpp)
*/
static BYTE TEST_RLE_BITMAP_EXPERIMENTAL_01[16384] =
static const BYTE TEST_RLE_BITMAP_EXPERIMENTAL_01[16384] =
"\x1B\x1A\x16\xFF\x1C\x1A\x16\xFF\x18\x17\x13\xFF\x19\x18\x14\xFF\x17\x16\x12\xFF\x18\x16\x12\xFF\x19\x18\x14\xFF\x19\x18\x14\xFF"
"\x1D\x1C\x17\xFF\x1D\x1B\x17\xFF\x1C\x1B\x17\xFF\x1B\x1A\x16\xFF\x1A\x19\x15\xFF\x1A\x19\x15\xFF\x18\x17\x13\xFF\x1A\x19\x15\xFF"
"\x1B\x1A\x16\xFF\x19\x18\x14\xFF\x19\x18\x14\xFF\x18\x16\x14\xFF\x1C\x1A\x16\xFF\x1A\x18\x14\xFF\x1B\x1A\x16\xFF\x19\x17\x13\xFF"
@ -530,7 +530,7 @@ static BYTE TEST_RLE_BITMAP_EXPERIMENTAL_01[16384] =
* Experimental Case 02: 64x64 (32bpp)
*/
static BYTE TEST_RLE_BITMAP_EXPERIMENTAL_02[16384] =
static const BYTE TEST_RLE_BITMAP_EXPERIMENTAL_02[16384] =
"\x1C\x1C\x17\xFF\x1D\x1B\x18\xFF\x1B\x19\x15\xFF\x19\x18\x13\xFF\x19\x18\x14\xFF\x17\x16\x12\xFF\x17\x17\x13\xFF\x19\x17\x14\xFF"
"\x15\x14\x11\xFF\x13\x13\x10\xFF\x4F\x4B\x3E\xFF\x21\x20\x1A\xFF\x22\x21\x1B\xFF\x22\x21\x1C\xFF\x22\x21\x1B\xFF\x21\x21\x1A\xFF"
"\x22\x21\x1B\xFF\x21\x20\x1A\xFF\x21\x20\x1A\xFF\x21\x20\x1A\xFF\x22\x21\x1B\xFF\x23\x22\x1D\xFF\x22\x20\x1A\xFF\x21\x20\x1A\xFF"
@ -1048,7 +1048,7 @@ static BYTE TEST_RLE_BITMAP_EXPERIMENTAL_02[16384] =
* Experimental Case 03: 64x64 (32bpp)
*/
static BYTE TEST_RLE_BITMAP_EXPERIMENTAL_03[16384] =
static const BYTE TEST_RLE_BITMAP_EXPERIMENTAL_03[16384] =
"\x27\x2A\x23\xFF\x23\x25\x1F\xFF\x23\x23\x1E\xFF\x24\x23\x1D\xFF\x25\x23\x1D\xFF\x25\x23\x1E\xFF\x25\x23\x1D\xFF\x25\x24\x1F\xFF"
"\x28\x2B\x23\xFF\x37\x60\x4A\xFF\x4A\xA2\x78\xFF\x47\x97\x71\xFF\x41\x84\x64\xFF\x3D\x75\x58\xFF\x38\x62\x4B\xFF\x33\x50\x3E\xFF"
"\x2E\x3C\x30\xFF\x2A\x34\x29\xFF\x28\x30\x26\xFF\x27\x2C\x24\xFF\x26\x29\x22\xFF\x27\x28\x21\xFF\x27\x26\x20\xFF\x27\x25\x20\xFF"
@ -2663,7 +2663,7 @@ BYTE TEST_64X64_BLUE_PLANE_RLE[3724] =
* [MS-RDPEGDI] Test Bitmap 32x32 (16bpp)
*/
const BYTE TEST_RLE_UNCOMPRESSED_BITMAP_16BPP[2048] =
static const BYTE TEST_RLE_UNCOMPRESSED_BITMAP_16BPP[2048] =
"\xFF\xFF\x99\xD6\x99\xD6\x99\xD6\x99\xD6\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x99\xD6\x99\xD6\x99\xD6\x10\x84\x08\x42"
"\x08\x42\x10\x84\x99\xD6\x99\xD6\x99\xD6\x99\xD6\x00\x00\x00\x00"
@ -2797,7 +2797,7 @@ const BYTE TEST_RLE_UNCOMPRESSED_BITMAP_16BPP[2048] =
* [MS-RDPEGDI] Test Bitmap 32x32 (RLE Encoded, not RDP6)
*/
const BYTE TEST_RLE_COMPRESSED_BITMAP[220] =
static const BYTE TEST_RLE_COMPRESSED_BITMAP[220] =
"\x85\xFF\xFF\x99\xD6\x99\xD6\x99\xD6\x99\xD6\x06\x8B\x99\xD6\x99"
"\xD6\x99\xD6\x10\x84\x08\x42\x08\x42\x10\x84\x99\xD6\x99\xD6\x99"
"\xD6\x99\xD6\x06\x84\x99\xD6\x99\xD6\x99\xD6\xFF\xFF\x16\x69\x99"
@ -2813,7 +2813,7 @@ const BYTE TEST_RLE_COMPRESSED_BITMAP[220] =
"\xC3\x80\x61\x00\x00\x00\x00\x00\xCC\x89\x52\x03\x6E\xFF\xFF\x02"
"\xCB\x18\xC6\x84\x08\x42\x08\x42\x08\x42\xFF\xFF";
const BYTE TEST_RLE_SCANLINE_UNCOMPRESSED[12] =
static const BYTE TEST_RLE_SCANLINE_UNCOMPRESSED[12] =
"AAAABBCCCCCD";
/**
@ -2822,7 +2822,7 @@ const BYTE TEST_RLE_SCANLINE_UNCOMPRESSED[12] =
/* Scanline Absolute Values */
const BYTE TEST_RDP6_SCANLINES_ABSOLUTE[3][6] =
static const BYTE TEST_RDP6_SCANLINES_ABSOLUTE[3][6] =
{
{ 255, 255, 255, 255, 254, 253 },
{ 254, 192, 132, 96, 75, 25 },
@ -2830,8 +2830,7 @@ const BYTE TEST_RDP6_SCANLINES_ABSOLUTE[3][6] =
};
/* Scanline Delta Values */
const int TEST_RDP6_SCANLINES_DELTA[3][6] =
static const int TEST_RDP6_SCANLINES_DELTA[3][6] =
{
{ 255, 255, 255, 255, 254, 253 },
{ -1, -63, -123, -159, -179, -228 },
@ -2840,7 +2839,7 @@ const int TEST_RDP6_SCANLINES_DELTA[3][6] =
/* Scanline Delta Values (1-byte two's complement) */
const char TEST_RDP6_SCANLINES_DELTA_2C[3][6] =
static const BYTE TEST_RDP6_SCANLINES_DELTA_2C[3][6] =
{
{ -1, -1, -1, -1, -2, -3 },
{ -1, -63, -123, 97, 77, 28 },
@ -2849,7 +2848,7 @@ const char TEST_RDP6_SCANLINES_DELTA_2C[3][6] =
/* Scanline Delta Values (1-byte two's complement, encoded) */
const char TEST_RDP6_SCANLINES_DELTA_2C_ENCODED[3][6] =
static const BYTE TEST_RDP6_SCANLINES_DELTA_2C_ENCODED[3][6] =
{
{ -1, -1, -1, -1, -2, -3 },
{ -1, 125, 11, -62, -102, 56 },
@ -2858,7 +2857,7 @@ const char TEST_RDP6_SCANLINES_DELTA_2C_ENCODED[3][6] =
/* Scanline Delta Values (1-byte two's complement, encoded, unsigned) */
const BYTE TEST_RDP6_SCANLINES_DELTA_2C_ENCODED_UNSIGNED[3][6] =
static const BYTE TEST_RDP6_SCANLINES_DELTA_2C_ENCODED_UNSIGNED[3][6] =
{
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFD },
{ 0x01, 0x7D, 0xF5, 0xC2, 0x9A, 0x38 },
@ -2880,7 +2879,7 @@ static void fill_bitmap_alpha_channel(BYTE* data, int width, int height, BYTE va
}
}
void fill_bitmap_red_channel(BYTE* data, int width, int height, BYTE value)
static void fill_bitmap_red_channel(BYTE* data, int width, int height, BYTE value)
{
int i, j;
UINT32* pixel;
@ -2895,7 +2894,7 @@ void fill_bitmap_red_channel(BYTE* data, int width, int height, BYTE value)
}
}
void fill_bitmap_green_channel(BYTE* data, int width, int height, BYTE value)
static void fill_bitmap_green_channel(BYTE* data, int width, int height, BYTE value)
{
int i, j;
UINT32* pixel;
@ -2910,7 +2909,7 @@ void fill_bitmap_green_channel(BYTE* data, int width, int height, BYTE value)
}
}
void fill_bitmap_blue_channel(BYTE* data, int width, int height, BYTE value)
static void fill_bitmap_blue_channel(BYTE* data, int width, int height, BYTE value)
{
int i, j;
UINT32* pixel;
@ -2925,7 +2924,7 @@ void fill_bitmap_blue_channel(BYTE* data, int width, int height, BYTE value)
}
}
void dump_color_channel(BYTE* data, int width, int height)
static void dump_color_channel(BYTE* data, int width, int height)
{
int i, j;
@ -2940,14 +2939,14 @@ void dump_color_channel(BYTE* data, int width, int height)
}
}
int test_individual_planes_encoding_rle()
static int test_individual_planes_encoding_rle(void)
{
int width;
int height;
UINT32 width;
UINT32 height;
BYTE* pOutput;
int planeSize;
int compareSize;
int dstSizes[4];
UINT32 dstSizes[4];
int availableSize;
DWORD planarFlags;
BITMAP_PLANAR_CONTEXT* planar;
@ -3073,10 +3072,9 @@ int test_individual_planes_encoding_rle()
int TestFreeRDPCodecPlanar(int argc, char* argv[])
{
int i;
int dstSize;
UINT32 dstSize;
UINT32 format;
BYTE* pDstData;
HCLRCONV clrconv;
DWORD planarFlags;
BYTE* srcBitmap32;
BYTE* srcBitmap16;
@ -3089,10 +3087,20 @@ int TestFreeRDPCodecPlanar(int argc, char* argv[])
planarFlags = PLANAR_FORMAT_HEADER_NA;
planarFlags |= PLANAR_FORMAT_HEADER_RLE;
planar = freerdp_bitmap_planar_context_new(planarFlags, 64, 64);
clrconv = freerdp_clrconv_new(0);
srcBitmap16 = (BYTE*) TEST_RLE_UNCOMPRESSED_BITMAP_16BPP;
srcBitmap32 = freerdp_image_convert(srcBitmap16, NULL, 32, 32, 16, 32, clrconv);
format = PIXEL_FORMAT_ARGB32;
pDstData = calloc(32*32, GetBytesPerPixel(format));
if (!pDstData)
return -1;
if (freerdp_image_copy(pDstData, format,
32 * GetBytesPerPixel(format),
0, 0, 32, 32, srcBitmap16, PIXEL_FORMAT_RGB16,
32 * GetBytesPerPixel(PIXEL_FORMAT_RGB16),
0, 0, NULL))
return -1;
#if 0
freerdp_bitmap_compress_planar(planar, srcBitmap32, format, 32, 32, 32 * 4, NULL, &dstSize);
freerdp_bitmap_planar_compress_plane_rle((BYTE*) TEST_RLE_SCANLINE_UNCOMPRESSED, 12, 1, NULL, &dstSize);
@ -3309,7 +3317,6 @@ int TestFreeRDPCodecPlanar(int argc, char* argv[])
free(compressedBitmap);
free(decompressedBitmap);
freerdp_clrconv_free(clrconv);
_aligned_free(srcBitmap32);
freerdp_bitmap_planar_context_free(planar);
return 0;

View File

@ -844,7 +844,7 @@ static int test_memcmp_count(const BYTE* mem1, const BYTE* mem2, int size, int m
return count;
}
int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE files[4], EGFX_SAMPLE_FILE bitmaps[4], int quarter, int count)
static int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE files[4], EGFX_SAMPLE_FILE bitmaps[4], int quarter, int count)
{
int cnt;
int pass;
@ -868,7 +868,7 @@ int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE f
for (pass = 0; pass < count; pass++)
{
status = progressive_decompress(progressive, files[pass].buffer, files[pass].size,
&g_DstData, PIXEL_FORMAT_XRGB32, g_DstStep, 0, 0, g_Width, g_Height, 0);
g_DstData, PIXEL_FORMAT_XRGB32, g_DstStep, 0, 0, g_Width, g_Height, 0);
printf("ProgressiveDecompress: status: %d pass: %d\n", status, pass + 1);
@ -948,7 +948,7 @@ int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE f
return 1;
}
int test_progressive_ms_sample(char* ms_sample_path)
static int test_progressive_ms_sample(char* ms_sample_path)
{
int i, j, k;
int count;

View File

@ -41,11 +41,11 @@ static BOOL compareRectangles(const RECTANGLE_16 *src1, const RECTANGLE_16 *src2
}
static int test_basic() {
static int test_basic(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
/* R1 + R2 ==> disjointed rects */
RECTANGLE_16 r1 = { 0, 101, 200, 201};
@ -85,11 +85,11 @@ out:
}
static int test_r1_r3() {
static int test_r1_r3(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r3 = {150, 151, 250, 251};
@ -139,11 +139,11 @@ out:
}
static int test_r9_r10() {
static int test_r9_r10(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
/*
* +===============================================================
@ -155,8 +155,8 @@ static int test_r9_r10() {
* || | | | =====> | |
* || | | | | |
* || | | | | |
* |+--| |-+ +--+---+-+
* | +---+ +---+
* |+--| |-+ +--+---+-+
* | +---+ +---+
*/
RECTANGLE_16 r9 = { 0, 100, 400, 200};
RECTANGLE_16 r10 = {200, 0, 300, 300};
@ -182,11 +182,11 @@ out:
}
static int test_r1_r5() {
static int test_r1_r5(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r5 = {150, 121, 300, 131};
@ -207,9 +207,9 @@ static int test_r1_r5() {
* || | r5 | =====> | |
* || +-------+ +--------+----+
* || | | |
* |+--------+ +--------+
* |
*
* |+--------+ +--------+
* |
*
*/
if (!region16_union_rect(&region, &region, &r1))
goto out;
@ -226,11 +226,11 @@ out:
return retCode;
}
static int test_r1_r6() {
static int test_r1_r6(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r6 = {150, 121, 170, 131};
@ -245,8 +245,8 @@ static int test_r1_r6() {
* || |r6| | =====> | |
* || +--+ | | |
* || | | |
* |+--------+ +--------+
* |
* |+--------+ +--------+
* |
*/
region16_clear(&region);
if (!region16_union_rect(&region, &region, &r1))
@ -264,11 +264,11 @@ out:
}
static int test_r1_r2_r4() {
static int test_r1_r2_r4(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r2 = {150, 301, 250, 401};
RECTANGLE_16 r4 = {150, 251, 250, 301};
@ -312,11 +312,11 @@ out:
}
static int test_r1_r7_r8() {
static int test_r1_r7_r8(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r7 = {300, 101, 500, 201};
RECTANGLE_16 r8 = {150, 121, 400, 131};
@ -338,8 +338,8 @@ static int test_r1_r7_r8() {
* || | r8 | | =====> | |
* || +------------+ | +--------+---+--------+
* || | | | | | | |
* |+--------+ +--------+ +--------+ +--------+
* |
* |+--------+ +--------+ +--------+ +--------+
* |
*/
region16_init(&region);
if (!region16_union_rect(&region, &region, &r1))
@ -381,11 +381,11 @@ out:
}
static int test_r1_r2_r3_r4() {
static int test_r1_r2_r3_r4(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r2 = {150, 301, 250, 401};
RECTANGLE_16 r3 = {150, 151, 250, 251};
@ -435,7 +435,7 @@ static int test_r1_r2_r3_r4() {
* |
* |+-----+ +-----+
* || | | |
* |+-----+--------+ +-----+--------+
* |+-----+--------+ +-----+--------+
* || | ==> | |
* |+-----+--------+ +-----+--------+
* | | | | |
@ -459,7 +459,7 @@ out:
}
static int test_from_weston()
static int test_from_weston(void)
{
/*
* 0: 0,0 -> 640,32 (w=640 h=32)
@ -469,7 +469,7 @@ static int test_from_weston()
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 0, 640, 32};
RECTANGLE_16 r2 = {236, 169, 268, 201};
RECTANGLE_16 r3 = {246, 258, 278, 290};
@ -513,11 +513,11 @@ out:
return retCode;
}
static int test_r1_inter_r3() {
static int test_r1_inter_r3(void) {
REGION16 region, intersection;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r3 = {150, 151, 250, 251};
@ -557,11 +557,11 @@ out:
return retCode;
}
static int test_r1_r3_inter_r11() {
static int test_r1_r3_inter_r11(void) {
REGION16 region, intersection;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects;
UINT32 nbRects;
RECTANGLE_16 r1 = { 0, 101, 200, 201};
RECTANGLE_16 r3 = {150, 151, 250, 251};
RECTANGLE_16 r11 ={170, 151, 600, 301};
@ -614,11 +614,11 @@ out:
return retCode;
}
static int test_norbert_case() {
static int test_norbert_case(void) {
REGION16 region, intersection;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects, i;
UINT32 nbRects, i;
RECTANGLE_16 inRectangles[5] = {
{1680, 0, 1920, 242},
@ -654,14 +654,14 @@ static int test_norbert_case() {
* | | |
* | | R[3]|
* 1036 | | +------+
* 1040 | +----+
* 1040 | +----+
* | |R[4]| Union of R[0-4]|
* 1078 | +----+ - - - - - - - -+
* 1080 |
*
*
* 1080 |
*
*
* The result is union of R[0] - R[4].
* After intersected with the full screen rect, the
* After intersected with the full screen rect, the
* result should keep the same.
*/
for (i = 0; i < 5; i++)
@ -689,11 +689,11 @@ out:
return retCode;
}
static int test_norbert2_case() {
static int test_norbert2_case(void) {
REGION16 region;
int retCode = -1;
const RECTANGLE_16 *rects;
int nbRects = 0;
UINT32 nbRects = 0;
RECTANGLE_16 rect1 = { 464, 696, 476, 709 };
RECTANGLE_16 rect2 = { 0, 0, 1024, 32 };
@ -750,7 +750,7 @@ out:
return retCode;
}
static int test_empty_rectangle() {
static int test_empty_rectangle(void) {
REGION16 region, intersection;
int retCode = -1;
int i;
@ -768,7 +768,7 @@ static int test_empty_rectangle() {
100, 100, 200, 200
};
RECTANGLE_16 expected_inter_extents = {
0, 0, 0, 0
0, 0, 0, 0
};
region16_init(&region);
@ -808,13 +808,13 @@ out:
return retCode;
}
typedef int (*TestFunction)();
typedef int (*TestFunction)(void);
struct UnitaryTest {
const char *name;
TestFunction func;
};
struct UnitaryTest tests[] = {
static struct UnitaryTest tests[] = {
{"Basic trivial tests", test_basic},
{"R1+R3 and R3+R1", test_r1_r3},
{"R1+R5", test_r1_r5},

View File

@ -31,7 +31,6 @@ rdpBitmap* Bitmap_Alloc(rdpContext* context)
{
rdpBitmap* bitmap;
rdpGraphics* graphics;
graphics = context->graphics;
bitmap = (rdpBitmap*) calloc(1, graphics->Bitmap_Prototype->size);
@ -62,7 +61,8 @@ void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
}
}
void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap, UINT16 left, UINT16 top, UINT16 right, UINT16 bottom)
void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap, UINT16 left,
UINT16 top, UINT16 right, UINT16 bottom)
{
bitmap->left = left;
bitmap->top = top;
@ -70,7 +70,8 @@ void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap, UINT16 left, UI
bitmap->bottom = bottom;
}
void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, UINT16 width, UINT16 height)
void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, UINT16 width,
UINT16 height)
{
bitmap->width = width;
bitmap->height = height;
@ -79,7 +80,8 @@ void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, UINT16 width,
/* static method */
BOOL Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
{
return context->graphics->Bitmap_Prototype->SetSurface(context, bitmap, primary);
return context->graphics->Bitmap_Prototype->SetSurface(context, bitmap,
primary);
}
void graphics_register_bitmap(rdpGraphics* graphics, rdpBitmap* bitmap)
@ -88,12 +90,10 @@ void graphics_register_bitmap(rdpGraphics* graphics, rdpBitmap* bitmap)
}
/* Pointer Class */
rdpPointer* Pointer_Alloc(rdpContext* context)
{
rdpPointer* pointer;
rdpGraphics* graphics;
graphics = context->graphics;
pointer = (rdpPointer*) calloc(1, graphics->Pointer_Prototype->size);
@ -133,7 +133,7 @@ void Pointer_Free(rdpContext* context, rdpPointer* pointer)
}
/* static method */
BOOL Pointer_Set(rdpContext* context, rdpPointer* pointer)
BOOL Pointer_Set(rdpContext* context, const rdpPointer* pointer)
{
return context->graphics->Pointer_Prototype->Set(context, pointer);
}
@ -150,7 +150,8 @@ BOOL Pointer_SetDefault(rdpContext* context)
BOOL Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
{
return IFCALLRESULT(TRUE, context->graphics->Pointer_Prototype->SetPosition, context, x, y);
return IFCALLRESULT(TRUE, context->graphics->Pointer_Prototype->SetPosition,
context, x, y);
}
void graphics_register_pointer(rdpGraphics* graphics, rdpPointer* pointer)
@ -164,7 +165,6 @@ rdpGlyph* Glyph_Alloc(rdpContext* context)
{
rdpGlyph* glyph;
rdpGraphics* graphics;
graphics = context->graphics;
glyph = (rdpGlyph*) calloc(1, graphics->Glyph_Prototype->size);
@ -191,14 +191,18 @@ BOOL Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
return context->graphics->Glyph_Prototype->Draw(context, glyph, x, y);
}
BOOL Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
BOOL Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height,
UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
{
return context->graphics->Glyph_Prototype->BeginDraw(context, x, y, width, height, bgcolor, fgcolor, fOpRedundant);
return context->graphics->Glyph_Prototype->BeginDraw(context, x, y, width,
height, bgcolor, fgcolor, fOpRedundant);
}
BOOL Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor)
BOOL Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height,
UINT32 bgcolor, UINT32 fgcolor)
{
return context->graphics->Glyph_Prototype->EndDraw(context, x, y, width, height, bgcolor, fgcolor);
return context->graphics->Glyph_Prototype->EndDraw(context, x, y, width, height,
bgcolor, fgcolor);
}
void graphics_register_glyph(rdpGraphics* graphics, rdpGlyph* glyph)
@ -211,45 +215,41 @@ void graphics_register_glyph(rdpGraphics* graphics, rdpGlyph* glyph)
rdpGraphics* graphics_new(rdpContext* context)
{
rdpGraphics* graphics;
graphics = (rdpGraphics*) calloc(1, sizeof(rdpGraphics));
if (graphics)
{
graphics->context = context;
graphics->Bitmap_Prototype = (rdpBitmap*) calloc(1, sizeof(rdpBitmap));
if (!graphics->Bitmap_Prototype)
{
free (graphics);
free(graphics);
return NULL;
}
graphics->Bitmap_Prototype->size = sizeof(rdpBitmap);
graphics->Bitmap_Prototype->New = Bitmap_New;
graphics->Bitmap_Prototype->Free = Bitmap_Free;
graphics->Pointer_Prototype = (rdpPointer*) calloc(1, sizeof(rdpPointer));
if (!graphics->Pointer_Prototype)
{
free (graphics->Bitmap_Prototype);
free (graphics);
free(graphics->Bitmap_Prototype);
free(graphics);
return NULL;
}
graphics->Pointer_Prototype->size = sizeof(rdpPointer);
graphics->Pointer_Prototype->New = Pointer_New;
graphics->Pointer_Prototype->Free = Pointer_Free;
graphics->Glyph_Prototype = (rdpGlyph*) calloc(1, sizeof(rdpGlyph));
if (!graphics->Glyph_Prototype)
{
free (graphics->Pointer_Prototype);
free (graphics->Bitmap_Prototype);
free (graphics);
free(graphics->Pointer_Prototype);
free(graphics->Bitmap_Prototype);
free(graphics);
return NULL;
}

View File

@ -51,7 +51,8 @@ static BOOL update_message_EndPaint(rdpContext* context)
MakeMessageId(Update, EndPaint), NULL, NULL);
}
static BOOL update_message_SetBounds(rdpContext* context, rdpBounds* bounds)
static BOOL update_message_SetBounds(rdpContext* context,
const rdpBounds* bounds)
{
rdpBounds* wParam = NULL;
@ -79,7 +80,8 @@ static BOOL update_message_DesktopResize(rdpContext* context)
MakeMessageId(Update, DesktopResize), NULL, NULL);
}
static BOOL update_message_BitmapUpdate(rdpContext* context, BITMAP_UPDATE* bitmap)
static BOOL update_message_BitmapUpdate(rdpContext* context,
const BITMAP_UPDATE* bitmap)
{
UINT32 index;
BITMAP_UPDATE* wParam;
@ -123,7 +125,8 @@ static BOOL update_message_BitmapUpdate(rdpContext* context, BITMAP_UPDATE* bitm
MakeMessageId(Update, BitmapUpdate), (void*) wParam, NULL);
}
static BOOL update_message_Palette(rdpContext* context, PALETTE_UPDATE* palette)
static BOOL update_message_Palette(rdpContext* context,
const PALETTE_UPDATE* palette)
{
PALETTE_UPDATE* wParam;
@ -136,7 +139,8 @@ static BOOL update_message_Palette(rdpContext* context, PALETTE_UPDATE* palette)
MakeMessageId(Update, Palette), (void*) wParam, NULL);
}
static BOOL update_message_PlaySound(rdpContext* context, PLAY_SOUND_UPDATE* playSound)
static BOOL update_message_PlaySound(rdpContext* context,
const PLAY_SOUND_UPDATE* playSound)
{
PLAY_SOUND_UPDATE* wParam;
@ -155,7 +159,8 @@ static BOOL update_message_SetKeyboardIndicators(rdpContext* context, UINT16 led
MakeMessageId(Update, SetKeyboardIndicators), (void*)(size_t)led_flags, NULL);
}
static BOOL update_message_RefreshRect(rdpContext* context, BYTE count, RECTANGLE_16* areas)
static BOOL update_message_RefreshRect(rdpContext* context, BYTE count,
const RECTANGLE_16* areas)
{
RECTANGLE_16* lParam;
@ -168,7 +173,8 @@ static BOOL update_message_RefreshRect(rdpContext* context, BYTE count, RECTANGL
MakeMessageId(Update, RefreshRect), (void*) (size_t) count, (void*) lParam);
}
static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow, RECTANGLE_16* area)
static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow,
const RECTANGLE_16* area)
{
RECTANGLE_16* lParam = NULL;
@ -199,7 +205,8 @@ static BOOL update_message_SurfaceCommand(rdpContext* context, wStream* s)
MakeMessageId(Update, SurfaceCommand), (void*) wParam, NULL);
}
static BOOL update_message_SurfaceBits(rdpContext* context, SURFACE_BITS_COMMAND* surfaceBitsCommand)
static BOOL update_message_SurfaceBits(rdpContext* context,
const SURFACE_BITS_COMMAND* surfaceBitsCommand)
{
SURFACE_BITS_COMMAND* wParam;
@ -224,7 +231,8 @@ static BOOL update_message_SurfaceBits(rdpContext* context, SURFACE_BITS_COMMAND
MakeMessageId(Update, SurfaceBits), (void*) wParam, NULL);
}
static BOOL update_message_SurfaceFrameMarker(rdpContext* context, SURFACE_FRAME_MARKER* surfaceFrameMarker)
static BOOL update_message_SurfaceFrameMarker(rdpContext* context,
const SURFACE_FRAME_MARKER* surfaceFrameMarker)
{
SURFACE_FRAME_MARKER* wParam;
@ -245,7 +253,7 @@ static BOOL update_message_SurfaceFrameAcknowledge(rdpContext* context, UINT32 f
/* Primary Update */
static BOOL update_message_DstBlt(rdpContext* context, DSTBLT_ORDER* dstBlt)
static BOOL update_message_DstBlt(rdpContext* context, const DSTBLT_ORDER* dstBlt)
{
DSTBLT_ORDER* wParam;
@ -273,7 +281,8 @@ static BOOL update_message_PatBlt(rdpContext* context, PATBLT_ORDER* patBlt)
MakeMessageId(PrimaryUpdate, PatBlt), (void*) wParam, NULL);
}
static BOOL update_message_ScrBlt(rdpContext* context, SCRBLT_ORDER* scrBlt)
static BOOL update_message_ScrBlt(rdpContext* context,
const SCRBLT_ORDER* scrBlt)
{
SCRBLT_ORDER* wParam;
@ -286,7 +295,9 @@ static BOOL update_message_ScrBlt(rdpContext* context, SCRBLT_ORDER* scrBlt)
MakeMessageId(PrimaryUpdate, ScrBlt), (void*) wParam, NULL);
}
static BOOL update_message_OpaqueRect(rdpContext* context, OPAQUE_RECT_ORDER* opaqueRect)
static BOOL update_message_OpaqueRect(
rdpContext* context,
const OPAQUE_RECT_ORDER* opaqueRect)
{
OPAQUE_RECT_ORDER* wParam;
@ -299,7 +310,9 @@ static BOOL update_message_OpaqueRect(rdpContext* context, OPAQUE_RECT_ORDER* op
MakeMessageId(PrimaryUpdate, OpaqueRect), (void*) wParam, NULL);
}
static BOOL update_message_DrawNineGrid(rdpContext* context, DRAW_NINE_GRID_ORDER* drawNineGrid)
static BOOL update_message_DrawNineGrid(
rdpContext* context,
const DRAW_NINE_GRID_ORDER* drawNineGrid)
{
DRAW_NINE_GRID_ORDER* wParam;
@ -312,7 +325,8 @@ static BOOL update_message_DrawNineGrid(rdpContext* context, DRAW_NINE_GRID_ORDE
MakeMessageId(PrimaryUpdate, DrawNineGrid), (void*) wParam, NULL);
}
static BOOL update_message_MultiDstBlt(rdpContext* context, MULTI_DSTBLT_ORDER* multiDstBlt)
static BOOL update_message_MultiDstBlt(rdpContext* context,
const MULTI_DSTBLT_ORDER* multiDstBlt)
{
MULTI_DSTBLT_ORDER* wParam;
@ -325,7 +339,8 @@ static BOOL update_message_MultiDstBlt(rdpContext* context, MULTI_DSTBLT_ORDER*
MakeMessageId(PrimaryUpdate, MultiDstBlt), (void*) wParam, NULL);
}
static BOOL update_message_MultiPatBlt(rdpContext* context, MULTI_PATBLT_ORDER* multiPatBlt)
static BOOL update_message_MultiPatBlt(rdpContext* context,
const MULTI_PATBLT_ORDER* multiPatBlt)
{
MULTI_PATBLT_ORDER* wParam;
@ -340,7 +355,8 @@ static BOOL update_message_MultiPatBlt(rdpContext* context, MULTI_PATBLT_ORDER*
MakeMessageId(PrimaryUpdate, MultiPatBlt), (void*) wParam, NULL);
}
static BOOL update_message_MultiScrBlt(rdpContext* context, MULTI_SCRBLT_ORDER* multiScrBlt)
static BOOL update_message_MultiScrBlt(rdpContext* context,
const MULTI_SCRBLT_ORDER* multiScrBlt)
{
MULTI_SCRBLT_ORDER* wParam;
@ -353,7 +369,9 @@ static BOOL update_message_MultiScrBlt(rdpContext* context, MULTI_SCRBLT_ORDER*
MakeMessageId(PrimaryUpdate, MultiScrBlt), (void*) wParam, NULL);
}
static BOOL update_message_MultiOpaqueRect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multiOpaqueRect)
static BOOL update_message_MultiOpaqueRect(
rdpContext* context,
const MULTI_OPAQUE_RECT_ORDER* multiOpaqueRect)
{
MULTI_OPAQUE_RECT_ORDER* wParam;
@ -366,7 +384,8 @@ static BOOL update_message_MultiOpaqueRect(rdpContext* context, MULTI_OPAQUE_REC
MakeMessageId(PrimaryUpdate, MultiOpaqueRect), (void*) wParam, NULL);
}
static BOOL update_message_MultiDrawNineGrid(rdpContext* context, MULTI_DRAW_NINE_GRID_ORDER* multiDrawNineGrid)
static BOOL update_message_MultiDrawNineGrid(rdpContext* context,
const MULTI_DRAW_NINE_GRID_ORDER* multiDrawNineGrid)
{
MULTI_DRAW_NINE_GRID_ORDER* wParam;
@ -381,7 +400,8 @@ static BOOL update_message_MultiDrawNineGrid(rdpContext* context, MULTI_DRAW_NIN
MakeMessageId(PrimaryUpdate, MultiDrawNineGrid), (void*) wParam, NULL);
}
static BOOL update_message_LineTo(rdpContext* context, LINE_TO_ORDER* lineTo)
static BOOL update_message_LineTo(rdpContext* context,
const LINE_TO_ORDER* lineTo)
{
LINE_TO_ORDER* wParam;
@ -394,7 +414,8 @@ static BOOL update_message_LineTo(rdpContext* context, LINE_TO_ORDER* lineTo)
MakeMessageId(PrimaryUpdate, LineTo), (void*) wParam, NULL);
}
static BOOL update_message_Polyline(rdpContext* context, POLYLINE_ORDER* polyline)
static BOOL update_message_Polyline(rdpContext* context,
const POLYLINE_ORDER* polyline)
{
POLYLINE_ORDER* wParam;
@ -443,7 +464,8 @@ static BOOL update_message_Mem3Blt(rdpContext* context, MEM3BLT_ORDER* mem3Blt)
MakeMessageId(PrimaryUpdate, Mem3Blt), (void*) wParam, NULL);
}
static BOOL update_message_SaveBitmap(rdpContext* context, SAVE_BITMAP_ORDER* saveBitmap)
static BOOL update_message_SaveBitmap(rdpContext* context,
const SAVE_BITMAP_ORDER* saveBitmap)
{
SAVE_BITMAP_ORDER* wParam;
@ -456,7 +478,8 @@ static BOOL update_message_SaveBitmap(rdpContext* context, SAVE_BITMAP_ORDER* sa
MakeMessageId(PrimaryUpdate, SaveBitmap), (void*) wParam, NULL);
}
static BOOL update_message_GlyphIndex(rdpContext* context, GLYPH_INDEX_ORDER* glyphIndex)
static BOOL update_message_GlyphIndex(rdpContext* context,
GLYPH_INDEX_ORDER* glyphIndex)
{
GLYPH_INDEX_ORDER* wParam;
@ -471,7 +494,8 @@ static BOOL update_message_GlyphIndex(rdpContext* context, GLYPH_INDEX_ORDER* gl
MakeMessageId(PrimaryUpdate, GlyphIndex), (void*) wParam, NULL);
}
static BOOL update_message_FastIndex(rdpContext* context, FAST_INDEX_ORDER* fastIndex)
static BOOL update_message_FastIndex(rdpContext* context,
const FAST_INDEX_ORDER* fastIndex)
{
FAST_INDEX_ORDER* wParam;
@ -484,7 +508,8 @@ static BOOL update_message_FastIndex(rdpContext* context, FAST_INDEX_ORDER* fast
MakeMessageId(PrimaryUpdate, FastIndex), (void*) wParam, NULL);
}
static BOOL update_message_FastGlyph(rdpContext* context, FAST_GLYPH_ORDER* fastGlyph)
static BOOL update_message_FastGlyph(rdpContext* context,
const FAST_GLYPH_ORDER* fastGlyph)
{
FAST_GLYPH_ORDER* wParam;
@ -512,7 +537,8 @@ static BOOL update_message_FastGlyph(rdpContext* context, FAST_GLYPH_ORDER* fast
MakeMessageId(PrimaryUpdate, FastGlyph), (void*) wParam, NULL);
}
static BOOL update_message_PolygonSC(rdpContext* context, POLYGON_SC_ORDER* polygonSC)
static BOOL update_message_PolygonSC(rdpContext* context,
const POLYGON_SC_ORDER* polygonSC)
{
POLYGON_SC_ORDER* wParam;
@ -556,7 +582,8 @@ static BOOL update_message_PolygonCB(rdpContext* context, POLYGON_CB_ORDER* poly
MakeMessageId(PrimaryUpdate, PolygonCB), (void*) wParam, NULL);
}
static BOOL update_message_EllipseSC(rdpContext* context, ELLIPSE_SC_ORDER* ellipseSC)
static BOOL update_message_EllipseSC(rdpContext* context,
const ELLIPSE_SC_ORDER* ellipseSC)
{
ELLIPSE_SC_ORDER* wParam;
@ -569,7 +596,8 @@ static BOOL update_message_EllipseSC(rdpContext* context, ELLIPSE_SC_ORDER* elli
MakeMessageId(PrimaryUpdate, EllipseSC), (void*) wParam, NULL);
}
static BOOL update_message_EllipseCB(rdpContext* context, ELLIPSE_CB_ORDER* ellipseCB)
static BOOL update_message_EllipseCB(rdpContext* context,
const ELLIPSE_CB_ORDER* ellipseCB)
{
ELLIPSE_CB_ORDER* wParam;
@ -586,7 +614,8 @@ static BOOL update_message_EllipseCB(rdpContext* context, ELLIPSE_CB_ORDER* elli
/* Secondary Update */
static BOOL update_message_CacheBitmap(rdpContext* context, CACHE_BITMAP_ORDER* cacheBitmapOrder)
static BOOL update_message_CacheBitmap(rdpContext* context,
const CACHE_BITMAP_ORDER* cacheBitmapOrder)
{
CACHE_BITMAP_ORDER* wParam;
@ -649,7 +678,9 @@ static BOOL update_message_CacheBitmapV3(rdpContext* context, CACHE_BITMAP_V3_OR
MakeMessageId(SecondaryUpdate, CacheBitmapV3), (void*) wParam, NULL);
}
static BOOL update_message_CacheColorTable(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cacheColorTableOrder)
static BOOL update_message_CacheColorTable(
rdpContext* context,
const CACHE_COLOR_TABLE_ORDER* cacheColorTableOrder)
{
CACHE_COLOR_TABLE_ORDER* wParam;
@ -662,7 +693,9 @@ static BOOL update_message_CacheColorTable(rdpContext* context, CACHE_COLOR_TABL
MakeMessageId(SecondaryUpdate, CacheColorTable), (void*) wParam, NULL);
}
static BOOL update_message_CacheGlyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyphOrder)
static BOOL update_message_CacheGlyph(
rdpContext* context,
const CACHE_GLYPH_ORDER* cacheGlyphOrder)
{
CACHE_GLYPH_ORDER* wParam;
@ -675,7 +708,9 @@ static BOOL update_message_CacheGlyph(rdpContext* context, CACHE_GLYPH_ORDER* ca
MakeMessageId(SecondaryUpdate, CacheGlyph), (void*) wParam, NULL);
}
static BOOL update_message_CacheGlyphV2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order)
static BOOL update_message_CacheGlyphV2(
rdpContext* context,
const CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order)
{
CACHE_GLYPH_V2_ORDER* wParam;
@ -688,7 +723,9 @@ static BOOL update_message_CacheGlyphV2(rdpContext* context, CACHE_GLYPH_V2_ORDE
MakeMessageId(SecondaryUpdate, CacheGlyphV2), (void*) wParam, NULL);
}
static BOOL update_message_CacheBrush(rdpContext* context, CACHE_BRUSH_ORDER* cacheBrushOrder)
static BOOL update_message_CacheBrush(
rdpContext* context,
const CACHE_BRUSH_ORDER* cacheBrushOrder)
{
CACHE_BRUSH_ORDER* wParam;
@ -703,7 +740,9 @@ static BOOL update_message_CacheBrush(rdpContext* context, CACHE_BRUSH_ORDER* ca
/* Alternate Secondary Update */
static BOOL update_message_CreateOffscreenBitmap(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
static BOOL update_message_CreateOffscreenBitmap(
rdpContext* context,
const CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
{
CREATE_OFFSCREEN_BITMAP_ORDER* wParam;
@ -726,7 +765,9 @@ static BOOL update_message_CreateOffscreenBitmap(rdpContext* context, CREATE_OFF
MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (void*) wParam, NULL);
}
static BOOL update_message_SwitchSurface(rdpContext* context, SWITCH_SURFACE_ORDER* switchSurface)
static BOOL update_message_SwitchSurface(
rdpContext* context,
const SWITCH_SURFACE_ORDER* switchSurface)
{
SWITCH_SURFACE_ORDER* wParam;
@ -739,7 +780,9 @@ static BOOL update_message_SwitchSurface(rdpContext* context, SWITCH_SURFACE_ORD
MakeMessageId(AltSecUpdate, SwitchSurface), (void*) wParam, NULL);
}
static BOOL update_message_CreateNineGridBitmap(rdpContext* context, CREATE_NINE_GRID_BITMAP_ORDER* createNineGridBitmap)
static BOOL update_message_CreateNineGridBitmap(
rdpContext* context,
const CREATE_NINE_GRID_BITMAP_ORDER* createNineGridBitmap)
{
CREATE_NINE_GRID_BITMAP_ORDER* wParam;
@ -752,7 +795,9 @@ static BOOL update_message_CreateNineGridBitmap(rdpContext* context, CREATE_NINE
MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (void*) wParam, NULL);
}
static BOOL update_message_FrameMarker(rdpContext* context, FRAME_MARKER_ORDER* frameMarker)
static BOOL update_message_FrameMarker(
rdpContext* context,
const FRAME_MARKER_ORDER* frameMarker)
{
FRAME_MARKER_ORDER* wParam;
@ -765,7 +810,9 @@ static BOOL update_message_FrameMarker(rdpContext* context, FRAME_MARKER_ORDER*
MakeMessageId(AltSecUpdate, FrameMarker), (void*) wParam, NULL);
}
static BOOL update_message_StreamBitmapFirst(rdpContext* context, STREAM_BITMAP_FIRST_ORDER* streamBitmapFirst)
static BOOL update_message_StreamBitmapFirst(
rdpContext* context,
const STREAM_BITMAP_FIRST_ORDER* streamBitmapFirst)
{
STREAM_BITMAP_FIRST_ORDER* wParam;
@ -780,7 +827,9 @@ static BOOL update_message_StreamBitmapFirst(rdpContext* context, STREAM_BITMAP_
MakeMessageId(AltSecUpdate, StreamBitmapFirst), (void*) wParam, NULL);
}
static BOOL update_message_StreamBitmapNext(rdpContext* context, STREAM_BITMAP_NEXT_ORDER* streamBitmapNext)
static BOOL update_message_StreamBitmapNext(
rdpContext* context,
const STREAM_BITMAP_NEXT_ORDER* streamBitmapNext)
{
STREAM_BITMAP_NEXT_ORDER* wParam;
@ -795,7 +844,9 @@ static BOOL update_message_StreamBitmapNext(rdpContext* context, STREAM_BITMAP_N
MakeMessageId(AltSecUpdate, StreamBitmapNext), (void*) wParam, NULL);
}
static BOOL update_message_DrawGdiPlusFirst(rdpContext* context, DRAW_GDIPLUS_FIRST_ORDER* drawGdiPlusFirst)
static BOOL update_message_DrawGdiPlusFirst(
rdpContext* context,
const DRAW_GDIPLUS_FIRST_ORDER* drawGdiPlusFirst)
{
DRAW_GDIPLUS_FIRST_ORDER* wParam;
@ -810,7 +861,9 @@ static BOOL update_message_DrawGdiPlusFirst(rdpContext* context, DRAW_GDIPLUS_FI
MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (void*) wParam, NULL);
}
static BOOL update_message_DrawGdiPlusNext(rdpContext* context, DRAW_GDIPLUS_NEXT_ORDER* drawGdiPlusNext)
static BOOL update_message_DrawGdiPlusNext(
rdpContext* context,
const DRAW_GDIPLUS_NEXT_ORDER* drawGdiPlusNext)
{
DRAW_GDIPLUS_NEXT_ORDER* wParam;
@ -825,7 +878,9 @@ static BOOL update_message_DrawGdiPlusNext(rdpContext* context, DRAW_GDIPLUS_NEX
MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (void*) wParam, NULL);
}
static BOOL update_message_DrawGdiPlusEnd(rdpContext* context, DRAW_GDIPLUS_END_ORDER* drawGdiPlusEnd)
static BOOL update_message_DrawGdiPlusEnd(
rdpContext* context,
const DRAW_GDIPLUS_END_ORDER* drawGdiPlusEnd)
{
DRAW_GDIPLUS_END_ORDER* wParam;
@ -840,7 +895,9 @@ static BOOL update_message_DrawGdiPlusEnd(rdpContext* context, DRAW_GDIPLUS_END_
MakeMessageId(AltSecUpdate, DrawGdiPlusEnd), (void*) wParam, NULL);
}
static BOOL update_message_DrawGdiPlusCacheFirst(rdpContext* context, DRAW_GDIPLUS_CACHE_FIRST_ORDER* drawGdiPlusCacheFirst)
static BOOL update_message_DrawGdiPlusCacheFirst(
rdpContext* context,
const DRAW_GDIPLUS_CACHE_FIRST_ORDER* drawGdiPlusCacheFirst)
{
DRAW_GDIPLUS_CACHE_FIRST_ORDER* wParam;
@ -855,7 +912,9 @@ static BOOL update_message_DrawGdiPlusCacheFirst(rdpContext* context, DRAW_GDIPL
MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (void*) wParam, NULL);
}
static BOOL update_message_DrawGdiPlusCacheNext(rdpContext* context, DRAW_GDIPLUS_CACHE_NEXT_ORDER* drawGdiPlusCacheNext)
static BOOL update_message_DrawGdiPlusCacheNext(
rdpContext* context,
const DRAW_GDIPLUS_CACHE_NEXT_ORDER* drawGdiPlusCacheNext)
{
DRAW_GDIPLUS_CACHE_NEXT_ORDER* wParam;
@ -870,7 +929,9 @@ static BOOL update_message_DrawGdiPlusCacheNext(rdpContext* context, DRAW_GDIPLU
MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (void*) wParam, NULL);
}
static BOOL update_message_DrawGdiPlusCacheEnd(rdpContext* context, DRAW_GDIPLUS_CACHE_END_ORDER* drawGdiPlusCacheEnd)
static BOOL update_message_DrawGdiPlusCacheEnd(
rdpContext* context,
const DRAW_GDIPLUS_CACHE_END_ORDER* drawGdiPlusCacheEnd)
{
DRAW_GDIPLUS_CACHE_END_ORDER* wParam;
@ -1125,7 +1186,8 @@ static BOOL update_message_NonMonitoredDesktop(rdpContext* context, WINDOW_ORDER
/* Pointer Update */
static BOOL update_message_PointerPosition(rdpContext* context, POINTER_POSITION_UPDATE* pointerPosition)
static BOOL update_message_PointerPosition(rdpContext* context,
const POINTER_POSITION_UPDATE* pointerPosition)
{
POINTER_POSITION_UPDATE* wParam;
@ -1138,7 +1200,8 @@ static BOOL update_message_PointerPosition(rdpContext* context, POINTER_POSITION
MakeMessageId(PointerUpdate, PointerPosition), (void*) wParam, NULL);
}
static BOOL update_message_PointerSystem(rdpContext* context, POINTER_SYSTEM_UPDATE* pointerSystem)
static BOOL update_message_PointerSystem(rdpContext* context,
const POINTER_SYSTEM_UPDATE* pointerSystem)
{
POINTER_SYSTEM_UPDATE* wParam;
@ -1151,7 +1214,8 @@ static BOOL update_message_PointerSystem(rdpContext* context, POINTER_SYSTEM_UPD
MakeMessageId(PointerUpdate, PointerSystem), (void*) wParam, NULL);
}
static BOOL update_message_PointerColor(rdpContext* context, POINTER_COLOR_UPDATE* pointerColor)
static BOOL update_message_PointerColor(rdpContext* context,
const POINTER_COLOR_UPDATE* pointerColor)
{
POINTER_COLOR_UPDATE* wParam;
@ -1188,7 +1252,8 @@ out_fail:
return FALSE;
}
static BOOL update_message_PointerNew(rdpContext* context, POINTER_NEW_UPDATE* pointerNew)
static BOOL update_message_PointerNew(rdpContext* context,
const POINTER_NEW_UPDATE* pointerNew)
{
POINTER_NEW_UPDATE* wParam;
@ -1225,7 +1290,8 @@ out_fail:
return FALSE;
}
static BOOL update_message_PointerCached(rdpContext* context, POINTER_CACHED_UPDATE* pointerCached)
static BOOL update_message_PointerCached(rdpContext* context,
const POINTER_CACHED_UPDATE* pointerCached)
{
POINTER_CACHED_UPDATE* wParam;

View File

@ -3,6 +3,8 @@
* Drawing Orders
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -611,7 +613,8 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag
return TRUE;
}
static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags)
static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush,
BYTE fieldFlags)
{
if (fieldFlags & ORDER_FIELD_01)
{
@ -840,8 +843,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
} while(0)
/* Primary Drawing Orders */
BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt)
static BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt)
{
ORDER_FIELD_COORD(1, dstblt->nLeftRect);
ORDER_FIELD_COORD(2, dstblt->nTopRect);
@ -851,12 +853,14 @@ BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* d
return TRUE;
}
int update_approximate_dstblt_order(ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt)
int update_approximate_dstblt_order(ORDER_INFO* orderInfo,
const DSTBLT_ORDER* dstblt)
{
return 32;
}
BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt)
BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo,
const DSTBLT_ORDER* dstblt)
{
if (!Stream_EnsureRemainingCapacity(s, update_approximate_dstblt_order(orderInfo, dstblt)))
@ -882,7 +886,7 @@ BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER*
return TRUE;
}
BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
static BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
{
ORDER_FIELD_COORD(1, patblt->nLeftRect);
ORDER_FIELD_COORD(2, patblt->nTopRect);
@ -938,7 +942,8 @@ BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER*
return TRUE;
}
BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt)
static BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo,
SCRBLT_ORDER* scrblt)
{
ORDER_FIELD_COORD(1, scrblt->nLeftRect);
ORDER_FIELD_COORD(2, scrblt->nTopRect);
@ -951,12 +956,14 @@ BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* s
return TRUE;
}
int update_approximate_scrblt_order(ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt)
int update_approximate_scrblt_order(ORDER_INFO* orderInfo,
const SCRBLT_ORDER* scrblt)
{
return 32;
}
BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt)
BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo,
const SCRBLT_ORDER* scrblt)
{
if (!Stream_EnsureRemainingCapacity(s, update_approximate_scrblt_order(orderInfo, scrblt)))
@ -988,7 +995,8 @@ BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER*
return TRUE;
}
BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect)
static BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,
OPAQUE_RECT_ORDER* opaque_rect)
{
BYTE byte;
@ -1027,16 +1035,19 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC
return TRUE;
}
int update_approximate_opaque_rect_order(ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect)
int update_approximate_opaque_rect_order(ORDER_INFO* orderInfo,
const OPAQUE_RECT_ORDER* opaque_rect)
{
return 32;
}
BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect)
BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,
const OPAQUE_RECT_ORDER* opaque_rect)
{
BYTE byte;
int inf = update_approximate_opaque_rect_order(orderInfo, opaque_rect);
if (!Stream_EnsureRemainingCapacity(s, update_approximate_opaque_rect_order(orderInfo, opaque_rect)))
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
orderInfo->fieldFlags = 0;
@ -1065,7 +1076,8 @@ BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RE
return TRUE;
}
BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid)
static BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo,
DRAW_NINE_GRID_ORDER* draw_nine_grid)
{
ORDER_FIELD_COORD(1, draw_nine_grid->srcLeft);
ORDER_FIELD_COORD(2, draw_nine_grid->srcTop);
@ -1076,17 +1088,8 @@ BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NI
return TRUE;
}
int update_approximate_draw_nine_grid_order(ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid)
{
return 32;
}
BOOL update_write_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid)
{
return TRUE;
}
BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt)
static BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo,
MULTI_DSTBLT_ORDER* multi_dstblt)
{
ORDER_FIELD_COORD(1, multi_dstblt->nLeftRect);
ORDER_FIELD_COORD(2, multi_dstblt->nTopRect);
@ -1108,17 +1111,8 @@ BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DST
return TRUE;
}
int update_approximate_multi_dstblt_order(ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt)
{
return 32;
}
BOOL update_write_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt)
{
return TRUE;
}
BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt)
static BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo,
MULTI_PATBLT_ORDER* multi_patblt)
{
ORDER_FIELD_COORD(1, multi_patblt->nLeftRect);
ORDER_FIELD_COORD(2, multi_patblt->nTopRect);
@ -1146,17 +1140,8 @@ BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PAT
return TRUE;
}
int update_approximate_multi_patblt_order(ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt)
{
return 32;
}
BOOL update_write_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt)
{
return TRUE;
}
BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt)
static BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo,
MULTI_SCRBLT_ORDER* multi_scrblt)
{
ORDER_FIELD_COORD(1, multi_scrblt->nLeftRect);
ORDER_FIELD_COORD(2, multi_scrblt->nTopRect);
@ -1178,17 +1163,9 @@ BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCR
return TRUE;
}
int update_approximate_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt)
{
return 32;
}
BOOL update_write_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt)
{
return TRUE;
}
BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
static BOOL update_read_multi_opaque_rect_order(wStream* s,
ORDER_INFO* orderInfo,
MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
BYTE byte;
@ -1237,17 +1214,9 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT
return TRUE;
}
int update_approximate_multi_opaque_rect_order(ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
return 32;
}
BOOL update_write_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
return TRUE;
}
BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
static BOOL update_read_multi_draw_nine_grid_order(wStream* s,
ORDER_INFO* orderInfo,
MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
{
ORDER_FIELD_COORD(1, multi_draw_nine_grid->srcLeft);
ORDER_FIELD_COORD(2, multi_draw_nine_grid->srcTop);
@ -1264,17 +1233,8 @@ BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, M
return TRUE;
}
int update_approximate_multi_draw_nine_grid_order(ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
{
return 32;
}
BOOL update_write_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
{
return TRUE;
}
BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to)
static BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo,
LINE_TO_ORDER* line_to)
{
ORDER_FIELD_UINT16(1, line_to->backMode);
ORDER_FIELD_COORD(2, line_to->nXStart);
@ -1289,12 +1249,14 @@ BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER*
return TRUE;
}
int update_approximate_line_to_order(ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to)
int update_approximate_line_to_order(ORDER_INFO* orderInfo,
const LINE_TO_ORDER* line_to)
{
return 32;
}
BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to)
BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo,
const LINE_TO_ORDER* line_to)
{
if (!Stream_EnsureRemainingCapacity(s, update_approximate_line_to_order(orderInfo, line_to)))
return FALSE;
@ -1334,7 +1296,8 @@ BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER
return TRUE;
}
BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline)
static BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo,
POLYLINE_ORDER* polyline)
{
UINT16 word;
UINT32 new_num = polyline->numDeltaEntries;
@ -1372,17 +1335,8 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE
return TRUE;
}
int update_approximate_polyline_order(ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline)
{
return 32;
}
BOOL update_write_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline)
{
return TRUE;
}
BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt)
static BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo,
MEMBLT_ORDER* memblt)
{
ORDER_FIELD_UINT16(1, memblt->cacheId);
ORDER_FIELD_COORD(2, memblt->nLeftRect);
@ -1401,12 +1355,14 @@ BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* m
return TRUE;
}
int update_approximate_memblt_order(ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt)
int update_approximate_memblt_order(ORDER_INFO* orderInfo,
const MEMBLT_ORDER* memblt)
{
return 64;
}
BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt)
BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo,
const MEMBLT_ORDER* memblt)
{
UINT16 cacheId;
@ -1445,7 +1401,8 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER*
return TRUE;
}
BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt)
static BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo,
MEM3BLT_ORDER* mem3blt)
{
ORDER_FIELD_UINT16(1, mem3blt->cacheId);
ORDER_FIELD_COORD(2, mem3blt->nLeftRect);
@ -1469,17 +1426,8 @@ BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER*
return TRUE;
}
int update_approximate_mem3blt_order(ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt)
{
return 32;
}
BOOL update_write_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt)
{
return TRUE;
}
BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap)
static BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo,
SAVE_BITMAP_ORDER* save_bitmap)
{
ORDER_FIELD_UINT32(1, save_bitmap->savedBitmapPosition);
ORDER_FIELD_COORD(2, save_bitmap->nLeftRect);
@ -1490,17 +1438,8 @@ BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMA
return TRUE;
}
int update_approximate_save_bitmap_order(ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap)
{
return 32;
}
BOOL update_write_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap)
{
return TRUE;
}
BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index)
static BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo,
GLYPH_INDEX_ORDER* glyph_index)
{
ORDER_FIELD_BYTE(1, glyph_index->cacheId);
ORDER_FIELD_BYTE(2, glyph_index->flAccel);
@ -1540,15 +1479,18 @@ BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDE
return TRUE;
}
int update_approximate_glyph_index_order(ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index)
int update_approximate_glyph_index_order(ORDER_INFO* orderInfo,
const GLYPH_INDEX_ORDER* glyph_index)
{
return 64;
}
BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index)
BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo,
GLYPH_INDEX_ORDER* glyph_index)
{
int inf = update_approximate_glyph_index_order(orderInfo, glyph_index);
if (!Stream_EnsureRemainingCapacity(s, update_approximate_glyph_index_order(orderInfo, glyph_index)))
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
orderInfo->fieldFlags = 0;
@ -1615,7 +1557,8 @@ BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_IND
return TRUE;
}
BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index)
static BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo,
FAST_INDEX_ORDER* fast_index)
{
ORDER_FIELD_BYTE(1, fast_index->cacheId);
ORDER_FIELD_2BYTE(2, fast_index->ulCharInc, fast_index->flAccel);
@ -1649,17 +1592,8 @@ BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_
return TRUE;
}
int update_approximate_fast_index_order(ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index)
{
return 32;
}
BOOL update_write_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index)
{
return TRUE;
}
BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fastGlyph)
static BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo,
FAST_GLYPH_ORDER* fastGlyph)
{
BYTE* phold;
GLYPH_DATA_V2* glyph = &fastGlyph->glyphData;
@ -1734,17 +1668,8 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
return TRUE;
}
int update_approximate_fast_glyph_order(ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph)
{
return 32;
}
BOOL update_write_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph)
{
return TRUE;
}
BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc)
static BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo,
POLYGON_SC_ORDER* polygon_sc)
{
UINT32 num = polygon_sc->numPoints;
@ -1777,17 +1702,8 @@ BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_
return TRUE;
}
int update_approximate_polygon_sc_order(ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc)
{
return 32;
}
BOOL update_write_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc)
{
return TRUE;
}
BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb)
static BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo,
POLYGON_CB_ORDER* polygon_cb)
{
UINT32 num = polygon_cb->numPoints;
@ -1828,17 +1744,8 @@ BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_
return TRUE;
}
int update_approximate_polygon_cb_order(ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb)
{
return 32;
}
BOOL update_write_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb)
{
return TRUE;
}
BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc)
static BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo,
ELLIPSE_SC_ORDER* ellipse_sc)
{
ORDER_FIELD_COORD(1, ellipse_sc->leftRect);
ORDER_FIELD_COORD(2, ellipse_sc->topRect);
@ -1850,17 +1757,8 @@ BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_
return TRUE;
}
int update_approximate_ellipse_sc_order(ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc)
{
return 32;
}
BOOL update_write_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc)
{
return TRUE;
}
BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb)
static BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo,
ELLIPSE_CB_ORDER* ellipse_cb)
{
ORDER_FIELD_COORD(1, ellipse_cb->leftRect);
ORDER_FIELD_COORD(2, ellipse_cb->topRect);
@ -1873,19 +1771,9 @@ BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_
return update_read_brush(s, &ellipse_cb->brush, orderInfo->fieldFlags >> 8);
}
int update_approximate_ellipse_cb_order(ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb)
{
return 32;
}
BOOL update_write_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb)
{
return TRUE;
}
/* Secondary Drawing Orders */
BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap, BOOL compressed, UINT16 flags)
static BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap,
BOOL compressed, UINT16 flags)
{
if (Stream_GetRemainingLength(s) < 9)
return FALSE;
@ -1936,28 +1824,32 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap
return TRUE;
}
int update_approximate_cache_bitmap_order(CACHE_BITMAP_ORDER* cache_bitmap, BOOL compressed, UINT16* flags)
int update_approximate_cache_bitmap_order(const CACHE_BITMAP_ORDER* cache_bitmap,
BOOL compressed, UINT16* flags)
{
return 64 + cache_bitmap->bitmapLength;
}
BOOL update_write_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap, BOOL compressed, UINT16* flags)
BOOL update_write_cache_bitmap_order(wStream* s,
const CACHE_BITMAP_ORDER* cache_bitmap,
BOOL compressed, UINT16* flags)
{
if (!Stream_EnsureRemainingCapacity(s, update_approximate_cache_bitmap_order(cache_bitmap, compressed, flags)))
UINT32 bitmapLength = cache_bitmap->bitmapLength;
int inf = update_approximate_cache_bitmap_order(cache_bitmap, compressed, flags);
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
*flags = NO_BITMAP_COMPRESSION_HDR;
if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0)
cache_bitmap->bitmapLength += 8;
bitmapLength += 8;
Stream_Write_UINT8(s, cache_bitmap->cacheId); /* cacheId (1 byte) */
Stream_Write_UINT8(s, 0); /* pad1Octet (1 byte) */
Stream_Write_UINT8(s, cache_bitmap->bitmapWidth); /* bitmapWidth (1 byte) */
Stream_Write_UINT8(s, cache_bitmap->bitmapHeight); /* bitmapHeight (1 byte) */
Stream_Write_UINT8(s, cache_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */
Stream_Write_UINT16(s, cache_bitmap->bitmapLength); /* bitmapLength (2 bytes) */
Stream_Write_UINT16(s, bitmapLength); /* bitmapLength (2 bytes) */
Stream_Write_UINT16(s, cache_bitmap->cacheIndex); /* cacheIndex (2 bytes) */
if (compressed)
@ -1966,20 +1858,22 @@ BOOL update_write_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitma
{
BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap->bitmapComprHdr);
Stream_Write(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */
cache_bitmap->bitmapLength -= 8;
bitmapLength -= 8;
}
Stream_Write(s, cache_bitmap->bitmapDataStream, cache_bitmap->bitmapLength);
Stream_Write(s, cache_bitmap->bitmapDataStream, bitmapLength);
}
else
{
Stream_Write(s, cache_bitmap->bitmapDataStream, cache_bitmap->bitmapLength);
Stream_Write(s, cache_bitmap->bitmapDataStream, bitmapLength);
}
return TRUE;
}
BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2, BOOL compressed, UINT16 flags)
static BOOL update_read_cache_bitmap_v2_order(wStream* s,
CACHE_BITMAP_V2_ORDER* cache_bitmap_v2,
BOOL compressed, UINT16 flags)
{
BYTE bitsPerPixelId;
@ -2122,7 +2016,9 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache
return TRUE;
}
BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3, UINT16 flags)
static BOOL update_read_cache_bitmap_v3_order(wStream* s,
CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,
UINT16 flags)
{
BYTE bitsPerPixelId;
BITMAP_DATA_EX* bitmapData;
@ -2208,7 +2104,9 @@ BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache
return TRUE;
}
BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16 flags)
static BOOL update_read_cache_color_table_order(wStream* s,
CACHE_COLOR_TABLE_ORDER* cache_color_table,
UINT16 flags)
{
int i;
UINT32* colorTable;
@ -2238,20 +2136,24 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca
return TRUE;
}
int update_approximate_cache_color_table_order(CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags)
int update_approximate_cache_color_table_order(
const CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags)
{
return 16 + (256 * 4);
}
BOOL update_write_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags)
BOOL update_write_cache_color_table_order(wStream* s,
const CACHE_COLOR_TABLE_ORDER* cache_color_table,
UINT16* flags)
{
int i;
int i, inf;
UINT32* colorTable;
if (cache_color_table->numberColors != 256)
return FALSE;
if (!Stream_EnsureRemainingCapacity(s, update_approximate_cache_color_table_order(cache_color_table, flags)))
inf = update_approximate_cache_color_table_order(cache_color_table, flags);
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
Stream_Write_UINT8(s, cache_color_table->cacheIndex); /* cacheIndex (1 byte) */
@ -2267,7 +2169,9 @@ BOOL update_write_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* c
return TRUE;
}
BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags)
static BOOL update_read_cache_glyph_order(wStream* s,
CACHE_GLYPH_ORDER* cache_glyph_order,
UINT16 flags)
{
int i;
INT16 lsi16;
@ -2314,18 +2218,22 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or
return TRUE;
}
int update_approximate_cache_glyph_order(CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags)
int update_approximate_cache_glyph_order(
const CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags)
{
return 2 + cache_glyph->cGlyphs * 32;
}
BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags)
BOOL update_write_cache_glyph_order(wStream* s,
const CACHE_GLYPH_ORDER* cache_glyph,
UINT16* flags)
{
int i;
int i, inf;
INT16 lsi16;
GLYPH_DATA* glyph;
const GLYPH_DATA* glyph;
if (!Stream_EnsureRemainingCapacity(s, update_approximate_cache_glyph_order(cache_glyph, flags)))
inf = update_approximate_cache_glyph_order(cache_glyph, flags);
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
Stream_Write_UINT8(s, cache_glyph->cacheId); /* cacheId (1 byte) */
@ -2333,6 +2241,8 @@ BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph,
for (i = 0; i < (int) cache_glyph->cGlyphs; i++)
{
UINT32 cb;
glyph = &cache_glyph->glyphData[i];
Stream_Write_UINT16(s, glyph->cacheIndex); /* cacheIndex (2 bytes) */
@ -2346,10 +2256,10 @@ BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph,
Stream_Write_UINT16(s, glyph->cx); /* cx (2 bytes) */
Stream_Write_UINT16(s, glyph->cy); /* cy (2 bytes) */
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
cb = ((glyph->cx + 7) / 8) * glyph->cy;
cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0;
Stream_Write(s, glyph->aj, glyph->cb);
Stream_Write(s, glyph->aj, cb);
}
if (*flags & CG_GLYPH_UNICODE_PRESENT)
@ -2360,7 +2270,9 @@ BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph,
return TRUE;
}
BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16 flags)
static BOOL update_read_cache_glyph_v2_order(wStream* s,
CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
UINT16 flags)
{
int i;
GLYPH_DATA_V2* glyph;
@ -2406,17 +2318,20 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl
return TRUE;
}
int update_approximate_cache_glyph_v2_order(CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags)
int update_approximate_cache_glyph_v2_order(
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags)
{
return 8 + cache_glyph_v2->cGlyphs * 32;
}
BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags)
BOOL update_write_cache_glyph_v2_order(wStream* s,
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
UINT16* flags)
{
int i;
GLYPH_DATA_V2* glyph;
int i, inf;
if (!Stream_EnsureRemainingCapacity(s, update_approximate_cache_glyph_v2_order(cache_glyph_v2, flags)))
inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, flags);
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
*flags = (cache_glyph_v2->cacheId & 0x000F) |
@ -2425,7 +2340,8 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g
for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++)
{
glyph = &cache_glyph_v2->glyphData[i];
UINT32 cb;
const GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i];
Stream_Write_UINT8(s, glyph->cacheIndex);
@ -2437,9 +2353,9 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g
return FALSE;
}
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
Stream_Write(s, glyph->aj, glyph->cb);
cb = ((glyph->cx + 7) / 8) * glyph->cy;
cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0;
Stream_Write(s, glyph->aj, cb);
}
if (*flags & CG_GLYPH_UNICODE_PRESENT)
@ -2450,7 +2366,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g
return TRUE;
}
BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp)
static BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp)
{
int index;
int x, y, k;
@ -2483,12 +2399,14 @@ BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp)
return TRUE;
}
BOOL update_compress_brush(wStream* s, BYTE* input, BYTE bpp)
static BOOL update_compress_brush(wStream* s, const BYTE* input, BYTE bpp)
{
return FALSE;
}
BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, UINT16 flags)
static BOOL update_read_cache_brush_order(wStream* s,
CACHE_BRUSH_ORDER* cache_brush,
UINT16 flags)
{
int i;
int size;
@ -2563,12 +2481,15 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, U
return TRUE;
}
int update_approximate_cache_brush_order(CACHE_BRUSH_ORDER* cache_brush, UINT16* flags)
int update_approximate_cache_brush_order(
const CACHE_BRUSH_ORDER* cache_brush, UINT16* flags)
{
return 64;
}
BOOL update_write_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, UINT16* flags)
BOOL update_write_cache_brush_order(wStream* s,
const CACHE_BRUSH_ORDER* cache_brush,
UINT16* flags)
{
int i;
int size;
@ -2637,8 +2558,8 @@ BOOL update_write_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush,
}
/* Alternate Secondary Drawing Orders */
BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
static BOOL update_read_create_offscreen_bitmap_order(wStream* s,
CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
UINT16 flags;
BOOL deleteListPresent;
@ -2693,17 +2614,20 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM
return TRUE;
}
int update_approximate_create_offscreen_bitmap_order(CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
int update_approximate_create_offscreen_bitmap_order(
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
OFFSCREEN_DELETE_LIST* deleteList = &(create_offscreen_bitmap->deleteList);
const OFFSCREEN_DELETE_LIST* deleteList = &(create_offscreen_bitmap->deleteList);
return 32 + deleteList->cIndices * 2;
}
BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
BOOL update_write_create_offscreen_bitmap_order(
wStream* s,
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
UINT16 flags;
BOOL deleteListPresent;
OFFSCREEN_DELETE_LIST* deleteList;
const OFFSCREEN_DELETE_LIST* deleteList;
if (!Stream_EnsureRemainingCapacity(s, update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap)))
return FALSE;
@ -2737,7 +2661,8 @@ BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BIT
return TRUE;
}
BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface)
static BOOL update_read_switch_surface_order(wStream* s,
SWITCH_SURFACE_ORDER* switch_surface)
{
if (Stream_GetRemainingLength(s) < 2)
return FALSE;
@ -2747,14 +2672,17 @@ BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_s
return TRUE;
}
int update_approximate_switch_surface_order(SWITCH_SURFACE_ORDER* switch_surface)
int update_approximate_switch_surface_order(
const SWITCH_SURFACE_ORDER* switch_surface)
{
return 2;
}
BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface)
BOOL update_write_switch_surface_order(
wStream* s, const SWITCH_SURFACE_ORDER* switch_surface)
{
if (!Stream_EnsureRemainingCapacity(s, update_approximate_switch_surface_order(switch_surface)))
int inf = update_approximate_switch_surface_order(switch_surface);
if (!Stream_EnsureRemainingCapacity(s, inf))
return FALSE;
Stream_Write_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */
@ -2762,7 +2690,9 @@ BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_
return TRUE;
}
BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap)
static BOOL update_read_create_nine_grid_bitmap_order(
wStream* s,
CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap)
{
NINE_GRID_BITMAP_INFO* nineGridInfo;
@ -2788,7 +2718,8 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM
return TRUE;
}
BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker)
static BOOL update_read_frame_marker_order(wStream* s,
FRAME_MARKER_ORDER* frame_marker)
{
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
@ -2798,12 +2729,8 @@ BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker
return TRUE;
}
BOOL update_write_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker)
{
return TRUE;
}
BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first)
static BOOL update_read_stream_bitmap_first_order(
wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first)
{
if (Stream_GetRemainingLength(s) < 10) // 8 + 2 at least
return FALSE;
@ -2840,12 +2767,8 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER
return TRUE;
}
BOOL update_write_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first)
{
return TRUE;
}
BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next)
static BOOL update_read_stream_bitmap_next_order(
wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next)
{
if (Stream_GetRemainingLength(s) < 5)
return FALSE;
@ -2857,12 +2780,8 @@ BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER*
return TRUE;
}
BOOL update_write_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next)
{
return TRUE;
}
BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first)
static BOOL update_read_draw_gdiplus_first_order(
wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first)
{
if (Stream_GetRemainingLength(s) < 11)
return FALSE;
@ -2875,12 +2794,8 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER*
return Stream_SafeSeek(s, draw_gdiplus_first->cbSize); /* emfRecords */
}
BOOL update_write_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first)
{
return TRUE;
}
BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
static BOOL update_read_draw_gdiplus_next_order(
wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
{
if (Stream_GetRemainingLength(s) < 3)
return FALSE;
@ -2891,12 +2806,8 @@ BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* dr
return TRUE;
}
BOOL update_write_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
{
return TRUE;
}
BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end)
static BOOL update_read_draw_gdiplus_end_order(
wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end)
{
if (Stream_GetRemainingLength(s) < 11)
return FALSE;
@ -2909,12 +2820,8 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw
return Stream_SafeSeek(s, draw_gdiplus_end->cbSize); /* emfRecords */
}
BOOL update_write_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end)
{
return TRUE;
}
BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
static BOOL update_read_draw_gdiplus_cache_first_order(
wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
{
if (Stream_GetRemainingLength(s) < 11)
return FALSE;
@ -2928,12 +2835,8 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F
return Stream_SafeSeek(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */
}
BOOL update_write_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
{
return TRUE;
}
BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
static BOOL update_read_draw_gdiplus_cache_next_order(
wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
{
if (Stream_GetRemainingLength(s) < 7)
return FALSE;
@ -2946,12 +2849,8 @@ BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NE
return TRUE;
}
BOOL update_write_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
{
return TRUE;
}
BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end)
static BOOL update_read_draw_gdiplus_cache_end_order(
wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end)
{
if (Stream_GetRemainingLength(s) < 11)
return FALSE;
@ -2965,12 +2864,7 @@ BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END
return Stream_SafeSeek(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */
}
BOOL update_write_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end)
{
return TRUE;
}
BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes)
static BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes)
{
int i;
BYTE byte;
@ -3032,7 +2926,7 @@ BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fi
return TRUE;
}
BOOL update_read_bounds(wStream* s, rdpBounds* bounds)
static BOOL update_read_bounds(wStream* s, rdpBounds* bounds)
{
BYTE flags;

View File

@ -3,6 +3,8 @@
* Drawing Orders
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -186,166 +188,104 @@
#define CG_GLYPH_UNICODE_PRESENT 0x0010
extern const BYTE PRIMARY_DRAWING_ORDER_FIELD_BYTES[];
BOOL update_recv_order(rdpUpdate* update, wStream* s);
BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes);
BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes);
BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags,
BYTE fieldBytes);
BOOL update_read_bounds(wStream* s, rdpBounds* bounds);
BOOL update_write_bounds(wStream* s, ORDER_INFO* orderInfo);
BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt);
int update_approximate_dstblt_order(ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt);
BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt);
int update_approximate_dstblt_order(ORDER_INFO* orderInfo,
const DSTBLT_ORDER* dstblt);
BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo,
const DSTBLT_ORDER* dstblt);
BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt);
int update_approximate_patblt_order(ORDER_INFO* orderInfo, PATBLT_ORDER* patblt);
BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt);
int update_approximate_patblt_order(ORDER_INFO* orderInfo,
PATBLT_ORDER* patblt);
BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo,
PATBLT_ORDER* patblt);
BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt);
int update_approximate_scrblt_order(ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt);
BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt);
int update_approximate_scrblt_order(ORDER_INFO* orderInfo,
const SCRBLT_ORDER* scrblt);
BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo,
const SCRBLT_ORDER* scrblt);
BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect);
int update_approximate_opaque_rect_order(ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect);
BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect);
int update_approximate_opaque_rect_order(ORDER_INFO* orderInfo,
const OPAQUE_RECT_ORDER* opaque_rect);
BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,
const OPAQUE_RECT_ORDER* opaque_rect);
BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid);
int update_approximate_draw_nine_grid_order(ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid);
BOOL update_write_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid);
int update_approximate_line_to_order(ORDER_INFO* orderInfo,
const LINE_TO_ORDER* line_to);
BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo,
const LINE_TO_ORDER* line_to);
BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt);
int update_approximate_multi_dstblt_order(ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt);
BOOL update_write_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt);
int update_approximate_memblt_order(ORDER_INFO* orderInfo,
const MEMBLT_ORDER* memblt);
BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo,
const MEMBLT_ORDER* memblt);
BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt);
int update_approximate_multi_patblt_order(ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt);
BOOL update_write_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt);
int update_approximate_glyph_index_order(ORDER_INFO* orderInfo,
const GLYPH_INDEX_ORDER* glyph_index);
BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo,
GLYPH_INDEX_ORDER* glyph_index);
BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt);
int update_approximate_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt);
BOOL update_write_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt);
int update_approximate_cache_bitmap_order(const CACHE_BITMAP_ORDER* cache_bitmap,
BOOL compressed, UINT16* flags);
BOOL update_write_cache_bitmap_order(wStream* s, const CACHE_BITMAP_ORDER* cache_bitmap_order,
BOOL compressed, UINT16* flags);
BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect);
int update_approximate_multi_opaque_rect_order(ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect);
BOOL update_write_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect);
int update_approximate_cache_bitmap_v2_order(CACHE_BITMAP_V2_ORDER* cache_bitmap_v2,
BOOL compressed, UINT16* flags);
BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order,
BOOL compressed, UINT16* flags);
BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid);
int update_approximate_multi_draw_nine_grid_order(ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid);
BOOL update_write_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid);
int update_approximate_cache_bitmap_v3_order(CACHE_BITMAP_V3_ORDER* cache_bitmap_v3,
UINT16* flags);
BOOL update_write_cache_bitmap_v3_order(wStream* s,
CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order,
UINT16* flags);
BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to);
int update_approximate_line_to_order(ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to);
BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to);
int update_approximate_cache_color_table_order(const CACHE_COLOR_TABLE_ORDER* cache_color_table,
UINT16* flags);
BOOL update_write_cache_color_table_order(wStream* s,
const CACHE_COLOR_TABLE_ORDER* cache_color_table_order,
UINT16* flags);
BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline);
int update_approximate_polyline_order(ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline);
BOOL update_write_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline);
int update_approximate_cache_glyph_order(const CACHE_GLYPH_ORDER* cache_glyph,
UINT16* flags);
BOOL update_write_cache_glyph_order(wStream* s,
const CACHE_GLYPH_ORDER* cache_glyph_order,
UINT16* flags);
BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt);
int update_approximate_memblt_order(ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt);
BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt);
int update_approximate_cache_glyph_v2_order(
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
UINT16* flags);
BOOL update_write_cache_glyph_v2_order(
wStream* s,
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2,
UINT16* flags);
BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt);
int update_approximate_mem3blt_order(ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt);
BOOL update_write_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt);
int update_approximate_cache_brush_order(
const CACHE_BRUSH_ORDER* cache_brush,
UINT16* flags);
BOOL update_write_cache_brush_order(
wStream* s,
const CACHE_BRUSH_ORDER* cache_brush_order,
UINT16* flags);
BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap);
int update_approximate_save_bitmap_order(ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap);
BOOL update_write_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap);
int update_approximate_create_offscreen_bitmap_order(
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
BOOL update_write_create_offscreen_bitmap_order(
wStream* s,
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index);
int update_approximate_glyph_index_order(ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index);
BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index);
BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index);
int update_approximate_fast_index_order(ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index);
BOOL update_write_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index);
BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph);
int update_approximate_fast_glyph_order(ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph);
BOOL update_write_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph);
BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc);
int update_approximate_polygon_sc_order(ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc);
BOOL update_write_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc);
BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb);
int update_approximate_polygon_cb_order(ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb);
BOOL update_write_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb);
BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc);
int update_approximate_ellipse_sc_order(ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc);
BOOL update_write_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc);
BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb);
int update_approximate_ellipse_cb_order(ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb);
BOOL update_write_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb);
BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16 flags);
int update_approximate_cache_bitmap_order(CACHE_BITMAP_ORDER* cache_bitmap, BOOL compressed, UINT16* flags);
BOOL update_write_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16* flags);
BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16 flags);
int update_approximate_cache_bitmap_v2_order(CACHE_BITMAP_V2_ORDER* cache_bitmap_v2, BOOL compressed, UINT16* flags);
BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16* flags);
BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, UINT16 flags);
int update_approximate_cache_bitmap_v3_order(CACHE_BITMAP_V3_ORDER* cache_bitmap_v3, UINT16* flags);
BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, UINT16* flags);
BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16 flags);
int update_approximate_cache_color_table_order(CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags);
BOOL update_write_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16* flags);
BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags);
int update_approximate_cache_glyph_order(CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags);
BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16* flags);
BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order, UINT16 flags);
int update_approximate_cache_glyph_v2_order(CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags);
BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags);
BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags);
int update_approximate_cache_brush_order(CACHE_BRUSH_ORDER* cache_brush, UINT16* flags);
BOOL update_write_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16* flags);
BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
int update_approximate_create_offscreen_bitmap_order(CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap);
BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface);
int update_approximate_switch_surface_order(SWITCH_SURFACE_ORDER* switch_surface);
BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface);
BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap);
BOOL update_write_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap);
BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker);
BOOL update_write_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker);
BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first);
BOOL update_write_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first);
BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next);
BOOL update_write_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next);
BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first);
BOOL update_write_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first);
BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next);
BOOL update_write_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next);
BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end);
BOOL update_write_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end);
BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first);
BOOL update_write_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first);
BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next);
BOOL update_write_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next);
BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end);
BOOL update_write_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end);
int update_approximate_switch_surface_order(
const SWITCH_SURFACE_ORDER* switch_surface);
BOOL update_write_switch_surface_order(
wStream* s,
const SWITCH_SURFACE_ORDER* switch_surface);
#endif /* __ORDERS_H */

View File

@ -137,7 +137,8 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s)
return 0;
}
BOOL update_write_surfcmd_surface_bits_header(wStream* s, SURFACE_BITS_COMMAND* cmd)
BOOL update_write_surfcmd_surface_bits_header(wStream* s,
const SURFACE_BITS_COMMAND* cmd)
{
if (!Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH))
return FALSE;

View File

@ -36,7 +36,8 @@ enum SURFCMD_CMDTYPE
int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s);
BOOL update_write_surfcmd_surface_bits_header(wStream* s, SURFACE_BITS_COMMAND* cmd);
BOOL update_write_surfcmd_surface_bits_header(wStream* s,
const SURFACE_BITS_COMMAND* cmd);
BOOL update_write_surfcmd_frame_marker(wStream* s, UINT16 frameAction, UINT32 frameId);
#endif /* __SURFACE */

View File

@ -3,6 +3,8 @@
* Update Data PDUs
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -47,8 +49,6 @@ const char* const UPDATE_TYPE_STRINGS[] =
"Synchronize"
};
extern const BYTE PRIMARY_DRAWING_ORDER_FIELD_BYTES[];
BOOL update_recv_orders(rdpUpdate* update, wStream* s)
{
UINT16 numberOrders;
@ -207,7 +207,8 @@ BOOL update_read_bitmap_update(rdpUpdate* update, wStream* s, BITMAP_UPDATE* bit
return TRUE;
}
BOOL update_write_bitmap_update(rdpUpdate* update, wStream* s, BITMAP_UPDATE* bitmapUpdate)
static BOOL update_write_bitmap_update(rdpUpdate* update, wStream* s,
const BITMAP_UPDATE* bitmapUpdate)
{
int i;
@ -709,7 +710,8 @@ static BOOL update_check_flush(rdpContext* context, int size)
return FALSE;
}
static BOOL update_set_bounds(rdpContext* context, rdpBounds* bounds)
static BOOL update_set_bounds(rdpContext* context,
const rdpBounds* bounds)
{
rdpUpdate* update = context->update;
@ -793,7 +795,8 @@ int update_prepare_bounds(rdpContext* context, ORDER_INFO* orderInfo)
return length;
}
int update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo, UINT32 orderType)
static int update_prepare_order_info(rdpContext* context,
ORDER_INFO* orderInfo, UINT32 orderType)
{
int length = 1;
@ -812,7 +815,8 @@ int update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo, UINT32
return length;
}
int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderInfo, int offset)
int update_write_order_info(rdpContext* context, wStream* s,
ORDER_INFO* orderInfo, int offset)
{
int position;
@ -834,7 +838,8 @@ int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderIn
return 0;
}
static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* areas)
static void update_write_refresh_rect(wStream* s, BYTE count,
const RECTANGLE_16* areas)
{
int i;
@ -850,7 +855,8 @@ static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* area
}
}
static BOOL update_send_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_16* areas)
static BOOL update_send_refresh_rect(rdpContext* context, BYTE count,
const RECTANGLE_16* areas)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -870,7 +876,8 @@ static BOOL update_send_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_
return TRUE;
}
static void update_write_suppress_output(wStream* s, BYTE allow, RECTANGLE_16* area)
static void update_write_suppress_output(wStream* s, BYTE allow,
const RECTANGLE_16* area)
{
Stream_Write_UINT8(s, allow); /* allowDisplayUpdates (1 byte) */
/* Use zeros for padding (like mstsc) for compatibility with legacy servers */
@ -885,7 +892,8 @@ static void update_write_suppress_output(wStream* s, BYTE allow, RECTANGLE_16* a
}
}
static BOOL update_send_suppress_output(rdpContext* context, BYTE allow, RECTANGLE_16* area)
static BOOL update_send_suppress_output(rdpContext* context, BYTE allow,
const RECTANGLE_16* area)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -927,7 +935,8 @@ out:
return ret;
}
static BOOL update_send_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surfaceBitsCommand)
static BOOL update_send_surface_bits(rdpContext* context,
const SURFACE_BITS_COMMAND* surfaceBitsCommand)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -956,7 +965,8 @@ out_fail:
return ret;
}
static BOOL update_send_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surfaceFrameMarker)
static BOOL update_send_surface_frame_marker(rdpContext* context,
const SURFACE_FRAME_MARKER* surfaceFrameMarker)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -980,7 +990,9 @@ out_fail:
return ret;
}
static BOOL update_send_surface_frame_bits(rdpContext* context, SURFACE_BITS_COMMAND* cmd, BOOL first, BOOL last, UINT32 frameId)
static BOOL update_send_surface_frame_bits(rdpContext* context,
const SURFACE_BITS_COMMAND* cmd,
BOOL first, BOOL last, UINT32 frameId)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -1059,7 +1071,8 @@ static BOOL update_send_desktop_resize(rdpContext* context)
return rdp_server_reactivate(context->rdp);
}
static BOOL update_send_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
static BOOL update_send_bitmap_update(rdpContext* context,
const BITMAP_UPDATE* bitmapUpdate)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -1085,7 +1098,8 @@ out_fail:
return ret;
}
static BOOL update_send_play_sound(rdpContext* context, PLAY_SOUND_UPDATE* play_sound)
static BOOL update_send_play_sound(rdpContext* context,
const PLAY_SOUND_UPDATE* play_sound)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -1107,17 +1121,20 @@ static BOOL update_send_play_sound(rdpContext* context, PLAY_SOUND_UPDATE* play_
* Primary Drawing Orders
*/
static BOOL update_send_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
static BOOL update_send_dstblt(rdpContext* context,
const DSTBLT_ORDER* dstblt)
{
wStream* s;
int offset;
int headerLength;
UINT32 offset;
UINT32 headerLength;
ORDER_INFO orderInfo;
int inf;
rdpUpdate* update = context->update;
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
update_check_flush(context, headerLength + update_approximate_dstblt_order(&orderInfo, dstblt));
inf = update_approximate_dstblt_order(&orderInfo, dstblt);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1164,17 +1181,19 @@ static BOOL update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt)
return TRUE;
}
static BOOL update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
static BOOL update_send_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
{
wStream* s;
int offset;
int headerLength;
UINT32 offset;
UINT32 headerLength;
ORDER_INFO orderInfo;
int inf;
rdpUpdate* update = context->update;
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
update_check_flush(context, headerLength + update_approximate_scrblt_order(&orderInfo, scrblt));
inf = update_approximate_scrblt_order(&orderInfo, scrblt);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1192,7 +1211,8 @@ static BOOL update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt)
return TRUE;
}
static BOOL update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
static BOOL update_send_opaque_rect(rdpContext* context,
const OPAQUE_RECT_ORDER* opaque_rect)
{
wStream* s;
int offset;
@ -1220,17 +1240,20 @@ static BOOL update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq
return TRUE;
}
static BOOL update_send_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
static BOOL update_send_line_to(rdpContext* context,
const LINE_TO_ORDER* line_to)
{
wStream* s;
int offset;
int headerLength;
ORDER_INFO orderInfo;
int inf;
rdpUpdate* update = context->update;
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
update_check_flush(context, headerLength + update_approximate_line_to_order(&orderInfo, line_to));
inf = update_approximate_line_to_order(&orderInfo, line_to);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1276,17 +1299,20 @@ static BOOL update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
return TRUE;
}
static BOOL update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index)
static BOOL update_send_glyph_index(rdpContext* context,
GLYPH_INDEX_ORDER* glyph_index)
{
wStream* s;
int offset;
int headerLength;
int inf;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
update_check_flush(context, headerLength + update_approximate_glyph_index_order(&orderInfo, glyph_index));
inf = update_approximate_glyph_index_order(&orderInfo, glyph_index);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1308,12 +1334,14 @@ static BOOL update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp
* Secondary Drawing Orders
*/
static BOOL update_send_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cache_bitmap)
static BOOL update_send_cache_bitmap(rdpContext* context,
const CACHE_BITMAP_ORDER* cache_bitmap)
{
wStream* s;
int bm, em;
BYTE orderType;
int headerLength;
int inf;
UINT16 extraFlags;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1324,7 +1352,10 @@ static BOOL update_send_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* ca
orderType = cache_bitmap->compressed ?
ORDER_TYPE_CACHE_BITMAP_COMPRESSED : ORDER_TYPE_BITMAP_UNCOMPRESSED;
update_check_flush(context, headerLength + update_approximate_cache_bitmap_order(cache_bitmap, cache_bitmap->compressed, &extraFlags));
inf = update_approximate_cache_bitmap_order(cache_bitmap,
cache_bitmap->compressed,
&extraFlags);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1450,11 +1481,12 @@ static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORD
return TRUE;
}
static BOOL update_send_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cache_color_table)
static BOOL update_send_cache_color_table(rdpContext* context,
const CACHE_COLOR_TABLE_ORDER* cache_color_table)
{
wStream* s;
UINT16 flags;
int bm, em;
int bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1462,7 +1494,8 @@ static BOOL update_send_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE
flags = 0;
headerLength = 6;
update_check_flush(context, headerLength + update_approximate_cache_color_table_order(cache_color_table, &flags));
inf = update_approximate_cache_color_table_order(cache_color_table, &flags);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1493,11 +1526,12 @@ static BOOL update_send_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE
return TRUE;
}
static BOOL update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
static BOOL update_send_cache_glyph(rdpContext* context,
const CACHE_GLYPH_ORDER* cache_glyph)
{
wStream* s;
UINT16 flags;
int bm, em;
int bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1505,7 +1539,8 @@ static BOOL update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cach
flags = 0;
headerLength = 6;
update_check_flush(context, headerLength + update_approximate_cache_glyph_order(cache_glyph, &flags));
inf = update_approximate_cache_glyph_order(cache_glyph, &flags);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1535,11 +1570,12 @@ static BOOL update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cach
return TRUE;
}
static BOOL update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
static BOOL update_send_cache_glyph_v2(rdpContext* context,
const CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
{
wStream* s;
UINT16 flags;
int bm, em;
int bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1547,7 +1583,8 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER
flags = 0;
headerLength = 6;
update_check_flush(context, headerLength + update_approximate_cache_glyph_v2_order(cache_glyph_v2, &flags));
inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, &flags);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1577,11 +1614,12 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER
return TRUE;
}
static BOOL update_send_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
static BOOL update_send_cache_brush(rdpContext* context,
const CACHE_BRUSH_ORDER* cache_brush)
{
wStream* s;
UINT16 flags;
int bm, em;
int bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1589,7 +1627,8 @@ static BOOL update_send_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cach
flags = 0;
headerLength = 6;
update_check_flush(context, headerLength + update_approximate_cache_brush_order(cache_brush, &flags));
inf = update_approximate_cache_brush_order(cache_brush, &flags);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1622,10 +1661,12 @@ static BOOL update_send_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cach
* Alternate Secondary Drawing Orders
*/
static BOOL update_send_create_offscreen_bitmap_order(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
static BOOL update_send_create_offscreen_bitmap_order(
rdpContext* context,
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
wStream* s;
int bm, em;
int bm, em, inf;
BYTE orderType;
BYTE controlFlags;
int headerLength;
@ -1635,7 +1676,8 @@ static BOOL update_send_create_offscreen_bitmap_order(rdpContext* context, CREAT
orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP;
controlFlags = ORDER_SECONDARY | (orderType << 2);
update_check_flush(context, headerLength + update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap));
inf = update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1658,10 +1700,12 @@ static BOOL update_send_create_offscreen_bitmap_order(rdpContext* context, CREAT
return TRUE;
}
static BOOL update_send_switch_surface_order(rdpContext* context, SWITCH_SURFACE_ORDER* switch_surface)
static BOOL update_send_switch_surface_order(
rdpContext* context,
const SWITCH_SURFACE_ORDER* switch_surface)
{
wStream* s;
int bm, em;
int bm, em, inf;
BYTE orderType;
BYTE controlFlags;
int headerLength;
@ -1671,7 +1715,8 @@ static BOOL update_send_switch_surface_order(rdpContext* context, SWITCH_SURFACE
orderType = ORDER_TYPE_SWITCH_SURFACE;
controlFlags = ORDER_SECONDARY | (orderType << 2);
update_check_flush(context, headerLength + update_approximate_switch_surface_order(switch_surface));
inf = update_approximate_switch_surface_order(switch_surface);
update_check_flush(context, headerLength + inf);
s = update->us;
if (!s)
@ -1694,7 +1739,8 @@ static BOOL update_send_switch_surface_order(rdpContext* context, SWITCH_SURFACE
return TRUE;
}
static BOOL update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system)
static BOOL update_send_pointer_system(rdpContext* context,
const POINTER_SYSTEM_UPDATE* pointer_system)
{
wStream* s;
BYTE updateCode;
@ -1715,7 +1761,8 @@ static BOOL update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDAT
return ret;
}
static BOOL update_send_pointer_position(rdpContext* context, POINTER_POSITION_UPDATE* pointerPosition)
static BOOL update_send_pointer_position(rdpContext* context,
const POINTER_POSITION_UPDATE* pointerPosition)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -1737,9 +1784,10 @@ out_fail:
return ret;
}
static BOOL update_write_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color)
static BOOL update_write_pointer_color(wStream* s,
const POINTER_COLOR_UPDATE* pointer_color)
{
if (!Stream_EnsureRemainingCapacity(s, 32 + (int) pointer_color->lengthAndMask + (int) pointer_color->lengthXorMask))
if (!Stream_EnsureRemainingCapacity(s, 32 + pointer_color->lengthAndMask + pointer_color->lengthXorMask))
return FALSE;
Stream_Write_UINT16(s, pointer_color->cacheIndex);
@ -1760,7 +1808,8 @@ static BOOL update_write_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer
return TRUE;
}
static BOOL update_send_pointer_color(rdpContext* context, POINTER_COLOR_UPDATE* pointer_color)
static BOOL update_send_pointer_color(rdpContext* context,
const POINTER_COLOR_UPDATE* pointer_color)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -1780,7 +1829,8 @@ out_fail:
return ret;
}
static BOOL update_send_pointer_new(rdpContext* context, POINTER_NEW_UPDATE* pointer_new)
static BOOL update_send_pointer_new(rdpContext* context,
const POINTER_NEW_UPDATE* pointer_new)
{
wStream* s;
rdpRdp* rdp = context->rdp;
@ -1794,7 +1844,7 @@ static BOOL update_send_pointer_new(rdpContext* context, POINTER_NEW_UPDATE* poi
goto out_fail;
Stream_Write_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */
update_write_pointer_color(s, &pointer_new->colorPtrAttr);
update_write_pointer_color(s, &pointer_new->colorPtrAttr);
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_POINTER, s, FALSE);
@ -1803,7 +1853,8 @@ out_fail:
return ret;
}
static BOOL update_send_pointer_cached(rdpContext* context, POINTER_CACHED_UPDATE* pointer_cached)
static BOOL update_send_pointer_cached(rdpContext* context,
const POINTER_CACHED_UPDATE* pointer_cached)
{
wStream* s;
rdpRdp* rdp = context->rdp;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -21,16 +21,12 @@ set(MODULE_PREFIX "FREERDP_GDI")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(${MODULE_PREFIX}_SRCS
8bpp.c
16bpp.c
32bpp.c
bitmap.c
brush.c
clipping.c
dc.c
drawing.c
line.c
palette.c
pen.c
region.c
shape.c
@ -43,6 +39,6 @@ set(${MODULE_PREFIX}_SRCS
freerdp_module_add(${${MODULE_PREFIX}_SRCS})
if(BUILD_TESTING)
add_subdirectory(test)
# add_subdirectory(test)
endif()

View File

@ -3,6 +3,8 @@
* GDI Bitmap Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,20 +32,14 @@
#include <freerdp/gdi/gdi.h>
#include <freerdp/codec/color.h>
#include <freerdp/gdi/32bpp.h>
#include <freerdp/gdi/16bpp.h>
#include <freerdp/gdi/8bpp.h>
#include <freerdp/gdi/region.h>
#include <freerdp/gdi/bitmap.h>
#include <freerdp/log.h>
p_BitBlt BitBlt_[5] =
{
NULL,
BitBlt_8bpp,
BitBlt_16bpp,
NULL,
BitBlt_32bpp
};
#include "brush.h"
#include "clipping.h"
#define TAG FREERDP_TAG("gdi.bitmap")
/**
* Get pixel at the given coordinates.\n
@ -54,41 +50,18 @@ p_BitBlt BitBlt_[5] =
* @return pixel color
*/
INLINE GDI_COLOR gdi_GetPixel(HGDI_DC hdc, int nXPos, int nYPos)
INLINE UINT32 gdi_GetPixel(HGDI_DC hdc, UINT32 nXPos, UINT32 nYPos)
{
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
GDI_COLOR* colorp = (GDI_COLOR*)&(hBmp->data[(nYPos * hBmp->width * hdc->bytesPerPixel) + nXPos * hdc->bytesPerPixel]);
return (GDI_COLOR) *colorp;
BYTE* data = &(hBmp->data[(nYPos * hBmp->scanline) + nXPos * GetBytesPerPixel(
hBmp->format)]);
return ReadColor(data, hBmp->format);
}
INLINE BYTE gdi_GetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y)
INLINE BYTE* gdi_GetPointer(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y)
{
return *((BYTE*)&(hBmp->data[(Y * hBmp->width) + X]));
}
INLINE UINT16 gdi_GetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return *((UINT16*)&(hBmp->data[(Y * hBmp->width * 2) + X * 2]));
}
INLINE UINT32 gdi_GetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return *((UINT32*)&(hBmp->data[(Y * hBmp->width * 4) + X * 4]));
}
INLINE BYTE* gdi_GetPointer_8bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return ((BYTE*)&(hBmp->data[(Y * hBmp->width) + X]));
}
INLINE UINT16* gdi_GetPointer_16bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return ((UINT16*)&(hBmp->data[(Y * hBmp->width * 2) + X * 2]));
}
INLINE UINT32* gdi_GetPointer_32bpp(HGDI_BITMAP hBmp, int X, int Y)
{
return ((UINT32*)&(hBmp->data[(Y * hBmp->width * 4) + X * 4]));
UINT32 bpp = GetBytesPerPixel(hBmp->format);
return &hBmp->data[(Y * hBmp->width * bpp) + X * bpp];
}
/**
@ -101,26 +74,19 @@ INLINE UINT32* gdi_GetPointer_32bpp(HGDI_BITMAP hBmp, int X, int Y)
* @return
*/
INLINE GDI_COLOR gdi_SetPixel(HGDI_DC hdc, int X, int Y, GDI_COLOR crColor)
static INLINE UINT32 gdi_SetPixelBmp(HGDI_BITMAP hBmp, UINT32 X, UINT32 Y,
UINT32 crColor)
{
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
*((GDI_COLOR*)&(hBmp->data[(Y * hBmp->width * hdc->bytesPerPixel) + X * hdc->bytesPerPixel])) = crColor;
BYTE* p = &hBmp->data[(Y * hBmp->scanline) + X * GetBytesPerPixel(
hBmp->format)];
WriteColor(p, hBmp->format, crColor);
return crColor;
}
INLINE void gdi_SetPixel_8bpp(HGDI_BITMAP hBmp, int X, int Y, BYTE pixel)
INLINE UINT32 gdi_SetPixel(HGDI_DC hdc, UINT32 X, UINT32 Y, UINT32 crColor)
{
*((BYTE*)&(hBmp->data[(Y * hBmp->width) + X])) = pixel;
}
INLINE void gdi_SetPixel_16bpp(HGDI_BITMAP hBmp, int X, int Y, UINT16 pixel)
{
*((UINT16*)&(hBmp->data[(Y * hBmp->width * 2) + X * 2])) = pixel;
}
INLINE void gdi_SetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y, UINT32 pixel)
{
*((UINT32*)&(hBmp->data[(Y * hBmp->width * 4) + X * 4])) = pixel;
HGDI_BITMAP hBmp = (HGDI_BITMAP) hdc->selectedObject;
return gdi_SetPixelBmp(hBmp, X, Y, crColor);
}
/**
@ -134,13 +100,14 @@ INLINE void gdi_SetPixel_32bpp(HGDI_BITMAP hBmp, int X, int Y, UINT32 pixel)
* @return new bitmap
*/
HGDI_BITMAP gdi_CreateBitmap(int nWidth, int nHeight, int cBitsPerPixel, BYTE* data)
HGDI_BITMAP gdi_CreateBitmap(UINT32 nWidth, UINT32 nHeight, UINT32 format,
BYTE* data)
{
return gdi_CreateBitmapEx(nWidth, nHeight, cBitsPerPixel, data, _aligned_free);
return gdi_CreateBitmapEx(nWidth, nHeight, format, 0, data, _aligned_free);
}
HGDI_BITMAP gdi_CreateBitmapEx(int nWidth, int nHeight, int cBitsPerPixel, BYTE* data,
void (*fkt_free)(void*))
HGDI_BITMAP gdi_CreateBitmapEx(UINT32 nWidth, UINT32 nHeight, UINT32 format,
UINT32 stride, BYTE* data, void (*fkt_free)(void*))
{
HGDI_BITMAP hBitmap = (HGDI_BITMAP) calloc(1, sizeof(GDI_BITMAP));
@ -148,14 +115,17 @@ HGDI_BITMAP gdi_CreateBitmapEx(int nWidth, int nHeight, int cBitsPerPixel, BYTE*
return NULL;
hBitmap->objectType = GDIOBJECT_BITMAP;
hBitmap->bitsPerPixel = cBitsPerPixel;
hBitmap->bytesPerPixel = (cBitsPerPixel + 1) / 8;
hBitmap->scanline = nWidth * hBitmap->bytesPerPixel;
hBitmap->format = format;
if (stride > 0)
hBitmap->scanline = stride;
else
hBitmap->scanline = nWidth * GetBytesPerPixel(hBitmap->format);
hBitmap->width = nWidth;
hBitmap->height = nHeight;
hBitmap->data = data;
hBitmap->free = fkt_free;
return hBitmap;
}
@ -168,7 +138,8 @@ HGDI_BITMAP gdi_CreateBitmapEx(int nWidth, int nHeight, int cBitsPerPixel, BYTE*
* @return new bitmap
*/
HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, int nWidth, int nHeight)
HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, UINT32 nWidth,
UINT32 nHeight)
{
HGDI_BITMAP hBitmap = (HGDI_BITMAP) calloc(1, sizeof(GDI_BITMAP));
@ -176,22 +147,629 @@ HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, int nWidth, int nHeight)
return NULL;
hBitmap->objectType = GDIOBJECT_BITMAP;
hBitmap->bytesPerPixel = hdc->bytesPerPixel;
hBitmap->bitsPerPixel = hdc->bitsPerPixel;
hBitmap->format = hdc->format;
hBitmap->width = nWidth;
hBitmap->height = nHeight;
hBitmap->data = _aligned_malloc(nWidth * nHeight * hBitmap->bytesPerPixel, 16);
hBitmap->data = _aligned_malloc(nWidth * nHeight * GetBytesPerPixel(
hBitmap->format), 16);
hBitmap->free = _aligned_free;
if (!hBitmap->data)
{
free(hBitmap);
return NULL;
}
hBitmap->scanline = nWidth * hBitmap->bytesPerPixel;
hBitmap->scanline = nWidth * GetBytesPerPixel(hBitmap->format);
return hBitmap;
}
static BOOL BitBlt_SRCCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 y;
BYTE* srcp;
BYTE* dstp;
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);
if (srcp != 0 && dstp != 0)
memmove(dstp, srcp, nWidth * GetBytesPerPixel(hdcDest->format));
}
}
else if (nYSrc > nYDest || nXSrc > nXDest)
{
/* copy up or left (top top bottom) */
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));
}
}
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));
}
}
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 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color = ReadColor(srcp, hdcSrc->format);
color = ConvertColor(color, hdcSrc->format, hdcDest->format, NULL);
color = ~color;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_SRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = colorA & ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_NOTSRCERASE(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = ~colorA & ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_SRCINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = colorA ^ colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_SRCAND(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = colorA & colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_SRCPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = colorA | colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_DSPDxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
UINT32 color;
if (!hdcDest || !hdcSrc)
return FALSE;
/* D = (S & P) | (~S & D) */
color = hdcDest->textColor;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x<nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = (colorA & color) | (~colorA & colorB);
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_PSDPxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
{
UINT32 colorC = hdcDest->brush->color;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x<nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = (colorA & colorB) | (~colorA & colorC);
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
else
{
for (y = 0; y < nHeight; y++)
{
for (x = 0; x<nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(
hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(
hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 color;
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);
color = (colorA & colorB) | (~colorA & colorC);
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
return TRUE;
}
static BOOL BitBlt_SPDSxax(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
/* D = S ^ (P & (D ^ S)) */
if (hdcDest->brush->style == GDI_BS_SOLID)
{
UINT32 color = hdcDest->brush->color;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x<nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
colorD = colorA ^ (color & (colorB ^ colorA));
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
else
{
for (y = 0; y < nHeight; y++)
{
for (x = 0; x<nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(
hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(
hdcDest, nXDest + x, nYDest + y);
if (srcp && dstp)
{
UINT32 colorD;
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);
colorD = colorA ^ (color & (colorB ^ colorA));
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
return TRUE;
}
static BOOL BitBlt_SPna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(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);
color = colorA & ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_DSna(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = ~colorA & colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_MERGECOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(
hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(
hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(
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);
color = colorA & colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_MERGEPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
BYTE* dstp = gdi_get_bitmap_pointer(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);
color = ~colorA | colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
/**
* Perform a bit blit operation on the given pixel buffers.\n
* @msdn{dd183370}
@ -206,13 +784,90 @@ HGDI_BITMAP gdi_CreateCompatibleBitmap(HGDI_DC hdc, int nWidth, int nHeight)
* @param rop raster operation code
* @return 0 on failure, non-zero otherwise
*/
BOOL gdi_BitBlt(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, DWORD rop)
BOOL gdi_BitBlt(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc, DWORD rop)
{
p_BitBlt _BitBlt = BitBlt_[IBPP(hdcDest->bitsPerPixel)];
if (_BitBlt == NULL)
if (!hdcDest)
return FALSE;
return _BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, rop);
if (hdcSrc != NULL)
{
if (!gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc))
return TRUE;
}
else
{
if (!gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL))
return TRUE;
}
if (!gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight))
return FALSE;
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);
case GDI_SPna:
return BitBlt_SPna(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_DSna:
return BitBlt_DSna(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_DSPDxax:
return BitBlt_DSPDxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_PSDPxax:
return BitBlt_PSDPxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_SPDSxax:
return BitBlt_SPDSxax(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
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);
case GDI_SRCERASE:
return BitBlt_SRCERASE(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_NOTSRCERASE:
return BitBlt_NOTSRCERASE(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_SRCINVERT:
return BitBlt_SRCINVERT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_SRCAND:
return BitBlt_SRCAND(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_SRCPAINT:
return BitBlt_SRCPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
case GDI_MERGECOPY:
return BitBlt_MERGECOPY(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
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);
case GDI_PATPAINT:
return BitBlt_PATPAINT(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc);
}
WLog_ERR(TAG, "BitBlt: unknown rop: 0x%08X", rop);
return FALSE;
}

View File

@ -3,6 +3,8 @@
* GDI Brush Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,21 +30,12 @@
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/region.h>
#include <freerdp/log.h>
#include <freerdp/gdi/32bpp.h>
#include <freerdp/gdi/16bpp.h>
#include <freerdp/gdi/8bpp.h>
#include "clipping.h"
#include <freerdp/gdi/brush.h>
p_PatBlt PatBlt_[5] =
{
NULL,
PatBlt_8bpp,
PatBlt_16bpp,
NULL,
PatBlt_32bpp
};
#define TAG FREERDP_TAG("gdi.brush")
/**
* Create a new solid brush.\n
@ -51,11 +44,13 @@ p_PatBlt PatBlt_[5] =
* @return new brush
*/
HGDI_BRUSH gdi_CreateSolidBrush(GDI_COLOR crColor)
HGDI_BRUSH gdi_CreateSolidBrush(UINT32 crColor)
{
HGDI_BRUSH hBrush = (HGDI_BRUSH) calloc(1, sizeof(GDI_BRUSH));
if (!hBrush)
return NULL;
hBrush->objectType = GDIOBJECT_BRUSH;
hBrush->style = GDI_BS_SOLID;
hBrush->color = crColor;
@ -72,8 +67,10 @@ HGDI_BRUSH gdi_CreateSolidBrush(GDI_COLOR crColor)
HGDI_BRUSH gdi_CreatePatternBrush(HGDI_BITMAP hbmp)
{
HGDI_BRUSH hBrush = (HGDI_BRUSH) calloc(1, sizeof(GDI_BRUSH));
if (!hBrush)
return NULL;
hBrush->objectType = GDIOBJECT_BRUSH;
hBrush->style = GDI_BS_PATTERN;
hBrush->pattern = hbmp;
@ -83,8 +80,10 @@ HGDI_BRUSH gdi_CreatePatternBrush(HGDI_BITMAP hbmp)
HGDI_BRUSH gdi_CreateHatchBrush(HGDI_BITMAP hbmp)
{
HGDI_BRUSH hBrush = (HGDI_BRUSH) calloc(1, sizeof(GDI_BRUSH));
if (!hBrush)
return NULL;
hBrush->objectType = GDIOBJECT_BRUSH;
hBrush->style = GDI_BS_HATCHED;
hBrush->pattern = hbmp;
@ -102,13 +101,288 @@ HGDI_BRUSH gdi_CreateHatchBrush(HGDI_BITMAP hbmp)
* @param rop raster operation code
* @return nonzero if successful, 0 otherwise
*/
BOOL gdi_PatBlt(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD rop)
static BOOL BitBlt_DPa(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight)
{
p_PatBlt _PatBlt = PatBlt_[IBPP(hdc->bitsPerPixel)];
UINT32 x, y;
if (_PatBlt == NULL)
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (dstp && patp)
{
UINT32 color = ReadColor(patp, hdcDest->format);
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
static BOOL BitBlt_PDxn(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (dstp && patp)
{
UINT32 colorA = ReadColor(dstp, hdcDest->format);
UINT32 colorB = ReadColor(patp, hdcDest->format);
UINT32 color = colorA ^ ~colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
BOOL BitBlt_PATINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
if (hdcDest->brush->style == GDI_BS_SOLID)
{
UINT32 color = hdcDest->brush->color;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (dstp)
{
color ^= color;
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
else
{
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (patp && dstp)
{
UINT32 colorA = ReadColor(patp, hdcDest->format);
UINT32 colorB = ReadColor(dstp, hdcDest->format);
UINT32 color = colorA ^ colorB;
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
return TRUE;
}
BOOL BitBlt_PATPAINT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight, HGDI_DC hdcSrc,
UINT32 nXSrc, UINT32 nYSrc)
{
UINT32 x, y;
if (!hdcDest || !hdcSrc)
return FALSE;
return _PatBlt(hdc, nXLeft, nYLeft, nWidth, nHeight, rop);
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc + x, nYSrc + y);
const BYTE* patp = gdi_get_brush_pointer(hdcDest, nXDest + x, nYDest + y);
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (srcp && patp && dstp)
{
UINT32 colorA = ReadColor(dstp, hdcDest->format);
UINT32 colorB = ReadColor(patp, hdcDest->format);
UINT32 colorC = ReadColor(srcp, hdcDest->format);
UINT32 color = colorA | colorB | ~colorC;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
BOOL BitBlt_PATCOPY(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y, xOffset, yOffset;
if (hdcDest->brush->style == GDI_BS_SOLID)
{
UINT32 color = hdcDest->brush->color;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
BYTE* dstp = gdi_get_bitmap_pointer(
hdcDest, nXDest + x, nYDest + y);
if (dstp)
WriteColor(dstp, hdcDest->format, color);
}
}
}
else
{
if (hdcDest->brush->style == GDI_BS_HATCHED)
{
xOffset = 0;
yOffset = 2; /* +2 added after comparison to mstsc */
}
else
{
xOffset = 0;
yOffset = 0;
}
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
const BYTE* patp = gdi_get_brush_pointer(
hdcDest, nXDest + x + xOffset,
nYDest + y + yOffset);
BYTE* dstp = gdi_get_bitmap_pointer(
hdcDest, nXDest + x,
nYDest + y);
if (patp && dstp)
{
UINT32 color = ReadColor(patp, hdcDest->format);
WriteColor(dstp, hdcDest->format, color);
}
}
}
}
return TRUE;
}
BOOL BitBlt_DSTINVERT(HGDI_DC hdcDest, UINT32 nXDest, UINT32 nYDest,
UINT32 nWidth, UINT32 nHeight)
{
UINT32 x, y;
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
BYTE* dstp = gdi_get_bitmap_pointer(
hdcDest, nXDest + x, nYDest + y);
if (dstp)
{
UINT32 color = ReadColor(dstp, hdcDest->format);
color = ~color;
WriteColor(dstp, hdcDest->format, color);
}
}
}
return TRUE;
}
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);
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (dstp)
WriteColor(dstp, hdcDest->format, color);
}
}
return TRUE;
}
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);
for (y = 0; y < nHeight; y++)
{
for (x = 0; x < nWidth; x++)
{
BYTE* dstp = gdi_get_bitmap_pointer(hdcDest, nXDest + x, nYDest + y);
if (dstp)
WriteColor(dstp, hdcDest->format, color);
}
}
return TRUE;
}
BOOL gdi_PatBlt(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight, DWORD rop)
{
if (!gdi_ClipCoords(hdc, &nXLeft, &nYLeft, &nWidth, &nHeight, NULL, NULL))
return TRUE;
if (!gdi_InvalidateRegion(hdc, nXLeft, nYLeft, nWidth, nHeight))
return FALSE;
switch (rop)
{
case GDI_PATCOPY:
return BitBlt_PATCOPY(hdc, nXLeft, nYLeft, nWidth, nHeight);
case GDI_PATINVERT:
return BitBlt_PATINVERT(hdc, nXLeft, nYLeft, nWidth, nHeight);
case GDI_DSTINVERT:
return BitBlt_DSTINVERT(hdc, nXLeft, nYLeft, nWidth, nHeight);
case GDI_BLACKNESS:
return BitBlt_BLACKNESS(hdc, nXLeft, nYLeft, nWidth, nHeight);
case GDI_WHITENESS:
return BitBlt_WHITENESS(hdc, nXLeft, nYLeft, nWidth, nHeight);
case GDI_DPa:
return BitBlt_DPa(hdc, nXLeft, nYLeft, nWidth, nHeight);
case GDI_PDxn:
return BitBlt_PDxn(hdc, nXLeft, nYLeft, nWidth, nHeight);
default:
break;
}
WLog_ERR(TAG, "PatBlt: unknown rop: 0x%08X", rop);
return FALSE;
}

59
libfreerdp/gdi/brush.h Normal file
View File

@ -0,0 +1,59 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* GDI Brush Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FREERDP_GDI_BRUSH_H
#define FREERDP_GDI_BRUSH_H
#include <freerdp/api.h>
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
extern "C" {
#endif
HGDI_BRUSH gdi_CreateSolidBrush(UINT32 crColor);
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);
#ifdef __cplusplus
}
#endif
typedef BOOL (*p_PatBlt)(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft,
UINT32 nWidth, UINT32 nHeight, DWORD rop);
#endif /* FREERDP_GDI_BRUSH_H */

View File

@ -3,6 +3,8 @@
* GDI Clipping Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,9 +32,9 @@
#include <freerdp/gdi/region.h>
#include <freerdp/gdi/clipping.h>
#include "clipping.h"
BOOL gdi_SetClipRgn(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight)
BOOL gdi_SetClipRgn(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft, UINT32 nWidth, UINT32 nHeight)
{
return gdi_SetRgn(hdc->clip, nXLeft, nYLeft, nWidth, nHeight);
}
@ -74,7 +76,8 @@ BOOL gdi_SetNullClipRgn(HGDI_DC hdc)
* @return nonzero if there is something to draw, 0 otherwise
*/
BOOL gdi_ClipCoords(HGDI_DC hdc, int *x, int *y, int *w, int *h, int *srcx, int *srcy)
BOOL gdi_ClipCoords(HGDI_DC hdc, UINT32 *x, UINT32 *y, UINT32 *w, UINT32 *h,
UINT32 *srcx, UINT32 *srcy)
{
GDI_RECT bmp;
GDI_RECT clip;

View File

@ -3,6 +3,8 @@
* GDI Clipping Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,10 +29,11 @@
extern "C" {
#endif
FREERDP_API BOOL gdi_SetClipRgn(HGDI_DC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight);
FREERDP_API HGDI_RGN gdi_GetClipRgn(HGDI_DC hdc);
FREERDP_API BOOL gdi_SetNullClipRgn(HGDI_DC hdc);
FREERDP_API BOOL gdi_ClipCoords(HGDI_DC hdc, int *x, int *y, int *w, int *h, int *srcx, int *srcy);
BOOL gdi_SetClipRgn(HGDI_DC hdc, UINT32 nXLeft, UINT32 nYLeft, UINT32 nWidth, UINT32 nHeight);
HGDI_RGN gdi_GetClipRgn(HGDI_DC hdc);
BOOL gdi_SetNullClipRgn(HGDI_DC hdc);
BOOL gdi_ClipCoords(HGDI_DC hdc, UINT32 *x, UINT32 *y,
UINT32 *w, UINT32 *h, UINT32 *srcx, UINT32 *srcy);
#ifdef __cplusplus
}

View File

@ -3,6 +3,8 @@
* GDI Device Context Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,14 +41,13 @@
* @return current device context
*/
HGDI_DC gdi_GetDC()
HGDI_DC gdi_GetDC(void)
{
HGDI_DC hDC = (HGDI_DC) malloc(sizeof(GDI_DC));
HGDI_DC hDC = (HGDI_DC) calloc(1, sizeof(GDI_DC));
if (!hDC)
return NULL;
hDC->bytesPerPixel = 4;
hDC->bitsPerPixel = 32;
hDC->format = PIXEL_FORMAT_XRGB32;
hDC->drawMode = GDI_R2_BLACK;
hDC->clip = gdi_CreateRectRgn(0, 0, 0, 0);
if (!hDC->clip)
@ -65,7 +66,7 @@ HGDI_DC gdi_GetDC()
* @return new device context
*/
HGDI_DC gdi_CreateDC(UINT32 flags, int bpp)
HGDI_DC gdi_CreateDC(UINT32 format)
{
HGDI_DC hDC;
@ -80,12 +81,7 @@ HGDI_DC gdi_CreateDC(UINT32 flags, int bpp)
hDC->clip->null = 1;
hDC->hwnd = NULL;
hDC->bitsPerPixel = bpp;
hDC->bytesPerPixel = bpp / 8;
hDC->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE;
hDC->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE;
hDC->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE;
hDC->format = format;
if (!(hDC->hwnd = (HGDI_WND) calloc(1, sizeof(GDI_WND))))
goto fail;
@ -117,7 +113,7 @@ fail:
HGDI_DC gdi_CreateCompatibleDC(HGDI_DC hdc)
{
HGDI_DC hDC = (HGDI_DC) malloc(sizeof(GDI_DC));
HGDI_DC hDC = (HGDI_DC) calloc(1, sizeof(GDI_DC));
if (!hDC)
return NULL;
@ -127,13 +123,9 @@ HGDI_DC gdi_CreateCompatibleDC(HGDI_DC hdc)
return NULL;
}
hDC->clip->null = 1;
hDC->bytesPerPixel = hdc->bytesPerPixel;
hDC->bitsPerPixel = hdc->bitsPerPixel;
hDC->format = hdc->format;
hDC->drawMode = hdc->drawMode;
hDC->hwnd = NULL;
hDC->alpha = hdc->alpha;
hDC->invert = hdc->invert;
hDC->rgb555 = hdc->rgb555;
return hDC;
}

View File

@ -3,6 +3,8 @@
* GDI Drawing Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +33,7 @@
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/dc.h>
#include <freerdp/gdi/drawing.h>
#include "drawing.h"
/**
* Set current foreground draw mode.\n
@ -40,7 +42,7 @@
* @return draw mode
*/
int gdi_GetROP2(HGDI_DC hdc)
UINT32 gdi_GetROP2(HGDI_DC hdc)
{
return hdc->drawMode;
}
@ -53,9 +55,9 @@ int gdi_GetROP2(HGDI_DC hdc)
* @return previous draw mode
*/
int gdi_SetROP2(HGDI_DC hdc, int fnDrawMode)
UINT32 gdi_SetROP2(HGDI_DC hdc, int fnDrawMode)
{
int prevDrawMode = hdc->drawMode;
UINT32 prevDrawMode = hdc->drawMode;
if (fnDrawMode > 0 && fnDrawMode <= 16)
hdc->drawMode = fnDrawMode;
@ -70,7 +72,7 @@ int gdi_SetROP2(HGDI_DC hdc, int fnDrawMode)
* @return background color
*/
GDI_COLOR gdi_GetBkColor(HGDI_DC hdc)
UINT32 gdi_GetBkColor(HGDI_DC hdc)
{
return hdc->bkColor;
}
@ -83,9 +85,9 @@ GDI_COLOR gdi_GetBkColor(HGDI_DC hdc)
* @return previous background color
*/
GDI_COLOR gdi_SetBkColor(HGDI_DC hdc, GDI_COLOR crColor)
UINT32 gdi_SetBkColor(HGDI_DC hdc, UINT32 crColor)
{
GDI_COLOR previousBkColor = hdc->bkColor;
UINT32 previousBkColor = hdc->bkColor;
hdc->bkColor = crColor;
return previousBkColor;
}
@ -97,7 +99,7 @@ GDI_COLOR gdi_SetBkColor(HGDI_DC hdc, GDI_COLOR crColor)
* @return background mode
*/
int gdi_GetBkMode(HGDI_DC hdc)
UINT32 gdi_GetBkMode(HGDI_DC hdc)
{
return hdc->bkMode;
}
@ -110,7 +112,8 @@ int gdi_GetBkMode(HGDI_DC hdc)
* @return previous background mode on success, 0 on failure
*/
int gdi_SetBkMode(HGDI_DC hdc, int iBkMode)
BOOL gdi_SetBkMode(HGDI_DC hdc, int iBkMode)
{
if (iBkMode == GDI_OPAQUE || iBkMode == GDI_TRANSPARENT)
{
@ -118,7 +121,8 @@ int gdi_SetBkMode(HGDI_DC hdc, int iBkMode)
hdc->bkMode = iBkMode;
return previousBkMode;
}
return 0;
return TRUE;
}
/**
@ -129,9 +133,9 @@ int gdi_SetBkMode(HGDI_DC hdc, int iBkMode)
* @return previous text color
*/
GDI_COLOR gdi_SetTextColor(HGDI_DC hdc, GDI_COLOR crColor)
UINT32 gdi_SetTextColor(HGDI_DC hdc, UINT32 crColor)
{
GDI_COLOR previousTextColor = hdc->textColor;
UINT32 previousTextColor = hdc->textColor;
hdc->textColor = crColor;
return previousTextColor;
}

View File

@ -3,6 +3,8 @@
* GDI Drawing Functions
*
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,19 +26,19 @@
#include <freerdp/gdi/gdi.h>
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
FREERDP_API int gdi_GetROP2(HGDI_DC hdc);
FREERDP_API int gdi_SetROP2(HGDI_DC hdc, int fnDrawMode);
FREERDP_API GDI_COLOR gdi_GetBkColor(HGDI_DC hdc);
FREERDP_API GDI_COLOR gdi_SetBkColor(HGDI_DC hdc, GDI_COLOR crColor);
FREERDP_API int gdi_GetBkMode(HGDI_DC hdc);
FREERDP_API int gdi_SetBkMode(HGDI_DC hdc, int iBkMode);
FREERDP_API GDI_COLOR gdi_SetTextColor(HGDI_DC hdc, GDI_COLOR crColor);
UINT32 gdi_GetROP2(HGDI_DC hdc);
UINT32 gdi_SetROP2(HGDI_DC hdc, int fnDrawMode);
UINT32 gdi_GetBkColor(HGDI_DC hdc);
UINT32 gdi_SetBkColor(HGDI_DC hdc, UINT32 crColor);
UINT32 gdi_GetBkMode(HGDI_DC hdc);
BOOL gdi_SetBkMode(HGDI_DC hdc, int iBkMode);
UINT32 gdi_SetTextColor(HGDI_DC hdc, UINT32 crColor);
#ifdef __cplusplus
}
}
#endif
#endif /* FREERDP_GDI_DRAWING_H */

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,8 @@ UINT gdi_ResetGraphics(RdpgfxClientContext* context, RDPGFX_RESET_GRAPHICS_PDU*
free(pSurfaceIds);
if (!freerdp_client_codecs_reset(gdi->codecs, FREERDP_CODEC_ALL, gdi->width, gdi->height))
if (!freerdp_client_codecs_reset(gdi->codecs, FREERDP_CODEC_ALL,
gdi->width, gdi->height))
return ERROR_INTERNAL_ERROR;
gdi->graphicsReset = TRUE;
@ -310,8 +311,7 @@ UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi, RdpgfxClientContext* context, RDPG
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_REMOTEFX,
surface->width, surface->height))
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_REMOTEFX))
return ERROR_INTERNAL_ERROR;
if (!(message = rfx_process_message(surface->codecs->rfx, cmd->data, cmd->length)))
@ -391,8 +391,7 @@ UINT gdi_SurfaceCommand_ClearCodec(rdpGdi* gdi, RdpgfxClientContext* context, RD
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_CLEARCODEC,
gdi->width, gdi->height))
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_CLEARCODEC))
return ERROR_INTERNAL_ERROR;
DstData = surface->data;
@ -436,8 +435,7 @@ UINT gdi_SurfaceCommand_Planar(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_PLANAR,
surface->width, surface->height))
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_PLANAR))
return ERROR_INTERNAL_ERROR;
DstData = surface->data;
@ -476,8 +474,7 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, RdpgfxClientContext* context,
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_AVC420,
surface->width, surface->height))
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_AVC420))
return ERROR_INTERNAL_ERROR;
bs = (RDPGFX_AVC420_BITMAP_STREAM*) cmd->extra;
@ -532,8 +529,7 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context,
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_AVC444,
surface->width, surface->height))
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_AVC444))
return ERROR_INTERNAL_ERROR;
bs = (RDPGFX_AVC444_BITMAP_STREAM*) cmd->extra;
@ -598,8 +594,7 @@ UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context, RDPGFX_
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_ALPHACODEC,
surface->width, surface->height))
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_ALPHACODEC))
return ERROR_INTERNAL_ERROR;
WLog_DBG(TAG, "gdi_SurfaceCommand_Alpha: status: %d", status);
@ -651,8 +646,7 @@ UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* context, R
if (!surface)
return ERROR_INTERNAL_ERROR;
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_PROGRESSIVE,
surface->width, surface->height))
if (!freerdp_client_codecs_prepare(surface->codecs, FREERDP_CODEC_PROGRESSIVE))
return ERROR_INTERNAL_ERROR;
progressive_create_surface_context(surface->codecs->progressive, cmd->surfaceId, surface->width, surface->height);
@ -814,6 +808,13 @@ UINT gdi_CreateSurface(RdpgfxClientContext* context, RDPGFX_CREATE_SURFACE_PDU*
return CHANNEL_RC_NO_MEMORY;
}
if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
createSurface->width, createSurface->height))
{
free (surface);
return ERROR_INTERNAL_ERROR;
}
surface->surfaceId = createSurface->surfaceId;
surface->width = (UINT32) createSurface->width;
surface->height = (UINT32) createSurface->height;

View File

@ -3,6 +3,8 @@
* Graphical Objects
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,92 +27,95 @@
#include <freerdp/log.h>
#include <freerdp/gdi/dc.h>
#include <freerdp/gdi/brush.h>
#include <freerdp/gdi/shape.h>
#include <freerdp/gdi/region.h>
#include <freerdp/gdi/bitmap.h>
#include <freerdp/gdi/drawing.h>
#include "drawing.h"
#include "brush.h"
#include "graphics.h"
#define TAG FREERDP_TAG("gdi")
/* Bitmap Class */
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int nWidth, int nHeight, int bpp, BYTE* data)
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 nWidth, UINT32 nHeight,
UINT32 SrcFormat, BYTE* data)
{
int nSrcStep;
int nDstStep;
UINT32 nSrcStep;
UINT32 nDstStep;
BYTE* pSrcData;
BYTE* pDstData;
UINT32 SrcFormat;
int bytesPerPixel;
HGDI_BITMAP bitmap;
nDstStep = nWidth * gdi->bytesPerPixel;
nDstStep = nWidth * GetBytesPerPixel(gdi->dstFormat);
pDstData = _aligned_malloc(nHeight * nDstStep, 16);
if (!pDstData)
return NULL;
pSrcData = data;
switch (bpp)
{
case 32:
bytesPerPixel = 4;
SrcFormat = PIXEL_FORMAT_XRGB32;
break;
case 24:
bytesPerPixel = 3;
SrcFormat = PIXEL_FORMAT_RGB24;
break;
case 16:
bytesPerPixel = 2;
SrcFormat = PIXEL_FORMAT_RGB565;
break;
case 15:
bytesPerPixel = 2;
SrcFormat = PIXEL_FORMAT_RGB555;
break;
case 8:
bytesPerPixel = 1;
SrcFormat = PIXEL_FORMAT_RGB8;
break;
default:
SrcFormat = PIXEL_FORMAT_RGB565;
bytesPerPixel = 2;
break;
}
nSrcStep = nWidth * bytesPerPixel;
freerdp_image_copy(pDstData, gdi->format, nDstStep, 0, 0,
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, gdi->palette);
bitmap = gdi_CreateBitmap(nWidth, nHeight, gdi->dstBpp, pDstData);
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
freerdp_image_copy(pDstData, gdi->dstFormat, nDstStep, 0, 0,
nWidth, nHeight, pSrcData, SrcFormat, nSrcStep, 0, 0, gdi->palette);
bitmap = gdi_CreateBitmap(nWidth, nHeight, gdi->dstFormat, pDstData);
return bitmap;
}
BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
static BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
{
gdiBitmap* gdi_bitmap;
rdpGdi* gdi = context->gdi;
gdi_bitmap = (gdiBitmap*) bitmap;
gdi_bitmap->hdc = gdi_CreateCompatibleDC(gdi->hdc);
if (!gdi_bitmap->hdc)
return FALSE;
if (!bitmap->data)
gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(gdi->hdc, bitmap->width, bitmap->height);
gdi_bitmap->bitmap = gdi_CreateCompatibleBitmap(
gdi->hdc, bitmap->width,
bitmap->height);
else
gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width, bitmap->height, bitmap->bpp, bitmap->data);
{
UINT32 format;
switch (bitmap->bpp)
{
case 32:
format = PIXEL_FORMAT_RGBX32;
break;
case 24:
format = PIXEL_FORMAT_RGB24;
break;
case 16:
format = PIXEL_FORMAT_RGB16;
break;
case 15:
format = PIXEL_FORMAT_RGB15;
break;
case 8:
format = PIXEL_FORMAT_RGB8;
break;
case 4:
format = PIXEL_FORMAT_A4;
break;
case 1:
format = PIXEL_FORMAT_MONO;
break;
default:
return FALSE;
}
gdi_bitmap->bitmap = gdi_create_bitmap(gdi, bitmap->width,
bitmap->height,
format, bitmap->data);
}
if (!gdi_bitmap->bitmap)
{
@ -123,7 +128,7 @@ BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
return TRUE;
}
void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
static void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
{
gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
@ -135,36 +140,32 @@ void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
}
}
BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
static BOOL gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
{
int width, height;
gdiBitmap* gdi_bitmap = (gdiBitmap*) bitmap;
width = bitmap->right - bitmap->left + 1;
height = bitmap->bottom - bitmap->top + 1;
return gdi_BitBlt(context->gdi->primary->hdc, bitmap->left, bitmap->top,
width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
width, height, gdi_bitmap->hdc, 0, 0, GDI_SRCCOPY);
}
BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
BYTE* data, int width, int height, int bpp, int length,
BOOL compressed, int codecId)
static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
const BYTE* data, UINT32 width, UINT32 height,
UINT32 bpp, UINT32 length, BOOL compressed,
UINT32 codecId)
{
int status;
UINT16 size;
BYTE* pSrcData;
const BYTE* pSrcData;
BYTE* pDstData;
UINT32 SrcSize;
UINT32 SrcFormat;
UINT32 bytesPerPixel;
rdpGdi* gdi = context->gdi;
bytesPerPixel = (bpp + 7) / 8;
size = width * height * 4;
bitmap->data = (BYTE*) _aligned_malloc(size, 16);
pSrcData = data;
SrcSize = (UINT32) length;
pDstData = bitmap->data;
@ -177,8 +178,12 @@ BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
gdi->width, gdi->height))
return FALSE;
status = interleaved_decompress(gdi->codecs->interleaved, pSrcData, SrcSize, bpp,
&pDstData, gdi->format, -1, 0, 0, width, height, gdi->palette);
status = interleaved_decompress(gdi->codecs->interleaved,
pSrcData, SrcSize,
bpp,
pDstData, gdi->dstFormat,
-1, 0, 0, width, height,
gdi->palette);
}
else
{
@ -187,7 +192,7 @@ BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
return FALSE;
status = planar_decompress(gdi->codecs->planar, pSrcData, SrcSize, &pDstData,
gdi->format, -1, 0, 0, width, height, TRUE);
gdi->dstFormat, -1, 0, 0, width, height, TRUE);
}
if (status < 0)
@ -199,18 +204,18 @@ BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
else
{
SrcFormat = gdi_get_pixel_format(bpp, TRUE);
status = freerdp_image_copy(pDstData, gdi->format, -1, 0, 0,
width, height, pSrcData, SrcFormat, -1, 0, 0, gdi->palette);
status = freerdp_image_copy(pDstData, gdi->dstFormat, -1, 0, 0,
width, height, pSrcData, SrcFormat, -1, 0, 0, gdi->palette);
}
bitmap->compressed = FALSE;
bitmap->length = size;
bitmap->bpp = gdi->dstBpp;
bitmap->bpp = GetBitsPerPixel(gdi->dstFormat);
return TRUE;
}
BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
static BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap,
BOOL primary)
{
rdpGdi* gdi = context->gdi;
@ -223,45 +228,44 @@ BOOL gdi_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
}
/* Glyph Class */
BOOL gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph)
static BOOL gdi_Glyph_New(rdpContext* context, rdpGlyph* glyph)
{
BYTE* data;
gdiGlyph* gdi_glyph;
gdi_glyph = (gdiGlyph*) glyph;
gdi_glyph->hdc = gdi_GetDC();
if (!gdi_glyph->hdc)
return FALSE;
gdi_glyph->hdc->bytesPerPixel = 1;
gdi_glyph->hdc->bitsPerPixel = 1;
gdi_glyph->hdc->format = PIXEL_FORMAT_MONO;
data = freerdp_glyph_convert(glyph->cx, glyph->cy, glyph->aj);
if (!data)
{
gdi_DeleteDC(gdi_glyph->hdc);
return FALSE;
}
gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, 1, data);
gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
data);
if (!gdi_glyph->bitmap)
{
gdi_DeleteDC(gdi_glyph->hdc);
_aligned_free(data);
return FALSE;
}
gdi_glyph->bitmap->bytesPerPixel = 1;
gdi_glyph->bitmap->bitsPerPixel = 1;
gdi_glyph->bitmap->format = PIXEL_FORMAT_MONO;
gdi_SelectObject(gdi_glyph->hdc, (HGDIOBJECT) gdi_glyph->bitmap);
gdi_glyph->org_bitmap = NULL;
return TRUE;
}
void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
static void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
{
gdiGlyph* gdi_glyph;
gdi_glyph = (gdiGlyph*) glyph;
if (gdi_glyph)
@ -272,28 +276,28 @@ void gdi_Glyph_Free(rdpContext* context, rdpGlyph* glyph)
}
}
BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y)
static BOOL gdi_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, UINT32 x,
UINT32 y)
{
gdiGlyph* gdi_glyph;
rdpGdi* gdi = context->gdi;
gdi_glyph = (gdiGlyph*) glyph;
return gdi_BitBlt(gdi->drawing->hdc, x, y, gdi_glyph->bitmap->width,
gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax);
gdi_glyph->bitmap->height, gdi_glyph->hdc, 0, 0, GDI_DSPDxax);
}
BOOL gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant)
static BOOL gdi_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor,
UINT32 fgcolor, BOOL fOpRedundant)
{
GDI_RECT rect;
HGDI_BRUSH brush;
rdpGdi* gdi = context->gdi;
BOOL ret = FALSE;
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
/* TODO: handle fOpRedundant! See xf_Glyph_BeginDraw() */
bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format, gdi->palette);
fgcolor = freerdp_convert_gdi_order_color(fgcolor, gdi->srcBpp, gdi->format, 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;
@ -301,17 +305,18 @@ BOOL gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh
gdi_CRgnToRect(x, y, width, height, &rect);
ret = gdi_FillRect(gdi->drawing->hdc, &rect, brush);
gdi_DeleteObject((HGDIOBJECT) brush);
out:
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
return ret;
}
BOOL gdi_Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor)
static BOOL gdi_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, UINT32 bgcolor, UINT32 fgcolor)
{
rdpGdi* gdi = context->gdi;
bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format, gdi->palette);
UINT32 SrcFormat = gdi_get_pixel_format(context->settings->ColorDepth, FALSE);
bgcolor = ConvertColor(bgcolor, SrcFormat,
gdi->dstFormat, gdi->palette);
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
return TRUE;
}
@ -322,36 +327,30 @@ 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);
return TRUE;

View File

@ -3,6 +3,8 @@
* Graphical Objects
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
* Copyright 2016 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,13 +25,9 @@
#include <freerdp/gdi/gdi.h>
#include <freerdp/graphics.h>
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int width, int height, int bpp, BYTE* data);
HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, UINT32 width, UINT32 height,
UINT32 format, BYTE* data);
BOOL gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap);
void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap);
BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
BYTE* data, int width, int height, int bpp, int length,
BOOL compressed, int codec_id);
BOOL gdi_register_graphics(rdpGraphics* graphics);
#endif /* __GDI_GRAPHICS_H */

Some files were not shown because too many files have changed in this diff Show More