|
|
@ -153,6 +153,10 @@ Image::~Image() { |
|
|
|
cairo_surface_destroy(_surface); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Load callback. |
|
|
|
*/ |
|
|
|
|
|
|
|
static int |
|
|
|
EIO_Load(eio_req *req) { |
|
|
|
Image *img = (Image *) req->data; |
|
|
@ -160,6 +164,10 @@ EIO_Load(eio_req *req) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* After load callback. |
|
|
|
*/ |
|
|
|
|
|
|
|
static int |
|
|
|
EIO_AfterLoad(eio_req *req) { |
|
|
|
HandleScope scope; |
|
|
@ -175,13 +183,22 @@ EIO_AfterLoad(eio_req *req) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Initiate image loading. |
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
Image::load() { |
|
|
|
Ref(); |
|
|
|
complete = false; |
|
|
|
eio_custom(EIO_Load, EIO_PRI_DEFAULT, EIO_AfterLoad, this); |
|
|
|
ev_ref(EV_DEFAULT_UC); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Invoke onload (when assigned). |
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
Image::loaded() { |
|
|
|
HandleScope scope; |
|
|
@ -199,6 +216,10 @@ Image::loaded() { |
|
|
|
Unref(); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Invoke onerror (when assigned) with the given err. |
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
Image::error(Local<Value> err) { |
|
|
|
HandleScope scope; |
|
|
@ -209,6 +230,12 @@ Image::error(Local<Value> err) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Load cairo surface from the image src. |
|
|
|
* |
|
|
|
* TODO: support more formats |
|
|
|
*/ |
|
|
|
|
|
|
|
cairo_status_t |
|
|
|
Image::loadSurface() { |
|
|
|
_surface = cairo_image_surface_create_from_png(filename); |
|
|
|