- if (srcCanvas.width != 0 && srcCanvas.height != 0)
- displayContext.drawImage(srcCanvas, srcx, srcy, srcw, srch, x, y, srcw, srch);
+ if (srcCanvas.width != 0 && srcCanvas.height != 0) {
+
+ // Copy source data into temporary canvas (drawing from
+ // source canvas directly can cause the operation to be
+ // performed lazily by the underlying Canvas implementation,
+ // which undermines the sychronization built into these
+ // layers).
+ temp.width = srcw;
+ temp.height = srch;
+ tempContext.putImageData(
+ srcLayer.getContext().getImageData(srcx, srcy, srcw, srch),
+ 0, 0);
+
+ // Draw from temporary canvas
+ displayContext.drawImage(temp, 0, 0, srcw, srch, x, y, srcw, srch);
+
+ }