mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 08:27:19 +02:00
Merge pull request #21590 from Snuffleupagus/canvas-_getPattern-getOrInsertComputed
Use `getOrInsertComputed` in the `CanvasGraphics.prototype._getPattern` method
This commit is contained in:
commit
e624336b2e
@ -3092,13 +3092,9 @@ class CanvasGraphics {
|
||||
}
|
||||
|
||||
_getPattern(opIdx, objId, matrix = null) {
|
||||
let pattern;
|
||||
if (this.cachedPatterns.has(objId)) {
|
||||
pattern = this.cachedPatterns.get(objId);
|
||||
} else {
|
||||
pattern = getShadingPattern(this.getObject(opIdx, objId));
|
||||
this.cachedPatterns.set(objId, pattern);
|
||||
}
|
||||
const pattern = this.cachedPatterns.getOrInsertComputed(objId, () =>
|
||||
getShadingPattern(this.getObject(opIdx, objId))
|
||||
);
|
||||
if (matrix) {
|
||||
pattern.matrix = matrix;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user