[gtk+] [broadway] Make the surface object a plain js object, not the context
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] [broadway] Make the surface object a plain js object, not the context
- Date: Thu, 7 Apr 2011 19:20:11 +0000 (UTC)
commit 7c20d594118bfadc33db64549243f0fb59b1703e
Author: Alexander Larsson <alexl redhat com>
Date: Wed Apr 6 09:46:49 2011 +0200
[broadway] Make the surface object a plain js object, not the context
gdk/broadway/broadway.js | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index e00e3eb..12900a2 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -94,21 +94,26 @@ var inputSocket = null;
function createSurface(id, x, y, width, height, isTemp)
{
+ var surface = { id: id, x: x, y:y, width: width, height: height, isTemp: isTemp };
+ surface.drawQueue = [];
+ surface.transientParent = 0;
+
var canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
- canvas.surfaceId = id;
+ canvas.surface = surface;
canvas.style["position"] = "absolute";
canvas.style["left"] = x + "px";
canvas.style["top"] = y + "px";
canvas.style["display"] = "none";
+ document.body.appendChild(canvas);
+ surface.canvas = canvas;
+
var context = canvas.getContext("2d");
context.globalCompositeOperation = "source-over";
- document.body.appendChild(canvas);
- context.drawQueue = [];
- context.isTemp = isTemp;
- context.transientParent = 0;
- surfaces[id] = context;
+ surface.context = context;
+
+ surfaces[id] = surface;
}
var GDK_CROSSING_NORMAL = 0;
@@ -152,19 +157,17 @@ function flushSurface(surface)
{
var commands = surface.drawQueue;
surface.queue = [];
+ var context = surface.context;
var i = 0;
for (i = 0; i < commands.length; i++) {
var cmd = commands[i];
- var context = surfaces[cmd.id];
switch (cmd.op) {
- /* put image data surface */
- case 'i':
+ case 'i': // put image data surface
context.globalCompositeOperation = "source-over";
context.drawImage(cmd.img, cmd.x, cmd.y);
break;
- /* copy rects */
- case 'b':
+ case 'b': // copy rects
context.save();
context.beginPath();
@@ -199,7 +202,7 @@ function flushSurface(surface)
context.restore();
break;
- default:
+ default:
alert("Unknown drawing op " + cmd.op);
}
}
@@ -293,8 +296,8 @@ function handleCommands(cmdObj)
surface.canvas.width = w;
surface.canvas.height = h;
- surface.globalCompositeOperation = "copy";
- surface.drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height);
+ surface.context.globalCompositeOperation = "copy";
+ surface.context.drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height);
break;
@@ -411,9 +414,9 @@ function handleLoad(event)
}
function getSurfaceId(ev) {
- var id = ev.target.surfaceId;
- if (id != undefined)
- return id;
+ var surface = ev.target.surface;
+ if (surface != undefined)
+ return surface.id;
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]