/[rdesktop]/jpeg/rdesktop/trunk/xwin.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /jpeg/rdesktop/trunk/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1507 by dpavlin, Mon Jul 20 16:45:11 2009 UTC revision 1508 by dpavlin, Mon Jul 20 16:47:49 2009 UTC
# Line 30  Line 30 
30  #include "rdesktop.h"  #include "rdesktop.h"
31  #include "xproto.h"  #include "xproto.h"
32    
33    /* DJ globals begin */
34    extern uint8 * g_bitmap_data;
35    extern uint8 * g_bitmap_data_last_write;
36    extern uint32 g_pixels_changed;
37    extern unsigned long long g_time_last_change;
38    /* DJ globals end */
39    
40  extern int g_width;  extern int g_width;
41  extern int g_height;  extern int g_height;
42  extern int g_xpos;  extern int g_xpos;
# Line 2690  ui_create_bitmap(int width, int height, Line 2697  ui_create_bitmap(int width, int height,
2697  }  }
2698    
2699  void  void
2700    update_bitmap(int x, int y, int width, int height, uint8 * data)
2701    {
2702            int size;
2703            uint8 *out;
2704            uint8 *end;
2705            uint8 *c_current;
2706            uint8 *c_update;
2707            uint8 *c_written;
2708            int col;
2709            int row;
2710            BOOL matches_written;
2711            BOOL matches_current;
2712    
2713            size = width * height * 3;   /* force 24-bit color for libjpeg: R G B */
2714            out = (uint8 *) xmalloc(size);
2715            end = out + size;
2716    
2717            switch (g_server_depth)
2718            {
2719                    case 24:
2720                            translate24to24(data, out, end);
2721                            break;
2722                    case 16:
2723                            translate16to24((uint16 *) data, out, end);
2724                            break;
2725                    case 15:
2726                            translate15to24((uint16 *) data, out, end);
2727                            break;
2728                    case 8:
2729                            translate8to24(data, out, end);
2730                            break;
2731            }
2732    
2733            for (row=0; row<height; row++)
2734            {
2735                    /* truncate if out of bounds */
2736                    if (g_height <= (y + row))
2737                            break;
2738    
2739                    c_update = out + row * width * 3;
2740                    c_current = g_bitmap_data + (row + y) * g_width * 3 + x * 3;
2741                    c_written = g_bitmap_data_last_write + (row + y) * g_width * 3 + x * 3;
2742    
2743                    for (col = 0; col < width; col++)
2744                    {
2745                            /* truncate if out of bounds */
2746                            if (g_width <= (x + col))
2747                                    break;
2748    
2749                            matches_written = True;
2750                            matches_current = True;
2751    
2752                            /* updates come in as BGR order... force RGB */
2753                            if (*c_current != *(c_update+2))
2754                            {
2755                                    if (*(c_update+2) != *c_written)
2756                                            matches_written = False;
2757                                    matches_current = False;
2758                                    *c_current = *(c_update+2);
2759                            }
2760    
2761                            c_written++;
2762    
2763                            if (*(++c_current) != *(++c_update))
2764                            {
2765                                    if (*c_update != *c_written)
2766                                            matches_written = False;
2767                                    matches_current = False;
2768                                    *c_current = *c_update;
2769                            }
2770    
2771                            c_written++;
2772    
2773                            if (*(++c_current) != *(++c_update-2))
2774                            {
2775                                    if (*(c_update-2) != *c_written)
2776                                            matches_written = False;
2777                                    matches_current = False;
2778                                    *c_current = *(c_update-2);
2779                            }
2780    
2781                            c_written++;
2782                            c_current++;
2783                            c_update++;
2784    
2785                            if (!matches_current)
2786                            {
2787                                    if (matches_written)
2788                                            g_pixels_changed--;
2789                                    else
2790                                            g_pixels_changed++;
2791                            }
2792                    }
2793            }
2794    
2795            //printf("g_pixels_changed=%d\n", g_pixels_changed);
2796    
2797            xfree(out);
2798            g_time_last_change = tod();
2799    }
2800    
2801    void
2802  ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data)  ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data)
2803  {  {
2804          XImage *image;          XImage *image;
2805          uint8 *tdata;          uint8 *tdata;
2806          int bitmap_pad;          int bitmap_pad;
2807    
2808            update_bitmap(x, y, width, height, data);
2809    
2810          if (g_server_depth == 8)          if (g_server_depth == 8)
2811          {          {
2812                  bitmap_pad = 8;                  bitmap_pad = 8;

Legend:
Removed from v.1507  
changed lines
  Added in v.1508

  ViewVC Help
Powered by ViewVC 1.1.26