Permalink
Browse files

Work around the WebKit bug that bit me yesterday and tonight: we can …

…only use

the not-so-useful form of context.drawImage() at present, because the versions
that actually include the image dimensions always throw exceptions.
  • Loading branch information...
Adam Harvey
Adam Harvey committed Jan 19, 2010
1 parent 72e2bc2 commit f47e471021836c9956309c0602278b528d7ecdca
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/Player.js
View
@@ -65,6 +65,14 @@ cinejs.Player.prototype.check = function () {
throw "The frame delay must be a non-negative number";
}
+ /* Temporary WebKit bug workaround: because WebKit only correctly
+ * implements the first version of the context.drawImage() API, which
+ * is the least useful one. (Of course.) This means we can't alter
+ * image dimensions from the source to the destination. */
+ if (this.options.source.width != this.options.destination.width || this.options.source.height != this.options.destination.height) {
+ throw "The source and destination dimensions must be specified and identical";
+ }
+
// Check any and all defined filters.
for (var i in this.filters) {
if (this.filters.hasOwnProperty(i)) {
@@ -98,8 +106,8 @@ cinejs.Player.prototype.createIntermediateCanvas = function () {
canvas.style.display = "none";
// Grab the destination size as our intermediate size.
- canvas.width = this.options.destination.width;
- canvas.height = this.options.destination.height;
+ canvas.width = this.options.source.width;
+ canvas.height = this.options.source.height;
document.body.appendChild(canvas);
@@ -155,7 +163,7 @@ cinejs.Player.prototype.renderFrame = function (source, intermediate, destinatio
/* Put the current source frame onto the intermediate canvas so
* we can get its raw image data. */
- intermediateContext.drawImage(source, 0, 0, intermediate.width, intermediate.height);
+ intermediateContext.drawImage(source, 0, 0);
var imageData = intermediateContext.getImageData(0, 0, intermediate.width, intermediate.height);
// Now apply each filter in turn.

0 comments on commit f47e471

Please sign in to comment.