Bug 588452 - Don't render to zoom snapshot canvas before prior render finishes [r=stechz]

--HG--
extra : rebase_source : f4994456ae0bd2704aa8ae52f80810607a6c2bbd
This commit is contained in:
Matt Brubeck 2010-08-18 19:30:42 -07:00
Родитель 7263fddc3c
Коммит 30dae6761b
1 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -51,6 +51,10 @@ let Cu = Components.utils;
function AnimatedZoom(aBrowserView) { function AnimatedZoom(aBrowserView) {
this.bv = aBrowserView; this.bv = aBrowserView;
this.snapshot = AnimatedZoom.createCanvas();
if (this.snapshot.pending_render)
return;
// Render a snapshot of the viewport contents around the visible rect // Render a snapshot of the viewport contents around the visible rect
let [w, h] = this.bv.getViewportDimensions(); let [w, h] = this.bv.getViewportDimensions();
let viewportRect = new Rect(0, 0, w, h); let viewportRect = new Rect(0, 0, w, h);
@ -61,8 +65,6 @@ function AnimatedZoom(aBrowserView) {
// sanitize the snapshot rectangle to fit inside viewport // sanitize the snapshot rectangle to fit inside viewport
this.snapshotRect.translateInside(viewportRect).restrictTo(viewportRect).expandToIntegers(); this.snapshotRect.translateInside(viewportRect).restrictTo(viewportRect).expandToIntegers();
this.snapshot = AnimatedZoom.createCanvas();
this.snapshotRect.width = Math.min(this.snapshotRect.width, this.snapshot.width); this.snapshotRect.width = Math.min(this.snapshotRect.width, this.snapshot.width);
this.snapshotRect.height = Math.min(this.snapshotRect.height, this.snapshot.height); this.snapshotRect.height = Math.min(this.snapshotRect.height, this.snapshot.height);
@ -74,6 +76,7 @@ function AnimatedZoom(aBrowserView) {
if (remote) { if (remote) {
this.canvasReady = false; this.canvasReady = false;
this.snapshot.addEventListener("MozAsyncCanvasRender", this, false); this.snapshot.addEventListener("MozAsyncCanvasRender", this, false);
this.snapshot.pending_render = true;
} else { } else {
this.canvasReady = true; this.canvasReady = true;
this.startAnimation(); this.startAnimation();
@ -82,8 +85,11 @@ function AnimatedZoom(aBrowserView) {
AnimatedZoom.prototype.handleEvent = function(aEvent) { AnimatedZoom.prototype.handleEvent = function(aEvent) {
if (aEvent.type == "MozAsyncCanvasRender") { if (aEvent.type == "MozAsyncCanvasRender") {
this.snapshot.removeEventListener("MozAsyncCanvasRender", this, false); let snapshot = aEvent.originalTarget;
if (aEvent.originalTarget == this.snapshot) { snapshot.pending_render = false;
snapshot.removeEventListener("MozAsyncCanvasRender", this, false);
if (this.snapshot == snapshot) {
this.canvasReady = true; this.canvasReady = true;
this.startAnimation(); this.startAnimation();
} }
@ -150,6 +156,9 @@ AnimatedZoom.prototype.startAnimation = function()
AnimatedZoom.prototype.updateTo = function(nextRect) { AnimatedZoom.prototype.updateTo = function(nextRect) {
this.zoomRect = nextRect; this.zoomRect = nextRect;
if (this.snapshot.pending_render)
return;
// prepare to draw to the zoom canvas // prepare to draw to the zoom canvas
let canvasRect = new Rect(0, 0, Elements.viewBuffer.width, Elements.viewBuffer.height); let canvasRect = new Rect(0, 0, Elements.viewBuffer.width, Elements.viewBuffer.height);
let ctx = Elements.viewBuffer.getContext("2d"); let ctx = Elements.viewBuffer.getContext("2d");