44
46
#include "videoarch.h"
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];
52
void uicolor_init_video_colors();
49
#define DBG(_x_) log_debug _x_
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];
60
void uicolor_init_video_colors(void);
54
62
/*-----------------------------------------------------------------------*/
112
120
return ((color >> 24) & 0x000000ff) | ((color >> 8) & 0x0000ff00) | ((color << 8) & 0x00ff0000) | ((color << 24) & 0xff000000);
119
127
int uicolor_set_palette(struct video_canvas_s *c, const palette_t *palette)
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;
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,
136
GdkVisual *vis = c->gdk_image->visual;
140
gb = vis->green_prec;
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);
146
153
#ifdef WORDS_BIGENDIAN
147
swap = vis->byte_order == GDK_LSB_FIRST;
154
swap = (gdk_visual_get_byte_order(vis) == GDK_LSB_FIRST);
149
swap = vis->byte_order == GDK_MSB_FIRST;
156
swap = (gdk_visual_get_byte_order(vis) == GDK_MSB_FIRST);
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);
168
log_error(ui_log, "uicolor_set_palette: unsupported color space");
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. */
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));
158
187
for (i = 0; i < palette->num_entries; i++) {
159
188
palette_entry_t color = palette->entries[i];