fix(image-pipeline): make preview histogram opt-in
This commit is contained in:
@@ -8,6 +8,7 @@ type PreviewWorkerPayload = {
|
||||
sourceUrl: string;
|
||||
steps: readonly PipelineStep[];
|
||||
previewWidth: number;
|
||||
includeHistogram?: boolean;
|
||||
};
|
||||
|
||||
type WorkerRequestMessage =
|
||||
@@ -93,6 +94,7 @@ async function handlePreviewRequest(requestId: number, payload: PreviewWorkerPay
|
||||
sourceUrl: payload.sourceUrl,
|
||||
steps: payload.steps,
|
||||
previewWidth: payload.previewWidth,
|
||||
includeHistogram: payload.includeHistogram,
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PipelineStep } from "@/lib/image-pipeline/contracts";
|
||||
import { computeHistogram, type HistogramData } from "@/lib/image-pipeline/histogram";
|
||||
import { computeHistogram, emptyHistogram, type HistogramData } from "@/lib/image-pipeline/histogram";
|
||||
import { applyPipelineStep } from "@/lib/image-pipeline/render-core";
|
||||
import { loadSourceBitmap } from "@/lib/image-pipeline/source-loader";
|
||||
|
||||
@@ -54,6 +54,7 @@ export async function renderPreview(options: {
|
||||
sourceUrl: string;
|
||||
steps: readonly PipelineStep[];
|
||||
previewWidth: number;
|
||||
includeHistogram?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}): Promise<PreviewRenderResult> {
|
||||
const bitmap = await loadSourceBitmap(options.sourceUrl, {
|
||||
@@ -82,7 +83,9 @@ export async function renderPreview(options: {
|
||||
}
|
||||
}
|
||||
|
||||
const histogram = computeHistogram(imageData.data);
|
||||
const histogram = options.includeHistogram === false
|
||||
? emptyHistogram()
|
||||
: computeHistogram(imageData.data);
|
||||
|
||||
return {
|
||||
width,
|
||||
|
||||
@@ -13,6 +13,7 @@ type PreviewWorkerPayload = {
|
||||
sourceUrl: string;
|
||||
steps: readonly PipelineStep[];
|
||||
previewWidth: number;
|
||||
includeHistogram?: boolean;
|
||||
};
|
||||
|
||||
type WorkerRequestMessage =
|
||||
@@ -261,6 +262,7 @@ export async function renderPreviewWithWorkerFallback(options: {
|
||||
sourceUrl: string;
|
||||
steps: readonly PipelineStep[];
|
||||
previewWidth: number;
|
||||
includeHistogram?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}): Promise<PreviewRenderResult> {
|
||||
try {
|
||||
@@ -270,6 +272,7 @@ export async function renderPreviewWithWorkerFallback(options: {
|
||||
sourceUrl: options.sourceUrl,
|
||||
steps: options.steps,
|
||||
previewWidth: options.previewWidth,
|
||||
includeHistogram: options.includeHistogram,
|
||||
},
|
||||
signal: options.signal,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user