Browse Source

Image loading is sync until race-condition is resolved

v1.x
Tj Holowaychuk 14 years ago
parent
commit
50c2e63da3
  1. 34
      src/Image.cc
  2. 2
      src/Image.h

34
src/Image.cc

@ -168,37 +168,6 @@ Image::~Image() {
if (filename) free(filename);
}
/*
* Load callback.
*/
int
Image::EIO_Load(eio_req *req) {
Image *img = (Image *) req->data;
req->result = img->loadSurface();
return 0;
}
/*
* After load callback.
*/
int
Image::EIO_AfterLoad(eio_req *req) {
HandleScope scope;
Image *img = (Image *) req->data;
if (req->result) {
img->error(Canvas::Error((cairo_status_t) req->result));
} else {
img->loaded();
}
img->Unref();
ev_unref(EV_DEFAULT_UC);
return 0;
}
/*
* Initiate image loading.
*/
@ -208,8 +177,7 @@ Image::load() {
if (LOADING != state) {
Ref();
state = LOADING;
eio_custom(EIO_Load, EIO_PRI_DEFAULT, EIO_AfterLoad, this);
ev_ref(EV_DEFAULT_UC);
loadSync();
}
}

2
src/Image.h

@ -31,8 +31,6 @@ class Image: public node::ObjectWrap {
inline cairo_surface_t *surface(){ return _surface; }
inline uint8_t *data(){ return cairo_image_surface_get_data(_surface); }
inline int stride(){ return cairo_image_surface_get_stride(_surface); }
static int EIO_Load(eio_req *req);
static int EIO_AfterLoad(eio_req *req);
cairo_status_t loadSurface();
cairo_status_t loadPNG();
#ifdef HAVE_JPEG

Loading…
Cancel
Save