summaryrefslogtreecommitdiffstats
path: root/client/x11/red_drawable.cpp
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-02-19 16:48:55 +0100
committerAlexander Larsson <alexl@redhat.com>2010-02-23 22:52:06 +0100
commit295738b453f44f43a941d072290c5e975c3a6cb4 (patch)
tree87a160082a6c8ed13ab657902398ea7f2c11c16a /client/x11/red_drawable.cpp
parent1caa4b65c54e4371fe7f6eeda0a356e70663bb28 (diff)
downloadspice-295738b453f44f43a941d072290c5e975c3a6cb4.tar.gz
spice-295738b453f44f43a941d072290c5e975c3a6cb4.tar.xz
spice-295738b453f44f43a941d072290c5e975c3a6cb4.zip
Remove cairo use in client
Diffstat (limited to 'client/x11/red_drawable.cpp')
-rw-r--r--client/x11/red_drawable.cpp199
1 files changed, 119 insertions, 80 deletions
diff --git a/client/x11/red_drawable.cpp b/client/x11/red_drawable.cpp
index 7485c94d..e020b845 100644
--- a/client/x11/red_drawable.cpp
+++ b/client/x11/red_drawable.cpp
@@ -237,18 +237,18 @@ static inline void copy_to_pixmap_from_shmdrawable(const RedDrawable_p* dest,
const PixelsSource_p* source,
int src_x, int src_y)
{
- cairo_t* cairo = dest->cairo;
- cairo_surface_t* surf = source->x_shm_drawable.cairo_surf;
-
- ASSERT(cairo);
- ASSERT(surf);
-
- cairo_set_source_surface(cairo, surf, area.left + offset.x - src_x,
- area.top + offset.y - src_y);
- cairo_set_operator(cairo, CAIRO_OPERATOR_RASTER_COPY);
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_fill(cairo);
+ pixman_image_t *dest_surface = dest->source.pixmap.pixman_image;
+ pixman_image_t *src_surface = source->x_shm_drawable.pixman_image;
+
+ pixman_image_composite32(PIXMAN_OP_SRC,
+ src_surface, NULL, dest_surface,
+ src_x + offset.x,
+ src_y + offset.y,
+ 0, 0,
+ area.left + offset.x,
+ area.top + offset.y,
+ area.right - area.left,
+ area.bottom - area.top);
}
static inline void copy_to_pixmap_from_pixmap(const RedDrawable_p* dest,
@@ -257,18 +257,18 @@ static inline void copy_to_pixmap_from_pixmap(const RedDrawable_p* dest,
const PixelsSource_p* source,
int src_x, int src_y)
{
- cairo_t* cairo = dest->cairo;
- cairo_surface_t* surf = source->pixmap.cairo_surf;
-
- ASSERT(cairo);
- ASSERT(surf);
-
- cairo_set_source_surface(cairo, surf, area.left + offset.x - src_x,
- area.top + offset.y - src_y);
- cairo_set_operator(cairo, CAIRO_OPERATOR_RASTER_COPY);
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_fill(cairo);
+ pixman_image_t *dest_surface = dest->source.pixmap.pixman_image;
+ pixman_image_t *src_surface = source->pixmap.pixman_image;
+
+ pixman_image_composite32(PIXMAN_OP_SRC,
+ src_surface, NULL, dest_surface,
+ src_x + offset.x,
+ src_y + offset.y,
+ 0, 0,
+ area.left + offset.x,
+ area.top + offset.y,
+ area.right - area.left,
+ area.bottom - area.top);
}
static inline void copy_to_pixmap_from_gltexture(const RedDrawable_p* dest,
@@ -384,18 +384,18 @@ static inline void blend_to_pixmap_from_pixmap(const RedDrawable_p* dest,
const PixelsSource_p* source,
int src_x, int src_y)
{
- cairo_t* cairo = dest->cairo;
- cairo_surface_t* surf = source->pixmap.cairo_surf;
-
- ASSERT(cairo);
- ASSERT(surf);
-
- cairo_set_source_surface(cairo, surf, (area.left + offset.x - src_x),
- (area.top + offset.y - src_y));
- cairo_set_operator(cairo, CAIRO_OPERATOR_ATOP);
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_fill(cairo);
+ pixman_image_t *dest_surface = dest->source.pixmap.pixman_image;
+ pixman_image_t *src_surface = source->pixmap.pixman_image;
+
+ pixman_image_composite32 (PIXMAN_OP_ATOP,
+ src_surface, NULL, dest_surface,
+ src_x + offset.x,
+ src_y + offset.y,
+ 0, 0,
+ area.left + offset.x,
+ area.top + offset.y,
+ area.right - area.left,
+ area.bottom - area.top);
}
static inline void blend_to_pixmap(const RedDrawable_p* dest,
@@ -460,41 +460,74 @@ static inline void combine_to_pixmap_from_pixmap(const RedDrawable_p* dest,
int src_x, int src_y,
RedDrawable::CombineOP op)
{
- cairo_t* cairo = dest->cairo;
- cairo_surface_t* surf = source->pixmap.cairo_surf;
+ pixman_image_t *dest_surface = dest->source.pixmap.pixman_image;
+ pixman_image_t *src_surface = source->pixmap.pixman_image;
- ASSERT(cairo);
- ASSERT(surf);
- cairo_operator_t cairo_op;
+ SpiceROP rop;
switch (op) {
case RedDrawable::OP_COPY:
- cairo_op = CAIRO_OPERATOR_RASTER_COPY;
+ rop = SPICE_ROP_COPY;
break;
case RedDrawable::OP_AND:
- cairo_op = CAIRO_OPERATOR_RASTER_AND;
+ rop = SPICE_ROP_AND;
break;
case RedDrawable::OP_XOR:
- cairo_op = CAIRO_OPERATOR_RASTER_XOR;
+ rop = SPICE_ROP_XOR;
break;
default:
THROW("invalid op %d", op);
}
- cairo_set_operator(cairo, cairo_op);
- if (cairo_image_surface_get_format(surf) == CAIRO_FORMAT_A1) {
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_clip(cairo);
- cairo_set_source_rgb(cairo, 1, 1, 1);
- cairo_mask_surface(cairo, surf, area.left + offset.x - src_x, area.top + offset.y - src_y);
- cairo_reset_clip(cairo);
+ if (pixman_image_get_depth (src_surface) == 1) {
+ pixman_image_t *temp;
+
+ temp = pixman_image_create_bits(pixman_image_get_depth(dest_surface) == 24 ?
+ PIXMAN_x8r8g8b8 : PIXMAN_a8r8g8b8,
+ area.right - area.left,
+ area.bottom - area.top, NULL, 0);
+
+ /* Copy from dest to temp */
+ pixman_image_composite32(PIXMAN_OP_SRC,
+ dest_surface, NULL, temp,
+ area.left + offset.x,
+ area.top + offset.y,
+ 0, 0,
+ 0, 0,
+ area.right - area.left,
+ area.bottom - area.top);
+
+ /* rop white over temp */
+ spice_pixman_fill_rect_rop(temp,
+ 0, 0,
+ area.right - area.left,
+ area.bottom - area.top,
+ 0xffffff,
+ rop);
+
+ /* copy back using a1 mask */
+ pixman_image_composite32(PIXMAN_OP_SRC,
+ temp, src_surface, dest_surface,
+ 0, 0,
+ src_x + offset.x,
+ src_y + offset.y,
+ area.left + offset.x,
+ area.top + offset.y,
+ area.right - area.left,
+ area.bottom - area.top);
+
+ pixman_image_unref(temp);
+
} else {
- cairo_set_source_surface(cairo, surf, area.left + offset.x - src_x,
- area.top + offset.y - src_y);
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_fill(cairo);
+ spice_pixman_blit_rop(dest_surface,
+ src_surface,
+ src_x + offset.x,
+ src_y + offset.y,
+ area.left + offset.x,
+ area.top + offset.y,
+ area.right - area.left,
+ area.bottom - area.top,
+ rop);
}
}
@@ -606,17 +639,13 @@ static inline void fill_gl_drawable(RedDrawable_p* dest, const SpiceRect& area,
static inline void fill_pixmap(RedDrawable_p* dest, const SpiceRect& area, rgb32_t color,
const SpicePoint& offset)
{
- cairo_t* cairo = dest->cairo;
-
- ASSERT(cairo);
- cairo_set_source_rgb(cairo,
- (double)rgb32_get_red(color) / 0xff,
- (double)rgb32_get_green(color) / 0xff,
- (double)rgb32_get_blue(color) / 0xff);
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_set_operator(cairo, CAIRO_OPERATOR_RASTER_COPY);
- cairo_fill(cairo);
+ pixman_image_t *dest_surface = dest->source.pixmap.pixman_image;
+
+ spice_pixman_fill_rect(dest_surface,
+ area.left + offset.x, area.top + offset.y,
+ area.right - area.left,
+ area.bottom - area.top,
+ color);
}
void RedDrawable::fill_rect(const SpiceRect& area, rgb32_t color)
@@ -668,18 +697,28 @@ static inline void frame_drawable(RedDrawable_p* dest, const SpiceRect& area, rg
static inline void frame_pixmap(RedDrawable_p* dest, const SpiceRect& area, rgb32_t color,
const SpicePoint& offset)
{
- cairo_t* cairo = dest->cairo;
-
- ASSERT(cairo);
- cairo_set_source_rgb(cairo,
- (double)rgb32_get_red(color) / 0xff,
- (double)rgb32_get_green(color) / 0xff,
- (double)rgb32_get_blue(color) / 0xff);
- cairo_rectangle(cairo, area.left + offset.x, area.top + offset.y, area.right - area.left,
- area.bottom - area.top);
- cairo_set_line_width(cairo, 1);
- cairo_set_operator(cairo, CAIRO_OPERATOR_RASTER_COPY);
- cairo_stroke(cairo);
+ pixman_image_t *dest_surface = dest->source.pixmap.pixman_image;
+
+ spice_pixman_fill_rect(dest_surface,
+ area.left + offset.x, area.top + offset.y,
+ area.right - area.left,
+ 1,
+ color);
+ spice_pixman_fill_rect(dest_surface,
+ area.left + offset.x, area.bottom + offset.y,
+ area.right - area.left,
+ 1,
+ color);
+ spice_pixman_fill_rect(dest_surface,
+ area.left + offset.x, area.top + offset.y,
+ 1,
+ area.bottom - area.top,
+ color);
+ spice_pixman_fill_rect(dest_surface,
+ area.right + offset.x, area.top + offset.y,
+ 1,
+ area.bottom - area.top,
+ color);
}
void RedDrawable::frame_rect(const SpiceRect& area, rgb32_t color)