Compare commits

...

2 Commits

Author SHA1 Message Date
fd98d67b3e lol this was meant to be 10 seconds. 2018-12-07 14:26:45 +00:00
db1db8506e Move early exit for no-rotation. 2018-12-07 14:26:22 +00:00
3 changed files with 9 additions and 7 deletions

View File

@ -20,7 +20,7 @@ import * as browserPDF from './browser-pdf/encoder';
type ProcessorWorkerApi = import('./processor-worker').ProcessorWorkerApi;
/** How long the worker should be idle before terminating. */
const workerTimeout = 1000;
const workerTimeout = 10000;
interface ProcessingJobOptions {
needsWorker?: boolean;

View File

@ -4,10 +4,6 @@ const bpp = 4;
export function rotate(data: ImageData, opts: RotateOptions): ImageData {
const { rotate } = opts;
// Early exit if there's no transform.
if (rotate === 0) return data;
const flipDimensions = rotate % 180 !== 0;
const { width: inputWidth, height: inputHeight } = data;
const outputWidth = flipDimensions ? inputHeight : inputWidth;

View File

@ -85,12 +85,18 @@ interface UpdateImageOptions {
skipPreprocessing?: boolean;
}
function processInput(
async function processInput(
data: ImageData,
inputProcessData: InputProcessorState,
processor: Processor,
) {
return processor.rotate(data, inputProcessData.rotate);
let processedData = data;
if (inputProcessData.rotate.rotate !== 0) {
processedData = await processor.rotate(processedData, inputProcessData.rotate);
}
return processedData;
}
async function preprocessImage(