From 3c2cf684e4520e4d5008a3bac42484d5bfe80f54 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Fri, 13 Jan 2012 08:49:18 -0800 Subject: [PATCH] slight refactor --- src/JPEGStream.h | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 753949f..0085bd8 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -10,21 +10,25 @@ #include #include -/* Expanded data destination object for closure output */ -/* inspired by IJG's jdatadst.c */ -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ +/* + * Expanded data destination object for closure output, + * inspired by IJG's jdatadst.c + */ - closure_t * closure; - JOCTET * buffer; +typedef struct { + struct jpeg_destination_mgr pub; + closure_t *closure; + JOCTET *buffer; int bufsize; } closure_destination_mgr; -void init_closure_destination(j_compress_ptr cinfo){ +void +init_closure_destination(j_compress_ptr cinfo){ // we really don't have to do anything here } -boolean empty_closure_output_buffer(j_compress_ptr cinfo){ +boolean +empty_closure_output_buffer(j_compress_ptr cinfo){ closure_destination_mgr * dest = (closure_destination_mgr *) cinfo->dest; Local buf = Buffer::New(dest->bufsize); memcpy(Buffer::Data(buf->handle_), dest->buffer, dest->bufsize); @@ -39,7 +43,8 @@ boolean empty_closure_output_buffer(j_compress_ptr cinfo){ return true; } -void term_closure_destination(j_compress_ptr cinfo){ +void +term_closure_destination(j_compress_ptr cinfo){ closure_destination_mgr * dest = (closure_destination_mgr *) cinfo->dest; /* emit remaining data */ size_t remaining = dest->bufsize - cinfo->dest->free_in_buffer; @@ -60,7 +65,8 @@ void term_closure_destination(j_compress_ptr cinfo){ dest->closure->fn->Call(Context::GetCurrent()->Global(), 3, end_argv); } -void jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int bufsize){ +void +jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int bufsize){ closure_destination_mgr * dest; /* The destination object is made permanent so that multiple JPEG images @@ -86,7 +92,8 @@ void jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int bufsize){ cinfo->dest->free_in_buffer = dest->bufsize; } -void write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int quality, closure_t * closure){ +void +write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int quality, closure_t * closure){ /* libjs code adapted from the Cairo R graphics project: http://www.rforge.net/Cairo/