diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-04-09 14:15:49 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-04-09 14:15:49 +0200 |
commit | 7b57a601227811a94dd14abfa3d09bd6d5717d43 (patch) | |
tree | 7a78d147630f695a8543b00cd231039e202f0180 | |
parent | 421333019553a4fcd8dc214e9f4c4cc2adb6eeef (diff) |
Better scrolling
-rw-r--r-- | daemon.c | 35 |
1 files changed, 22 insertions, 13 deletions
@@ -708,20 +708,19 @@ static int next_surface = 1; static int font_surface; static int -alloc_surface(void) +alloc_surface(GOutputStream *out, int w, int h) { - return next_surface++; + int id = next_surface++; + send_new_surface(out, id, w, h); + return id; } static void send_font (GOutputStream *out) { - font_surface = alloc_surface(); - - send_new_surface(out, font_surface, font_w, font_h); + font_surface = alloc_surface(out, font_w, font_h); send_select_surface(out, font_surface); send_image_a (out, 0, 0, font_w, font_h, font_w, font_data); - send_select_surface(out, 0); } static void @@ -734,6 +733,9 @@ send_text (GOutputStream *out, char *str, int x, int y) } } +#define SCROLL_DX 3 +#define SCROLL_H 30 + static gboolean demo (GOutputStream *out) { @@ -741,7 +743,7 @@ demo (GOutputStream *out) GOutputStream *cout; char *header; int i; - int ball; + int ball, save; header = "HTTP/1.1 200 OK\r\n" @@ -755,25 +757,28 @@ demo (GOutputStream *out) compressor = g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP, -1); cout = g_converter_output_stream_new (out, G_CONVERTER (compressor)); + /* Need an initial multipart boundary */ send_boundary (cout); - i = 0; - - ball = alloc_surface(); - send_new_surface(cout, ball, ball_w, ball_h); + ball = alloc_surface(cout, ball_w, ball_h); send_select_surface(cout, ball); send_image_rgba (cout, 0, 0, ball_w, ball_h, ball_w, ball_data); - send_select_surface(cout, 0); send_font(cout); + save = alloc_surface(cout, SCROLL_DX, SCROLL_H); + + send_select_surface(cout, 0); + send_rgb (cout, 0x0000ff); send_text(cout, "welcome to ajax broadway", 400, 400); send_rgb (cout, 0x4000ff00); send_text(cout, "welcome to ajax broadway", 403, 403); + i = 0; while (1) { + send_select_surface(cout, 0); send_rgb (cout, 0xff0000 + i * 32); send_rect (cout, i*10, i*10, 15, 15); send_rgba (cout, 0x80ff0000 + i * 32); @@ -784,7 +789,11 @@ demo (GOutputStream *out) i ++; - send_copyrect (cout, 3, 400, 800 - 3, 30, 0, 400); + send_select_surface(cout, save); + send_blit (cout, 0, 0, 400, SCROLL_DX, SCROLL_H, 0, 0); + send_select_surface(cout, 0); + send_copyrect (cout, SCROLL_DX, 400, 800 - SCROLL_DX, SCROLL_H, 0, 400); + send_blit (cout, save, 0, 0, SCROLL_DX, SCROLL_H, 800 - SCROLL_DX, 400); flush (cout); |