libfreerdp-gdi: integrate libfreerdp-rfx
authorVic Lee <llyzs@163.com>
Wed, 10 Aug 2011 14:51:55 +0000 (22:51 +0800)
committerVic Lee <llyzs@163.com>
Wed, 10 Aug 2011 14:55:11 +0000 (22:55 +0800)
client/DirectFB/dfreerdp.c
libfreerdp-gdi/CMakeLists.txt
libfreerdp-gdi/decode.c [deleted file]
libfreerdp-gdi/decode.h [deleted file]
libfreerdp-gdi/gdi.c

index acb1311..bec65c6 100644 (file)
@@ -72,19 +72,6 @@ void df_end_paint(rdpUpdate* update)
        dfi->primary->Blit(dfi->primary, dfi->surface, &(dfi->update_rect), dfi->update_rect.x, dfi->update_rect.y);
 }
 
-void df_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
-{
-#if 0
-       printf("df_surface_bits: destLeft %d destTop %d destRight %d destBottom %d "
-               "bpp %d codecID %d width %d height %d length %d\n",
-               surface_bits_command->destLeft, surface_bits_command->destTop,
-               surface_bits_command->destRight, surface_bits_command->destBottom,
-               surface_bits_command->bpp, surface_bits_command->codecID,
-               surface_bits_command->width, surface_bits_command->height,
-               surface_bits_command->bitmapDataLength);
-#endif
-}
-
 boolean df_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount)
 {
        dfInfo* dfi;
@@ -194,7 +181,6 @@ boolean df_post_connect(freerdp* instance)
 
        instance->update->BeginPaint = df_begin_paint;
        instance->update->EndPaint = df_end_paint;
-       instance->update->SurfaceBits = df_surface_bits;
 
        df_keyboard_init();
 
@@ -266,11 +252,13 @@ int dfreerdp_run(freerdp* instance)
        void* wfds[32];
        fd_set rfds_set;
        fd_set wfds_set;
+       dfInfo* dfi;
        rdpChanMan* chanman;
 
        memset(rfds, 0, sizeof(rfds));
        memset(wfds, 0, sizeof(wfds));
 
+       dfi = GET_DFI(instance);
        chanman = GET_CHANMAN(instance);
 
        instance->Connect(instance);
@@ -345,6 +333,8 @@ int dfreerdp_run(freerdp* instance)
 
        freerdp_chanman_close(chanman, instance);
        freerdp_chanman_free(chanman);
+       xfree(dfi);
+       gdi_free(instance);
        freerdp_free(instance);
 
        return 0;
index 0550661..4132d91 100644 (file)
@@ -22,8 +22,6 @@ include_directories(../libfreerdp-cache)
 set(FREERDP_GDI_SRCS
        color.c
        color.h
-       decode.c
-       decode.h
        gdi_8bpp.c
        gdi_8bpp.h
        gdi_16bpp.c
@@ -56,6 +54,7 @@ set(FREERDP_GDI_SRCS
 add_library(freerdp-gdi SHARED ${FREERDP_GDI_SRCS})
 
 target_link_libraries(freerdp-gdi freerdp-cache)
+target_link_libraries(freerdp-gdi freerdp-rfx)
 
 set_target_properties(freerdp-gdi PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION})
 
diff --git a/libfreerdp-gdi/decode.c b/libfreerdp-gdi/decode.c
deleted file mode 100644 (file)
index eaef36e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Client
- * GDI RemoteFX Decoder
- *
- * Copyright 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <freerdp/freerdp.h>
-#include <freerdp/utils/stream.h>
-
-#include "gdi.h"
-#include "gdi_bitmap.h"
-#include "gdi_region.h"
-#include "gdi_clipping.h"
-
-#include "decode.h"
-
-void gdi_decode_frame(GDI *gdi, int x, int y, uint8 * data, uint32 length)
-{
-
-}
-
-void gdi_decode_data(GDI *gdi, uint8 * data, int data_size)
-{
-
-}
diff --git a/libfreerdp-gdi/decode.h b/libfreerdp-gdi/decode.h
deleted file mode 100644 (file)
index 1505440..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Client
- * GDI RemoteFX Decoder
- *
- * Copyright 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 __DECODE_H
-#define __DECODE_H
-
-#include <freerdp/freerdp.h>
-
-#include "gdi.h"
-
-void gdi_decode_frame(GDI *gdi, int x, int y, uint8 * data, uint32 length);
-void gdi_decode_data(GDI *gdi, uint8 * data, int data_size);
-
-#endif /* __DECODE_H */
index e216470..359c43b 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <freerdp/freerdp.h>
+#include <freerdp/constants.h>
+#include <freerdp/rfx.h>
 
 #include "color.h"
-#include "decode.h"
 
 #include "gdi_dc.h"
 #include "gdi_pen.h"
@@ -695,6 +696,38 @@ void gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush)
        brush_put(gdi->cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
 }
 
+void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
+{
+       GDI* gdi = GET_GDI(update);
+       RFX_CONTEXT* context = (RFX_CONTEXT*)gdi->rfx_context;
+       RFX_MESSAGE* message;
+       STREAM* s;
+
+       DEBUG_GDI("gdi_surface_bits: destLeft %d destTop %d destRight %d destBottom %d "
+               "bpp %d codecID %d width %d height %d length %d",
+               surface_bits_command->destLeft, surface_bits_command->destTop,
+               surface_bits_command->destRight, surface_bits_command->destBottom,
+               surface_bits_command->bpp, surface_bits_command->codecID,
+               surface_bits_command->width, surface_bits_command->height,
+               surface_bits_command->bitmapDataLength);
+
+       if (surface_bits_command->codecID == CODEC_ID_REMOTEFX)
+       {
+               s = stream_new(0);
+               stream_attach(s, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
+
+               message = rfx_process_message(context, s);
+               rfx_message_free(context, message);
+
+               stream_detach(s);
+               stream_free(s);
+       }
+       else
+       {
+               printf("Unsupported codecID %d\n", surface_bits_command->codecID);
+       }
+}
+
 /**
  * Register GDI callbacks with libfreerdp-core.
  * @param inst current instance
@@ -734,6 +767,8 @@ void gdi_register_update_callbacks(rdpUpdate* update)
        update->CacheBitmapV2 = gdi_cache_bitmap_v2;
        update->CacheColorTable = gdi_cache_color_table;
        update->CacheBrush = gdi_cache_brush;
+
+       update->SurfaceBits = gdi_surface_bits;
 }
 
 /**
@@ -811,6 +846,8 @@ int gdi_init(freerdp* instance, uint32 flags)
 
        gdi->cache = cache_new(instance->settings);
 
+       gdi->rfx_context = rfx_context_new();
+
        return 0;
 }
 
@@ -822,6 +859,7 @@ void gdi_free(freerdp* instance)
        {
                gdi_bitmap_free(gdi->primary);
                gdi_DeleteDC(gdi->hdc);
+               rfx_context_free((RFX_CONTEXT*)gdi->rfx_context);
                free(gdi->clrconv);
                free(gdi);
        }