Rename BroadwayClient to BroadwayOutput

This commit is contained in:
Alexander Larsson 2010-11-24 21:40:25 +01:00
parent 5a9f7a1e35
commit f407b4a5f5
6 changed files with 92 additions and 92 deletions

View File

@ -138,7 +138,7 @@ snippet(cairo_t *cr, int i)
}
static void
demo2 (BroadwayClient *client)
demo2 (BroadwayOutput *output)
{
cairo_t *cr;
cairo_surface_t *surface, *old_surface;
@ -146,7 +146,7 @@ demo2 (BroadwayClient *client)
double da = 0;
int i;
broadway_client_new_surface(client, 0, 100, 100, 800, 600);
broadway_output_new_surface(output, 0, 100, 100, 800, 600);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
800, 600);
@ -174,19 +174,19 @@ demo2 (BroadwayClient *client)
if (i == 0)
{
broadway_client_put_rgb (client, 0, 0, 0, 800, 600, 800*4,
broadway_output_put_rgb (output, 0, 0, 0, 800, 600, 800*4,
cairo_image_surface_get_data(surface)
);
broadway_client_show_surface (client, 0);
broadway_output_show_surface (output, 0);
}
else
{
diff_surfaces (surface,
old_surface);
broadway_client_put_rgba (client, 0, 0, 0, 800, 600, 800*4,
broadway_output_put_rgba (output, 0, 0, 0, 800, 600, 800*4,
cairo_image_surface_get_data(old_surface));
}
broadway_client_move_surface (client, 0, 100 + i, 100 + i);
broadway_output_move_surface (output, 0, 100 + i, 100 + i);
rects[0].x = 500;
rects[0].y = 0;
@ -196,12 +196,12 @@ demo2 (BroadwayClient *client)
rects[1].y = 100;
rects[1].width = 100;
rects[1].height = 100;
broadway_client_copy_rectangles (client,
broadway_output_copy_rectangles (output,
0,
rects, 2,
400, 0);
broadway_client_flush (client);
broadway_output_flush (output);
cr = cairo_create (old_surface);
cairo_set_source_surface (cr, surface, 0, 0);
@ -214,17 +214,17 @@ demo2 (BroadwayClient *client)
cairo_surface_destroy (surface);
broadway_client_destroy_surface(client, 0);
broadway_client_flush (client);
broadway_output_destroy_surface(output, 0);
broadway_output_flush (output);
}
int
main (int argc, char *argv[])
{
BroadwayClient *client;
BroadwayOutput *output;
client = broadway_client_new (STDOUT_FILENO);
demo2(client);
output = broadway_output_new (STDOUT_FILENO);
demo2(output);
return 0;
}

View File

@ -618,13 +618,13 @@ to_png_a (int w, int h, int byte_stride, uint8_t *data)
* Basic I/O primitives *
************************************************************************/
struct BroadwayClient {
struct BroadwayOutput {
int fd;
gzFile *zfd;
} ;
static void
broadway_client_write_raw (BroadwayClient *client,
broadway_output_write_raw (BroadwayOutput *output,
const void *buf, size_t count)
{
ssize_t res;
@ -633,18 +633,18 @@ broadway_client_write_raw (BroadwayClient *client,
while (count > 0)
{
res = write(client->fd, ptr, count);
res = write(output->fd, ptr, count);
if (res == -1)
{
errsave = errno;
if (errsave == EINTR)
continue;
fprintf(stderr, "Error on write_raw to client %d\n", errsave);
fprintf(stderr, "Error on write_raw to output %d\n", errsave);
exit(1);
}
if (res == 0)
{
fprintf(stderr, "Short write_raw to client\n");
fprintf(stderr, "Short write_raw to output\n");
exit(1);
}
count -= res;
@ -653,7 +653,7 @@ broadway_client_write_raw (BroadwayClient *client,
}
static void
broadway_client_write (BroadwayClient *client,
broadway_output_write (BroadwayOutput *output,
const void *buf, size_t count)
{
ssize_t res;
@ -661,15 +661,15 @@ broadway_client_write (BroadwayClient *client,
while (count > 0)
{
res = gzwrite(client->zfd, ptr, count);
res = gzwrite(output->zfd, ptr, count);
if (res == -1)
{
fprintf(stderr, "Error on write to client\n");
fprintf(stderr, "Error on write to output\n");
exit(1);
}
if (res == 0)
{
fprintf(stderr, "Short write to client\n");
fprintf(stderr, "Short write to output\n");
exit(1);
}
count -= res;
@ -678,7 +678,7 @@ broadway_client_write (BroadwayClient *client,
}
static void
broadway_client_write_header (BroadwayClient *client)
broadway_output_write_header (BroadwayOutput *output)
{
char *header;
@ -687,44 +687,44 @@ broadway_client_write_header (BroadwayClient *client)
"Content-type: multipart/x-mixed-replace;boundary=x\r\n"
"Content-Encoding: gzip\r\n"
"\r\n";
broadway_client_write_raw (client,
broadway_output_write_raw (output,
header, strlen (header));
}
static void
send_boundary (BroadwayClient *client)
send_boundary (BroadwayOutput *output)
{
char *boundary =
"--x\r\n"
"\r\n";
broadway_client_write (client, boundary, strlen (boundary));
broadway_output_write (output, boundary, strlen (boundary));
}
BroadwayClient *
broadway_client_new(int fd)
BroadwayOutput *
broadway_output_new(int fd)
{
BroadwayClient *client;
BroadwayOutput *output;
client = bw_new0 (BroadwayClient, 1);
output = bw_new0 (BroadwayOutput, 1);
client->fd = fd;
output->fd = fd;
broadway_client_write_header (client);
broadway_output_write_header (output);
client->zfd = gzdopen(fd, "wb");
output->zfd = gzdopen(fd, "wb");
/* Need an initial multipart boundary */
send_boundary (client);
send_boundary (output);
return client;
return output;
}
void
broadway_client_flush (BroadwayClient *client)
broadway_output_flush (BroadwayOutput *output)
{
send_boundary (client);
gzflush (client->zfd, Z_SYNC_FLUSH);
send_boundary (output);
gzflush (output->zfd, Z_SYNC_FLUSH);
}
@ -733,7 +733,7 @@ broadway_client_flush (BroadwayClient *client)
************************************************************************/
void
broadway_client_copy_rectangles (BroadwayClient *client, int id,
broadway_output_copy_rectangles (BroadwayOutput *output, int id,
BroadwayRect *rects, int n_rects,
int dx, int dy)
{
@ -757,12 +757,12 @@ broadway_client_copy_rectangles (BroadwayClient *client, int id,
base64_uint16(dx, &buf[p]); p +=3;
base64_uint16(dy, &buf[p]); p +=3;
broadway_client_write (client, buf, len);
broadway_output_write (output, buf, len);
free (buf);
}
void
broadway_client_new_surface(BroadwayClient *client, int id, int x, int y, int w, int h)
broadway_output_new_surface(BroadwayOutput *output, int id, int x, int y, int w, int h)
{
char buf[16];
@ -773,44 +773,44 @@ broadway_client_new_surface(BroadwayClient *client, int id, int x, int y, int w
base64_uint16(w, &buf[10]);
base64_uint16(h, &buf[13]);
broadway_client_write (client, buf, 16);
broadway_output_write (output, buf, 16);
}
void
broadway_client_show_surface(BroadwayClient *client, int id)
broadway_output_show_surface(BroadwayOutput *output, int id)
{
char buf[4];
buf[0] = 'S';
base64_uint16(id, &buf[1]);
broadway_client_write (client, buf, 4);
broadway_output_write (output, buf, 4);
}
void
broadway_client_hide_surface(BroadwayClient *client, int id)
broadway_output_hide_surface(BroadwayOutput *output, int id)
{
char buf[4];
buf[0] = 'H';
base64_uint16(id, &buf[1]);
broadway_client_write (client, buf, 4);
broadway_output_write (output, buf, 4);
}
void
broadway_client_destroy_surface(BroadwayClient *client, int id)
broadway_output_destroy_surface(BroadwayOutput *output, int id)
{
char buf[4];
buf[0] = 'd';
base64_uint16(id, &buf[1]);
broadway_client_write (client, buf, 4);
broadway_output_write (output, buf, 4);
}
void
broadway_client_move_surface(BroadwayClient *client, int id, int x, int y)
broadway_output_move_surface(BroadwayOutput *output, int id, int x, int y)
{
char buf[10];
@ -819,11 +819,11 @@ broadway_client_move_surface(BroadwayClient *client, int id, int x, int y)
base64_uint16(x, &buf[4]);
base64_uint16(y, &buf[7]);
broadway_client_write (client, buf, 10);
broadway_output_write (output, buf, 10);
}
void
broadway_client_resize_surface(BroadwayClient *client, int id, int w, int h)
broadway_output_resize_surface(BroadwayOutput *output, int id, int w, int h)
{
char buf[10];
@ -832,11 +832,11 @@ broadway_client_resize_surface(BroadwayClient *client, int id, int w, int h)
base64_uint16(w, &buf[4]);
base64_uint16(h, &buf[7]);
broadway_client_write (client, buf, 10);
broadway_output_write (output, buf, 10);
}
void
broadway_client_put_rgb (BroadwayClient *client, int id, int x, int y,
broadway_output_put_rgb (BroadwayOutput *output, int id, int x, int y,
int w, int h, int byte_stride, void *data)
{
char buf[16];
@ -852,9 +852,9 @@ broadway_client_put_rgb (BroadwayClient *client, int id, int x, int y,
len = strlen (url);
base64_uint32(len, &buf[10]);
broadway_client_write (client, buf, 16);
broadway_output_write (output, buf, 16);
broadway_client_write (client, url, len);
broadway_output_write (output, url, len);
free (url);
}
@ -1083,7 +1083,7 @@ rgba_find_rects (unsigned char *data,
}
void
broadway_client_put_rgba (BroadwayClient *client, int id, int x, int y,
broadway_output_put_rgba (BroadwayOutput *output, int id, int x, int y,
int w, int h, int byte_stride, void *data)
{
char buf[16];
@ -1110,9 +1110,9 @@ broadway_client_put_rgba (BroadwayClient *client, int id, int x, int y,
len = strlen (url);
base64_uint32(len, &buf[10]);
broadway_client_write (client, buf, 16);
broadway_output_write (output, buf, 16);
broadway_client_write (client, url, len);
broadway_output_write (output, url, len);
free (url);
}
@ -1122,7 +1122,7 @@ broadway_client_put_rgba (BroadwayClient *client, int id, int x, int y,
#if 0
static void
send_image_a (BroadwayClient *client, int id, int x, int y,
send_image_a (BroadwayOutput *output, int id, int x, int y,
int w, int h, int byte_stride, uint8_t *data)
{
char buf[16];
@ -1138,9 +1138,9 @@ send_image_a (BroadwayClient *client, int id, int x, int y,
len = strlen (url);
base64_uint32(len, &buf[10]);
broadway_client_write (client, buf, 16);
broadway_output_write (output, buf, 16);
broadway_client_write (client, url, len);
broadway_output_write (output, url, len);
free (url);
}

View File

@ -1,33 +1,33 @@
typedef struct BroadwayClient BroadwayClient;
typedef struct BroadwayOutput BroadwayOutput;
typedef struct {
int x, y;
int width, height;
} BroadwayRect;
BroadwayClient *broadway_client_new (int fd);
void broadway_client_flush (BroadwayClient *client);
void broadway_client_new_surface (BroadwayClient *client,
BroadwayOutput *broadway_output_new (int fd);
void broadway_output_flush (BroadwayOutput *output);
void broadway_output_new_surface (BroadwayOutput *output,
int id,
int x,
int y,
int w,
int h);
void broadway_client_show_surface (BroadwayClient *client,
void broadway_output_show_surface (BroadwayOutput *output,
int id);
void broadway_client_hide_surface (BroadwayClient *client,
void broadway_output_hide_surface (BroadwayOutput *output,
int id);
void broadway_client_destroy_surface (BroadwayClient *client,
void broadway_output_destroy_surface (BroadwayOutput *output,
int id);
void broadway_client_move_surface (BroadwayClient *client,
void broadway_output_move_surface (BroadwayOutput *output,
int id,
int x,
int y);
void broadway_client_resize_surface (BroadwayClient *client,
void broadway_output_resize_surface (BroadwayOutput *output,
int id,
int w,
int h);
void broadway_client_put_rgb (BroadwayClient *client,
void broadway_output_put_rgb (BroadwayOutput *output,
int id,
int x,
int y,
@ -35,7 +35,7 @@ void broadway_client_put_rgb (BroadwayClient *client,
int h,
int byte_stride,
void *data);
void broadway_client_put_rgba (BroadwayClient *client,
void broadway_output_put_rgba (BroadwayOutput *output,
int id,
int x,
int y,
@ -43,7 +43,7 @@ void broadway_client_put_rgba (BroadwayClient *client,
int h,
int byte_stride,
void *data);
void broadway_client_copy_rectangles (BroadwayClient *client,
void broadway_output_copy_rectangles (BroadwayOutput *output,
int id,
BroadwayRect *rects,
int n_rects,

View File

@ -455,7 +455,7 @@ start_output (HttpRequest *request)
display_broadway = GDK_DISPLAY_BROADWAY (request->display);
fd = g_socket_get_fd (socket);
set_fd_blocking (fd);
display_broadway->output = broadway_client_new (fd);
display_broadway->output = broadway_output_new (fd);
_gdk_broadway_resync_windows ();
/* TODO: This leaks the connection since we just keep the fd,

View File

@ -80,7 +80,7 @@ struct _GdkDisplayBroadway
GdkWindow *active_offscreen_window;
GSocketService *service;
BroadwayClient *output;
BroadwayOutput *output;
};
struct _GdkDisplayBroadwayClass

View File

@ -121,7 +121,7 @@ diff_surfaces (cairo_surface_t *surface,
static guint dirty_flush_id = 0;
static void
window_data_send (BroadwayClient *client, GdkWindowImplBroadway *impl)
window_data_send (BroadwayOutput *output, GdkWindowImplBroadway *impl)
{
GdkDrawableImplBroadway *drawable_impl = GDK_DRAWABLE_IMPL_BROADWAY (impl);
cairo_t *cr;
@ -133,7 +133,7 @@ window_data_send (BroadwayClient *client, GdkWindowImplBroadway *impl)
{
diff_surfaces (drawable_impl->surface,
drawable_impl->last_surface);
broadway_client_put_rgba (client, impl->id, 0, 0,
broadway_output_put_rgba (output, impl->id, 0, 0,
cairo_image_surface_get_width (drawable_impl->last_surface),
cairo_image_surface_get_height (drawable_impl->last_surface),
cairo_image_surface_get_stride (drawable_impl->last_surface),
@ -142,7 +142,7 @@ window_data_send (BroadwayClient *client, GdkWindowImplBroadway *impl)
else
{
impl->last_synced = TRUE;
broadway_client_put_rgb (client, impl->id, 0, 0,
broadway_output_put_rgb (output, impl->id, 0, 0,
cairo_image_surface_get_width (drawable_impl->surface),
cairo_image_surface_get_height (drawable_impl->surface),
cairo_image_surface_get_stride (drawable_impl->surface),
@ -160,13 +160,13 @@ dirty_flush_idle (gpointer data)
{
GList *l;
GdkDisplayBroadway *display;
BroadwayClient *client;
BroadwayOutput *output;
dirty_flush_id = 0;
display = GDK_DISPLAY_BROADWAY (gdk_display_get_default ());
client = display->output;
if (client == NULL)
output = display->output;
if (output == NULL)
return FALSE;
for (l = display->toplevels; l != NULL; l = l->next)
@ -180,7 +180,7 @@ dirty_flush_idle (gpointer data)
}
}
broadway_client_flush (client);
broadway_output_flush (output);
return FALSE;
}
@ -214,7 +214,7 @@ _gdk_broadway_resync_windows (void)
impl->dirty = FALSE;
impl->last_synced = FALSE;
broadway_client_new_surface (display->output,
broadway_output_new_surface (display->output,
impl->id,
private->x,
private->y,
@ -222,12 +222,12 @@ _gdk_broadway_resync_windows (void)
private->height);
if (GDK_WINDOW_IS_MAPPED (private))
{
broadway_client_show_surface (display->output, impl->id);
broadway_output_show_surface (display->output, impl->id);
window_data_send (display->output, impl);
}
}
broadway_client_flush (display->output);
broadway_output_flush (display->output);
}
static void
@ -355,7 +355,7 @@ _gdk_window_impl_new (GdkWindow *window,
}
if (display_broadway->output)
broadway_client_new_surface (display_broadway->output,
broadway_output_new_surface (display_broadway->output,
impl->id,
private->x,
private->y,
@ -403,7 +403,7 @@ _gdk_broadway_window_destroy (GdkWindow *window,
display_broadway = GDK_DISPLAY_BROADWAY (gdk_window_get_display (window));
if (display_broadway->output)
broadway_client_destroy_surface (display_broadway->output,
broadway_output_destroy_surface (display_broadway->output,
impl->id);
}
@ -463,7 +463,7 @@ gdk_window_broadway_show (GdkWindow *window, gboolean already_mapped)
display_broadway = GDK_DISPLAY_BROADWAY (gdk_window_get_display (window));
if (display_broadway->output)
{
broadway_client_show_surface (display_broadway->output, impl->id);
broadway_output_show_surface (display_broadway->output, impl->id);
queue_dirty_flush (display_broadway);
}
}
@ -487,7 +487,7 @@ gdk_window_broadway_hide (GdkWindow *window)
display_broadway = GDK_DISPLAY_BROADWAY (gdk_window_get_display (window));
if (display_broadway->output)
{
broadway_client_hide_surface (display_broadway->output, impl->id);
broadway_output_hide_surface (display_broadway->output, impl->id);
queue_dirty_flush (display_broadway);
}
@ -524,7 +524,7 @@ gdk_window_broadway_move_resize (GdkWindow *window,
private->y = y;
if (display_broadway->output != NULL)
{
broadway_client_move_surface (display_broadway->output,
broadway_output_move_surface (display_broadway->output,
impl->id, x, y);
queue_dirty_flush (display_broadway);
}
@ -548,7 +548,7 @@ gdk_window_broadway_move_resize (GdkWindow *window,
impl->dirty = TRUE;
impl->last_synced = FALSE;
broadway_client_resize_surface (display_broadway->output,
broadway_output_resize_surface (display_broadway->output,
impl->id, width, height);
queue_dirty_flush (display_broadway);
@ -1307,7 +1307,7 @@ _gdk_broadway_window_translate (GdkWindow *window,
rects[i].height = rect.height;
}
display_broadway = GDK_DISPLAY_BROADWAY (gdk_window_get_display (window));
broadway_client_copy_rectangles (display_broadway->output,
broadway_output_copy_rectangles (display_broadway->output,
GDK_WINDOW_IMPL_BROADWAY (impl)->id,
rects, n_rects, dx, dy);
queue_dirty_flush (display_broadway);