mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-28 16:29:56 +00:00
Move RedPixmap::Format to RedDrawable::Format
We need to know the format for other drawables too (like for instance the native format of a window), so we're pushing this down. This changes a bunch of references to be RedDrawable::, but not all. The the old RedPixmap:: references still work, but will be phased out.
This commit is contained in:
parent
98d91203c5
commit
2d6fbde89b
@ -888,7 +888,7 @@ GUI::GUI(Application& app, Application::State state)
|
||||
: ScreenLayer (SCREEN_LAYER_GUI, false)
|
||||
, _app (app)
|
||||
, _state (state)
|
||||
, _pixmap (new RedPixmapCairo(MAIN_GUI_WIDTH, MAIN_GUI_HEIGHT, RedPixmap::RGB32, true, NULL))
|
||||
, _pixmap (new RedPixmapCairo(MAIN_GUI_WIDTH, MAIN_GUI_HEIGHT, RedDrawable::RGB32, true, NULL))
|
||||
, _renderer (new CEGUI::SoftRenderer(_pixmap->get_data(), MAIN_GUI_WIDTH, MAIN_GUI_HEIGHT,
|
||||
_pixmap->get_stride()))
|
||||
, _gui_system (new CEGUI::System(_renderer, new CEGUIResourceProvider()))
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
#ifndef _H_RED_DRAWABLE
|
||||
#define _H_RED_DRAWABLE
|
||||
|
||||
#include <pixman_utils.h>
|
||||
#include "pixels_source.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef uint32_t rgb32_t;
|
||||
|
||||
@ -47,6 +49,56 @@ public:
|
||||
RedDrawable() {}
|
||||
virtual ~RedDrawable() {}
|
||||
|
||||
enum Format {
|
||||
ARGB32,
|
||||
RGB32,
|
||||
RGB16_555,
|
||||
RGB16_565,
|
||||
A1,
|
||||
};
|
||||
|
||||
static int format_to_bpp(Format format) {
|
||||
if (format == RedDrawable::A1) {
|
||||
return 1;
|
||||
} else if (format == RGB16_555 || format == RGB16_565) {
|
||||
return 16;
|
||||
} else {
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
|
||||
static pixman_format_code_t format_to_pixman(Format format) {
|
||||
switch (format) {
|
||||
case RedDrawable::ARGB32:
|
||||
return PIXMAN_a8r8g8b8;
|
||||
case RedDrawable::RGB32:
|
||||
return PIXMAN_x8r8g8b8;
|
||||
case RedDrawable::RGB16_555:
|
||||
return PIXMAN_x1r5g5b5;
|
||||
case RedDrawable::RGB16_565:
|
||||
return PIXMAN_r5g6b5;
|
||||
case RedDrawable::A1:
|
||||
return PIXMAN_a1;
|
||||
default:
|
||||
THROW("unsupported format %d", format);
|
||||
}
|
||||
}
|
||||
|
||||
static Format format_from_surface(uint32_t format) {
|
||||
switch (format) {
|
||||
case SPICE_SURFACE_FMT_16_555:
|
||||
return RedDrawable::RGB16_555;
|
||||
case SPICE_SURFACE_FMT_16_565:
|
||||
return RedDrawable::RGB16_565;
|
||||
case SPICE_SURFACE_FMT_32_xRGB:
|
||||
return RedDrawable::RGB32;
|
||||
case SPICE_SURFACE_FMT_32_ARGB:
|
||||
return RedDrawable::ARGB32;
|
||||
default:
|
||||
THROW("Unsupported RedPixman format");
|
||||
}
|
||||
}
|
||||
|
||||
enum CombineOP {
|
||||
OP_COPY,
|
||||
OP_AND,
|
||||
|
||||
@ -30,7 +30,7 @@ GDICanvas::GDICanvas(int width, int height, uint32_t format,
|
||||
, _pixmap (0)
|
||||
{
|
||||
_pixmap = new RedPixmapGdi(width, height,
|
||||
RedPixmap::format_from_surface(format),
|
||||
RedDrawable::format_from_surface(format),
|
||||
true, NULL);
|
||||
if (!(_canvas = gdi_canvas_create(width, height, _pixmap->get_dc(),
|
||||
&_pixmap->get_mutex(),
|
||||
|
||||
@ -33,7 +33,7 @@ GCanvas::GCanvas(int width, int height, uint32_t format, RedWindow *win,
|
||||
, _textures_lost (false)
|
||||
{
|
||||
_pixmap = new RedPixmapGL(width, height,
|
||||
RedPixmap::format_from_surface(format),
|
||||
RedDrawable::format_from_surface(format),
|
||||
true, win, rendertype);
|
||||
if (!(_canvas = gl_canvas_create(width, height,
|
||||
SPICE_SURFACE_FMT_DEPTH(format),
|
||||
|
||||
@ -21,60 +21,9 @@
|
||||
|
||||
#include "red_drawable.h"
|
||||
#include "utils.h"
|
||||
#include <pixman_utils.h>
|
||||
|
||||
class RedPixmap: public RedDrawable {
|
||||
public:
|
||||
enum Format {
|
||||
ARGB32,
|
||||
RGB32,
|
||||
RGB16_555,
|
||||
RGB16_565,
|
||||
A1,
|
||||
};
|
||||
|
||||
static int format_to_bpp(Format format) {
|
||||
if (format == RedPixmap::A1) {
|
||||
return 1;
|
||||
} else if (format == RGB16_555 || format == RGB16_565) {
|
||||
return 16;
|
||||
} else {
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
|
||||
static pixman_format_code_t format_to_pixman(Format format) {
|
||||
switch (format) {
|
||||
case RedPixmap::ARGB32:
|
||||
return PIXMAN_a8r8g8b8;
|
||||
case RedPixmap::RGB32:
|
||||
return PIXMAN_x8r8g8b8;
|
||||
case RedPixmap::RGB16_555:
|
||||
return PIXMAN_x1r5g5b5;
|
||||
case RedPixmap::RGB16_565:
|
||||
return PIXMAN_r5g6b5;
|
||||
case RedPixmap::A1:
|
||||
return PIXMAN_a1;
|
||||
default:
|
||||
THROW("unsupported format %d", format);
|
||||
}
|
||||
}
|
||||
|
||||
static Format format_from_surface(uint32_t format) {
|
||||
switch (format) {
|
||||
case SPICE_SURFACE_FMT_16_555:
|
||||
return RedPixmap::RGB16_555;
|
||||
case SPICE_SURFACE_FMT_16_565:
|
||||
return RedPixmap::RGB16_565;
|
||||
case SPICE_SURFACE_FMT_32_xRGB:
|
||||
return RedPixmap::RGB32;
|
||||
case SPICE_SURFACE_FMT_32_ARGB:
|
||||
return RedPixmap::ARGB32;
|
||||
default:
|
||||
THROW("Unsupported RedPixman format");
|
||||
}
|
||||
}
|
||||
|
||||
RedPixmap(int width, int height, Format format, bool top_bottom);
|
||||
virtual ~RedPixmap();
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "debug.h"
|
||||
#include "utils.h"
|
||||
|
||||
RedPixmap::RedPixmap(int width, int height, RedPixmap::Format format,
|
||||
RedPixmap::RedPixmap(int width, int height, RedDrawable::Format format,
|
||||
bool top_bottom)
|
||||
: _format (format)
|
||||
, _width (width)
|
||||
@ -37,6 +37,6 @@ RedPixmap::~RedPixmap()
|
||||
|
||||
bool RedPixmap::is_big_endian_bits()
|
||||
{
|
||||
return _format == RedPixmap::A1;
|
||||
return _format == RedDrawable::A1;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
|
||||
bool top_bottom, RedWindow *win)
|
||||
: RedPixmap(width, height, format, top_bottom)
|
||||
{
|
||||
ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
|
||||
ASSERT(format == RedDrawable::ARGB32 || format == RedDrawable::RGB32 || format == RedDrawable::A1);
|
||||
ASSERT(sizeof(RedPixmap_p) <= PIXELES_SOURCE_OPAQUE_SIZE);
|
||||
|
||||
struct {
|
||||
@ -60,10 +60,10 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
|
||||
#endif*/
|
||||
|
||||
bitmap_info.inf.bmiHeader.biPlanes = 1;
|
||||
bitmap_info.inf.bmiHeader.biBitCount = RedPixmap::format_to_bpp(format);
|
||||
bitmap_info.inf.bmiHeader.biBitCount = RedDrawable::format_to_bpp(format);
|
||||
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
|
||||
switch (format) {
|
||||
case RedPixmap::A1:
|
||||
case RedDrawable::A1:
|
||||
bitmap_info.inf.bmiColors[0].rgbRed = 0;
|
||||
bitmap_info.inf.bmiColors[0].rgbGreen = 0;
|
||||
bitmap_info.inf.bmiColors[0].rgbBlue = 0;
|
||||
|
||||
@ -29,10 +29,10 @@ struct RedPixmap_p {
|
||||
HBITMAP prev_bitmap;
|
||||
};
|
||||
|
||||
RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool top_bottom)
|
||||
RedPixmapGdi::RedPixmapGdi(int width, int height, RedDrawable::Format format, bool top_bottom)
|
||||
: RedPixmap(width, height, format, top_bottom, pallet)
|
||||
{
|
||||
ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
|
||||
ASSERT(format == RedDrawable::ARGB32 || format == RedDrawable::RGB32 || format == RedDrawable::A1);
|
||||
ASSERT(sizeof(RedPixmap_p) <= PIXELES_SOURCE_OPAQUE_SIZE);
|
||||
|
||||
struct {
|
||||
@ -46,10 +46,10 @@ RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool
|
||||
bitmap_info.inf.bmiHeader.biHeight = top_bottom ? -_height : _height;
|
||||
|
||||
bitmap_info.inf.bmiHeader.biPlanes = 1;
|
||||
bitmap_info.inf.bmiHeader.biBitCount = RedPixmap::format_to_bpp(format);
|
||||
bitmap_info.inf.bmiHeader.biBitCount = RedDrawable::format_to_bpp(format);
|
||||
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
|
||||
switch (format) {
|
||||
case RedPixmap::A1:
|
||||
case RedDrawable::A1:
|
||||
bitmap_info.inf.bmiColors[0].rgbRed = 0;
|
||||
bitmap_info.inf.bmiColors[0].rgbGreen = 0;
|
||||
bitmap_info.inf.bmiColors[0].rgbBlue = 0;
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
#include "red_window_p.h"
|
||||
|
||||
|
||||
RedPixmapGL::RedPixmapGL(int width, int height, RedPixmap::Format format,
|
||||
RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format,
|
||||
bool top_bottom, RedWindow *win,
|
||||
RenderType rendertype)
|
||||
: RedPixmap(width, height, format, top_bottom)
|
||||
@ -41,7 +41,7 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedPixmap::Format format,
|
||||
Win xwin;
|
||||
//GLint max_texture_size;
|
||||
|
||||
ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
|
||||
ASSERT(format == RedDrawable::ARGB32 || format == RedDrawable::RGB32 || format == RedDrawable::A1);
|
||||
ASSERT(sizeof(RedDrawable_p) <= PIXELES_SOURCE_OPAQUE_SIZE);
|
||||
|
||||
((PixelsSource_p*)get_opaque())->type = PIXELS_SOURCE_TYPE_GL_TEXTURE;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user