2010-11-16 11:42:53 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
2011-04-18 18:23:19 +00:00
|
|
|
#include <cairo.h>
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-12-23 21:05:02 +00:00
|
|
|
#include "broadway-output.h"
|
2010-11-16 11:42:53 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
2010-11-24 20:57:30 +00:00
|
|
|
* Base64 functions *
|
2010-11-16 11:42:53 +00:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
static const char base64_alphabet[] =
|
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
|
|
|
2011-04-06 20:23:35 +00:00
|
|
|
#if 0 /* Unused for now */
|
2010-11-16 11:42:53 +00:00
|
|
|
static void
|
2010-11-24 20:57:30 +00:00
|
|
|
base64_uint8 (guint8 v, char *c)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
|
|
|
c[0] = base64_alphabet[(v >> 0) & 0x3f];
|
|
|
|
c[1] = base64_alphabet[(v >> 6) & 0x3];
|
|
|
|
}
|
2011-04-06 20:23:35 +00:00
|
|
|
#endif
|
2010-11-16 11:42:53 +00:00
|
|
|
|
|
|
|
static void
|
2010-11-24 20:57:30 +00:00
|
|
|
base64_uint16 (guint32 v, char *c)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
|
|
|
c[0] = base64_alphabet[(v >> 0) & 0x3f];
|
|
|
|
c[1] = base64_alphabet[(v >> 6) & 0x3f];
|
|
|
|
c[2] = base64_alphabet[(v >> 12) & 0xf];
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void
|
2010-11-24 20:57:30 +00:00
|
|
|
base64_uint24 (guint32 v, char *c)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
|
|
|
c[0] = base64_alphabet[(v >> 0) & 0x3f];
|
|
|
|
c[1] = base64_alphabet[(v >> 6) & 0x3f];
|
|
|
|
c[2] = base64_alphabet[(v >> 12) & 0x3f];
|
|
|
|
c[3] = base64_alphabet[(v >> 18) & 0x3f];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
2010-11-24 20:57:30 +00:00
|
|
|
base64_uint32 (guint32 v, char *c)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
|
|
|
c[0] = base64_alphabet[(v >> 0) & 0x3f];
|
|
|
|
c[1] = base64_alphabet[(v >> 6) & 0x3f];
|
|
|
|
c[2] = base64_alphabet[(v >> 12) & 0x3f];
|
|
|
|
c[3] = base64_alphabet[(v >> 18) & 0x3f];
|
|
|
|
c[4] = base64_alphabet[(v >> 24) & 0x3f];
|
|
|
|
c[5] = base64_alphabet[(v >> 30) & 0x2];
|
|
|
|
}
|
|
|
|
|
2011-04-18 18:23:19 +00:00
|
|
|
/***********************************************************
|
|
|
|
* conversion of raw image data to png data: uris *
|
|
|
|
***********************************************************/
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-10-01 12:53:18 +00:00
|
|
|
static cairo_status_t
|
|
|
|
write_png_data (void *closure,
|
|
|
|
const unsigned char *data,
|
|
|
|
unsigned int data_len)
|
|
|
|
{
|
|
|
|
GString *buf = closure;
|
|
|
|
|
|
|
|
g_string_append_len (buf, (char *)data, data_len);
|
|
|
|
|
|
|
|
return CAIRO_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
to_png_rgb (GString *buf, int w, int h, int byte_stride, guint32 *data)
|
|
|
|
{
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
|
|
|
surface = cairo_image_surface_create_for_data ((guchar *)data,
|
|
|
|
CAIRO_FORMAT_RGB24, w, h, byte_stride);
|
|
|
|
|
|
|
|
cairo_surface_write_to_png_stream (surface, write_png_data, buf);
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
to_png_rgba (GString *buf, int w, int h, int byte_stride, guint32 *data)
|
|
|
|
{
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
|
|
|
surface = cairo_image_surface_create_for_data ((guchar *)data,
|
|
|
|
CAIRO_FORMAT_ARGB32, w, h, byte_stride);
|
|
|
|
|
|
|
|
cairo_surface_write_to_png_stream (surface, write_png_data, buf);
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
}
|
|
|
|
|
2011-04-18 18:23:19 +00:00
|
|
|
struct PngTarget {
|
2012-10-01 10:44:38 +00:00
|
|
|
GString *buf;
|
2011-04-18 18:23:19 +00:00
|
|
|
int state;
|
|
|
|
int save;
|
|
|
|
};
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2011-04-18 18:23:19 +00:00
|
|
|
static cairo_status_t
|
|
|
|
write_png_url (void *closure,
|
|
|
|
const unsigned char *data,
|
|
|
|
unsigned int data_len)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2011-04-18 18:23:19 +00:00
|
|
|
struct PngTarget *target = closure;
|
|
|
|
gsize res, old_len;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
old_len = target->buf->len;
|
|
|
|
g_string_set_size (target->buf,
|
2011-04-18 18:23:19 +00:00
|
|
|
old_len + (data_len / 3 + 1) * 4 + 4);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2011-04-18 18:23:19 +00:00
|
|
|
res = g_base64_encode_step (data, data_len, FALSE,
|
2012-10-01 10:44:38 +00:00
|
|
|
target->buf->str + old_len,
|
2011-04-18 18:23:19 +00:00
|
|
|
&target->state, &target->save);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_set_size (target->buf, old_len + res);
|
2011-04-18 18:23:19 +00:00
|
|
|
|
|
|
|
return CAIRO_STATUS_SUCCESS;
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
static void
|
|
|
|
to_png_url_rgb (GString *buf, int w, int h, int byte_stride, guint32 *data)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2011-04-18 18:23:19 +00:00
|
|
|
cairo_surface_t *surface;
|
|
|
|
struct PngTarget target;
|
|
|
|
gsize res, old_len;
|
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
target.buf = buf;
|
2011-04-18 18:23:19 +00:00
|
|
|
target.state = 0;
|
|
|
|
target.save = 0;
|
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_append (buf, "data:image/png;base64,");
|
|
|
|
|
2011-04-18 18:23:19 +00:00
|
|
|
surface = cairo_image_surface_create_for_data ((guchar *)data,
|
|
|
|
CAIRO_FORMAT_RGB24, w, h, byte_stride);
|
|
|
|
|
|
|
|
cairo_surface_write_to_png_stream (surface, write_png_url, &target);
|
2012-10-01 12:53:18 +00:00
|
|
|
cairo_surface_destroy (surface);
|
2011-04-18 18:23:19 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
old_len = buf->len;
|
2011-04-18 18:23:19 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_set_size (buf, old_len + 4);
|
2011-04-18 18:23:19 +00:00
|
|
|
res = g_base64_encode_close (FALSE,
|
2012-10-01 10:44:38 +00:00
|
|
|
buf->str + old_len,
|
2011-04-18 18:23:19 +00:00
|
|
|
&target.state, &target.save);
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_set_size (buf, old_len + res);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
static void
|
|
|
|
to_png_url_rgba (GString *buf, int w, int h, int byte_stride, guint32 *data)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2011-04-18 18:23:19 +00:00
|
|
|
cairo_surface_t *surface;
|
|
|
|
struct PngTarget target;
|
|
|
|
gsize res, old_len;
|
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
target.buf = buf;
|
2011-04-18 18:23:19 +00:00
|
|
|
target.state = 0;
|
|
|
|
target.save = 0;
|
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_append (buf, "data:image/png;base64,");
|
|
|
|
|
2011-04-18 18:23:19 +00:00
|
|
|
surface = cairo_image_surface_create_for_data ((guchar *)data,
|
|
|
|
CAIRO_FORMAT_ARGB32, w, h, byte_stride);
|
|
|
|
|
|
|
|
cairo_surface_write_to_png_stream (surface, write_png_url, &target);
|
2012-10-01 12:53:18 +00:00
|
|
|
cairo_surface_destroy (surface);
|
2011-04-18 18:23:19 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
old_len = buf->len;
|
2011-04-18 18:23:19 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_set_size (buf, old_len + 4);
|
2011-04-18 18:23:19 +00:00
|
|
|
res = g_base64_encode_close (FALSE,
|
2012-10-01 10:44:38 +00:00
|
|
|
buf->str + old_len,
|
2011-04-18 18:23:19 +00:00
|
|
|
&target.state, &target.save);
|
2012-10-01 10:44:38 +00:00
|
|
|
g_string_set_size (buf, old_len + res);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static char *
|
2010-11-24 20:57:30 +00:00
|
|
|
to_png_a (int w, int h, int byte_stride, guint8 *data)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2011-04-18 18:23:19 +00:00
|
|
|
cairo_surface_t *surface;
|
|
|
|
struct PngTarget target;
|
|
|
|
gsize res, old_len;
|
|
|
|
|
|
|
|
target.url = g_string_new ("data:image/png;base64,");
|
|
|
|
target.state = 0;
|
|
|
|
target.save = 0;
|
|
|
|
|
|
|
|
surface = cairo_image_surface_create_for_data (data,
|
|
|
|
CAIRO_FORMAT_A8, w, h, byte_stride);
|
|
|
|
|
|
|
|
cairo_surface_write_to_png_stream (surface, write_png_url, &target);
|
|
|
|
|
|
|
|
old_len = target.url->len;
|
|
|
|
|
|
|
|
g_string_set_size (target.url, old_len + 4);
|
|
|
|
res = g_base64_encode_close (FALSE,
|
|
|
|
target.url->str + old_len,
|
|
|
|
&target.state, &target.save);
|
|
|
|
g_string_set_size (target.url, old_len + res);
|
|
|
|
|
|
|
|
return g_string_free (target.url, FALSE);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Basic I/O primitives *
|
|
|
|
************************************************************************/
|
|
|
|
|
2010-11-24 20:40:25 +00:00
|
|
|
struct BroadwayOutput {
|
2011-04-18 17:52:05 +00:00
|
|
|
GOutputStream *out;
|
2012-10-01 10:09:07 +00:00
|
|
|
GString *buf;
|
2010-11-24 21:12:29 +00:00
|
|
|
int error;
|
2011-03-10 13:58:47 +00:00
|
|
|
guint32 serial;
|
2011-11-10 09:12:28 +00:00
|
|
|
gboolean proto_v7_plus;
|
2012-10-01 12:53:18 +00:00
|
|
|
gboolean binary;
|
2010-11-24 21:12:29 +00:00
|
|
|
};
|
2010-11-16 11:42:53 +00:00
|
|
|
|
|
|
|
static void
|
2011-11-10 09:12:28 +00:00
|
|
|
broadway_output_send_cmd (BroadwayOutput *output,
|
|
|
|
gboolean fin, BroadwayWSOpCode code,
|
|
|
|
const void *buf, gsize count)
|
|
|
|
{
|
|
|
|
gboolean mask = FALSE;
|
|
|
|
guchar header[16];
|
|
|
|
size_t p;
|
|
|
|
|
|
|
|
gboolean mid_header = count > 125 && count <= 65535;
|
|
|
|
gboolean long_header = count > 65535;
|
|
|
|
|
|
|
|
/* NB. big-endian spec => bit 0 == MSB */
|
|
|
|
header[0] = ( (fin ? 0x80 : 0) | (code & 0x0f) );
|
|
|
|
header[1] = ( (mask ? 0x80 : 0) |
|
|
|
|
(mid_header ? 126 : long_header ? 127 : count) );
|
|
|
|
p = 2;
|
|
|
|
if (mid_header)
|
|
|
|
{
|
|
|
|
*(guint16 *)(header + p) = GUINT16_TO_BE( (guint16)count );
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
else if (long_header)
|
|
|
|
{
|
|
|
|
*(guint64 *)(header + p) = GUINT64_TO_BE( count );
|
|
|
|
p += 8;
|
|
|
|
}
|
|
|
|
// FIXME: if we are paranoid we should 'mask' the data
|
|
|
|
// FIXME: we should really emit these as a single write
|
|
|
|
g_output_stream_write_all (output->out, header, p, NULL, NULL, NULL);
|
|
|
|
g_output_stream_write_all (output->out, buf, count, NULL, NULL, NULL);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2012-10-01 10:09:07 +00:00
|
|
|
static void
|
|
|
|
broadway_output_send_cmd_pre_v7 (BroadwayOutput *output,
|
|
|
|
const void *buf, gsize count)
|
|
|
|
{
|
|
|
|
g_output_stream_write_all (output->out, "\0", 1, NULL, NULL, NULL);
|
|
|
|
g_output_stream_write_all (output->out, buf, count, NULL, NULL, NULL);
|
|
|
|
g_output_stream_write_all (output->out, "\xff", 1, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2011-11-10 09:12:28 +00:00
|
|
|
void broadway_output_pong (BroadwayOutput *output)
|
|
|
|
{
|
|
|
|
if (output->proto_v7_plus)
|
|
|
|
broadway_output_send_cmd (output, TRUE, BROADWAY_WS_CNX_PONG, NULL, 0);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2011-11-10 09:12:28 +00:00
|
|
|
int
|
|
|
|
broadway_output_flush (BroadwayOutput *output)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2012-10-01 10:09:07 +00:00
|
|
|
if (output->buf->len == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
2011-11-10 09:12:28 +00:00
|
|
|
if (!output->proto_v7_plus)
|
2012-10-01 10:09:07 +00:00
|
|
|
broadway_output_send_cmd_pre_v7 (output, output->buf->str, output->buf->len);
|
2012-10-01 12:53:18 +00:00
|
|
|
else if (output->binary)
|
|
|
|
broadway_output_send_cmd (output, TRUE, BROADWAY_WS_BINARY,
|
|
|
|
output->buf->str, output->buf->len);
|
2012-10-01 10:09:07 +00:00
|
|
|
else
|
|
|
|
broadway_output_send_cmd (output, TRUE, BROADWAY_WS_TEXT,
|
|
|
|
output->buf->str, output->buf->len);
|
|
|
|
|
|
|
|
g_string_set_size (output->buf, 0);
|
|
|
|
|
|
|
|
return !output->error;
|
|
|
|
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 20:40:25 +00:00
|
|
|
BroadwayOutput *
|
2012-10-01 10:09:07 +00:00
|
|
|
broadway_output_new (GOutputStream *out, guint32 serial,
|
2012-10-01 12:53:18 +00:00
|
|
|
gboolean proto_v7_plus, gboolean binary)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-24 20:40:25 +00:00
|
|
|
BroadwayOutput *output;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-24 20:57:30 +00:00
|
|
|
output = g_new0 (BroadwayOutput, 1);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2011-04-18 17:52:05 +00:00
|
|
|
output->out = g_object_ref (out);
|
2012-10-01 10:09:07 +00:00
|
|
|
output->buf = g_string_new ("");
|
2011-03-10 13:58:47 +00:00
|
|
|
output->serial = serial;
|
2011-11-10 09:12:28 +00:00
|
|
|
output->proto_v7_plus = proto_v7_plus;
|
2012-10-01 12:53:18 +00:00
|
|
|
output->binary = binary;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-24 20:40:25 +00:00
|
|
|
return output;
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-24 21:12:29 +00:00
|
|
|
broadway_output_free (BroadwayOutput *output)
|
|
|
|
{
|
2011-04-18 17:52:05 +00:00
|
|
|
g_object_unref (output->out);
|
2010-11-24 21:12:29 +00:00
|
|
|
free (output);
|
|
|
|
}
|
|
|
|
|
2011-03-10 13:58:47 +00:00
|
|
|
guint32
|
|
|
|
broadway_output_get_next_serial (BroadwayOutput *output)
|
|
|
|
{
|
|
|
|
return output->serial;
|
|
|
|
}
|
|
|
|
|
2010-11-16 11:42:53 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Core rendering operations *
|
|
|
|
************************************************************************/
|
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
static void
|
|
|
|
append_char (BroadwayOutput *output, char c)
|
|
|
|
{
|
|
|
|
g_string_append_c (output->buf, c);
|
|
|
|
}
|
2011-03-10 12:59:30 +00:00
|
|
|
|
|
|
|
static void
|
2012-10-01 11:02:21 +00:00
|
|
|
append_bool (BroadwayOutput *output, gboolean val)
|
2011-03-10 12:59:30 +00:00
|
|
|
{
|
2012-10-01 12:53:18 +00:00
|
|
|
if (output->binary)
|
|
|
|
g_string_append_c (output->buf, val ? 1: 0);
|
|
|
|
else
|
|
|
|
g_string_append_c (output->buf, val ? '1': '0');
|
2011-03-10 12:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-01 11:02:21 +00:00
|
|
|
append_flags (BroadwayOutput *output, guint32 val)
|
2011-03-10 12:59:30 +00:00
|
|
|
{
|
2012-10-01 12:53:18 +00:00
|
|
|
if (output->binary)
|
|
|
|
g_string_append_c (output->buf, val);
|
|
|
|
else
|
|
|
|
g_string_append_c (output->buf, val + '0');
|
2011-03-10 12:59:30 +00:00
|
|
|
}
|
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
append_uint16 (BroadwayOutput *output, guint32 v)
|
2011-03-10 12:59:30 +00:00
|
|
|
{
|
2012-10-01 11:02:21 +00:00
|
|
|
gsize old_len = output->buf->len;
|
2012-12-19 20:57:58 +00:00
|
|
|
guint8 *buf;
|
2012-10-01 12:53:18 +00:00
|
|
|
|
|
|
|
if (output->binary)
|
|
|
|
{
|
|
|
|
g_string_set_size (output->buf, old_len + 2);
|
2012-12-19 20:57:58 +00:00
|
|
|
buf = (guint8 *)output->buf->str + old_len;
|
2012-10-01 12:53:18 +00:00
|
|
|
buf[0] = (v >> 0) & 0xff;
|
|
|
|
buf[1] = (v >> 8) & 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_string_set_size (output->buf, old_len + 3);
|
|
|
|
base64_uint16 (v, output->buf->str + old_len);
|
|
|
|
}
|
2012-10-01 11:02:21 +00:00
|
|
|
}
|
2011-03-10 12:59:30 +00:00
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
static void
|
|
|
|
append_uint32 (BroadwayOutput *output, guint32 v)
|
|
|
|
{
|
|
|
|
gsize old_len = output->buf->len;
|
2012-12-19 20:57:58 +00:00
|
|
|
guint8 *buf;
|
2012-10-01 12:53:18 +00:00
|
|
|
|
|
|
|
if (output->binary)
|
|
|
|
{
|
|
|
|
g_string_set_size (output->buf, old_len + 4);
|
2012-12-19 20:57:58 +00:00
|
|
|
buf = (guint8 *)output->buf->str + old_len;
|
2012-10-01 12:53:18 +00:00
|
|
|
buf[0] = (v >> 0) & 0xff;
|
|
|
|
buf[1] = (v >> 8) & 0xff;
|
|
|
|
buf[2] = (v >> 16) & 0xff;
|
|
|
|
buf[3] = (v >> 24) & 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_string_set_size (output->buf, old_len + 6);
|
|
|
|
base64_uint32 (v, output->buf->str + old_len);
|
|
|
|
}
|
2012-10-01 11:02:21 +00:00
|
|
|
}
|
2011-03-10 12:59:30 +00:00
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
static void
|
|
|
|
overwrite_uint32 (BroadwayOutput *output, gsize pos, guint32 v)
|
|
|
|
{
|
2012-10-01 12:53:18 +00:00
|
|
|
if (output->binary)
|
|
|
|
{
|
|
|
|
guint8 *buf = (guint8 *)output->buf->str + pos;
|
|
|
|
|
|
|
|
buf[0] = (v >> 0) & 0xff;
|
|
|
|
buf[1] = (v >> 8) & 0xff;
|
|
|
|
buf[2] = (v >> 16) & 0xff;
|
|
|
|
buf[3] = (v >> 24) & 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
base64_uint32 (v, output->buf->str + pos);
|
|
|
|
}
|
2012-10-01 11:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
write_header(BroadwayOutput *output, char op)
|
|
|
|
{
|
|
|
|
append_char (output, op);
|
|
|
|
append_uint32 (output, output->serial++);
|
2011-03-10 12:59:30 +00:00
|
|
|
}
|
|
|
|
|
2010-11-16 11:42:53 +00:00
|
|
|
void
|
2010-11-24 20:40:25 +00:00
|
|
|
broadway_output_copy_rectangles (BroadwayOutput *output, int id,
|
2010-11-16 11:42:53 +00:00
|
|
|
BroadwayRect *rects, int n_rects,
|
|
|
|
int dx, int dy)
|
|
|
|
{
|
2012-10-01 11:02:21 +00:00
|
|
|
int i;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_COPY_RECTANGLES);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_uint16 (output, n_rects);
|
2010-11-16 11:42:53 +00:00
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, rects[i].x);
|
|
|
|
append_uint16 (output, rects[i].y);
|
|
|
|
append_uint16 (output, rects[i].width);
|
|
|
|
append_uint16 (output, rects[i].height);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, dx);
|
|
|
|
append_uint16 (output, dy);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2011-04-01 14:29:03 +00:00
|
|
|
void
|
2011-03-14 10:46:43 +00:00
|
|
|
broadway_output_grab_pointer (BroadwayOutput *output,
|
|
|
|
int id,
|
2011-04-01 14:29:03 +00:00
|
|
|
gboolean owner_event)
|
2011-03-14 10:46:43 +00:00
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_GRAB_POINTER);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_bool (output, owner_event);
|
2011-03-14 10:46:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
guint32
|
2011-04-01 14:29:03 +00:00
|
|
|
broadway_output_ungrab_pointer (BroadwayOutput *output)
|
2011-03-14 10:46:43 +00:00
|
|
|
{
|
|
|
|
guint32 serial;
|
|
|
|
|
|
|
|
serial = output->serial;
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_UNGRAB_POINTER);
|
2011-03-14 10:46:43 +00:00
|
|
|
|
|
|
|
return serial;
|
|
|
|
}
|
|
|
|
|
2010-11-16 11:42:53 +00:00
|
|
|
void
|
2011-04-05 10:27:43 +00:00
|
|
|
broadway_output_new_surface(BroadwayOutput *output,
|
|
|
|
int id, int x, int y, int w, int h,
|
|
|
|
gboolean is_temp)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_NEW_SURFACE);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_uint16 (output, x);
|
|
|
|
append_uint16 (output, y);
|
|
|
|
append_uint16 (output, w);
|
|
|
|
append_uint16 (output, h);
|
|
|
|
append_bool (output, is_temp);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-24 20:40:25 +00:00
|
|
|
broadway_output_show_surface(BroadwayOutput *output, int id)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_SHOW_SURFACE);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-24 20:40:25 +00:00
|
|
|
broadway_output_hide_surface(BroadwayOutput *output, int id)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_HIDE_SURFACE);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-24 20:40:25 +00:00
|
|
|
broadway_output_destroy_surface(BroadwayOutput *output, int id)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_DESTROY_SURFACE);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-23 11:52:10 +00:00
|
|
|
void
|
2011-04-12 09:11:36 +00:00
|
|
|
broadway_output_move_resize_surface (BroadwayOutput *output,
|
|
|
|
int id,
|
|
|
|
gboolean has_pos,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
gboolean has_size,
|
|
|
|
int w,
|
|
|
|
int h)
|
|
|
|
{
|
|
|
|
int val;
|
2011-03-10 12:59:30 +00:00
|
|
|
|
2011-04-12 09:11:36 +00:00
|
|
|
if (!has_pos && !has_size)
|
|
|
|
return;
|
2011-03-10 12:59:30 +00:00
|
|
|
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_MOVE_RESIZE);
|
2011-04-12 09:11:36 +00:00
|
|
|
val = (!!has_pos) | ((!!has_size) << 1);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_flags (output, val);
|
2011-04-12 09:11:36 +00:00
|
|
|
if (has_pos)
|
|
|
|
{
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, x);
|
|
|
|
append_uint16 (output, y);
|
2011-04-12 09:11:36 +00:00
|
|
|
}
|
|
|
|
if (has_size)
|
|
|
|
{
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, w);
|
|
|
|
append_uint16 (output, h);
|
2011-04-12 09:11:36 +00:00
|
|
|
}
|
2010-11-23 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
2011-04-05 10:02:46 +00:00
|
|
|
void
|
|
|
|
broadway_output_set_transient_for (BroadwayOutput *output,
|
|
|
|
int id,
|
|
|
|
int parent_id)
|
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_SET_TRANSIENT_FOR);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_uint16 (output, parent_id);
|
2011-04-05 10:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-16 11:42:53 +00:00
|
|
|
void
|
2010-11-24 20:40:25 +00:00
|
|
|
broadway_output_put_rgb (BroadwayOutput *output, int id, int x, int y,
|
2010-11-16 11:42:53 +00:00
|
|
|
int w, int h, int byte_stride, void *data)
|
|
|
|
{
|
2012-10-01 11:02:21 +00:00
|
|
|
gsize size_start, image_start, len;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_PUT_RGB);
|
2012-10-01 10:44:38 +00:00
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_uint16 (output, x);
|
|
|
|
append_uint16 (output, y);
|
2012-10-01 10:44:38 +00:00
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
size_start = output->buf->len;
|
|
|
|
append_uint32 (output, 0);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
image_start = output->buf->len;
|
2012-10-01 12:53:18 +00:00
|
|
|
if (output->binary)
|
|
|
|
to_png_rgb (output->buf, w, h, byte_stride, (guint32*)data);
|
|
|
|
else
|
|
|
|
to_png_url_rgb (output->buf, w, h, byte_stride, (guint32*)data);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
len = output->buf->len - image_start;
|
2012-10-01 11:02:21 +00:00
|
|
|
|
|
|
|
overwrite_uint32 (output, size_start, len);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
typedef struct {
|
|
|
|
int x1, y1;
|
|
|
|
int x2, y2;
|
|
|
|
} BroadwayBox;
|
|
|
|
|
|
|
|
static int
|
2010-11-22 12:07:49 +00:00
|
|
|
is_any_x_set (unsigned char *data,
|
|
|
|
int box_x1, int box_x2,
|
|
|
|
int x1, int x2, int y, int *x_set,
|
|
|
|
int byte_stride)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-22 12:07:49 +00:00
|
|
|
int w ;
|
2010-11-24 20:57:30 +00:00
|
|
|
guint32 *ptr;
|
2010-11-22 12:07:49 +00:00
|
|
|
|
|
|
|
if (x1 < box_x1)
|
|
|
|
x1 = box_x1;
|
|
|
|
|
|
|
|
if (x2 > box_x2)
|
|
|
|
x2 = box_x2;
|
|
|
|
|
|
|
|
w = x2 - x1;
|
|
|
|
if (w > 0)
|
|
|
|
{
|
2010-11-24 20:57:30 +00:00
|
|
|
ptr = (guint32 *)(data + y * byte_stride + x1 * 4);
|
2010-11-22 12:07:49 +00:00
|
|
|
while (w-- > 0)
|
|
|
|
{
|
|
|
|
if (*ptr != 0)
|
|
|
|
{
|
|
|
|
if (x_set)
|
|
|
|
*x_set = x1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
x1++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2010-11-21 23:00:37 +00:00
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-22 12:07:49 +00:00
|
|
|
|
|
|
|
#define EXTEND_X_FUZZ 10
|
|
|
|
#define EXTEND_Y_FUZZ 10
|
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
static int
|
|
|
|
extend_x_range (unsigned char *data,
|
|
|
|
int box_x1, int box_y1,
|
|
|
|
int box_x2, int box_y2,
|
|
|
|
int *x1, int *x2, int y,
|
|
|
|
int byte_stride)
|
|
|
|
{
|
|
|
|
int extended = 0;
|
2010-11-22 12:07:49 +00:00
|
|
|
int new_x;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-22 12:07:49 +00:00
|
|
|
while (is_any_x_set (data, box_x1, box_x2, *x1 - EXTEND_X_FUZZ, *x1, y, &new_x, byte_stride))
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-22 12:07:49 +00:00
|
|
|
*x1 = new_x;
|
|
|
|
extended = 1;
|
2010-11-21 23:00:37 +00:00
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-22 12:07:49 +00:00
|
|
|
while (is_any_x_set (data, box_x1, box_x2, *x2, *x2 + EXTEND_X_FUZZ, y, &new_x, byte_stride))
|
2010-11-21 23:00:37 +00:00
|
|
|
{
|
2010-11-22 12:07:49 +00:00
|
|
|
*x2 = new_x + 1;
|
|
|
|
extended = 1;
|
2010-11-21 23:00:37 +00:00
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
return extended;
|
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
static int
|
|
|
|
extend_y_range (unsigned char *data,
|
|
|
|
int box_x1, int box_y1,
|
|
|
|
int box_x2, int box_y2,
|
|
|
|
int x1, int x2, int *y,
|
|
|
|
int byte_stride)
|
|
|
|
{
|
|
|
|
int extended = 0;
|
|
|
|
int found_set;
|
2010-11-22 12:07:49 +00:00
|
|
|
int yy, y2;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
while (*y < box_y2)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-21 23:00:37 +00:00
|
|
|
found_set = 0;
|
2010-11-22 12:07:49 +00:00
|
|
|
|
|
|
|
y2 = *y + EXTEND_Y_FUZZ;
|
|
|
|
if (y2 > box_y2)
|
|
|
|
y2 = box_y2;
|
|
|
|
|
|
|
|
for (yy = y2; yy > *y + 1; yy--)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-22 12:07:49 +00:00
|
|
|
if (is_any_x_set (data, box_x1, box_x2, x1, x2, yy - 1, NULL, byte_stride))
|
2010-11-21 23:00:37 +00:00
|
|
|
{
|
|
|
|
found_set = 1;
|
|
|
|
break;
|
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
2010-11-21 23:00:37 +00:00
|
|
|
if (!found_set)
|
2010-11-16 11:42:53 +00:00
|
|
|
break;
|
2010-11-22 12:07:49 +00:00
|
|
|
*y = yy;
|
2010-11-21 23:00:37 +00:00
|
|
|
extended = 1;
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
return extended;
|
|
|
|
}
|
|
|
|
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
static void
|
|
|
|
rgba_find_rects_extents (unsigned char *data,
|
|
|
|
int box_x1, int box_y1,
|
|
|
|
int box_x2, int box_y2,
|
|
|
|
int x, int y,
|
|
|
|
BroadwayBox *rect,
|
|
|
|
int byte_stride)
|
|
|
|
{
|
|
|
|
int x1, x2, y1, y2, yy;
|
|
|
|
int extended;
|
|
|
|
|
|
|
|
x1 = x;
|
|
|
|
x2 = x + 1;
|
|
|
|
y1 = y;
|
|
|
|
y2 = y + 1;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Expand maximally for all known rows */
|
|
|
|
do
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-21 23:00:37 +00:00
|
|
|
extended = 0;
|
|
|
|
|
|
|
|
for (yy = y1; yy < y2; yy++)
|
|
|
|
extended |= extend_x_range (data,
|
|
|
|
box_x1, box_y1,
|
|
|
|
box_x2, box_y2,
|
|
|
|
&x1, &x2, yy,
|
|
|
|
byte_stride);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
2010-11-21 23:00:37 +00:00
|
|
|
while (extended);
|
|
|
|
}
|
|
|
|
while (extend_y_range(data,
|
|
|
|
box_x1, box_y1,
|
|
|
|
box_x2, box_y2,
|
|
|
|
x1, x2, &y2,
|
|
|
|
byte_stride));
|
|
|
|
|
|
|
|
rect->x1 = x1;
|
|
|
|
rect->x2 = x2;
|
|
|
|
rect->y1 = y1;
|
|
|
|
rect->y2 = y2;
|
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
static void
|
|
|
|
rgba_find_rects_sub (unsigned char *data,
|
|
|
|
int box_x1, int box_y1,
|
|
|
|
int box_x2, int box_y2,
|
|
|
|
int byte_stride,
|
|
|
|
BroadwayBox **rects,
|
|
|
|
int *n_rects, int *alloc_rects)
|
|
|
|
{
|
2010-11-24 20:57:30 +00:00
|
|
|
guint32 *line;
|
2010-11-21 23:00:37 +00:00
|
|
|
BroadwayBox rect;
|
|
|
|
int x, y;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
if (box_x1 == box_x2 || box_y1 == box_y2)
|
|
|
|
return;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
for (y = box_y1; y < box_y2; y++)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-24 20:57:30 +00:00
|
|
|
line = (guint32 *)(data + y * byte_stride + box_x1 * 4);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
for (x = box_x1; x < box_x2; x++)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-21 23:00:37 +00:00
|
|
|
if (*line != 0)
|
|
|
|
{
|
|
|
|
rgba_find_rects_extents (data,
|
|
|
|
box_x1, box_y1, box_x2, box_y2,
|
|
|
|
x, y, &rect, byte_stride);
|
|
|
|
if (*n_rects == *alloc_rects)
|
|
|
|
{
|
|
|
|
(*alloc_rects) *= 2;
|
2010-11-24 20:57:30 +00:00
|
|
|
*rects = g_renew (BroadwayBox, *rects, *alloc_rects);
|
2010-11-21 23:00:37 +00:00
|
|
|
}
|
|
|
|
(*rects)[*n_rects] = rect;
|
|
|
|
(*n_rects)++;
|
|
|
|
rgba_find_rects_sub (data,
|
|
|
|
box_x1, rect.y1,
|
|
|
|
rect.x1, rect.y2,
|
|
|
|
byte_stride,
|
|
|
|
rects, n_rects, alloc_rects);
|
|
|
|
rgba_find_rects_sub (data,
|
|
|
|
rect.x2, rect.y1,
|
|
|
|
box_x2, rect.y2,
|
|
|
|
byte_stride,
|
|
|
|
rects, n_rects, alloc_rects);
|
|
|
|
rgba_find_rects_sub (data,
|
|
|
|
box_x1, rect.y2,
|
|
|
|
box_x2, box_y2,
|
|
|
|
byte_stride,
|
|
|
|
rects, n_rects, alloc_rects);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
line++;
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-21 23:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BroadwayBox *
|
|
|
|
rgba_find_rects (unsigned char *data,
|
|
|
|
int w, int h, int byte_stride,
|
|
|
|
int *n_rects)
|
|
|
|
{
|
|
|
|
BroadwayBox *rects;
|
|
|
|
int alloc_rects;
|
|
|
|
|
|
|
|
alloc_rects = 20;
|
2010-11-24 20:57:30 +00:00
|
|
|
rects = g_new (BroadwayBox, alloc_rects);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
*n_rects = 0;
|
|
|
|
rgba_find_rects_sub (data,
|
|
|
|
0, 0, w, h, byte_stride,
|
|
|
|
&rects, n_rects, &alloc_rects);
|
|
|
|
|
|
|
|
return rects;
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-24 20:40:25 +00:00
|
|
|
broadway_output_put_rgba (BroadwayOutput *output, int id, int x, int y,
|
2010-11-21 18:52:05 +00:00
|
|
|
int w, int h, int byte_stride, void *data)
|
2010-11-16 11:42:53 +00:00
|
|
|
{
|
2010-11-21 23:00:37 +00:00
|
|
|
BroadwayBox *rects;
|
2012-10-01 11:02:21 +00:00
|
|
|
int i, n_rects;
|
|
|
|
gsize size_start, image_start, len;
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
rects = rgba_find_rects (data, w, h, byte_stride, &n_rects);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
2011-11-10 09:12:28 +00:00
|
|
|
guint8 *subdata;
|
|
|
|
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_PUT_RGB);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
|
|
|
append_uint16 (output, x + rects[i].x1);
|
|
|
|
append_uint16 (output, y + rects[i].y1);
|
2010-11-19 20:54:17 +00:00
|
|
|
|
2012-10-01 11:02:21 +00:00
|
|
|
size_start = output->buf->len;
|
|
|
|
append_uint32 (output, 0);
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2012-10-01 10:44:38 +00:00
|
|
|
image_start = output->buf->len;
|
|
|
|
|
|
|
|
subdata = (guint8 *)data + rects[i].x1 * 4 + rects[i].y1 * byte_stride;
|
2012-10-01 12:53:18 +00:00
|
|
|
if (output->binary)
|
|
|
|
to_png_rgba (output->buf, rects[i].x2 - rects[i].x1,
|
|
|
|
rects[i].y2 - rects[i].y1,
|
|
|
|
byte_stride, (guint32*)subdata);
|
|
|
|
else
|
|
|
|
to_png_url_rgba (output->buf, rects[i].x2 - rects[i].x1,
|
|
|
|
rects[i].y2 - rects[i].y1,
|
|
|
|
byte_stride, (guint32*)subdata);
|
2012-10-01 10:44:38 +00:00
|
|
|
|
|
|
|
len = output->buf->len - image_start;
|
2012-10-01 11:02:21 +00:00
|
|
|
|
|
|
|
overwrite_uint32 (output, size_start, len);
|
2010-11-21 23:00:37 +00:00
|
|
|
}
|
2010-11-16 11:42:53 +00:00
|
|
|
|
2010-11-21 23:00:37 +00:00
|
|
|
free (rects);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 08:50:07 +00:00
|
|
|
void
|
|
|
|
broadway_output_surface_flush (BroadwayOutput *output,
|
|
|
|
int id)
|
|
|
|
{
|
2012-12-20 13:20:20 +00:00
|
|
|
write_header (output, BROADWAY_OP_FLUSH);
|
2012-10-01 11:02:21 +00:00
|
|
|
append_uint16 (output, id);
|
2010-11-16 11:42:53 +00:00
|
|
|
}
|