Merge upstream.

This commit is contained in:
Brendan Dahl 2012-04-05 12:46:23 -07:00
commit fece736b8a
30 changed files with 2330 additions and 1891 deletions

View file

@ -20,56 +20,6 @@ var TextRenderingMode = {
// Minimal font size that would be used during canvas fillText operations.
var MIN_FONT_SIZE = 1;
var CanvasExtraState = (function CanvasExtraStateClosure() {
function CanvasExtraState(old) {
// Are soft masks and alpha values shapes or opacities?
this.alphaIsShape = false;
this.fontSize = 0;
this.fontSizeScale = 1;
this.textMatrix = IDENTITY_MATRIX;
this.fontMatrix = IDENTITY_MATRIX;
this.leading = 0;
// Current point (in user coordinates)
this.x = 0;
this.y = 0;
// Start of text line (in text coordinates)
this.lineX = 0;
this.lineY = 0;
// Character and word spacing
this.charSpacing = 0;
this.wordSpacing = 0;
this.textHScale = 1;
this.textRenderingMode = TextRenderingMode.FILL;
// Color spaces
this.fillColorSpace = new DeviceGrayCS();
this.fillColorSpaceObj = null;
this.strokeColorSpace = new DeviceGrayCS();
this.strokeColorSpaceObj = null;
this.fillColorObj = null;
this.strokeColorObj = null;
// Default fore and background colors
this.fillColor = '#000000';
this.strokeColor = '#000000';
// Note: fill alpha applies to all non-stroking operations
this.fillAlpha = 1;
this.strokeAlpha = 1;
this.lineWidth = 1;
this.old = old;
}
CanvasExtraState.prototype = {
clone: function canvasextra_clone() {
return Object.create(this);
},
setCurrentPoint: function canvasextra_setCurrentPoint(x, y) {
this.x = x;
this.y = y;
}
};
return CanvasExtraState;
})();
function createScratchCanvas(width, height) {
var canvas = document.createElement('canvas');
canvas.width = width;
@ -187,6 +137,56 @@ function addContextCurrentTransform(ctx) {
}
}
var CanvasExtraState = (function CanvasExtraStateClosure() {
function CanvasExtraState(old) {
// Are soft masks and alpha values shapes or opacities?
this.alphaIsShape = false;
this.fontSize = 0;
this.fontSizeScale = 1;
this.textMatrix = IDENTITY_MATRIX;
this.fontMatrix = IDENTITY_MATRIX;
this.leading = 0;
// Current point (in user coordinates)
this.x = 0;
this.y = 0;
// Start of text line (in text coordinates)
this.lineX = 0;
this.lineY = 0;
// Character and word spacing
this.charSpacing = 0;
this.wordSpacing = 0;
this.textHScale = 1;
this.textRenderingMode = TextRenderingMode.FILL;
// Color spaces
this.fillColorSpace = new DeviceGrayCS();
this.fillColorSpaceObj = null;
this.strokeColorSpace = new DeviceGrayCS();
this.strokeColorSpaceObj = null;
this.fillColorObj = null;
this.strokeColorObj = null;
// Default fore and background colors
this.fillColor = '#000000';
this.strokeColor = '#000000';
// Note: fill alpha applies to all non-stroking operations
this.fillAlpha = 1;
this.strokeAlpha = 1;
this.lineWidth = 1;
this.old = old;
}
CanvasExtraState.prototype = {
clone: function CanvasExtraState_clone() {
return Object.create(this);
},
setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
this.x = x;
this.y = y;
}
};
return CanvasExtraState;
})();
var CanvasGraphics = (function CanvasGraphicsClosure() {
// Defines the time the executeOperatorList is going to be executing
// before it stops and shedules a continue of execution.
@ -241,7 +241,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
'shadingFill': true
},
beginDrawing: function canvasGraphicsBeginDrawing(mediaBox) {
beginDrawing: function CanvasGraphics_beginDrawing(mediaBox) {
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height;
this.ctx.save();
switch (mediaBox.rotate) {
@ -267,7 +267,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.textLayer.beginLayout();
},
executeOperatorList: function canvasGraphicsExecuteOperatorList(
executeOperatorList: function CanvasGraphics_executeOperatorList(
operatorList,
executionStartIdx, continueCallback,
stepper) {
@ -332,7 +332,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
},
endDrawing: function canvasGraphicsEndDrawing() {
endDrawing: function CanvasGraphics_endDrawing() {
this.ctx.restore();
if (this.textLayer)
@ -340,32 +340,32 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
// Graphics state
setLineWidth: function canvasGraphicsSetLineWidth(width) {
setLineWidth: function CanvasGraphics_setLineWidth(width) {
this.current.lineWidth = width;
this.ctx.lineWidth = width;
},
setLineCap: function canvasGraphicsSetLineCap(style) {
setLineCap: function CanvasGraphics_setLineCap(style) {
this.ctx.lineCap = LINE_CAP_STYLES[style];
},
setLineJoin: function canvasGraphicsSetLineJoin(style) {
setLineJoin: function CanvasGraphics_setLineJoin(style) {
this.ctx.lineJoin = LINE_JOIN_STYLES[style];
},
setMiterLimit: function canvasGraphicsSetMiterLimit(limit) {
setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
this.ctx.miterLimit = limit;
},
setDash: function canvasGraphicsSetDash(dashArray, dashPhase) {
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
this.ctx.mozDash = dashArray;
this.ctx.mozDashOffset = dashPhase;
this.ctx.webkitLineDash = dashArray;
this.ctx.webkitLineDashOffset = dashPhase;
},
setRenderingIntent: function canvasGraphicsSetRenderingIntent(intent) {
setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
TODO('set rendering intent: ' + intent);
},
setFlatness: function canvasGraphicsSetFlatness(flatness) {
setFlatness: function CanvasGraphics_setFlatness(flatness) {
TODO('set flatness: ' + flatness);
},
setGState: function canvasGraphicsSetGState(states) {
setGState: function CanvasGraphics_setGState(states) {
for (var i = 0, ii = states.length; i < ii; i++) {
var state = states[i];
var key = state[0];
@ -406,52 +406,52 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
}
},
save: function canvasGraphicsSave() {
save: function CanvasGraphics_save() {
this.ctx.save();
var old = this.current;
this.stateStack.push(old);
this.current = old.clone();
},
restore: function canvasGraphicsRestore() {
restore: function CanvasGraphics_restore() {
var prev = this.stateStack.pop();
if (prev) {
this.current = prev;
this.ctx.restore();
}
},
transform: function canvasGraphicsTransform(a, b, c, d, e, f) {
transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
this.ctx.transform(a, b, c, d, e, f);
},
// Path
moveTo: function canvasGraphicsMoveTo(x, y) {
moveTo: function CanvasGraphics_moveTo(x, y) {
this.ctx.moveTo(x, y);
this.current.setCurrentPoint(x, y);
},
lineTo: function canvasGraphicsLineTo(x, y) {
lineTo: function CanvasGraphics_lineTo(x, y) {
this.ctx.lineTo(x, y);
this.current.setCurrentPoint(x, y);
},
curveTo: function canvasGraphicsCurveTo(x1, y1, x2, y2, x3, y3) {
curveTo: function CanvasGraphics_curveTo(x1, y1, x2, y2, x3, y3) {
this.ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
this.current.setCurrentPoint(x3, y3);
},
curveTo2: function canvasGraphicsCurveTo2(x2, y2, x3, y3) {
curveTo2: function CanvasGraphics_curveTo2(x2, y2, x3, y3) {
var current = this.current;
this.ctx.bezierCurveTo(current.x, current.y, x2, y2, x3, y3);
current.setCurrentPoint(x3, y3);
},
curveTo3: function canvasGraphicsCurveTo3(x1, y1, x3, y3) {
curveTo3: function CanvasGraphics_curveTo3(x1, y1, x3, y3) {
this.curveTo(x1, y1, x3, y3, x3, y3);
this.current.setCurrentPoint(x3, y3);
},
closePath: function canvasGraphicsClosePath() {
closePath: function CanvasGraphics_closePath() {
this.ctx.closePath();
},
rectangle: function canvasGraphicsRectangle(x, y, width, height) {
rectangle: function CanvasGraphics_rectangle(x, y, width, height) {
this.ctx.rect(x, y, width, height);
},
stroke: function canvasGraphicsStroke(consumePath) {
stroke: function CanvasGraphics_stroke(consumePath) {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx;
var strokeColor = this.current.strokeColor;
@ -476,11 +476,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// Restore the global alpha to the fill alpha
ctx.globalAlpha = this.current.fillAlpha;
},
closeStroke: function canvasGraphicsCloseStroke() {
closeStroke: function CanvasGraphics_closeStroke() {
this.closePath();
this.stroke();
},
fill: function canvasGraphicsFill(consumePath) {
fill: function CanvasGraphics_fill(consumePath) {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx;
var fillColor = this.current.fillColor;
@ -497,65 +497,65 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (consumePath)
this.consumePath();
},
eoFill: function canvasGraphicsEoFill() {
eoFill: function CanvasGraphics_eoFill() {
var savedFillRule = this.setEOFillRule();
this.fill();
this.restoreFillRule(savedFillRule);
},
fillStroke: function canvasGraphicsFillStroke() {
fillStroke: function CanvasGraphics_fillStroke() {
this.fill(false);
this.stroke(false);
this.consumePath();
},
eoFillStroke: function canvasGraphicsEoFillStroke() {
eoFillStroke: function CanvasGraphics_eoFillStroke() {
var savedFillRule = this.setEOFillRule();
this.fillStroke();
this.restoreFillRule(savedFillRule);
},
closeFillStroke: function canvasGraphicsCloseFillStroke() {
closeFillStroke: function CanvasGraphics_closeFillStroke() {
this.closePath();
this.fillStroke();
},
closeEOFillStroke: function canvasGraphicsCloseEOFillStroke() {
closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
var savedFillRule = this.setEOFillRule();
this.closePath();
this.fillStroke();
this.restoreFillRule(savedFillRule);
},
endPath: function canvasGraphicsEndPath() {
endPath: function CanvasGraphics_endPath() {
this.consumePath();
},
// Clipping
clip: function canvasGraphicsClip() {
clip: function CanvasGraphics_clip() {
this.pendingClip = NORMAL_CLIP;
},
eoClip: function canvasGraphicsEoClip() {
eoClip: function CanvasGraphics_eoClip() {
this.pendingClip = EO_CLIP;
},
// Text
beginText: function canvasGraphicsBeginText() {
beginText: function CanvasGraphics_beginText() {
this.current.textMatrix = IDENTITY_MATRIX;
this.current.x = this.current.lineX = 0;
this.current.y = this.current.lineY = 0;
},
endText: function canvasGraphicsEndText() {
endText: function CanvasGraphics_endText() {
},
setCharSpacing: function canvasGraphicsSetCharSpacing(spacing) {
setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
this.current.charSpacing = spacing;
},
setWordSpacing: function canvasGraphicsSetWordSpacing(spacing) {
setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
this.current.wordSpacing = spacing;
},
setHScale: function canvasGraphicsSetHScale(scale) {
setHScale: function CanvasGraphics_setHScale(scale) {
this.current.textHScale = scale / 100;
},
setLeading: function canvasGraphicsSetLeading(leading) {
setLeading: function CanvasGraphics_setLeading(leading) {
this.current.leading = -leading;
},
setFont: function canvasGraphicsSetFont(fontRefName, size) {
setFont: function CanvasGraphics_setFont(fontRefName, size) {
var fontObj = this.objs.get(fontRefName);
var current = this.current;
@ -609,32 +609,32 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
this.ctx.font = rule;
},
setTextRenderingMode: function canvasGraphicsSetTextRenderingMode(mode) {
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
if (mode >= TextRenderingMode.FILL_ADD_TO_PATH)
TODO('unsupported text rendering mode: ' + mode);
this.current.textRenderingMode = mode;
},
setTextRise: function canvasGraphicsSetTextRise(rise) {
setTextRise: function CanvasGraphics_setTextRise(rise) {
TODO('text rise: ' + rise);
},
moveText: function canvasGraphicsMoveText(x, y) {
moveText: function CanvasGraphics_moveText(x, y) {
this.current.x = this.current.lineX += x;
this.current.y = this.current.lineY += y;
},
setLeadingMoveText: function canvasGraphicsSetLeadingMoveText(x, y) {
setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
this.setLeading(-y);
this.moveText(x, y);
},
setTextMatrix: function canvasGraphicsSetTextMatrix(a, b, c, d, e, f) {
setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
this.current.textMatrix = [a, b, c, d, e, f];
this.current.x = this.current.lineX = 0;
this.current.y = this.current.lineY = 0;
},
nextLine: function canvasGraphicsNextLine() {
nextLine: function CanvasGraphics_nextLine() {
this.moveText(0, this.current.leading);
},
applyTextTransforms: function canvasApplyTransforms() {
applyTextTransforms: function CanvasGraphics_applyTextTransforms() {
var ctx = this.ctx;
var current = this.current;
var textHScale = current.textHScale;
@ -646,7 +646,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
ctx.transform.apply(ctx, fontMatrix);
ctx.scale(textHScale, 1);
},
getTextGeometry: function canvasGetTextGeometry() {
getTextGeometry: function CanvasGraphics_getTextGeometry() {
var geometry = {};
var ctx = this.ctx;
var font = this.current.font;
@ -663,7 +663,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return geometry;
},
showText: function canvasGraphicsShowText(str, skipTextSelection) {
showText: function CanvasGraphics_showText(str, skipTextSelection) {
var ctx = this.ctx;
var current = this.current;
var font = current.font;
@ -752,28 +752,30 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
continue;
}
var char = glyph.fontChar;
var character = glyph.fontChar;
var charWidth = glyph.width * fontSize * 0.001 +
Util.sign(current.fontMatrix[0]) * charSpacing;
var scaledX = x / fontSizeScale;
switch (textRenderingMode) {
default: // other unsupported rendering modes
case TextRenderingMode.FILL:
case TextRenderingMode.FILL_ADD_TO_PATH:
ctx.fillText(char, scaledX, 0);
break;
case TextRenderingMode.STROKE:
case TextRenderingMode.STROKE_ADD_TO_PATH:
ctx.strokeText(char, scaledX, 0);
break;
case TextRenderingMode.FILL_STROKE:
case TextRenderingMode.FILL_STROKE_ADD_TO_PATH:
ctx.fillText(char, scaledX, 0);
ctx.strokeText(char, scaledX, 0);
break;
case TextRenderingMode.INVISIBLE:
break;
if (!glyph.disabled) {
var scaledX = x / fontSizeScale;
switch (textRenderingMode) {
default: // other unsupported rendering modes
case TextRenderingMode.FILL:
case TextRenderingMode.FILL_ADD_TO_PATH:
ctx.fillText(character, scaledX, 0);
break;
case TextRenderingMode.STROKE:
case TextRenderingMode.STROKE_ADD_TO_PATH:
ctx.strokeText(character, scaledX, 0);
break;
case TextRenderingMode.FILL_STROKE:
case TextRenderingMode.FILL_STROKE_ADD_TO_PATH:
ctx.fillText(character, scaledX, 0);
ctx.strokeText(character, scaledX, 0);
break;
case TextRenderingMode.INVISIBLE:
break;
}
}
x += charWidth;
@ -799,7 +801,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return text;
},
showSpacedText: function canvasGraphicsShowSpacedText(arr) {
showSpacedText: function CanvasGraphics_showSpacedText(arr) {
var ctx = this.ctx;
var current = this.current;
var font = current.font;
@ -863,25 +865,25 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (textSelection)
this.textLayer.appendText(text, font.loadedName, fontSize);
},
nextLineShowText: function canvasGraphicsNextLineShowText(text) {
nextLineShowText: function CanvasGraphics_nextLineShowText(text) {
this.nextLine();
this.showText(text);
},
nextLineSetSpacingShowText:
function canvasGraphicsNextLineSetSpacingShowText(wordSpacing,
charSpacing,
text) {
function CanvasGraphics_nextLineSetSpacingShowText(wordSpacing,
charSpacing,
text) {
this.setWordSpacing(wordSpacing);
this.setCharSpacing(charSpacing);
this.nextLineShowText(text);
},
// Type3 fonts
setCharWidth: function canvasGraphicsSetCharWidth(xWidth, yWidth) {
setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
// We can safely ignore this since the width should be the same
// as the width in the Widths array.
},
setCharWidthAndBounds: function canvasGraphicsSetCharWidthAndBounds(xWidth,
setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth,
yWidth,
llx,
lly,
@ -895,20 +897,20 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
// Color
setStrokeColorSpace: function canvasGraphicsSetStrokeColorSpace(raw) {
setStrokeColorSpace: function CanvasGraphics_setStrokeColorSpace(raw) {
this.current.strokeColorSpace = ColorSpace.fromIR(raw);
},
setFillColorSpace: function canvasGraphicsSetFillColorSpace(raw) {
setFillColorSpace: function CanvasGraphics_setFillColorSpace(raw) {
this.current.fillColorSpace = ColorSpace.fromIR(raw);
},
setStrokeColor: function canvasGraphicsSetStrokeColor(/*...*/) {
setStrokeColor: function CanvasGraphics_setStrokeColor(/*...*/) {
var cs = this.current.strokeColorSpace;
var rgbColor = cs.getRgb(arguments);
var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
},
getColorN_Pattern: function canvasGraphicsGetColorN_Pattern(IR, cs) {
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR, cs) {
if (IR[0] == 'TilingPattern') {
var args = IR[1];
var base = cs.base;
@ -930,7 +932,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
return pattern;
},
setStrokeColorN: function canvasGraphicsSetStrokeColorN(/*...*/) {
setStrokeColorN: function CanvasGraphics_setStrokeColorN(/*...*/) {
var cs = this.current.strokeColorSpace;
if (cs.name == 'Pattern') {
@ -939,14 +941,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.setStrokeColor.apply(this, arguments);
}
},
setFillColor: function canvasGraphicsSetFillColor(/*...*/) {
setFillColor: function CanvasGraphics_setFillColor(/*...*/) {
var cs = this.current.fillColorSpace;
var rgbColor = cs.getRgb(arguments);
var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
this.ctx.fillStyle = color;
this.current.fillColor = color;
},
setFillColorN: function canvasGraphicsSetFillColorN(/*...*/) {
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
var cs = this.current.fillColorSpace;
if (cs.name == 'Pattern') {
@ -955,7 +957,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.setFillColor.apply(this, arguments);
}
},
setStrokeGray: function canvasGraphicsSetStrokeGray(gray) {
setStrokeGray: function CanvasGraphics_setStrokeGray(gray) {
if (!(this.current.strokeColorSpace instanceof DeviceGrayCS))
this.current.strokeColorSpace = new DeviceGrayCS();
@ -963,7 +965,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
},
setFillGray: function canvasGraphicsSetFillGray(gray) {
setFillGray: function CanvasGraphics_setFillGray(gray) {
if (!(this.current.fillColorSpace instanceof DeviceGrayCS))
this.current.fillColorSpace = new DeviceGrayCS();
@ -971,7 +973,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.fillStyle = color;
this.current.fillColor = color;
},
setStrokeRGBColor: function canvasGraphicsSetStrokeRGBColor(r, g, b) {
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
if (!(this.current.strokeColorSpace instanceof DeviceRgbCS))
this.current.strokeColorSpace = new DeviceRgbCS();
@ -979,7 +981,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
},
setFillRGBColor: function canvasGraphicsSetFillRGBColor(r, g, b) {
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
if (!(this.current.fillColorSpace instanceof DeviceRgbCS))
this.current.fillColorSpace = new DeviceRgbCS();
@ -987,7 +989,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.fillStyle = color;
this.current.fillColor = color;
},
setStrokeCMYKColor: function canvasGraphicsSetStrokeCMYKColor(c, m, y, k) {
setStrokeCMYKColor: function CanvasGraphics_setStrokeCMYKColor(c, m, y, k) {
if (!(this.current.strokeColorSpace instanceof DeviceCmykCS))
this.current.strokeColorSpace = new DeviceCmykCS();
@ -995,7 +997,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
},
setFillCMYKColor: function canvasGraphicsSetFillCMYKColor(c, m, y, k) {
setFillCMYKColor: function CanvasGraphics_setFillCMYKColor(c, m, y, k) {
if (!(this.current.fillColorSpace instanceof DeviceCmykCS))
this.current.fillColorSpace = new DeviceCmykCS();
@ -1004,7 +1006,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.fillColor = color;
},
shadingFill: function canvasGraphicsShadingFill(patternIR) {
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
var ctx = this.ctx;
this.save();
@ -1042,14 +1044,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
// Images
beginInlineImage: function canvasGraphicsBeginInlineImage() {
beginInlineImage: function CanvasGraphics_beginInlineImage() {
error('Should not call beginInlineImage');
},
beginImageData: function canvasGraphicsBeginImageData() {
beginImageData: function CanvasGraphics_beginImageData() {
error('Should not call beginImageData');
},
paintFormXObjectBegin: function canvasGraphicsPaintFormXObjectBegin(matrix,
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix,
bbox) {
this.save();
@ -1065,11 +1067,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
},
paintFormXObjectEnd: function canvasGraphicsPaintFormXObjectEnd() {
paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
this.restore();
},
paintJpegXObject: function canvasGraphicsPaintJpegXObject(objId, w, h) {
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
var domImage = this.objs.get(objId);
if (!domImage) {
error('Dependent image isn\'t ready yet');
@ -1087,7 +1089,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.restore();
},
paintImageMaskXObject: function canvasGraphicsPaintImageMaskXObject(
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(
imgArray, inverseDecode, width, height) {
function applyStencilMask(buffer, inverseDecode) {
var imgArrayPos = 0;
@ -1136,7 +1138,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.restore();
},
paintImageXObject: function canvasGraphicsPaintImageXObject(objId) {
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
var imgData = this.objs.get(objId);
if (!imgData)
error('Dependent image isn\'t ready yet');
@ -1156,41 +1158,41 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.restore();
},
putBinaryImageData: function canvasPutBinaryImageData() {
putBinaryImageData: function CanvasGraphics_putBinaryImageData() {
//
},
// Marked content
markPoint: function canvasGraphicsMarkPoint(tag) {
markPoint: function CanvasGraphics_markPoint(tag) {
TODO('Marked content');
},
markPointProps: function canvasGraphicsMarkPointProps(tag, properties) {
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
TODO('Marked content');
},
beginMarkedContent: function canvasGraphicsBeginMarkedContent(tag) {
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
TODO('Marked content');
},
beginMarkedContentProps:
function canvasGraphicsBeginMarkedContentProps(tag, properties) {
beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(
tag, properties) {
TODO('Marked content');
},
endMarkedContent: function canvasGraphicsEndMarkedContent() {
endMarkedContent: function CanvasGraphics_endMarkedContent() {
TODO('Marked content');
},
// Compatibility
beginCompat: function canvasGraphicsBeginCompat() {
beginCompat: function CanvasGraphics_beginCompat() {
TODO('ignore undefined operators (should we do that anyway?)');
},
endCompat: function canvasGraphicsEndCompat() {
endCompat: function CanvasGraphics_endCompat() {
TODO('stop ignoring undefined operators');
},
// Helper functions
consumePath: function canvasGraphicsConsumePath() {
consumePath: function CanvasGraphics_consumePath() {
if (this.pendingClip) {
var savedFillRule = null;
if (this.pendingClip == EO_CLIP)
@ -1207,15 +1209,15 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// We generally keep the canvas context set for
// nonzero-winding, and just set evenodd for the operations
// that need them.
setEOFillRule: function canvasGraphicsSetEOFillRule() {
setEOFillRule: function CanvasGraphics_setEOFillRule() {
var savedFillRule = this.ctx.mozFillRule;
this.ctx.mozFillRule = 'evenodd';
return savedFillRule;
},
restoreFillRule: function canvasGraphicsRestoreFillRule(rule) {
restoreFillRule: function CanvasGraphics_restoreFillRule(rule) {
this.ctx.mozFillRule = rule;
},
getSinglePixelWidth: function getSinglePixelWidth(scale) {
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
var inverse = this.ctx.mozCurrentTransformInverse;
return Math.abs(inverse[0] + inverse[2]);
}