mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 00:17:21 +02:00
Merge pull request #21206 from Snuffleupagus/unittest-11878-hash
Improve performance of the "caches image resources at the document/page level as expected (issue 11878)" unit-test
This commit is contained in:
commit
468d38e17c
@ -4844,7 +4844,8 @@ have written that much by now. So, here’s to squashing bugs.`);
|
|||||||
const pdfDoc = await loadingTask.promise;
|
const pdfDoc = await loadingTask.promise;
|
||||||
const { canvasFactory } = pdfDoc;
|
const { canvasFactory } = pdfDoc;
|
||||||
let checkedCopyLocalImage = false,
|
let checkedCopyLocalImage = false,
|
||||||
firstImgData = null;
|
firstImgData = null,
|
||||||
|
firstImg32 = null;
|
||||||
|
|
||||||
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
||||||
const pdfPage = await pdfDoc.getPage(i);
|
const pdfPage = await pdfDoc.getPage(i);
|
||||||
@ -4895,6 +4896,8 @@ have written that much by now. So, here’s to squashing bugs.`);
|
|||||||
expect(firstImgData.kind).toEqual(ImageKind.RGB_24BPP);
|
expect(firstImgData.kind).toEqual(ImageKind.RGB_24BPP);
|
||||||
expect(firstImgData.data).toBeInstanceOf(Uint8ClampedArray);
|
expect(firstImgData.data).toBeInstanceOf(Uint8ClampedArray);
|
||||||
expect(firstImgData.data.length).toEqual(25245000);
|
expect(firstImgData.data.length).toEqual(25245000);
|
||||||
|
|
||||||
|
firstImg32 = new Uint32Array(firstImgData.data.buffer);
|
||||||
} else {
|
} else {
|
||||||
const objsPool = i >= NUM_PAGES_THRESHOLD ? commonObjs : objs;
|
const objsPool = i >= NUM_PAGES_THRESHOLD ? commonObjs : objs;
|
||||||
const currentImgData = objsPool.get(objId);
|
const currentImgData = objsPool.get(objId);
|
||||||
@ -4906,10 +4909,10 @@ have written that much by now. So, here’s to squashing bugs.`);
|
|||||||
|
|
||||||
expect(currentImgData.kind).toEqual(firstImgData.kind);
|
expect(currentImgData.kind).toEqual(firstImgData.kind);
|
||||||
expect(currentImgData.data).toBeInstanceOf(Uint8ClampedArray);
|
expect(currentImgData.data).toBeInstanceOf(Uint8ClampedArray);
|
||||||
|
|
||||||
|
const currentImg32 = new Uint32Array(currentImgData.data.buffer);
|
||||||
expect(
|
expect(
|
||||||
currentImgData.data.every(
|
currentImg32.every((value, index) => value === firstImg32[index])
|
||||||
(value, index) => value === firstImgData.data[index]
|
|
||||||
)
|
|
||||||
).toEqual(true);
|
).toEqual(true);
|
||||||
|
|
||||||
if (i === NUM_PAGES_THRESHOLD) {
|
if (i === NUM_PAGES_THRESHOLD) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user