~ubuntu-branches/ubuntu/utopic/vice/utopic-proposed

« back to all changes in this revision

Viewing changes to src/arch/unix/x11/gnome/uicolor.c

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2014-05-10 21:08:23 UTC
  • mfrom: (17.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140510210823-v5aojvy1pv1sg132
Tags: 2.4.dfsg+2.4.6-1ubuntu1
Use autotools-dev to update config.{sub,guess} for new arches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 *
27
27
 */
28
28
 
 
29
/* #define DEBUG_GNOMEUI */
 
30
 
29
31
#include "vice.h"
30
32
 
31
33
#include <stdlib.h>
43
45
#include "video.h"
44
46
#include "videoarch.h"
45
47
 
46
 
 
47
 
extern int screen;
48
 
extern GdkColor drive_led_on_red_pixel, drive_led_on_green_pixel, drive_led_off_pixel, motor_running_pixel, tape_control_pixel;
49
 
extern GdkColor drive_led_on_red_pixels[16];
50
 
extern GdkColor drive_led_on_green_pixels[16];
51
 
 
52
 
void uicolor_init_video_colors();
 
48
#ifdef DEBUG_GNOMEUI
 
49
#define DBG(_x_) log_debug _x_
 
50
#else
 
51
#define DBG(_x_)
 
52
#endif
 
53
 
 
54
/* UI color constants shared by GUI elements */
 
55
GdkColor drive_led_on_red_pixel, drive_led_on_green_pixel;
 
56
GdkColor drive_led_off_pixel, motor_running_pixel, tape_control_pixel;
 
57
GdkColor drive_led_on_red_pixels[16];
 
58
GdkColor drive_led_on_green_pixels[16];
 
59
 
 
60
void uicolor_init_video_colors(void);
53
61
 
54
62
/*-----------------------------------------------------------------------*/
55
63
 
111
119
    if (bpp == 32) {
112
120
        return ((color >> 24) & 0x000000ff) | ((color >>  8) & 0x0000ff00) | ((color <<  8) & 0x00ff0000) | ((color << 24) & 0xff000000);
113
121
    }
114
 
    
 
122
 
115
123
    /* err? */
116
124
    return color;
117
125
}
118
126
 
119
127
int uicolor_set_palette(struct video_canvas_s *c, const palette_t *palette)
120
128
{
121
 
    unsigned int i, rs, gs, bs, rb, gb, bb, bpp, swap;
 
129
    unsigned int i, bpp, swap;
 
130
    gint rs, gs, bs, rb, gb, bb;
122
131
 
123
132
    /* Hwscaled colours are expected in GL_RGB order. 24 bpp renderers are
124
133
     * special, they always seem to expect color order to be logically ABGR,
133
142
        bs = 16;
134
143
        swap = 0;
135
144
    } else {
136
 
        GdkVisual *vis = c->gdk_image->visual;
137
 
 
138
 
        bpp = vis->depth;
139
 
        rb = vis->red_prec;
140
 
        gb = vis->green_prec;
141
 
        bb = vis->blue_prec;
142
 
        rs = vis->red_shift;
143
 
        gs = vis->green_shift;
144
 
        bs = vis->blue_shift;
 
145
#if !defined(HAVE_CAIRO)
 
146
        /* GdkImage is deprecated since 2.22 and removed in 3.0 */
 
147
        GdkVisual *vis = gdk_image_get_visual(c->gdk_image);
 
148
        bpp = gdk_visual_get_depth(vis);
 
149
        gdk_visual_get_red_pixel_details(vis, NULL, &rs, &rb);
 
150
        gdk_visual_get_green_pixel_details(vis, NULL, &gs, &gb);
 
151
        gdk_visual_get_blue_pixel_details(vis, NULL, &bs, &bb);
145
152
 
146
153
#ifdef WORDS_BIGENDIAN
147
 
        swap = vis->byte_order == GDK_LSB_FIRST;
 
154
        swap = (gdk_visual_get_byte_order(vis) == GDK_LSB_FIRST);
148
155
#else
149
 
        swap = vis->byte_order == GDK_MSB_FIRST;
 
156
        swap = (gdk_visual_get_byte_order(vis) == GDK_MSB_FIRST);
150
157
#endif
151
158
 
 
159
#else
 
160
        if (gdk_pixbuf_get_colorspace(c->gdk_pixbuf) == GDK_COLORSPACE_RGB) {
 
161
            bpp = gdk_pixbuf_get_n_channels(c->gdk_pixbuf) * gdk_pixbuf_get_bits_per_sample(c->gdk_pixbuf);
 
162
            rb = gb = bb = gdk_pixbuf_get_bits_per_sample(c->gdk_pixbuf);
 
163
            rs = 0;
 
164
            gs = 8;
 
165
            bs = 16;
 
166
            swap = 0;
 
167
        } else {
 
168
            log_error(ui_log, "uicolor_set_palette: unsupported color space");
 
169
            bpp = 24;
 
170
            rb = 8;
 
171
            gb = 8;
 
172
            bb = 8;
 
173
            rs = 0;
 
174
            gs = 8;
 
175
            bs = 16;
 
176
            swap = 0;
 
177
        }
 
178
#endif
152
179
        /* 24 bpp modes do not really work with the existing
153
180
         * arrangement as they have been written to assume the A component is
154
181
         * in the 32-bit longword bits 24-31. If any arch needs 24 bpp, that
155
182
         * code must be specially written for it. */
156
183
    }
 
184
    
 
185
    DBG(("bpp:%d rb:%d gb:%d bb:%d rs:%d gs:%d bs:%d swap:%d", bpp, rb, gb, bb, rs, gs, bs, swap));
157
186
 
158
187
    for (i = 0; i < palette->num_entries; i++) {
159
188
        palette_entry_t color = palette->entries[i];