1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28:06 +02:00

Replace the PDFJS.disableWebGL option with a enableWebGL option passed, via BaseViewer/PDFPageView, to PDFPageProxy.render

Please note that the, pre-existing, viewer preference is already named `enableWebGL`; fixes 4919.
This commit is contained in:
Jonas Jenwald 2018-02-13 14:16:10 +01:00
parent a1cfa5f4d7
commit 77efed6626
6 changed files with 16 additions and 15 deletions

View file

@ -139,6 +139,7 @@ let PDFViewerApplication = {
isInitialViewSet: false,
downloadComplete: false,
viewerPrefs: {
enableWebGL: false,
sidebarViewOnLoad: SidebarView.NONE,
pdfBugEnabled: false,
showPreviousViewOnLoad: true,
@ -203,7 +204,7 @@ let PDFViewerApplication = {
return Promise.all([
preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value;
viewerPrefs['enableWebGL'] = value;
}),
preferences.get('sidebarViewOnLoad').then(function resolved(value) {
viewerPrefs['sidebarViewOnLoad'] = value;
@ -304,7 +305,7 @@ let PDFViewerApplication = {
PDFJS.disableHistory = (hashParams['disablehistory'] === 'true');
}
if ('webgl' in hashParams) {
PDFJS.disableWebGL = (hashParams['webgl'] !== 'true');
viewerPrefs['enableWebGL'] = (hashParams['webgl'] === 'true');
}
if ('useonlycsszoom' in hashParams) {
PDFJS.useOnlyCssZoom = (hashParams['useonlycsszoom'] === 'true');
@ -394,6 +395,7 @@ let PDFViewerApplication = {
linkService: pdfLinkService,
downloadManager,
renderer: viewerPrefs['renderer'],
enableWebGL: viewerPrefs['enableWebGL'],
l10n: this.l10n,
textLayerMode: viewerPrefs['textLayerMode'],
imageResourcesPath: PDFJS.imageResourcesPath,
@ -1172,7 +1174,7 @@ let PDFViewerApplication = {
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
' / ' + (info.Creator || '-').trim() + ']' +
' (PDF.js: ' + (version || '-') +
(!PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
(this.viewerPrefs['enableWebGL'] ? ' [WebGL]' : '') + ')');
let pdfTitle;
if (metadata && metadata.has('dc:title')) {

View file

@ -52,6 +52,8 @@ const DEFAULT_CACHE_SIZE = 10;
* rotation of pages whose orientation differ from the first page upon
* printing. The default is `false`.
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
* @property {boolean} enableWebGL - (optional) Enables WebGL accelerated
* rendering for some operations. The default value is `false`.
* @property {boolean} useOnlyCssZoom - (optional) Enables CSS only zooming.
* The default value is `false`.
* @property {number} maxCanvasPixels - (optional) The maximum supported canvas
@ -123,6 +125,7 @@ class BaseViewer {
this.renderInteractiveForms = options.renderInteractiveForms || false;
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
this.renderer = options.renderer || RendererType.CANVAS;
this.enableWebGL = options.enableWebGL || false;
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || NullL10n;
@ -392,6 +395,7 @@ class BaseViewer {
imageResourcesPath: this.imageResourcesPath,
renderInteractiveForms: this.renderInteractiveForms,
renderer: this.renderer,
enableWebGL: this.enableWebGL,
useOnlyCssZoom: this.useOnlyCssZoom,
maxCanvasPixels: this.maxCanvasPixels,
l10n: this.l10n,

View file

@ -43,6 +43,8 @@ import { viewerCompatibilityParams } from './viewer_compatibility';
* @property {boolean} renderInteractiveForms - Turns on rendering of
* interactive form elements. The default is `false`.
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
* @property {boolean} enableWebGL - (optional) Enables WebGL accelerated
* rendering for some operations. The default value is `false`.
* @property {boolean} useOnlyCssZoom - (optional) Enables CSS only zooming.
* The default value is `false`.
* @property {number} maxCanvasPixels - (optional) The maximum supported canvas
@ -86,6 +88,7 @@ class PDFPageView {
this.textLayerFactory = options.textLayerFactory;
this.annotationLayerFactory = options.annotationLayerFactory;
this.renderer = options.renderer || RendererType.CANVAS;
this.enableWebGL = options.enableWebGL || false;
this.l10n = options.l10n || NullL10n;
this.paintTask = null;
@ -571,6 +574,7 @@ class PDFPageView {
canvasContext: ctx,
transform,
viewport: this.viewport,
enableWebGL: this.enableWebGL,
renderInteractiveForms: this.renderInteractiveForms,
};
let renderTask = this.pdfPage.render(renderContext);