Merge pull request #16079 from mozilla/Snuffleupagus-PDFObjects-bitmap
Move the `ImageBitmap` clean-up into the `PDFObjects` class
This commit is contained in:
commit
3f33fbf8cf
@ -1282,8 +1282,6 @@ class PDFPageProxy {
|
|||||||
this.commonObjs = transport.commonObjs;
|
this.commonObjs = transport.commonObjs;
|
||||||
this.objs = new PDFObjects();
|
this.objs = new PDFObjects();
|
||||||
|
|
||||||
this._bitmaps = new Set();
|
|
||||||
|
|
||||||
this.cleanupAfterRender = false;
|
this.cleanupAfterRender = false;
|
||||||
this.pendingCleanup = false;
|
this.pendingCleanup = false;
|
||||||
this._intentStates = new Map();
|
this._intentStates = new Map();
|
||||||
@ -1679,10 +1677,6 @@ class PDFPageProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.objs.clear();
|
this.objs.clear();
|
||||||
for (const bitmap of this._bitmaps) {
|
|
||||||
bitmap.close();
|
|
||||||
}
|
|
||||||
this._bitmaps.clear();
|
|
||||||
this.pendingCleanup = false;
|
this.pendingCleanup = false;
|
||||||
return Promise.all(waitOn);
|
return Promise.all(waitOn);
|
||||||
}
|
}
|
||||||
@ -1718,10 +1712,6 @@ class PDFPageProxy {
|
|||||||
if (resetStats && this._stats) {
|
if (resetStats && this._stats) {
|
||||||
this._stats = new StatTimer();
|
this._stats = new StatTimer();
|
||||||
}
|
}
|
||||||
for (const bitmap of this._bitmaps) {
|
|
||||||
bitmap.close();
|
|
||||||
}
|
|
||||||
this._bitmaps.clear();
|
|
||||||
this.pendingCleanup = false;
|
this.pendingCleanup = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2774,9 +2764,8 @@ class WorkerTransport {
|
|||||||
if (imageData) {
|
if (imageData) {
|
||||||
let length;
|
let length;
|
||||||
if (imageData.bitmap) {
|
if (imageData.bitmap) {
|
||||||
const { bitmap, width, height } = imageData;
|
const { width, height } = imageData;
|
||||||
length = width * height * 4;
|
length = width * height * 4;
|
||||||
pageProxy._bitmaps.add(bitmap);
|
|
||||||
} else {
|
} else {
|
||||||
length = imageData.data?.length || 0;
|
length = imageData.data?.length || 0;
|
||||||
}
|
}
|
||||||
@ -3150,6 +3139,10 @@ class PDFObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
for (const objId in this.#objs) {
|
||||||
|
const { data } = this.#objs[objId];
|
||||||
|
data?.bitmap?.close(); // Release any `ImageBitmap` data.
|
||||||
|
}
|
||||||
this.#objs = Object.create(null);
|
this.#objs = Object.create(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user