[api-minor] Remove the WebGL implementation

Reasons for the removal include:
 - This functionality was always somewhat experimental and has never been enabled by default, partly because of worries about rendering bugs caused by e.g. bad/outdated graphics drivers.

 - After the initial implementation, in PR 4286 (back in 2014), no additional functionality has been added to the WebGL implementation.

 - The vast majority of all documents do not benefit from WebGL rendering, since only a couple of *specific* features are supported (e.g. some Soft Masks and Patterns).

 - There is, and has always been, *zero* test-coverage for the WebGL implementation.

 - Overall performance, in the PDF.js library, has improved since the experimental WebGL implementation was added.

Rather than shipping unused *and* untested code, it seems reasonable to simply remove the WebGL implementation for now; thanks to version control it's always possible to bring back the code should the need ever arise.
This commit is contained in:
Jonas Jenwald 2021-05-09 15:54:26 +02:00
parent 99eac86478
commit 2ba4b65ca8
9 changed files with 28 additions and 608 deletions

View file

@ -808,7 +808,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
}
}
function composeSMask(ctx, smask, layerCtx, webGLContext) {
function composeSMask(ctx, smask, layerCtx) {
const mask = smask.canvas;
const maskCtx = smask.context;
@ -821,27 +821,13 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
smask.offsetY
);
const backdrop = smask.backdrop || null;
if (!smask.transferMap && webGLContext.isEnabled) {
const composed = webGLContext.composeSMask({
layer: layerCtx.canvas,
mask,
properties: {
subtype: smask.subtype,
backdrop,
},
});
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.drawImage(composed, smask.offsetX, smask.offsetY);
return;
}
genericComposeSMask(
maskCtx,
layerCtx,
mask.width,
mask.height,
smask.subtype,
backdrop,
smask.backdrop,
smask.transferMap
);
ctx.drawImage(mask, 0, 0);
@ -859,7 +845,6 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
commonObjs,
objs,
canvasFactory,
webGLContext,
imageLayer,
optionalContentConfig
) {
@ -873,7 +858,6 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
this.commonObjs = commonObjs;
this.objs = objs;
this.canvasFactory = canvasFactory;
this.webGLContext = webGLContext;
this.imageLayer = imageLayer;
this.groupStack = [];
this.processingType3 = null;
@ -1042,7 +1026,6 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
}
this.cachedCanvases.clear();
this.webGLContext.clear();
if (this.imageLayer) {
this.imageLayer.endLayout();
@ -1192,12 +1175,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
this.groupLevel--;
this.ctx = this.groupStack.pop();
composeSMask(
this.ctx,
this.current.activeSMask,
groupCtx,
this.webGLContext
);
composeSMask(this.ctx, this.current.activeSMask, groupCtx);
this.ctx.restore();
this.ctx.save(); // save is needed since SMask will be resumed.
copyCtxState(groupCtx, this.ctx);
@ -1235,12 +1213,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
this.groupLevel--;
this.ctx = this.groupStack.pop();
composeSMask(
this.ctx,
this.current.activeSMask,
groupCtx,
this.webGLContext
);
composeSMask(this.ctx, this.current.activeSMask, groupCtx);
this.ctx.restore();
copyCtxState(groupCtx, this.ctx);
// Transform was changed in the SMask canvas, reflecting this change on
@ -2004,8 +1977,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
ctx,
this.commonObjs,
this.objs,
this.canvasFactory,
this.webGLContext
this.canvasFactory
);
},
};