summaryrefslogtreecommitdiffstats
path: root/client/red_gl_canvas.cpp
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-04-19 16:19:43 +0200
committerAlexander Larsson <alexl@redhat.com>2010-04-23 16:36:35 +0200
commit98d91203c5d2f6f7249f38941466857b6a566f5d (patch)
treecdc2b54152f0be3d668ed49b903a35886fcc1c99 /client/red_gl_canvas.cpp
parent619c37af17406f77c7cb76f3b72bbfc268383d91 (diff)
downloadspice-98d91203c5d2f6f7249f38941466857b6a566f5d.tar.gz
spice-98d91203c5d2f6f7249f38941466857b6a566f5d.tar.xz
spice-98d91203c5d2f6f7249f38941466857b6a566f5d.zip
Make client canvas and pixmaps handle more formats and simplify
We now support 16bit format pixmaps as well as the old ones. Including both 555 and 565 modes. We drop the palette argument for pixmap construction as it was only used for black/white anyway. Canvas creation is simplified so that there is no separate set_mode state. Canvases are already created in the right mode and never change.
Diffstat (limited to 'client/red_gl_canvas.cpp')
-rw-r--r--client/red_gl_canvas.cpp55
1 files changed, 17 insertions, 38 deletions
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);