Browse Source

Added Context2d::{save,restore}()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
86837dbecc
  1. 26
      src/CanvasRenderingContext2d.cc
  2. 2
      src/CanvasRenderingContext2d.h

26
src/CanvasRenderingContext2d.cc

@ -171,6 +171,26 @@ Context2d::~Context2d() {
cairo_destroy(_context);
}
/*
* Save cairo / canvas state.
*/
void
Context2d::save() {
cairo_save(_context);
saveState();
}
/*
* Restore cairo / canvas state.
*/
void
Context2d::restore() {
cairo_restore(_context);
restoreState();
}
/*
* Save the current state.
*/
@ -630,8 +650,7 @@ Handle<Value>
Context2d::Save(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_save(context->getContext());
context->saveState();
context->save();
return Undefined();
}
@ -643,8 +662,7 @@ Handle<Value>
Context2d::Restore(const Arguments &args) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_restore(context->getContext());
context->restoreState();
context->restore();
return Undefined();
}

2
src/CanvasRenderingContext2d.h

@ -104,6 +104,8 @@ class Context2d: public node::ObjectWrap {
void setTextPath(const char *str, double x, double y);
void savePath();
void restorePath();
void save();
void restore();
void saveState();
void restoreState();

Loading…
Cancel
Save