Fix sending image data to main thread

This commit is contained in:
Julian Viereck 2011-06-23 14:36:45 +02:00
parent da7f555fd7
commit f32dfa9414
3 changed files with 8 additions and 6 deletions

View File

@ -12,8 +12,11 @@ var JpegStreamProxy = (function() {
// 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)
}
});
}

View File

@ -10,7 +10,7 @@ function load(userInput) {
pageNum = parseInt(queryParams().page) || 1;
var fileName = userInput;
if (!userInput) {
fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
fileName = "canvas.pdf";
}
open(fileName);
}

View File

@ -71,7 +71,7 @@ function WorkerPDFDoc(canvas) {
"$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);
@ -179,9 +179,8 @@ function WorkerPDFDoc(canvas) {
"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) {