Skip to content

Commit

Permalink
Modernize the ShadingIRs structure, in `src/display/pattern_helper.…
Browse files Browse the repository at this point in the history
…js`, to use standard classes

This patch replaces the old structure with an abstract base-class, which the new ShadingPattern classes then inherit from.
The old `createMeshCanvasClosure` can now be removed, since it's not necessary any more with modern JavaScript, and the `createMeshCanvas` function is now instead a method on the new `MeshShadingPattern` class (avoids unnecessary parameter passing).
  • Loading branch information
Snuffleupagus committed May 15, 2021
1 parent 40939d5 commit a984431
Show file tree
Hide file tree
Showing 2 changed files with 303 additions and 302 deletions.
6 changes: 3 additions & 3 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
Util,
warn,
} from "../shared/util.js";
import { getShadingPatternFromIR, TilingPattern } from "./pattern_helper.js";
import { getShadingPattern, TilingPattern } from "./pattern_helper.js";

// <canvas> contexts store most of the state we need natively.
// However, PDF needs a bit more state, which we store here.
Expand Down Expand Up @@ -1973,7 +1973,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
baseTransform
);
} else {
pattern = getShadingPatternFromIR(IR);
pattern = getShadingPattern(IR);
}
return pattern;
}
Expand Down Expand Up @@ -2007,7 +2007,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
const ctx = this.ctx;

this.save();
const pattern = getShadingPatternFromIR(patternIR);
const pattern = getShadingPattern(patternIR);
ctx.fillStyle = pattern.getPattern(ctx, this, true);

const inv = ctx.mozCurrentTransformInverse;
Expand Down
Loading

0 comments on commit a984431

Please sign in to comment.