From 6677953d87423144b0d8679bc6ce359f3bc242ca Mon Sep 17 00:00:00 2001 From: Philip Giuliani Date: Mon, 13 Apr 2015 19:05:23 +0200 Subject: [PATCH] Save and restore inside of the drawer --- src/drawer.js | 4 +++- src/tiledimage.js | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/drawer.js b/src/drawer.js index c9c94214..bfbc38c4 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -310,14 +310,16 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{ return; } + + this.saveContext(); if ( typeof fillStyle === "function" ) { this.context.fillStyle = fillStyle(this.context); } else { this.context.fillStyle = fillStyle; } - this.context.fillRect(rect.x, rect.y, rect.width, rect.height); + this.restoreContext(); }, // private diff --git a/src/tiledimage.js b/src/tiledimage.js index cea8d2b1..039a4f7f 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1172,12 +1172,8 @@ function drawTiles( tiledImage, lastDrawn ) { } if ( tiledImage.placeholderFillStyle && lastDrawn.length === 0 ) { - tiledImage._drawer.saveContext(); - var placeholderRect = tiledImage._drawer.viewportToDrawerRectangle(tiledImage.getBounds(true)); tiledImage._drawer.drawPlaceholder(placeholderRect, tiledImage.placeholderFillStyle); - - tiledImage._drawer.restoreContext(); } for ( i = lastDrawn.length - 1; i >= 0; i-- ) {