Skip to content

Commit e798491

Browse files
committed
ignore ctx.restore() if in the initial state
calling cairo_restore on the initial state makes all drawing operations afterwards do nothing, which does not match browser behavior
1 parent 259d1b7 commit e798491

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/CanvasRenderingContext2d.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ Context2d::save() {
233233

234234
void
235235
Context2d::restore() {
236-
cairo_restore(_context);
237-
restoreState();
236+
if (stateno > 0) {
237+
cairo_restore(_context);
238+
restoreState();
239+
}
238240
}
239241

240242
/*
@@ -258,7 +260,6 @@ Context2d::saveState() {
258260

259261
void
260262
Context2d::restoreState() {
261-
if (0 == stateno) return;
262263
// Olaf (2011-02-21): Free old state data
263264
#if HAVE_PANGO
264265
free(states[stateno]->fontFamily);

0 commit comments

Comments
 (0)