Move early exit for no-rotation.

This commit is contained in:
Jake Archibald
2018-12-07 14:26:22 +00:00
parent 7389c507fb
commit db1db8506e
2 changed files with 8 additions and 6 deletions

View File

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

View File

@@ -85,12 +85,18 @@ interface UpdateImageOptions {
skipPreprocessing?: boolean; skipPreprocessing?: boolean;
} }
function processInput( async function processInput(
data: ImageData, data: ImageData,
inputProcessData: InputProcessorState, inputProcessData: InputProcessorState,
processor: Processor, 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( async function preprocessImage(