mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Add an option to enable/disable hardware acceleration (bug 1902012)
This commit is contained in:
parent
341ff40e74
commit
ff6180a4c9
13 changed files with 62 additions and 12 deletions
|
@ -81,6 +81,8 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
|||
* @property {IL10n} [l10n] - Localization service.
|
||||
* @property {Object} [layerProperties] - The object that is used to lookup
|
||||
* the necessary layer-properties.
|
||||
* @property {boolean} [enableHWA] - Enables hardware acceleration for
|
||||
* rendering. The default value is `false`.
|
||||
*/
|
||||
|
||||
const DEFAULT_LAYER_PROPERTIES =
|
||||
|
@ -113,6 +115,8 @@ const LAYERS_ORDER = new Map([
|
|||
class PDFPageView {
|
||||
#annotationMode = AnnotationMode.ENABLE_FORMS;
|
||||
|
||||
#enableHWA = false;
|
||||
|
||||
#hasRestrictedScaling = false;
|
||||
|
||||
#layerProperties = null;
|
||||
|
@ -163,6 +167,7 @@ class PDFPageView {
|
|||
this.maxCanvasPixels =
|
||||
options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels");
|
||||
this.pageColors = options.pageColors || null;
|
||||
this.#enableHWA = options.enableHWA || false;
|
||||
|
||||
this.eventBus = options.eventBus;
|
||||
this.renderingQueue = options.renderingQueue;
|
||||
|
@ -981,7 +986,10 @@ class PDFPageView {
|
|||
canvasWrapper.append(canvas);
|
||||
this.canvas = canvas;
|
||||
|
||||
const ctx = canvas.getContext("2d", { alpha: false });
|
||||
const ctx = canvas.getContext("2d", {
|
||||
alpha: false,
|
||||
willReadFrequently: !this.#enableHWA,
|
||||
});
|
||||
const outputScale = (this.outputScale = new OutputScale());
|
||||
|
||||
if (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue