|
|
|
@ -214,7 +214,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -214,7 +214,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
// before it stops and shedules a continue of execution.
|
|
|
|
|
var EXECUTION_TIME = 15; |
|
|
|
|
|
|
|
|
|
function CanvasGraphics(canvasCtx, commonObjs, objs, textLayer) { |
|
|
|
|
function CanvasGraphics(canvasCtx, commonObjs, objs, textLayer, imageLayer) { |
|
|
|
|
this.ctx = canvasCtx; |
|
|
|
|
this.current = new CanvasExtraState(); |
|
|
|
|
this.stateStack = []; |
|
|
|
@ -224,6 +224,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -224,6 +224,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
this.commonObjs = commonObjs; |
|
|
|
|
this.objs = objs; |
|
|
|
|
this.textLayer = textLayer; |
|
|
|
|
this.imageLayer = imageLayer; |
|
|
|
|
if (canvasCtx) { |
|
|
|
|
addContextCurrentTransform(canvasCtx); |
|
|
|
|
} |
|
|
|
@ -399,8 +400,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -399,8 +400,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
this.ctx.save(); |
|
|
|
|
this.ctx.transform.apply(this.ctx, transform); |
|
|
|
|
|
|
|
|
|
if (this.textLayer) |
|
|
|
|
if (this.textLayer) { |
|
|
|
|
this.textLayer.beginLayout(); |
|
|
|
|
} |
|
|
|
|
if (this.imageLayer) { |
|
|
|
|
this.imageLayer.beginLayout(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
executeOperatorList: function CanvasGraphics_executeOperatorList( |
|
|
|
@ -477,8 +482,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -477,8 +482,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
endDrawing: function CanvasGraphics_endDrawing() { |
|
|
|
|
this.ctx.restore(); |
|
|
|
|
|
|
|
|
|
if (this.textLayer) |
|
|
|
|
if (this.textLayer) { |
|
|
|
|
this.textLayer.endLayout(); |
|
|
|
|
} |
|
|
|
|
if (this.imageLayer) { |
|
|
|
|
this.imageLayer.endLayout(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// Graphics state
|
|
|
|
@ -1275,7 +1284,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -1275,7 +1284,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
|
|
|
|
|
ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, |
|
|
|
|
0, -h, w, h); |
|
|
|
|
|
|
|
|
|
if (this.imageLayer) { |
|
|
|
|
var currentTransform = ctx.mozCurrentTransformInverse; |
|
|
|
|
var widthScale = Math.max(Math.abs(currentTransform[0]), 1); |
|
|
|
|
var heightScale = Math.max(Math.abs(currentTransform[3]), 1); |
|
|
|
|
var position = this.getCanvasPosition(0, 0); |
|
|
|
|
this.imageLayer.appendImage({ |
|
|
|
|
objId: objId, |
|
|
|
|
left: position[0], |
|
|
|
|
top: position[1], |
|
|
|
|
width: w / widthScale, |
|
|
|
|
height: h / heightScale |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.restore(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -1374,6 +1395,17 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -1374,6 +1395,17 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
} |
|
|
|
|
ctx.drawImage(tmpCanvas, 0, -height); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.imageLayer) { |
|
|
|
|
var position = this.getCanvasPosition(0, -height); |
|
|
|
|
this.imageLayer.appendImage({ |
|
|
|
|
imgData: imgData, |
|
|
|
|
left: position[0], |
|
|
|
|
top: position[1], |
|
|
|
|
width: width / widthScale, |
|
|
|
|
height: height / heightScale |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.restore(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -1394,6 +1426,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -1394,6 +1426,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
ctx.scale(1, -1); |
|
|
|
|
ctx.drawImage(tmpCanvas, entry.x, entry.y, entry.w, entry.h, |
|
|
|
|
0, -1, 1, 1); |
|
|
|
|
if (this.imageLayer) { |
|
|
|
|
var position = this.getCanvasPosition(entry.x, entry.y); |
|
|
|
|
this.imageLayer.appendImage({ |
|
|
|
|
imgData: imgData, |
|
|
|
|
left: position[0], |
|
|
|
|
top: position[1], |
|
|
|
|
width: w, |
|
|
|
|
height: h |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
ctx.restore(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -1459,6 +1501,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
@@ -1459,6 +1501,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|
|
|
|
return Math.sqrt(Math.max( |
|
|
|
|
(inverse[0] * inverse[0] + inverse[1] * inverse[1]), |
|
|
|
|
(inverse[2] * inverse[2] + inverse[3] * inverse[3]))); |
|
|
|
|
}, |
|
|
|
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { |
|
|
|
|
var transform = this.ctx.mozCurrentTransform; |
|
|
|
|
return [ |
|
|
|
|
transform[0] * x + transform[2] * y + transform[4], |
|
|
|
|
transform[1] * x + transform[3] * y + transform[5] |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|