GUAC-852: Abstract away color conversion.
This commit is contained in:
parent
f401597f10
commit
98195e606a
@ -423,6 +423,15 @@ then
|
||||
[RDP_LIBS="$RDP_LIBS -lfreerdp-codec"])
|
||||
fi
|
||||
|
||||
# Available color conversion functions
|
||||
if test "x${have_freerdp}" = "xyes"
|
||||
then
|
||||
AC_CHECK_DECL([freerdp_convert_gdi_order_color],
|
||||
[AC_DEFINE([HAVE_FREERDP_CONVERT_GDI_ORDER_COLOR],,
|
||||
[Whether freerdp_convert_gdi_order_color() id defined])],,
|
||||
[#include <freerdp/codec/color.h>])
|
||||
fi
|
||||
|
||||
# Check for interval polling in plugins
|
||||
if test "x${have_freerdp}" = "xyes"
|
||||
then
|
||||
|
@ -33,6 +33,7 @@ libguac_client_rdp_la_SOURCES = \
|
||||
guac_handlers.c \
|
||||
rdp_bitmap.c \
|
||||
rdp_cliprdr.c \
|
||||
rdp_color.c \
|
||||
rdp_fs.c \
|
||||
rdp_gdi.c \
|
||||
rdp_glyph.c \
|
||||
@ -83,6 +84,7 @@ noinst_HEADERS = \
|
||||
guac_handlers.h \
|
||||
rdp_bitmap.h \
|
||||
rdp_cliprdr.h \
|
||||
rdp_color.h \
|
||||
rdp_fs.h \
|
||||
rdp_gdi.h \
|
||||
rdp_glyph.h \
|
||||
|
56
src/protocols/rdp/rdp_color.c
Normal file
56
src/protocols/rdp/rdp_color.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "rdp_settings.h"
|
||||
|
||||
#include <freerdp/codec/color.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
#ifdef ENABLE_WINPR
|
||||
#include <winpr/wtypes.h>
|
||||
#else
|
||||
#include "compat/winpr-wtypes.h"
|
||||
#endif
|
||||
|
||||
UINT32 guac_rdp_convert_color(rdpContext* context, UINT32 color) {
|
||||
|
||||
#ifdef HAVE_FREERDP_CONVERT_GDI_ORDER_COLOR
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
|
||||
/* Convert given color to ARGB32 */
|
||||
return freerdp_convert_gdi_order_color(color,
|
||||
guac_rdp_get_depth(context->instance), PIXEL_FORMAT_ARGB32,
|
||||
(BYTE*) palette);
|
||||
#else
|
||||
CLRCONV* clrconv = ((rdp_freerdp_context*) context)->clrconv;
|
||||
|
||||
/* Convert given color to ARGB32 */
|
||||
return freerdp_color_convert_var(color,
|
||||
guac_rdp_get_depth(context->instance), 32,
|
||||
clrconv);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
42
src/protocols/rdp/rdp_color.h
Normal file
42
src/protocols/rdp/rdp_color.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GUAC_RDP_COLOR_H
|
||||
#define GUAC_RDP_COLOR_H
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
#ifdef ENABLE_WINPR
|
||||
#include <winpr/wtypes.h>
|
||||
#else
|
||||
#include "compat/winpr-wtypes.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Converts the given color to ARGB32. The color given may be an index
|
||||
* referring to the palette, a 16-bit or 32-bit color, etc. all depending on
|
||||
* the current color depth of the RDP session.
|
||||
*/
|
||||
UINT32 guac_rdp_convert_color(rdpContext* context, UINT32 color);
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "client.h"
|
||||
#include "guac_surface.h"
|
||||
#include "rdp_bitmap.h"
|
||||
#include "rdp_color.h"
|
||||
#include "rdp_settings.h"
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
@ -320,11 +321,8 @@ void guac_rdp_gdi_opaquerect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect
|
||||
|
||||
/* Get client data */
|
||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
|
||||
UINT32 color = freerdp_convert_gdi_order_color(opaque_rect->color,
|
||||
guac_rdp_get_depth(context->instance),
|
||||
PIXEL_FORMAT_ARGB32, (BYTE*) palette);
|
||||
UINT32 color = guac_rdp_convert_color(context, opaque_rect->color);
|
||||
|
||||
guac_common_surface* current_surface = ((rdp_guac_client_data*) client->data)->current_surface;
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "client.h"
|
||||
#include "guac_surface.h"
|
||||
#include "rdp_color.h"
|
||||
#include "rdp_glyph.h"
|
||||
#include "rdp_settings.h"
|
||||
|
||||
@ -128,7 +129,6 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
|
||||
int x, int y, int width, int height, UINT32 fgcolor, UINT32 bgcolor) {
|
||||
|
||||
guac_client* client = ((rdp_freerdp_context*) context)->client;
|
||||
UINT32* palette = ((rdp_freerdp_context*) context)->palette;
|
||||
rdp_guac_client_data* guac_client_data =
|
||||
(rdp_guac_client_data*) client->data;
|
||||
|
||||
@ -136,9 +136,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
|
||||
if (width != 0 && height != 0) {
|
||||
|
||||
/* Convert background color */
|
||||
bgcolor = freerdp_convert_gdi_order_color(bgcolor,
|
||||
guac_rdp_get_depth(context->instance),
|
||||
PIXEL_FORMAT_ARGB32, (BYTE*) palette);
|
||||
bgcolor = guac_rdp_convert_color(context, bgcolor);
|
||||
|
||||
guac_common_surface_rect(guac_client_data->current_surface, x, y, width, height,
|
||||
(bgcolor & 0xFF0000) >> 16,
|
||||
@ -148,10 +146,7 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
|
||||
}
|
||||
|
||||
/* Convert foreground color */
|
||||
guac_client_data->glyph_color =
|
||||
freerdp_convert_gdi_order_color(fgcolor,
|
||||
guac_rdp_get_depth(context->instance),
|
||||
PIXEL_FORMAT_ARGB32, (BYTE*) palette);
|
||||
guac_client_data->glyph_color = guac_rdp_convert_color(context, fgcolor);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user