From be9b2ee411425525bb1aa30fd5687b5279cbed59 Mon Sep 17 00:00:00 2001 From: Elijah Hamovitz Date: Thu, 12 Jan 2012 17:35:52 -0800 Subject: [PATCH] removed errant TODOs, reconsidered error handling --- src/Canvas.cc | 10 +--------- src/JPEGStream.h | 7 +++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Canvas.cc b/src/Canvas.cc index 42d6868..9df5cdb 100644 --- a/src/Canvas.cc +++ b/src/Canvas.cc @@ -308,19 +308,11 @@ Canvas::StreamJPEGSync(const Arguments &args) { closure_t closure; closure.fn = Handle::Cast(args[2]); - /* - TODO: tie jpeg_error_mgr into the error callback - */ TryCatch try_catch; - cairo_status_t status = write_to_jpeg_stream(canvas->surface(), args[0]->NumberValue(), args[1]->NumberValue(), &closure); + write_to_jpeg_stream(canvas->surface(), args[0]->NumberValue(), args[1]->NumberValue(), &closure); if (try_catch.HasCaught()) { return try_catch.ReThrow(); - // TODO : figure out libjpeg error handling, use this - } else if (status) { - // error state - Local argv[1] = { Canvas::Error(status) }; - closure.fn->Call(Context::GetCurrent()->Global(), 1, argv); } return Undefined(); } diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 73d5276..753949f 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -8,6 +8,7 @@ #include "Canvas.h" #include +#include /* Expanded data destination object for closure output */ /* inspired by IJG's jdatadst.c */ @@ -20,7 +21,7 @@ typedef struct { } closure_destination_mgr; void init_closure_destination(j_compress_ptr cinfo){ - // I don't think we really have to do anything here ... + // we really don't have to do anything here } boolean empty_closure_output_buffer(j_compress_ptr cinfo){ @@ -85,7 +86,7 @@ void jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int bufsize){ cinfo->dest->free_in_buffer = dest->bufsize; } -cairo_status_t 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/ @@ -103,7 +104,6 @@ cairo_status_t write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int q cinfo.image_width = w; cinfo.image_height = h; jpeg_set_defaults(&cinfo); - /* TODO: quality */ jpeg_set_quality(&cinfo, quality, (quality<25)?0:1); jpeg_closure_dest(&cinfo, closure, bufsize); @@ -130,7 +130,6 @@ cairo_status_t write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int q free(dst); jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); - return CAIRO_STATUS_SUCCESS; } #endif