wfreerdp: fix windows build after cache refactoring

This commit is contained in:
Marc-André Moreau 2011-10-13 20:10:59 -04:00
parent be6d043dd6
commit 0aba540ad2
4 changed files with 105 additions and 73 deletions

View File

@ -98,13 +98,13 @@ HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, uint8* data)
return bitmap; return bitmap;
} }
WF_IMAGE* wf_image_new(wfInfo* wfi, int width, int height, int bpp, uint8* data) wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, uint8* data)
{ {
HDC hdc; HDC hdc;
WF_IMAGE* image; wfBitmap* image;
hdc = GetDC(NULL); hdc = GetDC(NULL);
image = (WF_IMAGE*) malloc(sizeof(WF_IMAGE)); image = (wfBitmap*) malloc(sizeof(wfBitmap));
image->hdc = CreateCompatibleDC(hdc); image->hdc = CreateCompatibleDC(hdc);
if (data == NULL) if (data == NULL)
@ -118,7 +118,7 @@ WF_IMAGE* wf_image_new(wfInfo* wfi, int width, int height, int bpp, uint8* data)
return image; return image;
} }
void wf_image_free(WF_IMAGE* image) void wf_image_free(wfBitmap* image)
{ {
if (image != 0) if (image != 0)
{ {
@ -129,14 +129,14 @@ void wf_image_free(WF_IMAGE* image)
} }
} }
WF_IMAGE* wf_glyph_new(wfInfo* wfi, GLYPH_DATA* glyph) wfBitmap* wf_glyph_new(wfInfo* wfi, GLYPH_DATA* glyph)
{ {
WF_IMAGE* glyph_bmp; wfBitmap* glyph_bmp;
glyph_bmp = wf_image_new(wfi, glyph->cx, glyph->cy, 1, glyph->aj); glyph_bmp = wf_image_new(wfi, glyph->cx, glyph->cy, 1, glyph->aj);
return glyph_bmp; return glyph_bmp;
} }
void wf_glyph_free(WF_IMAGE* glyph) void wf_glyph_free(wfBitmap* glyph)
{ {
wf_image_free(glyph); wf_image_free(glyph);
} }
@ -164,7 +164,7 @@ void wf_gdi_bitmap_update(rdpUpdate* update, BITMAP_UPDATE* bitmap)
{ {
int i; int i;
rdpBitmap* bmp; rdpBitmap* bmp;
WF_IMAGE* wf_bmp; wfBitmap* wf_bmp;
wfInfo* wfi = GET_WFI(update); wfInfo* wfi = GET_WFI(update);
@ -311,15 +311,13 @@ void wf_gdi_polyline(rdpUpdate* update, POLYLINE_ORDER* polyline)
void wf_gdi_memblt(rdpUpdate* update, MEMBLT_ORDER* memblt) void wf_gdi_memblt(rdpUpdate* update, MEMBLT_ORDER* memblt)
{ {
void* extra; wfBitmap* bitmap;
WF_IMAGE* wf_bmp;
wfInfo* wfi = GET_WFI(update); wfInfo* wfi = GET_WFI(update);
bitmap_cache_get(wfi->cache->bitmap, memblt->cacheId, memblt->cacheIndex, (void**) &extra); bitmap = (wfBitmap*) memblt->bitmap;
wf_bmp = (WF_IMAGE*) extra;
BitBlt(wfi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect, BitBlt(wfi->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
memblt->nWidth, memblt->nHeight, wf_bmp->hdc, memblt->nWidth, memblt->nHeight, bitmap->hdc,
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop)); memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
if (wfi->drawing == wfi->primary) if (wfi->drawing == wfi->primary)
@ -336,44 +334,6 @@ void wf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
} }
void wf_gdi_create_offscreen_bitmap(rdpUpdate* update, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
WF_IMAGE* wf_bmp;
wfInfo* wfi = GET_WFI(update);
wf_bmp = wf_image_new(wfi, create_offscreen_bitmap->cx, create_offscreen_bitmap->cy, wfi->dstBpp, NULL);
offscreen_cache_put(wfi->cache->offscreen, create_offscreen_bitmap->id, (void*) wf_bmp);
}
void wf_gdi_switch_surface(rdpUpdate* update, SWITCH_SURFACE_ORDER* switch_surface)
{
WF_IMAGE* wf_bmp;
wfInfo* wfi = GET_WFI(update);
if (switch_surface->bitmapId == SCREEN_BITMAP_SURFACE)
{
wfi->drawing = (WF_IMAGE*) wfi->primary;
}
else
{
wf_bmp = (WF_IMAGE*) offscreen_cache_get(wfi->cache->offscreen, switch_surface->bitmapId);
wfi->drawing = wf_bmp;
}
}
void wf_gdi_cache_bitmap_v2(rdpUpdate* update, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
{
WF_IMAGE* bitmap;
rdpBitmap* bitmap_data;
wfInfo* wfi = GET_WFI(update);
bitmap_data = cache_bitmap_v2->bitmap_data;
bitmap = wf_image_new(wfi, bitmap_data->width, bitmap_data->height, wfi->srcBpp, bitmap_data->dstData);
bitmap_cache_put(wfi->cache->bitmap, cache_bitmap_v2->cacheId,
cache_bitmap_v2->cacheIndex, bitmap_data, (void*) bitmap);
}
void wf_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table) void wf_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_color_table)
{ {
wfInfo* wfi = GET_WFI(update); wfInfo* wfi = GET_WFI(update);
@ -383,7 +343,7 @@ void wf_gdi_cache_color_table(rdpUpdate* update, CACHE_COLOR_TABLE_ORDER* cache_
void wf_gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph) void wf_gdi_cache_glyph(rdpUpdate* update, CACHE_GLYPH_ORDER* cache_glyph)
{ {
int i; int i;
WF_IMAGE* wf_bmp; wfBitmap* wf_bmp;
GLYPH_DATA* glyph; GLYPH_DATA* glyph;
wfInfo* wfi = GET_WFI(update); wfInfo* wfi = GET_WFI(update);
@ -402,8 +362,7 @@ void wf_gdi_cache_glyph_v2(rdpUpdate* update, CACHE_GLYPH_V2_ORDER* cache_glyph_
void wf_gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush) void wf_gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush)
{ {
//wfInfo* wfi = GET_WFI(update);
//brush_put(wfi->cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
} }
void wf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command) void wf_gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
@ -464,10 +423,7 @@ void wf_gdi_register_update_callbacks(rdpUpdate* update)
update->PolygonCB = NULL; update->PolygonCB = NULL;
update->EllipseSC = NULL; update->EllipseSC = NULL;
update->EllipseCB = NULL; update->EllipseCB = NULL;
update->CreateOffscreenBitmap = wf_gdi_create_offscreen_bitmap;
update->SwitchSurface = wf_gdi_switch_surface;
update->CacheBitmapV2 = wf_gdi_cache_bitmap_v2;
update->CacheColorTable = wf_gdi_cache_color_table; update->CacheColorTable = wf_gdi_cache_color_table;
update->CacheGlyph = wf_gdi_cache_glyph; update->CacheGlyph = wf_gdi_cache_glyph;
update->CacheGlyphV2 = wf_gdi_cache_glyph_v2; update->CacheGlyphV2 = wf_gdi_cache_glyph_v2;

View File

@ -24,8 +24,9 @@
#include "wfreerdp.h" #include "wfreerdp.h"
WF_IMAGE* wf_image_new(wfInfo* wfi, int width, int height, int bpp, uint8* data); HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, uint8* data);
void wf_image_free(WF_IMAGE* image); wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, uint8* data);
void wf_image_free(wfBitmap* image);
void wf_toggle_fullscreen(wfInfo* wfi); void wf_toggle_fullscreen(wfInfo* wfi);
void wf_gdi_register_update_callbacks(rdpUpdate* update); void wf_gdi_register_update_callbacks(rdpUpdate* update);

View File

@ -97,8 +97,6 @@ void wf_sw_end_paint(rdpUpdate* update)
update_rect.right = x + w - 1; update_rect.right = x + w - 1;
update_rect.bottom = y + h - 1; update_rect.bottom = y + h - 1;
//printf("InvalidateRect: x:%d y:%d w:%d h:%d\n", x, y, w, h);
InvalidateRect(wfi->hwnd, &update_rect, FALSE); InvalidateRect(wfi->hwnd, &update_rect, FALSE);
} }
} }
@ -115,6 +113,69 @@ void wf_hw_end_paint(rdpUpdate* update)
} }
void wf_bitmap_size(rdpUpdate* update, uint32* size)
{
*size = sizeof(wfBitmap);
}
void wf_bitmap_new(rdpUpdate* update, wfBitmap* bitmap)
{
HDC hdc;
uint8* data;
rdpBitmap* _bitmap;
wfInfo* wfi = GET_WFI(update);
hdc = GetDC(NULL);
bitmap->hdc = CreateCompatibleDC(hdc);
_bitmap = &(bitmap->_p);
data = _bitmap->dstData;
if (data == NULL)
bitmap->bitmap = CreateCompatibleBitmap(hdc, _bitmap->width, _bitmap->height);
else
bitmap->bitmap = wf_create_dib(wfi, _bitmap->width, _bitmap->height, _bitmap->bpp, data);
bitmap->org_bitmap = (HBITMAP) SelectObject(bitmap->hdc, bitmap->bitmap);
ReleaseDC(NULL, hdc);
}
void wf_offscreen_bitmap_new(rdpUpdate* update, wfBitmap* bitmap)
{
HDC hdc;
rdpBitmap* _bitmap;
wfInfo* wfi = GET_WFI(update);
hdc = GetDC(NULL);
bitmap->hdc = CreateCompatibleDC(hdc);
_bitmap = &(bitmap->_p);
bitmap->bitmap = CreateCompatibleBitmap(hdc, _bitmap->width, _bitmap->height);
bitmap->org_bitmap = (HBITMAP) SelectObject(bitmap->hdc, bitmap->bitmap);
ReleaseDC(NULL, hdc);
}
void wf_set_surface(rdpUpdate* update, wfBitmap* bitmap, boolean primary)
{
wfInfo* wfi = GET_WFI(update);
if (primary)
wfi->drawing = wfi->primary;
else
wfi->drawing = bitmap;
}
void wf_bitmap_free(rdpUpdate* update, wfBitmap* bitmap)
{
if (bitmap != 0)
{
SelectObject(bitmap->hdc, bitmap->org_bitmap);
DeleteObject(bitmap->bitmap);
DeleteDC(bitmap->hdc);
}
}
boolean wf_pre_connect(freerdp* instance) boolean wf_pre_connect(freerdp* instance)
{ {
int i1; int i1;
@ -160,10 +221,9 @@ boolean wf_pre_connect(freerdp* instance)
wfi->clrconv->alpha = 1; wfi->clrconv->alpha = 1;
wfi->clrconv->palette = NULL; wfi->clrconv->palette = NULL;
if (wfi->sw_gdi) wfi->cache = cache_new(settings);
{ instance->cache = (void*) wfi->cache;
wfi->cache = cache_new(instance->settings); instance->update->cache = instance->cache;
}
if (wfi->percentscreen > 0) if (wfi->percentscreen > 0)
{ {
@ -294,6 +354,20 @@ boolean wf_post_connect(freerdp* instance)
instance->update->EndPaint = wf_hw_end_paint; instance->update->EndPaint = wf_hw_end_paint;
} }
if (wfi->sw_gdi != True)
{
bitmap_cache_register_callbacks(instance->update);
wfi->cache->bitmap->BitmapSize = (cbBitmapSize) wf_bitmap_size;
wfi->cache->bitmap->BitmapNew = (cbBitmapNew) wf_bitmap_new;
wfi->cache->bitmap->BitmapFree = (cbBitmapFree) wf_bitmap_free;
offscreen_cache_register_callbacks(instance->update);
wfi->cache->offscreen->OffscreenBitmapSize = (cbOffscreenBitmapSize) wf_bitmap_size;
wfi->cache->offscreen->OffscreenBitmapNew = (cbOffscreenBitmapNew) wf_offscreen_bitmap_new;
wfi->cache->offscreen->OffscreenBitmapFree = (cbOffscreenBitmapFree) wf_bitmap_free;
wfi->cache->offscreen->SetSurface = (cbSetSurface) wf_set_surface;
}
freerdp_chanman_post_connect(GET_CHANMAN(instance), instance); freerdp_chanman_post_connect(GET_CHANMAN(instance), instance);
return True; return True;

View File

@ -40,19 +40,20 @@
#include "wf_event.h" #include "wf_event.h"
#define SET_WFI(_instance, _wfi) (_instance)->param1 = _wfi #define SET_WFI(_instance, _wfi) (_instance)->client = _wfi
#define GET_WFI(_instance) ((wfInfo*) ((_instance)->param1)) #define GET_WFI(_instance) ((wfInfo*) ((_instance)->client))
#define SET_CHANMAN(_instance, _chanman) (_instance)->param2 = _chanman #define SET_CHANMAN(_instance, _chanman) (_instance)->chanman = _chanman
#define GET_CHANMAN(_instance) ((rdpChanMan*) ((_instance)->param2)) #define GET_CHANMAN(_instance) ((rdpChanMan*) ((_instance)->chanman))
struct _WF_IMAGE struct wf_bitmap
{ {
rdpBitmap _p;
HDC hdc; HDC hdc;
HBITMAP bitmap; HBITMAP bitmap;
HBITMAP org_bitmap; HBITMAP org_bitmap;
}; };
typedef struct _WF_IMAGE WF_IMAGE; typedef struct wf_bitmap wfBitmap;
struct wf_info struct wf_info
{ {
@ -66,8 +67,8 @@ struct wf_info
uint16 srcBpp; uint16 srcBpp;
uint16 dstBpp; uint16 dstBpp;
freerdp* instance; freerdp* instance;
WF_IMAGE* primary; wfBitmap* primary;
WF_IMAGE* drawing; wfBitmap* drawing;
HCLRCONV clrconv; HCLRCONV clrconv;
HCURSOR cursor; HCURSOR cursor;
HBRUSH brush; HBRUSH brush;