Merge pull request #4817 from p01/graphic_optimizations_3
Graphic optimizations 3
This commit is contained in:
commit
d39af0aba4
@ -24,7 +24,7 @@
|
|||||||
var EOF = {};
|
var EOF = {};
|
||||||
|
|
||||||
function isEOF(v) {
|
function isEOF(v) {
|
||||||
return (v == EOF);
|
return (v === EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
var Parser = (function ParserClosure() {
|
var Parser = (function ParserClosure() {
|
||||||
|
@ -983,10 +983,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
ctx.lineTo(x, y);
|
ctx.lineTo(x, y);
|
||||||
break;
|
break;
|
||||||
case OPS.curveTo:
|
case OPS.curveTo:
|
||||||
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3],
|
|
||||||
args[j + 4], args[j + 5]);
|
|
||||||
x = args[j + 4];
|
x = args[j + 4];
|
||||||
y = args[j + 5];
|
y = args[j + 5];
|
||||||
|
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3],
|
||||||
|
x, y);
|
||||||
j += 6;
|
j += 6;
|
||||||
break;
|
break;
|
||||||
case OPS.curveTo2:
|
case OPS.curveTo2:
|
||||||
@ -997,10 +997,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
j += 4;
|
j += 4;
|
||||||
break;
|
break;
|
||||||
case OPS.curveTo3:
|
case OPS.curveTo3:
|
||||||
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3],
|
|
||||||
args[j + 2], args[j + 3]);
|
|
||||||
x = args[j + 2];
|
x = args[j + 2];
|
||||||
y = args[j + 3];
|
y = args[j + 3];
|
||||||
|
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
|
||||||
j += 4;
|
j += 4;
|
||||||
break;
|
break;
|
||||||
case OPS.closePath:
|
case OPS.closePath:
|
||||||
@ -1068,21 +1067,21 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.pendingEOFill) {
|
if (this.pendingEOFill) {
|
||||||
if ('mozFillRule' in this.ctx) {
|
if (ctx.mozFillRule !== undefined) {
|
||||||
this.ctx.mozFillRule = 'evenodd';
|
ctx.mozFillRule = 'evenodd';
|
||||||
this.ctx.fill();
|
ctx.fill();
|
||||||
this.ctx.mozFillRule = 'nonzero';
|
ctx.mozFillRule = 'nonzero';
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.ctx.fill('evenodd');
|
ctx.fill('evenodd');
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// shouldn't really happen, but browsers might think differently
|
// shouldn't really happen, but browsers might think differently
|
||||||
this.ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pendingEOFill = false;
|
this.pendingEOFill = false;
|
||||||
} else {
|
} else {
|
||||||
this.ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needRestore) {
|
if (needRestore) {
|
||||||
@ -1134,12 +1133,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
this.current.y = this.current.lineY = 0;
|
this.current.y = this.current.lineY = 0;
|
||||||
},
|
},
|
||||||
endText: function CanvasGraphics_endText() {
|
endText: function CanvasGraphics_endText() {
|
||||||
if (!('pendingTextPaths' in this)) {
|
|
||||||
this.ctx.beginPath();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var paths = this.pendingTextPaths;
|
var paths = this.pendingTextPaths;
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
|
if (paths === undefined) {
|
||||||
|
ctx.beginPath();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
@ -1803,7 +1802,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
this.ctx = this.groupStack.pop();
|
this.ctx = this.groupStack.pop();
|
||||||
// Turn off image smoothing to avoid sub pixel interpolation which can
|
// Turn off image smoothing to avoid sub pixel interpolation which can
|
||||||
// look kind of blurry for some pdfs.
|
// look kind of blurry for some pdfs.
|
||||||
if ('imageSmoothingEnabled' in this.ctx) {
|
if (this.ctx.imageSmoothingEnabled !== undefined) {
|
||||||
this.ctx.imageSmoothingEnabled = false;
|
this.ctx.imageSmoothingEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
this.ctx.mozImageSmoothingEnabled = false;
|
this.ctx.mozImageSmoothingEnabled = false;
|
||||||
@ -2145,26 +2144,27 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
consumePath: function CanvasGraphics_consumePath() {
|
consumePath: function CanvasGraphics_consumePath() {
|
||||||
|
var ctx = this.ctx;
|
||||||
if (this.pendingClip) {
|
if (this.pendingClip) {
|
||||||
if (this.pendingClip == EO_CLIP) {
|
if (this.pendingClip == EO_CLIP) {
|
||||||
if ('mozFillRule' in this.ctx) {
|
if (ctx.mozFillRule !== undefined) {
|
||||||
this.ctx.mozFillRule = 'evenodd';
|
ctx.mozFillRule = 'evenodd';
|
||||||
this.ctx.clip();
|
ctx.clip();
|
||||||
this.ctx.mozFillRule = 'nonzero';
|
ctx.mozFillRule = 'nonzero';
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.ctx.clip('evenodd');
|
ctx.clip('evenodd');
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// shouldn't really happen, but browsers might think differently
|
// shouldn't really happen, but browsers might think differently
|
||||||
this.ctx.clip();
|
ctx.clip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.ctx.clip();
|
ctx.clip();
|
||||||
}
|
}
|
||||||
this.pendingClip = null;
|
this.pendingClip = null;
|
||||||
}
|
}
|
||||||
this.ctx.beginPath();
|
ctx.beginPath();
|
||||||
},
|
},
|
||||||
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
|
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
|
||||||
var inverse = this.ctx.mozCurrentTransformInverse;
|
var inverse = this.ctx.mozCurrentTransformInverse;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user