mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Split the existing WebGLUtils
in two classes, a private WebGLUtils
and a public WebGLContext
, and utilize the latter in the API to allow various code to access the methods of WebGLUtils
This patch is one (small) step on the way to reduce the general dependency on a global `PDFJS` object, for PDF.js version `2.0`.
This commit is contained in:
parent
503bc95a2b
commit
59b5e14301
4 changed files with 86 additions and 43 deletions
|
@ -30,6 +30,7 @@ import { CanvasGraphics } from './canvas';
|
|||
import globalScope from '../shared/global_scope';
|
||||
import { Metadata } from './metadata';
|
||||
import { PDFDataTransportStream } from './transport_stream';
|
||||
import { WebGLContext } from './webgl';
|
||||
|
||||
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
||||
|
||||
|
@ -820,6 +821,11 @@ 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'),
|
||||
});
|
||||
|
||||
if (!this.intentStates[renderingIntent]) {
|
||||
this.intentStates[renderingIntent] = Object.create(null);
|
||||
|
@ -870,7 +876,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||
this.commonObjs,
|
||||
intentState.operatorList,
|
||||
this.pageNumber,
|
||||
canvasFactory);
|
||||
canvasFactory,
|
||||
webGLContext);
|
||||
internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
|
||||
if (!intentState.renderTasks) {
|
||||
intentState.renderTasks = [];
|
||||
|
@ -2174,7 +2181,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
let canvasInRendering = new WeakMap();
|
||||
|
||||
function InternalRenderTask(callback, params, objs, commonObjs, operatorList,
|
||||
pageNumber, canvasFactory) {
|
||||
pageNumber, canvasFactory, webGLContext) {
|
||||
this.callback = callback;
|
||||
this.params = params;
|
||||
this.objs = objs;
|
||||
|
@ -2183,6 +2190,8 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
this.operatorList = operatorList;
|
||||
this.pageNumber = pageNumber;
|
||||
this.canvasFactory = canvasFactory;
|
||||
this.webGLContext = webGLContext;
|
||||
|
||||
this.running = false;
|
||||
this.graphicsReadyCallback = null;
|
||||
this.graphicsReady = false;
|
||||
|
@ -2225,7 +2234,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
var params = this.params;
|
||||
this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs,
|
||||
this.objs, this.canvasFactory,
|
||||
params.imageLayer);
|
||||
this.webGLContext, params.imageLayer);
|
||||
|
||||
this.gfx.beginDrawing({
|
||||
transform: params.transform,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue