Browse Source

Added Image::loadSync()

async seems to work fine in some cases, but something in cairo
is not thread-safe and messes up with `make test-server`
v1.x
Tj Holowaychuk 14 years ago
parent
commit
c94f2e64f8
  1. 22
      src/Image.cc
  2. 1
      src/Image.h

22
src/Image.cc

@ -198,10 +198,26 @@ EIO_AfterLoad(eio_req *req) {
void void
Image::load() { Image::load() {
if (LOADING != state) { if (LOADING != state) {
Ref(); // TODO: use node IO
// Ref();
state = LOADING; state = LOADING;
eio_custom(EIO_Load, EIO_PRI_DEFAULT, EIO_AfterLoad, this); loadSync();
ev_ref(EV_DEFAULT_UC); // eio_custom(EIO_Load, EIO_PRI_DEFAULT, EIO_AfterLoad, this);
// ev_ref(EV_DEFAULT_UC);
}
}
/*
* Load image synchronously.
*/
void
Image::loadSync() {
cairo_status_t status = loadSurface();
if (status) {
error(Canvas::Error(status));
} else {
loaded();
} }
} }

1
src/Image.h

@ -34,6 +34,7 @@ class Image: public node::ObjectWrap {
inline int stride(){ return cairo_image_surface_get_stride(_surface); } inline int stride(){ return cairo_image_surface_get_stride(_surface); }
cairo_status_t loadSurface(); cairo_status_t loadSurface();
void error(Local<Value>); void error(Local<Value>);
void loadSync();
void loaded(); void loaded();
void load(); void load();
Image(); Image();

Loading…
Cancel
Save