// Tell the main thread to create an image.
postMessage({
- action: jpeg_stream,
- data: bytesToString(bytes)
+ action: "jpeg_stream",
+ data: {
+ id: this.id,
+ raw: bytesToString(bytes)
+ }
});
}
pageNum = parseInt(queryParams().page) || 1;
var fileName = userInput;
if (!userInput) {
- fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
+ fileName = "canvas.pdf";
}
open(fileName);
}
"$drawImage": function(id, x, y, sx, sy, swidth, sheight) {
var image = imagesList[id];
if (!image) {
- throw "Image not found";
+ throw "Image not found: " + id;
}
this.drawImage(image, x, y, image.width, image.height,
sx, sy, swidth, sheight);
"jpeg_stream": function(data) {
var img = new Image();
- img.src = "data:image/jpeg;base64," + window.btoa(data);
+ img.src = "data:image/jpeg;base64," + window.btoa(data.raw);
imagesList[data.id] = img;
- console.log("got image", data.id)
},
"canvas_proxy_cmd_queue": function(data) {