summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/cursor_channel.cpp10
-rw-r--r--client/display_channel.cpp29
-rw-r--r--client/display_channel.h6
-rw-r--r--client/gui/gui.cpp3
-rw-r--r--client/red_cairo_canvas.cpp75
-rw-r--r--client/red_cairo_canvas.h10
-rw-r--r--client/red_gdi_canvas.cpp44
-rw-r--r--client/red_gdi_canvas.h9
-rw-r--r--client/red_gl_canvas.cpp55
-rw-r--r--client/red_gl_canvas.h7
-rw-r--r--client/red_pixmap.h49
-rw-r--r--client/red_pixmap_cairo.h3
-rw-r--r--client/red_pixmap_gdi.h3
-rw-r--r--client/red_pixmap_gl.h2
-rw-r--r--client/screen.cpp2
-rw-r--r--client/windows/red_pixmap.cpp4
-rw-r--r--client/windows/red_pixmap_cairo.cpp24
-rw-r--r--client/windows/red_pixmap_gdi.cpp21
-rw-r--r--client/x11/red_pixmap.cpp4
-rw-r--r--client/x11/red_pixmap_cairo.cpp26
-rw-r--r--client/x11/red_pixmap_gl.cpp4
21 files changed, 176 insertions, 214 deletions
diff --git a/client/cursor_channel.cpp b/client/cursor_channel.cpp
index 0dd9dcb6..289c059f 100644
--- a/client/cursor_channel.cpp
+++ b/client/cursor_channel.cpp
@@ -112,7 +112,7 @@ void UnsupportedCursor::draw(RedDrawable& dest, int x, int y, const SpiceRect& a
AlphaCursor::AlphaCursor(const SpiceCursorHeader& header, const uint8_t* data)
: _pixmap (new RedPixmapCairo(header.width, header.height,
- RedPixmap::ARGB32, true, NULL, NULL))
+ RedPixmap::ARGB32, true, NULL))
{
int stride = _pixmap->get_stride();
uint8_t* dest = _pixmap->get_data();
@@ -131,9 +131,8 @@ MonoCursor::MonoCursor(const SpiceCursorHeader& header, const uint8_t* data)
: _pixmap (NULL)
, _height (header.height)
{
- rgb32_t pallete[2] = { rgb32_make(0x00, 0x00, 0x00), rgb32_make(0xff, 0xff, 0xff)};
_pixmap.reset(new RedPixmapCairo(header.width, _height * 2, RedPixmap::A1,
- true, pallete, NULL));
+ true, NULL));
int dest_stride = _pixmap->get_stride();
uint8_t *dest_line = _pixmap->get_data();
@@ -177,12 +176,11 @@ private:
ColorCursor::ColorCursor(const SpiceCursorHeader& header)
: _pixmap (new RedPixmapCairo(header.width, header.height,
- RedPixmap::ARGB32, true, NULL, NULL))
+ RedPixmap::ARGB32, true, NULL))
, _invers (NULL)
{
- rgb32_t pallete[2] = { rgb32_make(0x00, 0x00, 0x00), rgb32_make(0xff, 0xff, 0xff)};
_invers.reset(new RedPixmapCairo(header.width, header.height, RedPixmap::A1,
- true, pallete, NULL));
+ true, NULL));
}
void ColorCursor::init_pixels(const SpiceCursorHeader& header, const uint8_t* pixels,
diff --git a/client/display_channel.cpp b/client/display_channel.cpp
index 719e7dfd..acbf5da7 100644
--- a/client/display_channel.cpp
+++ b/client/display_channel.cpp
@@ -1079,12 +1079,13 @@ void DisplayChannel::on_disconnect()
(*sync_event)->wait();
}
-bool DisplayChannel::create_cairo_canvas(int surface_id, int width, int height, int depth)
+bool DisplayChannel::create_cairo_canvas(int surface_id, int width, int height, uint32_t format)
{
try {
- CCanvas *canvas = new CCanvas(_pixmap_cache, _palette_cache, _glz_window,
+ CCanvas *canvas = new CCanvas(surface_id == 0, width, height, format,
+ screen()->get_window(),
+ _pixmap_cache, _palette_cache, _glz_window,
surfaces_mngr.get_surfaces());
- canvas->set_mode(width, height, depth, screen()->get_window());
surfaces_mngr.add_canvas(surface_id, canvas);
surfaces_mngr.add_surface(surface_id, canvas->get_internal_canvas());
if (surface_id == 0) {
@@ -1097,21 +1098,19 @@ bool DisplayChannel::create_cairo_canvas(int surface_id, int width, int height,
}
#ifdef USE_OGL
-bool DisplayChannel::create_ogl_canvas(int surface_id, int width, int height, int depth,
+bool DisplayChannel::create_ogl_canvas(int surface_id, int width, int height, uint32_t format,
bool recreate, RenderType rendertype)
{
try {
RedWindow *win;
- GCanvas *canvas = new GCanvas(_pixmap_cache,
+ win = screen()->get_window();
+ GCanvas *canvas = new GCanvas(width, height, format, win, rendertype,
+ _pixmap_cache,
_palette_cache,
_glz_window,
surfaces_mngr.get_surfaces());
- win = screen()->get_window();
-
- canvas->set_mode(width, height, depth, win, rendertype);
-
screen()->untouch_context();
surfaces_mngr.add_canvas(surface_id, canvas);
@@ -1129,12 +1128,12 @@ bool DisplayChannel::create_ogl_canvas(int surface_id, int width, int height, in
#endif
#ifdef WIN32
-bool DisplayChannel::create_gdi_canvas(int surface_id, int width, int height, int depth)
+bool DisplayChannel::create_gdi_canvas(int surface_id, int width, int height, uint32_t format)
{
try {
- GDICanvas *canvas = new GDICanvas(_pixmap_cache, _palette_cache, _glz_window,
+ GDICanvas *canvas = new GDICanvas(width, height, format,
+ _pixmap_cache, _palette_cache, _glz_window,
surfaces_mngr.get_surfaces());
- canvas->set_mode(width, height, depth);
surfaces_mngr.add_canvas(surface_id, canvas);
surfaces_mngr.add_surface(surface_id, canvas->get_internal_canvas());
if (surface_id == 0) {
@@ -1155,7 +1154,7 @@ void DisplayChannel::destroy_canvas(int surface_id)
if (!surfaces_mngr.is_present_canvas(surface_id)) {
return;
}
-
+
canvas = surfaces_mngr.get_canvas(surface_id);
#ifdef USE_OGL
@@ -1171,7 +1170,7 @@ void DisplayChannel::destroy_canvas(int surface_id)
}
void DisplayChannel::create_canvas(int surface_id, const std::vector<int>& canvas_types, int width,
- int height, int depth)
+ int height, uint32_t format)
{
#ifdef USE_OGL
bool recreate = true;
@@ -1417,7 +1416,7 @@ void DisplayChannel::handle_stream_destroy_all(RedPeer::InMessage* message)
destroy_strams();
}
-void DisplayChannel::create_primary_surface(int width, int height, int depth)
+void DisplayChannel::create_primary_surface(int width, int height, uint32_t format)
{
Canvas *canvas;
_mark = false;
diff --git a/client/display_channel.h b/client/display_channel.h
index 2bb697c5..a5761b35 100644
--- a/client/display_channel.h
+++ b/client/display_channel.h
@@ -133,13 +133,13 @@ protected:
private:
void set_draw_handlers();
void clear_draw_handlers();
- bool create_cairo_canvas(int surface_id, int width, int height, int depth);
+ bool create_cairo_canvas(int surface_id, int width, int height, uint32_t format);
#ifdef USE_OGL
- bool create_ogl_canvas(int surface_id, int width, int height, int depth, bool recreate,
+ bool create_ogl_canvas(int surface_id, int width, int height, uint32_t format, bool recreate,
RenderType rendertype);
#endif
#ifdef WIN32
- bool create_gdi_canvas(int surface_id, int width, int height, int depth);
+ bool create_gdi_canvas(int surface_id, int width, int height, uint32_t format);
#endif
void destroy_canvas(int surface_id);
void create_canvas(int surface_id, const std::vector<int>& canvas_type, int width, int height,
diff --git a/client/gui/gui.cpp b/client/gui/gui.cpp
index 0ff442e5..6debdd1b 100644
--- a/client/gui/gui.cpp
+++ b/client/gui/gui.cpp
@@ -888,8 +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,
- NULL))
+ , _pixmap (new RedPixmapCairo(MAIN_GUI_WIDTH, MAIN_GUI_HEIGHT, RedPixmap::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()))
diff --git a/client/red_cairo_canvas.cpp b/client/red_cairo_canvas.cpp
index 96f76375..9338d9ff 100644
--- a/client/red_cairo_canvas.cpp
+++ b/client/red_cairo_canvas.cpp
@@ -25,36 +25,44 @@
#include "region.h"
#include "red_pixmap_cairo.h"
-CCanvas::CCanvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache,
+CCanvas::CCanvas(bool onscreen,
+ int width, int height, uint32_t format, RedWindow *win,
+ PixmapCache& pixmap_cache, PaletteCache& palette_cache,
GlzDecoderWindow &glz_decoder_window, CSurfaces& csurfaces)
: Canvas (pixmap_cache, palette_cache, glz_decoder_window, csurfaces)
, _pixmap (0)
{
+ if (onscreen) {
+ _pixmap = new RedPixmapCairo(width, height,
+ RedPixmap::format_from_surface(format),
+ true, win);
+ _canvas = canvas_create_for_data(width, height, format,
+ _pixmap->get_data(),
+ _pixmap->get_stride(),
+ &pixmap_cache.base,
+ &palette_cache.base,
+ &csurfaces.base,
+ &glz_decoder());
+ } else {
+ _canvas = canvas_create(width, height, format,
+ &pixmap_cache.base,
+ &palette_cache.base,
+ &csurfaces.base,
+ &glz_decoder());
+ }
+ if (_canvas == NULL) {
+ THROW("create canvas failed");
+ }
}
CCanvas::~CCanvas()
{
- destroy();
-}
-
-void CCanvas::destroy()
-{
- if (_canvas) {
- _canvas->ops->destroy(_canvas);
- _canvas = NULL;
+ _canvas->ops->destroy(_canvas);
+ _canvas = NULL;
+ if (_pixmap) {
+ delete _pixmap;
+ _pixmap = NULL;
}
- destroy_pixmap();
-}
-
-void CCanvas::destroy_pixmap()
-{
- delete _pixmap;
- _pixmap = NULL;
-}
-
-void CCanvas::create_pixmap(int width, int height, RedWindow *win)
-{
- _pixmap = new RedPixmapCairo(width, height, RedPixmap::RGB32, true, NULL, win);
}
void CCanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc)
@@ -62,6 +70,8 @@ void CCanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc)
pixman_box32_t *rects;
int num_rects;
+ ASSERT(_pixmap != NULL);
+
rects = pixman_region32_rectangles((pixman_region32_t *)&region, &num_rects);
for (int i = 0; i < num_rects; i++) {
SpiceRect r;
@@ -79,29 +89,6 @@ void CCanvas::copy_pixels(const QRegion& region, RedDrawable* dest_dc, const Pix
copy_pixels(region, *dest_dc);
}
-void CCanvas::set_mode(int width, int height, int depth, RedWindow *win)
-{
- pixman_image_t *surface;
-
- destroy();
- create_pixmap(width, height, win);
- surface = pixman_image_create_bits(PIXMAN_x8r8g8b8, width, height,
- (uint32_t *)_pixmap->get_data(),
- _pixmap->get_stride());
- if (surface == NULL) {
- THROW("create surface failed, out of memory");
- }
-
- if (!(_canvas = canvas_create(surface, depth,
- &pixmap_cache().base,
- &palette_cache().base,
- &csurfaces().base,
- &glz_decoder()))) {
- THROW("create canvas failed");
- }
- pixman_image_unref (surface);
-}
-
CanvasType CCanvas::get_pixmap_type()
{
return CANVAS_TYPE_CAIRO;
diff --git a/client/red_cairo_canvas.h b/client/red_cairo_canvas.h
index 8d039bfb..9f4911bb 100644
--- a/client/red_cairo_canvas.h
+++ b/client/red_cairo_canvas.h
@@ -26,11 +26,12 @@ class RedPixmap;
class CCanvas: public Canvas {
public:
- CCanvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache,
+ CCanvas(bool onscreen,
+ int width, int height, uint32_t format, RedWindow *win,
+ PixmapCache& pixmap_cache, PaletteCache& palette_cache,
GlzDecoderWindow &glz_decoder_window, CSurfaces &csurfaces);
virtual ~CCanvas();
- virtual void set_mode(int x, int y, int bits, RedWindow *win);
virtual void thread_touch() {}
virtual void copy_pixels(const QRegion& region, RedDrawable* dc,
const PixmapHeader* pixmap);
@@ -39,11 +40,6 @@ public:
virtual CanvasType get_pixmap_type();
private:
- void create_pixmap(int width, int height, RedWindow *win);
- void destroy_pixmap();
- void destroy();
-
-private:
RedPixmap *_pixmap;
unsigned long _base;
unsigned long _max;
diff --git a/client/red_gdi_canvas.cpp b/client/red_gdi_canvas.cpp
index be7992c1..ae73ea2c 100644
--- a/client/red_gdi_canvas.cpp
+++ b/client/red_gdi_canvas.cpp
@@ -23,38 +23,33 @@
#include "region.h"
#include "red_pixmap_gdi.h"
-GDICanvas::GDICanvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache,
+GDICanvas::GDICanvas(int width, int height, uint32_t format,
+ PixmapCache& pixmap_cache, PaletteCache& palette_cache,
GlzDecoderWindow &glz_decoder_window, CSurfaces &csurfaces)
: Canvas (pixmap_cache, palette_cache, glz_decoder_window, csurfaces)
, _pixmap (0)
{
-}
-
-GDICanvas::~GDICanvas()
-{
- destroy();
-}
-
-void GDICanvas::destroy()
-{
- if (_canvas) {
- _canvas->ops->destroy(_canvas);
- _canvas = NULL;
+ _pixmap = new RedPixmapGdi(width, height,
+ RedPixmap::format_from_surface(format),
+ true, NULL);
+ if (!(_canvas = gdi_canvas_create(width, height, _pixmap->get_dc(),
+ &_pixmap->get_mutex(),
+ depth, &pixmap_cache().base,
+ &palette_cache().base,
+ &csurfaces().base,
+ &glz_decoder()))) {
+ THROW("create canvas failed");
}
- destroy_pixmap();
}
-void GDICanvas::destroy_pixmap()
+GDICanvas::~GDICanvas()
{
+ _canvas->ops->destroy(_canvas);
+ _canvas = NULL;
delete _pixmap;
_pixmap = NULL;
}
-void GDICanvas::create_pixmap(int width, int height)
-{
- _pixmap = new RedPixmapGdi(width, height, RedPixmap::RGB32, true, NULL);
-}
-
void GDICanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc)
{
pixman_box32_t *rects;
@@ -80,15 +75,6 @@ void GDICanvas::copy_pixels(const QRegion& region, RedDrawable* dest_dc, const P
void GDICanvas::set_mode(int width, int height, int depth)
{
destroy();
- create_pixmap(width, height);
- if (!(_canvas = gdi_canvas_create(width, height, _pixmap->get_dc(),
- &_pixmap->get_mutex(),
- depth, &pixmap_cache().base,
- &palette_cache().base,
- &csurfaces().base,
- &glz_decoder()))) {
- THROW("create canvas failed");
- }
}
CanvasType GDICanvas::get_pixmap_type()
diff --git a/client/red_gdi_canvas.h b/client/red_gdi_canvas.h
index d117282b..643f3c6c 100644
--- a/client/red_gdi_canvas.h
+++ b/client/red_gdi_canvas.h
@@ -27,11 +27,11 @@ class RedPixmap;
class GDICanvas: public Canvas {
public:
- GDICanvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache,
+ GDICanvas(int width, int height, uint32_t format,
+ PixmapCache& pixmap_cache, PaletteCache& palette_cache,
GlzDecoderWindow &glz_decoder_window, CSurfaces &csurfaces);
virtual ~GDICanvas();
- virtual void set_mode(int x, int y, int bits);
virtual void thread_touch() {}
virtual void copy_pixels(const QRegion& region, RedDrawable* dc,
const PixmapHeader* pixmap);
@@ -40,11 +40,6 @@ public:
virtual CanvasType get_pixmap_type();
private:
- void create_pixmap(int width, int height);
- void destroy_pixmap();
- void destroy();
-
-private:
RedPixmapGdi *_pixmap;
RedPixmapGdi *_helper_pixmap;
HDC _dc;
diff --git a/client/red_gl_canvas.cpp b/client/red_gl_canvas.cpp
index 2d285a50..dc743cfb 100644
--- a/client/red_gl_canvas.cpp
+++ b/client/red_gl_canvas.cpp
@@ -24,42 +24,36 @@
#include "red_pixmap_gl.h"
#include <GL/glx.h>
-GCanvas::GCanvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache,
+GCanvas::GCanvas(int width, int height, uint32_t format, RedWindow *win,
+ RenderType rendertype,
+ PixmapCache& pixmap_cache, PaletteCache& palette_cache,
GlzDecoderWindow &glz_decoder_window, CSurfaces &csurfaces)
: Canvas(pixmap_cache, palette_cache, glz_decoder_window, csurfaces)
, _pixmap (0)
, _textures_lost (false)
{
-}
-
-GCanvas::~GCanvas()
-{
- destroy();
-}
-
-void GCanvas::destroy()
-{
- if (_canvas) {
- gl_canvas_set_textures_lost (_canvas, (int)_textures_lost);
- _canvas->ops->destroy(_canvas);
- _canvas = NULL;
+ _pixmap = new RedPixmapGL(width, height,
+ RedPixmap::format_from_surface(format),
+ true, win, rendertype);
+ if (!(_canvas = gl_canvas_create(width, height,
+ SPICE_SURFACE_FMT_DEPTH(format),
+ &pixmap_cache.base,
+ &palette_cache.base,
+ &csurfaces.base,
+ &glz_decoder()))) {
+ THROW("create canvas failed");
}
- destroy_pixmap();
}
-void GCanvas::destroy_pixmap()
+GCanvas::~GCanvas()
{
+ gl_canvas_set_textures_lost (_canvas, (int)_textures_lost);
+ _canvas->ops->destroy(_canvas);
+ _canvas = NULL;
delete _pixmap;
_pixmap = NULL;
}
-void GCanvas::create_pixmap(int width, int height, RedWindow *win,
- RenderType rendertype)
-{
- _pixmap = new RedPixmapGL(width, height, RedPixmap::RGB32, true, NULL,
- win, rendertype);
-}
-
void GCanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc)
{
pixman_box32_t *rects;
@@ -83,21 +77,6 @@ void GCanvas::copy_pixels(const QRegion& region, RedDrawable* dest_dc, const Pix
copy_pixels(region, *dest_dc);
}
-void GCanvas::set_mode(int width, int height, int depth, RedWindow *win,
- RenderType rendertype)
-{
- destroy();
-
- create_pixmap(width, height, win, rendertype);
- if (!(_canvas = gl_canvas_create(width, height, depth,
- &pixmap_cache().base,
- &palette_cache().base,
- &csurfaces().base,
- &glz_decoder()))) {
- THROW("create canvas failed");
- }
-}
-
void GCanvas::touched_bbox(const SpiceRect *bbox)
{
_pixmap->update_texture(bbox);
diff --git a/client/red_gl_canvas.h b/client/red_gl_canvas.h
index 22491c49..dfe53d61 100644
--- a/client/red_gl_canvas.h
+++ b/client/red_gl_canvas.h
@@ -28,12 +28,13 @@ class RedPixmapGL;
class GCanvas: public Canvas {
public:
- GCanvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache,
+ GCanvas(int width, int height, uint32_t format, RedWindow *win,
+ RenderType rendertype,
+ PixmapCache& pixmap_cache, PaletteCache& palette_cache,
GlzDecoderWindow &glz_decoder_window, CSurfaces &csurfaces);
virtual ~GCanvas();
- void set_mode(int width, int height, int depth, RedWindow *win,
- RenderType rendertype);
+ void set_mode();
void clear();
void thread_touch() {}
void copy_pixels(const QRegion& region, RedDrawable* dc,
diff --git a/client/red_pixmap.h b/client/red_pixmap.h
index 1b469bdf..c81c2f77 100644
--- a/client/red_pixmap.h
+++ b/client/red_pixmap.h
@@ -20,17 +20,62 @@
#define _H_RED_PIXMAP
#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,
};
- RedPixmap(int width, int height, Format format, bool top_bottom,
- rgb32_t* pallete);
+ 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();
virtual SpicePoint get_size() { SpicePoint pt = {_width, _height}; return pt;}
diff --git a/client/red_pixmap_cairo.h b/client/red_pixmap_cairo.h
index 3f89db8f..7f9523e8 100644
--- a/client/red_pixmap_cairo.h
+++ b/client/red_pixmap_cairo.h
@@ -23,8 +23,7 @@
class RedPixmapCairo: public RedPixmap {
public:
- RedPixmapCairo(int width, int height, Format format, bool top_bottom,
- rgb32_t *pallete, RedWindow *win);
+ RedPixmapCairo(int width, int height, Format format, bool top_bottom, RedWindow *win);
~RedPixmapCairo();
};
diff --git a/client/red_pixmap_gdi.h b/client/red_pixmap_gdi.h
index 9e10adc1..524e6f31 100644
--- a/client/red_pixmap_gdi.h
+++ b/client/red_pixmap_gdi.h
@@ -25,8 +25,7 @@ class RecurciveMutex;
class RedPixmapGdi: public RedPixmap {
public:
- RedPixmapGdi(int width, int height, Format format, bool top_bottom,
- rgb32_t *pallete);
+ RedPixmapGdi(int width, int height, Format format, bool top_bottom);
HDC get_dc();
void *get_memptr();
~RedPixmapGdi();
diff --git a/client/red_pixmap_gl.h b/client/red_pixmap_gl.h
index f322d52c..f7a14af9 100644
--- a/client/red_pixmap_gl.h
+++ b/client/red_pixmap_gl.h
@@ -29,7 +29,7 @@ enum RenderType {
class RedPixmapGL: public RedPixmap {
public:
RedPixmapGL(int width, int height, Format format, bool top_bottom,
- rgb32_t *pallete, RedWindow *win, RenderType rendertype);
+ RedWindow *win, RenderType rendertype);
void textures_lost();
void touch_context();
diff --git a/client/screen.cpp b/client/screen.cpp
index f31a9a60..7edca121 100644
--- a/client/screen.cpp
+++ b/client/screen.cpp
@@ -172,7 +172,7 @@ void RedScreen::create_composit_area()
{
destroy_composit_area();
_composit_area = new RedPixmapCairo(_size.x, _size.y, RedPixmap::RGB32,
- false, NULL, NULL);
+ false, NULL);
}
void RedScreen::adjust_window_rect(int x, int y)
diff --git a/client/windows/red_pixmap.cpp b/client/windows/red_pixmap.cpp
index 1ec41faf..574d2851 100644
--- a/client/windows/red_pixmap.cpp
+++ b/client/windows/red_pixmap.cpp
@@ -21,11 +21,11 @@
#include "utils.h"
RedPixmap::RedPixmap(int width, int height, RedPixmap::Format format,
- bool top_bottom, rgb32_t* pallet)
+ bool top_bottom)
: _format (format)
, _width (width)
, _height (height)
- , _stride (SPICE_ALIGN(width * (_format == RedPixmap::A1 ? 1: 32), 32) / 8)
+ , _stride (SPICE_ALIGN(width * format_to_bpp(format), 32) / 8)
, _top_bottom (top_bottom)
, _data (NULL)
{
diff --git a/client/windows/red_pixmap_cairo.cpp b/client/windows/red_pixmap_cairo.cpp
index 6ed58068..793d21ed 100644
--- a/client/windows/red_pixmap_cairo.cpp
+++ b/client/windows/red_pixmap_cairo.cpp
@@ -29,14 +29,9 @@ struct RedPixmap_p {
HBITMAP prev_bitmap;
};
-static inline int format_to_bpp(RedPixmap::Format format)
-{
- return ((format == RedPixmap::A1) ? 1 : 32);
-}
-
-RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format, bool top_bottom,
- rgb32_t* pallet, RedWindow *win)
- : RedPixmap(width, height, format, top_bottom, pallet)
+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(sizeof(RedPixmap_p) <= PIXELES_SOURCE_OPAQUE_SIZE);
@@ -65,15 +60,16 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
#endif*/
bitmap_info.inf.bmiHeader.biPlanes = 1;
- bitmap_info.inf.bmiHeader.biBitCount = format_to_bpp(format);
+ bitmap_info.inf.bmiHeader.biBitCount = RedPixmap::format_to_bpp(format);
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
switch (format) {
case RedPixmap::A1:
- for (int i = 0; i < (1 << format_to_bpp(format)); i++) {
- bitmap_info.inf.bmiColors[i].rgbRed = rgb32_get_red(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbGreen = rgb32_get_green(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbBlue = rgb32_get_blue(pallet[i]);
- }
+ bitmap_info.inf.bmiColors[0].rgbRed = 0;
+ bitmap_info.inf.bmiColors[0].rgbGreen = 0;
+ bitmap_info.inf.bmiColors[0].rgbBlue = 0;
+ bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
break;
}
AutoDC dc(create_compatible_dc());
diff --git a/client/windows/red_pixmap_gdi.cpp b/client/windows/red_pixmap_gdi.cpp
index d4913c49..1c90f3d5 100644
--- a/client/windows/red_pixmap_gdi.cpp
+++ b/client/windows/red_pixmap_gdi.cpp
@@ -29,13 +29,7 @@ struct RedPixmap_p {
HBITMAP prev_bitmap;
};
-static inline int format_to_bpp(RedPixmap::Format format)
-{
- return ((format == RedPixmap::A1) ? 1 : 32);
-}
-
-RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool top_bottom,
- rgb32_t* pallet)
+RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool top_bottom)
: RedPixmap(width, height, format, top_bottom, pallet)
{
ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
@@ -52,15 +46,16 @@ 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 = format_to_bpp(format);
+ bitmap_info.inf.bmiHeader.biBitCount = RedPixmap::format_to_bpp(format);
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
switch (format) {
case RedPixmap::A1:
- for (int i = 0; i < (1 << format_to_bpp(format)); i++) {
- bitmap_info.inf.bmiColors[i].rgbRed = rgb32_get_red(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbGreen = rgb32_get_green(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbBlue = rgb32_get_blue(pallet[i]);
- }
+ bitmap_info.inf.bmiColors[0].rgbRed = 0;
+ bitmap_info.inf.bmiColors[0].rgbGreen = 0;
+ bitmap_info.inf.bmiColors[0].rgbBlue = 0;
+ bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
break;
}
AutoDC dc(create_compatible_dc());
diff --git a/client/x11/red_pixmap.cpp b/client/x11/red_pixmap.cpp
index 09455dd3..2a0eb99b 100644
--- a/client/x11/red_pixmap.cpp
+++ b/client/x11/red_pixmap.cpp
@@ -21,11 +21,11 @@
#include "utils.h"
RedPixmap::RedPixmap(int width, int height, RedPixmap::Format format,
- bool top_bottom, rgb32_t* pallet)
+ bool top_bottom)
: _format (format)
, _width (width)
, _height (height)
- , _stride (SPICE_ALIGN(width * (_format == RedPixmap::A1 ? 1 : 32), 32) / 8)
+ , _stride (SPICE_ALIGN(width * format_to_bpp(format), 32) / 8)
, _top_bottom (top_bottom)
, _data (NULL)
{
diff --git a/client/x11/red_pixmap_cairo.cpp b/client/x11/red_pixmap_cairo.cpp
index e73b8b41..1974ebc4 100644
--- a/client/x11/red_pixmap_cairo.cpp
+++ b/client/x11/red_pixmap_cairo.cpp
@@ -26,10 +26,12 @@
RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
- bool top_bottom, rgb32_t* pallet, RedWindow *win)
- : RedPixmap(width, height, format, top_bottom, pallet)
+ bool top_bottom, RedWindow *win)
+ : RedPixmap(width, height, format, top_bottom)
{
- ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
+ ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 ||
+ format == RedPixmap::RGB16_555 || format == RedPixmap::RGB16_565 ||
+ format == RedPixmap::A1);
ASSERT(sizeof(RedDrawable_p) <= PIXELES_SOURCE_OPAQUE_SIZE);
pixman_image_t *pixman_image;
XImage *image = NULL;
@@ -49,22 +51,8 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
using_shm = vinfo && XPlatform::is_x_shm_avail();
if (using_shm) {
- int depth;
-
- switch (format) {
- case RedPixmap::ARGB32:
- case RedPixmap::RGB32:
- depth = XPlatform::get_vinfo()[0]->depth;
- pixman_format = format == RedPixmap::ARGB32 ? PIXMAN_a8r8g8b8 :
- PIXMAN_x8r8g8b8;
- break;
- case RedPixmap::A1:
- depth = 1;
- pixman_format = PIXMAN_a1;
- break;
- default:
- THROW("unsupported format %d", format);
- }
+ int depth = RedPixmap::format_to_bpp(format);
+ pixman_format = RedPixmap::format_to_pixman(format);
shminfo = new XShmSegmentInfo;
shminfo->shmid = -1;
diff --git a/client/x11/red_pixmap_gl.cpp b/client/x11/red_pixmap_gl.cpp
index 2722476d..a3096517 100644
--- a/client/x11/red_pixmap_gl.cpp
+++ b/client/x11/red_pixmap_gl.cpp
@@ -31,9 +31,9 @@
RedPixmapGL::RedPixmapGL(int width, int height, RedPixmap::Format format,
- bool top_bottom, rgb32_t* pallet, RedWindow *win,
+ bool top_bottom, RedWindow *win,
RenderType rendertype)
- : RedPixmap(width, height, format, top_bottom, pallet)
+ : RedPixmap(width, height, format, top_bottom)
{
GLuint fbo;
GLuint tex;