summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-04-08 23:11:09 +0200
committerAlexander Larsson <alexl@redhat.com>2010-04-08 23:11:09 +0200
commit1b5cef669ec4bc62820fda596677cadf5b694828 (patch)
tree75e3822851f278032b01c420a68b52edd7b6da79
parent6ae7fefa5eccdbb017cd7ebce730470c4715e568 (diff)
Add mask operation
-rw-r--r--client.html33
-rw-r--r--daemon.c25
2 files changed, 58 insertions, 0 deletions
diff --git a/client.html b/client.html
index 7211bbe..64f51fd 100644
--- a/client.html
+++ b/client.html
@@ -211,6 +211,39 @@ function handleLoad(event)
break;
+ /* mask from surface */
+ case 'm':
+ source_id = base64_16(cmd, i);
+ i = i + 3;
+ sx = base64_16(cmd, i);
+ i = i + 3;
+ sy = base64_16(cmd, i);
+ i = i + 3;
+ w = base64_16(cmd, i);
+ i = i + 3;
+ h = base64_16(cmd, i);
+ i = i + 3;
+ dx = base64_16(cmd, i);
+ i = i + 3;
+ dy = base64_16(cmd, i);
+ i = i + 3;
+
+ var tmp = document.createElement("canvas");
+ tmp.width = w;
+ tmp.height = h;
+ var tmp_context = tmp.getContext("2d");
+ tmp_context.globalCompositeOperation = "copy";
+ tmp_context.drawImage(surfaces[source_id], sx, sy, w, h, 0, 0, w, h);
+ tmp_context.globalCompositeOperation = "source-in";
+ tmp_context.fillStyle = current_color;
+ tmp_context.fillRect(0, 0, w, h);
+
+ current_context.globalCompositeOperation = "source-over"
+ current_context.drawImage(tmp, 0, 0, w, h, dx, dy, w, h);
+ current_context.globalCompositeOperation = "copy"
+
+ break;
+
/* fill rect */
case 'r':
x = base64_16(cmd, i);
diff --git a/daemon.c b/daemon.c
index a4dbeeb..e912ac4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -145,6 +145,24 @@ send_blend_alpha (GOutputStream *out, int source_surface, int sx, int sy, int w,
}
static void
+send_mask (GOutputStream *out, int source_surface, int sx, int sy, int w, int h, int dx, int dy)
+{
+ char buf[22];
+
+ buf[0] = 'm';
+ base64_uint16(source_surface, &buf[1]);
+ base64_uint16(sx, &buf[4]);
+ base64_uint16(sy, &buf[7]);
+ base64_uint16(w, &buf[10]);
+ base64_uint16(h, &buf[13]);
+ base64_uint16(dx, &buf[16]);
+ base64_uint16(dy, &buf[19]);
+
+ g_output_stream_write_all (out, buf, 22,
+ NULL, NULL, NULL);
+}
+
+static void
send_blit (GOutputStream *out, int source_surface, int sx, int sy, int w, int h, int dx, int dy)
{
char buf[22];
@@ -718,6 +736,13 @@ send_draw_ops (GOutputStream *out)
send_image_a (cout, 2, 0, 2, 2, 2, pixelaa);
send_select_surface(cout, 0);
+ send_rgb (cout, 0x0000ff);
+ send_mask (cout, 1, 0, 0, 4, 2, 400, 400);
+ send_rgb (cout, 0x00ffff);
+ send_mask (cout, 1, 0, 0, 4, 2, 400, 402);
+ send_rgba (cout, 0x8000ffff);
+ send_mask (cout, 1, 0, 0, 4, 2, 400, 404);
+
while (1)
{
send_rgb (cout, 0xff0000 + i * 32);