Browse Source

hint v8 at Image surface

v1.x
Tj Holowaychuk 14 years ago
parent
commit
109efafedf
  1. 11
      src/Image.cc

11
src/Image.cc

@ -167,7 +167,10 @@ Image::Image() {
*/ */
Image::~Image() { Image::~Image() {
if (_surface) cairo_surface_destroy(_surface); if (_surface) {
V8::AdjustAmountOfExternalAllocatedMemory(-4 * width * height);
cairo_surface_destroy(_surface);
}
if (filename) free(filename); if (filename) free(filename);
} }
@ -194,6 +197,7 @@ Image::loadSync() {
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
error(try_catch); error(try_catch);
} else { } else {
V8::AdjustAmountOfExternalAllocatedMemory(4 * width * height);
loaded(); loaded();
} }
} }
@ -263,12 +267,12 @@ Image::loadSurface() {
Handle<Value> Handle<Value>
Image::loadPNG() { Image::loadPNG() {
_surface = cairo_image_surface_create_from_png(filename); _surface = cairo_image_surface_create_from_png(filename);
width = cairo_image_surface_get_width(_surface);
height = cairo_image_surface_get_height(_surface);
cairo_status_t status = cairo_surface_status(_surface); cairo_status_t status = cairo_surface_status(_surface);
if (status) { if (status) {
return ThrowException(Canvas::Error(status)); return ThrowException(Canvas::Error(status));
} else { } else {
width = cairo_image_surface_get_width(_surface);
height = cairo_image_surface_get_height(_surface);
return Undefined(); return Undefined();
} }
} }
@ -338,6 +342,7 @@ Image::loadJPEG() {
jpeg_finish_decompress(&info); jpeg_finish_decompress(&info);
jpeg_destroy_decompress(&info); jpeg_destroy_decompress(&info);
cairo_status_t status = cairo_surface_status(_surface); cairo_status_t status = cairo_surface_status(_surface);
if (status) { if (status) {
free(data); free(data);
return ThrowException(Canvas::Error(status)); return ThrowException(Canvas::Error(status));

Loading…
Cancel
Save