mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 07:38:07 +02:00
Allow subpixel anti-aliasing for most of the content.
This commit is contained in:
parent
f096e4ab91
commit
1d8800370a
7 changed files with 111 additions and 55 deletions
|
@ -166,8 +166,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
|
||||
var isScalingRestricted = false;
|
||||
if (this.canvas && PDFJS.maxCanvasPixels > 0) {
|
||||
var ctx = this.canvas.getContext('2d');
|
||||
var outputScale = getOutputScale(ctx);
|
||||
var outputScale = this.outputScale;
|
||||
var pixelsInViewport = this.viewport.width * this.viewport.height;
|
||||
var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport);
|
||||
if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) *
|
||||
|
@ -311,6 +310,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.id = 'page' + this.id;
|
||||
canvas.setAttribute('hidden', 'hidden');
|
||||
canvasWrapper.appendChild(canvas);
|
||||
if (this.annotationLayer && this.annotationLayer.div) {
|
||||
// annotationLayer needs to stay on top
|
||||
|
@ -318,10 +318,15 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
} else {
|
||||
div.appendChild(canvasWrapper);
|
||||
}
|
||||
var isCanvasHidden = true;
|
||||
this.canvas = canvas;
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
//#if MOZCENTRAL || FIREFOX || GENERIC
|
||||
canvas.mozOpaque = true;
|
||||
//#endif
|
||||
var ctx = canvas.getContext('2d', {alpha: false});
|
||||
var outputScale = getOutputScale(ctx);
|
||||
this.outputScale = outputScale;
|
||||
|
||||
if (PDFJS.useOnlyCssZoom) {
|
||||
var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
|
||||
|
@ -374,14 +379,6 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
}
|
||||
this.textLayer = textLayer;
|
||||
|
||||
if (outputScale.scaled) {
|
||||
//#if !(MOZCENTRAL || FIREFOX)
|
||||
// Used by the mozCurrentTransform polyfill in src/display/canvas.js.
|
||||
ctx._transformMatrix = [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
|
||||
//#endif
|
||||
ctx.scale(outputScale.sx, outputScale.sy);
|
||||
}
|
||||
|
||||
var resolveRenderPromise, rejectRenderPromise;
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
resolveRenderPromise = resolve;
|
||||
|
@ -461,12 +458,19 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
};
|
||||
return;
|
||||
}
|
||||
if (isCanvasHidden) {
|
||||
self.canvas.removeAttribute('hidden');
|
||||
isCanvasHidden = false;
|
||||
}
|
||||
cont();
|
||||
};
|
||||
}
|
||||
|
||||
var transform = !outputScale.scaled ? null :
|
||||
[outputScale.sx, 0, 0, outputScale.sy, 0, 0];
|
||||
var renderContext = {
|
||||
canvasContext: ctx,
|
||||
transform: transform,
|
||||
viewport: this.viewport,
|
||||
// intent: 'default', // === 'display'
|
||||
};
|
||||
|
|
|
@ -46,7 +46,10 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
|||
|
||||
// Since this is a temporary canvas, we need to fill the canvas with a white
|
||||
// background ourselves. |_getPageDrawContext| uses CSS rules for this.
|
||||
var ctx = tempCanvas.getContext('2d');
|
||||
//#if MOZCENTRAL || FIREFOX || GENERIC
|
||||
tempCanvas.mozOpaque = true;
|
||||
//#endif
|
||||
var ctx = tempCanvas.getContext('2d', {alpha: false});
|
||||
ctx.save();
|
||||
ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
@ -186,7 +189,10 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
|
|||
var canvas = document.createElement('canvas');
|
||||
this.canvas = canvas;
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
//#if MOZCENTRAL || FIREFOX || GENERIC
|
||||
canvas.mozOpaque = true;
|
||||
//#endif
|
||||
var ctx = canvas.getContext('2d', {alpha: false});
|
||||
var outputScale = getOutputScale(ctx);
|
||||
|
||||
canvas.width = (this.canvasWidth * outputScale.sx) | 0;
|
||||
|
|
|
@ -74,7 +74,10 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||
var textDivs = this.textDivs;
|
||||
var textDivsLength = textDivs.length;
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
//#if MOZCENTRAL || FIREFOX || GENERIC
|
||||
canvas.mozOpaque = true;
|
||||
//#endif
|
||||
var ctx = canvas.getContext('2d', {alpha: false});
|
||||
|
||||
// No point in rendering many divs as it would make the browser
|
||||
// unusable even after the divs are rendered.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue