[gtk+/broadway: 243/246] broadway: Fix flicker when resizing windows
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/broadway: 243/246] broadway: Fix flicker when resizing windows
- Date: Tue, 15 Mar 2011 12:01:27 +0000 (UTC)
commit 2635a27814410e8e0fe5c15f1171474e81430ec7
Author: Alexander Larsson <alexl redhat com>
Date: Tue Mar 15 10:18:07 2011 +0100
broadway: Fix flicker when resizing windows
Resizing a canvas causes a clear, so we have to save the previous
content and restore to avoid flickering.
gdk/broadway/broadway.js | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 89242e3..286f0de 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -276,10 +276,26 @@ function handleCommands(cmd_obj)
i = i + 3;
var h = base64_16(cmd, i);
i = i + 3;
- flushSurface(surfaces[id]);
- surfaces[id].canvas.width = w;
- surfaces[id].canvas.height = h;
- break;
+ var surface = surfaces[id];
+
+ /* Flush any outstanding draw ops before changing size */
+ flushSurface(surface);
+
+ /* Canvas resize clears the data, so we need to save it first */
+ var tmpCanvas = document.createElement("canvas");
+ tmpCanvas.width = surface.canvas.width;
+ tmpCanvas.height = surface.canvas.height;
+ var tmpContext = tmpCanvas.getContext("2d");
+ tmpContext.globalCompositeOperation = "copy";
+ tmpContext.drawImage(surface.canvas, 0, 0, tmpCanvas.width, tmpCanvas.height);
+
+ surface.canvas.width = w;
+ surface.canvas.height = h;
+
+ surface.globalCompositeOperation = "copy";
+ surface.drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height);
+
+ break;
/* put image data surface */
case 'i':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]