diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-02-17 21:33:23 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-02-23 22:52:06 +0100 |
commit | 98dde80ed3c01f6ac08bcd14d34d6643da9f8418 (patch) | |
tree | a872eb82b7012195c4dd08dc7d2115f0cfac7e71 /client | |
parent | 8f912e49179803fa640b3bddf75b62e81b2f7178 (diff) | |
download | spice-98dde80ed3c01f6ac08bcd14d34d6643da9f8418.tar.gz spice-98dde80ed3c01f6ac08bcd14d34d6643da9f8418.tar.xz spice-98dde80ed3c01f6ac08bcd14d34d6643da9f8418.zip |
Replace custom region implementation with pixman_region32_t
pixman_region32_t is an efficient well tested region implementation (its
the one used in X) that we already depend on via pixman and use in
some places. No need to have a custom region implementation.
Diffstat (limited to 'client')
-rw-r--r-- | client/application.cpp | 20 | ||||
-rw-r--r-- | client/canvas.h | 3 | ||||
-rw-r--r-- | client/cursor_channel.cpp | 14 | ||||
-rw-r--r-- | client/gui/gui.cpp | 26 | ||||
-rw-r--r-- | client/red_cairo_canvas.cpp | 15 | ||||
-rw-r--r-- | client/red_gl_canvas.cpp | 16 | ||||
-rw-r--r-- | client/screen.cpp | 50 | ||||
-rw-r--r-- | client/screen_layer.cpp | 21 | ||||
-rw-r--r-- | client/x11/red_window.cpp | 5 |
9 files changed, 135 insertions, 35 deletions
diff --git a/client/application.cpp b/client/application.cpp index cca7d434..0fa25b4f 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -171,13 +171,23 @@ InfoLayer::InfoLayer() void InfoLayer::draw_info(const QRegion& dest_region, RedDrawable& dest) { - for (int i = 0; i < (int)dest_region.num_rects; i++) { - SpiceRect* r = &dest_region.rects[i]; + pixman_box32_t *rects; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)&dest_region, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + /* is rect inside sticky region or info region? */ - if (_sticky_on && rect_intersects(*r, _sticky_rect)) { - dest.blend_pixels(_sticky_pixmap, r->left - _sticky_pos.x, r->top - _sticky_pos.y, *r); + if (_sticky_on && rect_intersects(r, _sticky_rect)) { + dest.blend_pixels(_sticky_pixmap, r.left - _sticky_pos.x, r.top - _sticky_pos.y, r); } else { - dest.blend_pixels(_info_pixmap, r->left - _info_pos.x, r->top - _info_pos.y, *r); + dest.blend_pixels(_info_pixmap, r.left - _info_pos.x, r.top - _info_pos.y, r); } } } diff --git a/client/canvas.h b/client/canvas.h index 1bd3180f..65856565 100644 --- a/client/canvas.h +++ b/client/canvas.h @@ -20,6 +20,7 @@ #include "common.h" #include "debug.h" +#include "region.h" #include "cairo.h" #include <spice/protocol.h> #include "cache.hpp" @@ -36,8 +37,6 @@ enum CanvasType { CANVAS_TYPE_GDI, }; -struct QRegion; - class PixmapCacheTreat { public: static inline pixman_image_t *get(pixman_image_t *surf) diff --git a/client/cursor_channel.cpp b/client/cursor_channel.cpp index 30c52d9d..0909f5c6 100644 --- a/client/cursor_channel.cpp +++ b/client/cursor_channel.cpp @@ -434,16 +434,26 @@ void CursorChannel::remove_cursor() void CursorChannel::copy_pixels(const QRegion& dest_region, RedDrawable& dest_dc) { + pixman_box32_t *rects; + int num_rects; + Lock lock(_update_lock); if (!_cursor_visible) { return; } - for (int i = 0; i < (int)dest_region.num_rects; i++) { + rects = pixman_region32_rectangles((pixman_region32_t *)&dest_region, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; ASSERT(_cursor && _cursor->get_opaque()); ((NaitivCursor*)_cursor->get_opaque())->draw(dest_dc, _cursor_rect.left, _cursor_rect.top, - dest_region.rects[i]); + r); } } diff --git a/client/gui/gui.cpp b/client/gui/gui.cpp index e4d69ee0..0ff442e5 100644 --- a/client/gui/gui.cpp +++ b/client/gui/gui.cpp @@ -1025,19 +1025,33 @@ void GUI::update_layer_area() void GUI::copy_pixels(const QRegion& dest_region, RedDrawable& dest) { + pixman_box32_t *rects; + int num_rects; + if (region_is_empty(&dest_region)) { return; } - for (int i = 0; i < (int)dest_region.num_rects; i++) { - SpiceRect* r = &dest_region.rects[i]; - _pixmap->copy_pixels(dest, r->left, r->top, *r); + rects = pixman_region32_rectangles((pixman_region32_t *)&dest_region, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + _pixmap->copy_pixels(dest, r.left, r.top, r); } _gui_system->renderGUI(); - for (int i = 0; i < (int)dest_region.num_rects; i++) { - SpiceRect* r = &dest_region.rects[i]; - dest.copy_pixels(*_pixmap, r->left, r->top, *r); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + dest.copy_pixels(*_pixmap, r.left, r.top, r); } } diff --git a/client/red_cairo_canvas.cpp b/client/red_cairo_canvas.cpp index 80a89b75..c2496ff4 100644 --- a/client/red_cairo_canvas.cpp +++ b/client/red_cairo_canvas.cpp @@ -68,9 +68,18 @@ void CCanvas::create_pixmap(int width, int height, RedWindow *win) void CCanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc) { - for (int i = 0; i < (int)region.num_rects; i++) { - SpiceRect* r = ®ion.rects[i]; - dest_dc.copy_pixels(*_pixmap, r->left, r->top, *r); + pixman_box32_t *rects; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)®ion, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + dest_dc.copy_pixels(*_pixmap, r.left, r.top, r); } } diff --git a/client/red_gl_canvas.cpp b/client/red_gl_canvas.cpp index 43bf4249..65984257 100644 --- a/client/red_gl_canvas.cpp +++ b/client/red_gl_canvas.cpp @@ -69,9 +69,19 @@ void GCanvas::create_pixmap(int width, int height, RedWindow *win, void GCanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc) { - for (int i = 0; i < (int)region.num_rects; i++) { - SpiceRect* r = ®ion.rects[i]; - dest_dc.copy_pixels(*_pixmap, r->left, r->top, *r); + pixman_box32_t *rects; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)®ion, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + + dest_dc.copy_pixels(*_pixmap, r.left, r.top, r); } } diff --git a/client/screen.cpp b/client/screen.cpp index 9e6b04ee..40e06764 100644 --- a/client/screen.cpp +++ b/client/screen.cpp @@ -288,9 +288,18 @@ void RedScreen::detach_layer(ScreenLayer& layer) void RedScreen::composit_to_screen(RedDrawable& win_dc, const QRegion& region) { - for (int i = 0; i < (int)region.num_rects; i++) { - SpiceRect* r = ®ion.rects[i]; - win_dc.copy_pixels(*_composit_area, r->left, r->top, *r); + pixman_box32_t *rects; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)®ion, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + win_dc.copy_pixels(*_composit_area, r.left, r.top, r); } } @@ -474,17 +483,40 @@ uint64_t RedScreen::invalidate(const SpiceRect& rect, bool urgent) void RedScreen::invalidate(const QRegion ®ion) { - SpiceRect *r = region.rects; - SpiceRect *end = r + region.num_rects; - while (r != end) { - invalidate(*r++, false); + pixman_box32_t *rects, *end; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)®ion, &num_rects); + end = rects + num_rects; + + while (rects != end) { + SpiceRect r; + + r.left = rects->x1; + r.top = rects->y1; + r.right = rects->x2; + r.bottom = rects->y2; + rects++; + + invalidate(r, false); } } inline void RedScreen::erase_background(RedDrawable& dc, const QRegion& composit_rgn) { - for (int i = 0; i < (int)composit_rgn.num_rects; i++) { - dc.fill_rect(composit_rgn.rects[i], 0); + pixman_box32_t *rects; + int num_rects; + + rects = pixman_region32_rectangles((pixman_region32_t *)&composit_rgn, &num_rects); + for (int i = 0; i < num_rects; i++) { + SpiceRect r; + + r.left = rects[i].x1; + r.top = rects[i].y1; + r.right = rects[i].x2; + r.bottom = rects[i].y2; + + dc.fill_rect(r, 0); } } diff --git a/client/screen_layer.cpp b/client/screen_layer.cpp index af25211e..ef5ef95e 100644 --- a/client/screen_layer.cpp +++ b/client/screen_layer.cpp @@ -93,13 +93,26 @@ uint64_t ScreenLayer::invalidate(const SpiceRect& r, bool urgent) void ScreenLayer::invalidate(const QRegion& region) { + pixman_box32_t *rects, *end; + int num_rects; + if (!_screen) { return; } - SpiceRect *r = region.rects; - SpiceRect *end = r + region.num_rects; - while (r != end) { - invalidate_rect(*r++, false); + + rects = pixman_region32_rectangles((pixman_region32_t *)®ion, &num_rects); + end = rects + num_rects; + + while (rects != end) { + SpiceRect r; + + r.left = rects->x1; + r.top = rects->y1; + r.right = rects->x2; + r.bottom = rects->y2; + rects++; + + invalidate_rect(r, false); } } diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp index 49c5533c..a38f7db6 100644 --- a/client/x11/red_window.cpp +++ b/client/x11/red_window.cpp @@ -1835,7 +1835,10 @@ public: if (region_is_empty(_region)) { bbox.left = bbox.right = bbox.top = bbox.bottom = 0; } else { - bbox = _region->bbox; + bbox.left = _region->extents.x1; + bbox.top = _region->extents.y1; + bbox.right = _region->extents.x2; + bbox.bottom = _region->extents.y2; } } |