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:
parent
a1cfa5f4d7
commit
77efed6626
@ -707,6 +707,8 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||
* calling of PDFPage.getViewport method.
|
||||
* @property {string} intent - Rendering intent, can be 'display' or 'print'
|
||||
* (default value is 'display').
|
||||
* @property {boolean} enableWebGL - (optional) Enables WebGL accelerated
|
||||
* rendering for some operations. The default value is `false`.
|
||||
* @property {boolean} renderInteractiveForms - (optional) Whether or not
|
||||
* interactive form elements are rendered in the display
|
||||
* layer. If so, we do not render them on canvas as well.
|
||||
@ -828,9 +830,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
|
||||
var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
|
||||
let webGLContext = new WebGLContext({
|
||||
// TODO: When moving this parameter from `PDFJS` to {RenderParameters},
|
||||
// change its name to `enableWebGL` instead.
|
||||
enable: !getDefaultSetting('disableWebGL'),
|
||||
enable: params.enableWebGL,
|
||||
});
|
||||
|
||||
if (!this.intentStates[renderingIntent]) {
|
||||
|
@ -345,8 +345,6 @@ function getDefaultSetting(id) {
|
||||
return globalSettings ? globalSettings.disableFontFace : false;
|
||||
case 'disableCreateObjectURL':
|
||||
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
||||
case 'disableWebGL':
|
||||
return globalSettings ? globalSettings.disableWebGL : true;
|
||||
case 'cMapUrl':
|
||||
return globalSettings ? globalSettings.cMapUrl : null;
|
||||
case 'cMapPacked':
|
||||
|
@ -180,13 +180,6 @@ PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ?
|
||||
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
||||
false : PDFJS.disableCreateObjectURL);
|
||||
|
||||
/**
|
||||
* Disables WebGL usage.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ?
|
||||
true : PDFJS.disableWebGL);
|
||||
|
||||
/**
|
||||
* Specifies the |target| attribute for external links.
|
||||
* The constants from {LinkTarget} should be used:
|
||||
|
@ -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')) {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user