diff options
Diffstat (limited to 'client/red_gl_canvas.cpp')
-rw-r--r-- | client/red_gl_canvas.cpp | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/client/red_gl_canvas.cpp b/client/red_gl_canvas.cpp index 2d285a5..dc743cf 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); |