Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(canvas): regenerate regions as live content masks

Josh Corbett9621989da48e
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index 1d2297439e..735b5245b3 100644
--- a/invokeai/frontend/webv2/performance/browser-baseline.json
+++ b/invokeai/frontend/webv2/performance/browser-baseline.json
@@ -25,13 +25,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 118.29999999701977,
+ "domContentLoadedMedianMs": 116.70000000298023,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 118.29999999701977,
- "longestTaskMaxMs": 70,
+ "loadMedianMs": 116.79999999701977,
+ "longestTaskMaxMs": 71,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -41,24 +41,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 38,
- "scriptRawBytes": 1636323,
+ "scriptRawBytes": 1636381,
"scriptRequestCount": 34,
- "totalRawBytes": 1822803
+ "totalRawBytes": 1822932
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 38,
- "scriptRawBytes": 1652687,
+ "scriptRawBytes": 1652745,
"scriptRequestCount": 34,
- "totalRawBytes": 1841032
+ "totalRawBytes": 1841162
},
- "routeReadyMedianMs": 259.3999999910593,
+ "routeReadyMedianMs": 261.59999999403954,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -85,13 +85,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 114.20000000298023,
+ "domContentLoadedMedianMs": 113.70000000298023,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 114.29999999701977,
- "longestTaskMaxMs": 68,
+ "loadMedianMs": 113.80000001192093,
+ "longestTaskMaxMs": 67,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -101,24 +101,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 38,
- "scriptRawBytes": 1636323,
+ "scriptRawBytes": 1636381,
"scriptRequestCount": 34,
- "totalRawBytes": 1822803
+ "totalRawBytes": 1822932
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 38,
- "scriptRawBytes": 1652687,
+ "scriptRawBytes": 1652745,
"scriptRequestCount": 34,
- "totalRawBytes": 1841032
+ "totalRawBytes": 1841162
},
- "routeReadyMedianMs": 275.20000000298023,
+ "routeReadyMedianMs": 271.8999999910593,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -145,15 +145,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 120,
+ "domContentLoadedMedianMs": 114.5,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 120.1000000089407,
- "longestTaskMaxMs": 105,
+ "loadMedianMs": 114.59999999403954,
+ "longestTaskMaxMs": 96,
"owner": "workbench",
- "projectSwitchMedianMs": 38.400000005960464,
+ "projectSwitchMedianMs": 36.79999999701977,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -161,24 +161,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 115,
- "scriptRawBytes": 3282268,
+ "scriptRawBytes": 3283435,
"scriptRequestCount": 110,
- "totalRawBytes": 3625124
+ "totalRawBytes": 3626362
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 115,
- "scriptRawBytes": 3315091,
+ "scriptRawBytes": 3316270,
"scriptRequestCount": 110,
- "totalRawBytes": 3661376
+ "totalRawBytes": 3662626
},
- "routeReadyMedianMs": 678.7000000029802,
+ "routeReadyMedianMs": 660.7999999970198,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -205,15 +205,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 115,
+ "domContentLoadedMedianMs": 113.5,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 115.20000000298023,
- "longestTaskMaxMs": 177,
+ "loadMedianMs": 113.6000000089407,
+ "longestTaskMaxMs": 179,
"owner": "workbench",
- "projectSwitchMedianMs": 73.30000001192093,
+ "projectSwitchMedianMs": 67.20000000298023,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -221,24 +221,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 115,
- "scriptRawBytes": 3282268,
+ "scriptRawBytes": 3283435,
"scriptRequestCount": 110,
- "totalRawBytes": 3625124
+ "totalRawBytes": 3626362
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 115,
- "scriptRawBytes": 3315091,
+ "scriptRawBytes": 3316270,
"scriptRequestCount": 110,
- "totalRawBytes": 3661376
+ "totalRawBytes": 3662626
},
- "routeReadyMedianMs": 435.8999999910593,
+ "routeReadyMedianMs": 438.5,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -247,31 +247,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 297014,
+ "largestAssetRawBytes": 297147,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 455388,
+ "scriptRawBytes": 455507,
"scriptRequestCount": 7,
- "totalRawBytes": 455388
+ "totalRawBytes": 455507
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 299985,
+ "largestAssetRawBytes": 300119,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 459942,
+ "scriptRawBytes": 460063,
"scriptRequestCount": 7,
- "totalRawBytes": 459942
+ "totalRawBytes": 460063
},
- "domContentLoadedMedianMs": 116.6000000089407,
+ "domContentLoadedMedianMs": 114.09999999403954,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.1000000089406967,
- "layoutReturnSwitchMedianMs": 55.099999994039536,
- "layoutSwitchMedianMs": 94.8999999910593,
- "loadMedianMs": 116.70000000298023,
- "longestTaskMaxMs": 125,
+ "layoutAckMedianMs": 2.2999999970197678,
+ "layoutReturnSwitchMedianMs": 54.20000000298023,
+ "layoutSwitchMedianMs": 94.29999999701977,
+ "loadMedianMs": 114.20000000298023,
+ "longestTaskMaxMs": 123,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -281,24 +281,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 122,
- "scriptRawBytes": 3737656,
+ "scriptRawBytes": 3738942,
"scriptRequestCount": 117,
- "totalRawBytes": 4080512
+ "totalRawBytes": 4081869
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 122,
- "scriptRawBytes": 3775033,
+ "scriptRawBytes": 3776332,
"scriptRequestCount": 117,
- "totalRawBytes": 4121318
+ "totalRawBytes": 4122688
},
- "routeReadyMedianMs": 1063.5999999940395,
+ "routeReadyMedianMs": 1047.5,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -307,31 +307,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 297014,
+ "largestAssetRawBytes": 297147,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 455388,
+ "scriptRawBytes": 455507,
"scriptRequestCount": 7,
- "totalRawBytes": 455388
+ "totalRawBytes": 455507
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 299985,
+ "largestAssetRawBytes": 300119,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 459942,
+ "scriptRawBytes": 460063,
"scriptRequestCount": 7,
- "totalRawBytes": 459942
+ "totalRawBytes": 460063
},
- "domContentLoadedMedianMs": 117.40000000596046,
+ "domContentLoadedMedianMs": 116.29999999701977,
"id": "editor-canvas",
"layoutAckMedianMs": 2.5,
- "layoutReturnSwitchMedianMs": 45.1000000089407,
- "layoutSwitchMedianMs": 86.29999999701977,
- "loadMedianMs": 117.5,
- "longestTaskMaxMs": 186,
+ "layoutReturnSwitchMedianMs": 51.20000000298023,
+ "layoutSwitchMedianMs": 92.29999999701977,
+ "loadMedianMs": 116.40000000596046,
+ "longestTaskMaxMs": 175,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -341,24 +341,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 122,
- "scriptRawBytes": 3737656,
+ "scriptRawBytes": 3738942,
"scriptRequestCount": 117,
- "totalRawBytes": 4080512
+ "totalRawBytes": 4081869
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 122,
- "scriptRawBytes": 3775033,
+ "scriptRawBytes": 3776332,
"scriptRequestCount": 117,
- "totalRawBytes": 4121318
+ "totalRawBytes": 4122688
},
- "routeReadyMedianMs": 1149.2999999970198,
+ "routeReadyMedianMs": 1138.9000000059605,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -385,12 +385,12 @@
"scriptRequestCount": 6,
"totalRawBytes": 383461
},
- "domContentLoadedMedianMs": 115.79999999701977,
+ "domContentLoadedMedianMs": 113.59999999403954,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.3999999910593033,
- "layoutReturnSwitchMedianMs": 32.900000005960464,
- "layoutSwitchMedianMs": 88.70000000298023,
- "loadMedianMs": 115.90000000596046,
+ "layoutAckMedianMs": 2.300000011920929,
+ "layoutReturnSwitchMedianMs": 33.79999999701977,
+ "layoutSwitchMedianMs": 91.29999999701977,
+ "loadMedianMs": 113.69999998807907,
"longestTaskMaxMs": 98,
"owner": "workflow",
"projectSwitchMedianMs": 0,
@@ -401,24 +401,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 122,
- "scriptRawBytes": 3646519,
+ "scriptRawBytes": 3647686,
"scriptRequestCount": 116,
- "totalRawBytes": 4004788
+ "totalRawBytes": 4006026
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 122,
- "scriptRawBytes": 3682985,
+ "scriptRawBytes": 3684163,
"scriptRequestCount": 116,
- "totalRawBytes": 4044836
+ "totalRawBytes": 4046087
},
- "routeReadyMedianMs": 1046.8999999910593,
+ "routeReadyMedianMs": 1044,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@ -445,13 +445,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383461
},
- "domContentLoadedMedianMs": 116,
+ "domContentLoadedMedianMs": 120.5,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.5999999940395355,
- "layoutReturnSwitchMedianMs": 40.1000000089407,
- "layoutSwitchMedianMs": 125.29999999701977,
- "loadMedianMs": 116.1000000089407,
- "longestTaskMaxMs": 345,
+ "layoutAckMedianMs": 2.9000000059604645,
+ "layoutReturnSwitchMedianMs": 41.099999994039536,
+ "layoutSwitchMedianMs": 125.20000000298023,
+ "loadMedianMs": 120.70000000298023,
+ "longestTaskMaxMs": 359,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -461,24 +461,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 122,
- "scriptRawBytes": 3646519,
+ "scriptRawBytes": 3647686,
"scriptRequestCount": 116,
- "totalRawBytes": 4004788
+ "totalRawBytes": 4006026
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 122,
- "scriptRawBytes": 3682985,
+ "scriptRawBytes": 3684163,
"scriptRequestCount": 116,
- "totalRawBytes": 4044836
+ "totalRawBytes": 4046087
},
- "routeReadyMedianMs": 1187.2999999970198,
+ "routeReadyMedianMs": 1189.5,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@ -505,13 +505,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 116.3999999910593,
+ "domContentLoadedMedianMs": 114.79999999701977,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 24.900000005960464,
- "loadMedianMs": 116.5,
- "longestTaskMaxMs": 98,
+ "layoutSwitchMedianMs": 24.899999991059303,
+ "loadMedianMs": 114.90000000596046,
+ "longestTaskMaxMs": 101,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -521,24 +521,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 115,
- "scriptRawBytes": 3282268,
+ "scriptRawBytes": 3283435,
"scriptRequestCount": 110,
- "totalRawBytes": 3625124
+ "totalRawBytes": 3626362
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 115,
- "scriptRawBytes": 3315091,
+ "scriptRawBytes": 3316270,
"scriptRequestCount": 110,
- "totalRawBytes": 3661376
+ "totalRawBytes": 3662626
},
- "routeReadyMedianMs": 1267.2999999970198,
+ "routeReadyMedianMs": 1262.699999988079,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -565,13 +565,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 117.5,
+ "domContentLoadedMedianMs": 116.20000000298023,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 88.70000000298023,
- "loadMedianMs": 117.59999999403954,
- "longestTaskMaxMs": 184,
+ "layoutSwitchMedianMs": 88.59999999403954,
+ "loadMedianMs": 116.40000000596046,
+ "longestTaskMaxMs": 177,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -581,24 +581,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160657,
+ "otherRawBytes": 160728,
"requestCount": 115,
- "scriptRawBytes": 3282268,
+ "scriptRawBytes": 3283435,
"scriptRequestCount": 110,
- "totalRawBytes": 3625124
+ "totalRawBytes": 3626362
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162264,
+ "otherRawBytes": 162336,
"requestCount": 115,
- "scriptRawBytes": 3315091,
+ "scriptRawBytes": 3316270,
"scriptRequestCount": 110,
- "totalRawBytes": 3661376
+ "totalRawBytes": 3662626
},
- "routeReadyMedianMs": 1433,
+ "routeReadyMedianMs": 1452.0999999940395,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 5d03c2c4b6..b378e71508 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3068,7 +3068,7 @@
"noise": "Noise",
"regenerateRegion": "Regenerate region",
"removeRegion": "Remove regenerate region",
- "regionHint": "Marks the area of this layer to regenerate. It rides the layer and joins the inpaint coverage while the layer is enabled.",
+ "regionHint": "Shows this layer's content as a live inpaint mask: everything on the layer, now and as you keep editing it, marks its area to regenerate while enabled.",
"noiseHelp": "Adds noise inside the masked area before generation.",
"removeDenoise": "Remove denoise limit",
"removeNoise": "Remove noise",
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
index aa9ee23e22..006f797988 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
@@ -237,15 +237,17 @@ export interface CanvasMaskContract {
}
/**
- * A raster layer's attached regenerate region: coverage in the PARENT's local
- * space (it rides the layer's transform), unioned into generation's inpaint
- * coverage while the layer contributes. Singleton, like a mask's noise
- * modifier; absent ⇒ never added.
+ * A raster layer's attached regenerate region: the layer's OWN content alpha
+ * presented as a live inpaint mask ("copy to inpaint mask", non-destructively).
+ * Every stroke, erase, and transform of the layer updates the coverage, which
+ * unions into generation's inpaint mask while the layer contributes. Singleton,
+ * like a mask's noise modifier; absent ⇒ never added. Carries no pixels of its
+ * own — only the overlay fill.
*/
export interface CanvasLayerRegionContract {
isEnabled: boolean;
name?: string;
- mask: CanvasMaskContract;
+ fill: CanvasMaskFillContract;
}
export interface CanvasRasterLayerContractV2 extends CanvasLayerBaseContract {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts
index 6f07553c74..6f3635c0ea 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts
@@ -760,7 +760,7 @@ describe('createDocumentModel', () => {
const project = projectWith(flat(), 'r1');
const inpaint = {
isEnabled: true,
- mask: { bitmap: null, fill: { color: '#e07575', style: 'diagonal' as const } },
+ fill: { color: '#e07575', style: 'diagonal' as const },
};
const added = roundTrip(project, {
before: { inpaint: null, layerType: 'raster' },
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
index 051931cfe4..ecd5007758 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
@@ -3110,6 +3110,7 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreC
groupSurface: getGroupSurface,
imageSmoothing: true,
maskPatternTile: getMaskPatternTile,
+ regionOverlays: true,
}
);
return { height: doc.height, width: doc.width, x: 0, y: 0 };
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositeFrame.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositeFrame.ts
index 0ad50c2277..cb81efbbbf 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositeFrame.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositeFrame.ts
@@ -213,6 +213,8 @@ export const createCompositeFrame = (deps: CreateCompositeFrameDeps): CompositeF
// map per frame for the overwhelmingly common case of none.
layerPreviews: !isolatedGuard && previews.filterCount() > 0 ? previews.filterSnapshot() : null,
maskPatternTile: deps.getMaskPatternTile,
+ // Screen frames are display-time: the region tint may draw.
+ regionOverlays: true,
// Candidate-specific placement wins for final images. Progress frames
// and legacy image inputs continue to follow the CURRENT bbox origin.
stagedPreview:
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.test.ts
index 3da1f7ad48..992ed5de20 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.test.ts
@@ -11,7 +11,7 @@ import type { Mat2d } from '@workbench/canvas-engine/types';
import { createCanvasDiagnostics } from '@workbench/canvas-engine/diagnostics';
import { stacksFrom } from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
import { identity } from '@workbench/canvas-engine/math/mat2d';
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
import type { RasterCallLogEntry, StubRasterSurface } from './raster.testStub';
@@ -377,6 +377,76 @@ describe('compositeDocument', () => {
expect(target.callLog.some((e) => e.op === 'drawImage')).toBe(true);
});
+ it("draws an enabled regenerate region as the layer's OWN content colorized above it; a disabled one draws nothing extra", () => {
+ const base = createTestStubRasterBackend();
+ const created: StubRasterSurface[] = [];
+ const backend = {
+ ...base,
+ createSurface: (w: number, h: number): StubRasterSurface => {
+ const surface = base.createSurface(w, h);
+ created.push(surface);
+ return surface;
+ },
+ };
+ const caches = createLayerCacheStore(backend);
+ const cacheEntry = caches.getOrCreate('r', 10, 10);
+ const layer = rasterLayer('r', {
+ inpaint: { fill: { color: '#e07575', style: 'solid' }, isEnabled: true },
+ });
+ const target = backend.createSurface(200, 200);
+
+ compositeDocument(target, makeDoc([layer]), caches, VIEW, { backend, regionOverlays: true });
+
+ // The colorize reads the LAYER's cache surface — the mask IS the content.
+ const colorized = created.find(
+ (s) =>
+ s !== target &&
+ s !== (cacheEntry.surface as StubRasterSurface) &&
+ s.callLog.some((e) => e.op === 'set' && e.args[0] === 'globalCompositeOperation' && e.args[1] === 'source-in')
+ );
+ expect(colorized).toBeDefined();
+ expect(findSet(colorized!.callLog, 'fillStyle')).toContain('#e07575');
+ // Layer blit + colorized coverage blit both land on the target.
+ expect(target.callLog.filter((e) => e.op === 'drawImage')).toHaveLength(2);
+
+ const disabledTarget = backend.createSurface(200, 200);
+ const disabledLayer = rasterLayer('r', {
+ inpaint: { fill: { color: '#e07575', style: 'solid' }, isEnabled: false },
+ });
+ compositeDocument(disabledTarget, makeDoc([disabledLayer]), caches, VIEW, { backend, regionOverlays: true });
+ expect(disabledTarget.callLog.filter((e) => e.op === 'drawImage')).toHaveLength(1);
+ });
+
+ it('overlays a region member above its adjusted group composite', () => {
+ const backend = createTestStubRasterBackend();
+ const caches = createLayerCacheStore(backend);
+ caches.getOrCreate('r', 10, 10);
+ const target = backend.createSurface(200, 200);
+ const groupResult = backend.createSurface(50, 50);
+ const layer = rasterLayer('r', {
+ inpaint: { fill: { color: '#e07575', style: 'solid' }, isEnabled: true },
+ });
+ const doc = makeDoc([]);
+ doc.stacks.raster = [
+ {
+ adjustments: [{ id: 'ga', isEnabled: true, type: 'invert' }],
+ children: [layer],
+ id: 'g1',
+ isEnabled: true,
+ isLocked: false,
+ name: 'g1',
+ type: 'group',
+ } as never,
+ ];
+ const groupSurface = vi.fn(() => ({ rect: { height: 50, width: 50, x: 0, y: 0 }, surface: groupResult }));
+
+ compositeDocument(target, doc, caches, VIEW, { backend, groupSurface, regionOverlays: true });
+
+ expect(groupSurface).toHaveBeenCalled();
+ // Group composite blit + the member's colorized region overlay.
+ expect(target.callLog.filter((e) => e.op === 'drawImage')).toHaveLength(2);
+ });
+
it('performs no effect allocations or pixel readbacks on a warmed unchanged composite', () => {
const base = createTestStubRasterBackend();
const created: StubRasterSurface[] = [];
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts
index b785525ae4..807740860d 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts
@@ -17,6 +17,7 @@ import type {
CanvasBlendMode,
CanvasDocumentContractV3,
CanvasLayerContract,
+ CanvasMaskFillContract,
} from '@workbench/canvas-engine/contracts';
import type { CanvasDiagnostics } from '@workbench/canvas-engine/diagnostics';
import type { SemanticLeaf } from '@workbench/canvas-engine/document-model/semanticLeaf';
@@ -155,6 +156,14 @@ export interface CompositeOptions {
* the checkerboard). Absent ⇒ solid fills only.
*/
maskPatternTile?: ((style: string, color: string) => RasterSurface | null) | null;
+ /**
+ * Opt-in for the regenerate-region overlays (a raster layer's own alpha
+ * colorized above it while its region is enabled). STRICTLY display-time:
+ * only screen frames and the Overview pass it — a composite whose pixels are
+ * consumed (generation, extraction, color sampling, exports) must not, or the
+ * tint becomes real content.
+ */
+ regionOverlays?: boolean;
/**
* Transient per-layer content previews (a non-destructive control-filter
* preview): a layer with an entry here draws the preview surface at its returned
@@ -481,9 +490,57 @@ const drawCachedLayer = (
ctx.drawImage((adjusted ?? entry.surface).canvas, origin.x, origin.y);
}
+ if (opts.regionOverlays && layer.type === 'raster' && layer.inpaint?.isEnabled && !preview && !isIsolated(opts)) {
+ drawRegionCoverage(ctx, layer.id, layer.inpaint.fill, entry, opts);
+ }
+
ctx.restore();
};
+/**
+ * Draws a raster layer's regenerate region: the layer's OWN content alpha,
+ * colorized like an inpaint mask and laid directly above the layer through the
+ * same (already applied) transform. The mask IS the layer — every stroke,
+ * erase, and transform updates it live, with nothing separate to persist.
+ */
+const drawRegionCoverage = (
+ ctx: Ctx,
+ layerId: string,
+ fill: CanvasMaskFillContract,
+ coverage: { surface: RasterSurface; rect: Rect; version: number },
+ opts: CompositeOptions
+): void => {
+ ctx.globalCompositeOperation = 'source-over';
+ ctx.globalAlpha = MASK_TINT_ALPHA;
+ if (opts.backend) {
+ const tile = opts.maskPatternTile ? opts.maskPatternTile(fill.style, fill.color) : null;
+ const colorized = opts.derivedSurfaces
+ ? opts.derivedSurfaces.get({
+ create: (target) =>
+ colorizeMask(
+ opts.backend!,
+ coverage.surface,
+ coverage.surface.width,
+ coverage.surface.height,
+ fill,
+ tile,
+ target
+ ),
+ kind: 'region-fill',
+ layerId,
+ paramsKey: `${fill.style}:${fill.color}`,
+ source: coverage.surface,
+ sourceVersion: coverage.version,
+ })
+ : colorizeMask(opts.backend, coverage.surface, coverage.surface.width, coverage.surface.height, fill, tile);
+ ctx.drawImage(colorized.canvas, coverage.rect.x, coverage.rect.y);
+ return;
+ }
+ ctx.fillStyle = fill.color;
+ ctx.drawImage(coverage.surface.canvas, coverage.rect.x, coverage.rect.y);
+ ctx.fillRect(coverage.rect.x, coverage.rect.y, coverage.rect.width, coverage.rect.height);
+};
+
/**
* Draws the floating selection over the layer it was cut from. Its pixels are
* layer-local, so they go through the layer's (possibly overridden) matrix and
@@ -624,6 +681,27 @@ export const compositeDocument = (
drawFloatingSelection(ctx, member, view, opts, opts.floatingSelection);
}
}
+ // Region overlays are display-only, so they ride ABOVE the group
+ // composite rather than being baked into (and staled with) its memo.
+ for (let memberIndex = 0; opts.regionOverlays && memberIndex < members.length; memberIndex += 1) {
+ const member = members[memberIndex]!;
+ const { layer } = member;
+ if (
+ excluded.has(member.id) ||
+ member.id === opts.skipLayerId ||
+ layer.type !== 'raster' ||
+ !layer.inpaint?.isEnabled
+ ) {
+ continue;
+ }
+ const memberEntry = caches.get(member.id);
+ if (memberEntry && memberEntry.rect.width > 0 && memberEntry.rect.height > 0) {
+ ctx.save();
+ setTransformFromMat(ctx, multiply(view, matrices[memberIndex]!));
+ drawRegionCoverage(ctx, layer.id, layer.inpaint.fill, memberEntry, opts);
+ ctx.restore();
+ }
+ }
index = scope.end - 1;
scopeIndex += 1;
continue;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/derivedSurfaceCache.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/derivedSurfaceCache.ts
index fbeb5fbba3..277edeb910 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/derivedSurfaceCache.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/derivedSurfaceCache.ts
@@ -2,7 +2,7 @@ import type { CanvasDiagnostics } from '@workbench/canvas-engine/diagnostics';
import type { RasterSurface } from './raster';
-export type DerivedSurfaceKind = 'adjustments' | 'mask-fill' | 'control-transparency';
+export type DerivedSurfaceKind = 'adjustments' | 'mask-fill' | 'region-fill' | 'control-transparency';
export interface DerivedSurfaceRequest {
layerId: string;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts
index d4bf3dfd3f..1126305052 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts
@@ -343,6 +343,31 @@ describe('composeForGeneration', () => {
expect(result.composites.maskImageName).toBe('composite-2.png');
});
+ it("composites a regenerate-region raster's own surface into the inpaint mask", async () => {
+ const base = rasterLayer('base');
+ const regionLayer: CanvasRasterLayerContractV2 = {
+ ...base,
+ inpaint: { fill: { color: '#e07575', style: 'diagonal' }, isEnabled: true },
+ };
+ const harness = makeHost(makeDoc([regionLayer]));
+ const detectMode = vi.fn((facts: GenerationModeFacts) =>
+ facts.hasActiveInpaintMask ? ('inpaint' as const) : ('img2img' as const)
+ );
+
+ const result = await compose(harness.host, { detectMode });
+
+ expect(result.status).toBe('ok');
+ if (result.status !== 'ok') {
+ return;
+ }
+ // Base upload + the region-driven inpaint-mask upload; the mask composite
+ // read the raster layer's own surface — the mask IS the layer content.
+ expect(result.composites.mode).toBe('inpaint');
+ expect(result.composites.maskImageName).toBe('composite-2.png');
+ expect(harness.surfaceIds).toContain('base');
+ expect(detectMode).toHaveBeenCalledWith(expect.objectContaining({ hasActiveInpaintMask: true }));
+ });
+
it.each([
{ expectedMask: null, expectedNoise: null, expectedUploads: 2, mode: 'img2img' as const },
{ expectedMask: 'composite-2.png', expectedNoise: 'composite-3.png', expectedUploads: 3, mode: 'inpaint' as const },
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts
index 43ae2ceb36..7687f228c1 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts
@@ -283,6 +283,53 @@ describe('planComposites — inpaint-mask entries', () => {
expect(entry!.maskLayers!.map((l) => l.id)).toEqual(['shown', 'hidden']);
});
+ it("unions a regenerate-region raster's own alpha into the inpaint mask at full denoise", () => {
+ const region = { fill: { color: '#e07575', style: 'diagonal' as const }, isEnabled: true };
+ const doc = makeDoc([rasterLayer('r1', { inpaint: region }), inpaintMask('m1')]);
+ const entry = entryOfKind(doc, 'inpaint-mask');
+ expect(entry!.maskLayers!.map((l) => l.id)).toEqual(['m1', 'r1']);
+ const ref = entry!.maskLayers![1]!;
+ expect(ref.attributeValue).toBe(1);
+ expect(ref.sourceRef).toBe('region:image:r1');
+ expect(ref.contentSize).toEqual({ height: 48, width: 64 });
+ });
+
+ it('emits an inpaint-mask entry for a region alone, and never a noise entry for it', () => {
+ const region = { fill: { color: '#e07575', style: 'diagonal' as const }, isEnabled: true };
+ const kinds = planComposites(makeDoc([rasterLayer('r1', { inpaint: region })]), BBOX).entries.map((e) => e.kind);
+ expect(kinds).toEqual(['base-raster', 'inpaint-mask']);
+ });
+
+ it('excludes disabled regions, empty paint layers, disabled layers, and unrasterizable polygons', () => {
+ const region = { fill: { color: '#e07575', style: 'diagonal' as const }, isEnabled: true };
+ const doc = makeDoc([
+ rasterLayer('on', { inpaint: region }),
+ rasterLayer('off', { inpaint: { ...region, isEnabled: false } }),
+ rasterLayer('empty', { inpaint: region, source: { bitmap: null, type: 'paint' } }),
+ rasterLayer('layer-off', { inpaint: region, isEnabled: false }),
+ rasterLayer('poly', {
+ inpaint: region,
+ source: { fill: '#fff', height: 10, kind: 'polygon', width: 10, type: 'shape' } as never,
+ }),
+ ]);
+ const entry = entryOfKind(doc, 'inpaint-mask');
+ expect(entry!.maskLayers!.map((l) => l.id)).toEqual(['on']);
+ });
+
+ it("keys a parametric-source region on the source's pixel-determining fields", () => {
+ const region = { fill: { color: '#e07575', style: 'diagonal' as const }, isEnabled: true };
+ const textDoc = (content: string) =>
+ makeDoc([
+ rasterLayer('t1', {
+ inpaint: region,
+ source: { color: '#fff', content, fontFamily: 'Inter', fontSize: 24, type: 'text' } as never,
+ }),
+ ]);
+ const keyFor = (doc: CanvasDocumentContractV3) => entryOfKind(doc, 'inpaint-mask')!.key;
+ expect(keyFor(textDoc('HELLO'))).not.toBe(keyFor(textDoc('WORLD')));
+ expect(keyFor(textDoc('HELLO'))).toBe(keyFor(textDoc('HELLO')));
+ });
+
it('resolves an undefined denoiseLimit to the legacy default (1.0)', () => {
const entry = entryOfKind(makeDoc([inpaintMask('m1')]), 'inpaint-mask');
expect(entry!.maskLayers![0]!.attributeValue).toBe(1);
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts
index 1a2fff3ac8..19b5e3be82 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts
@@ -4,6 +4,7 @@ import type {
CanvasInpaintMaskLayerContract,
CanvasLayerContract,
CanvasLayerSourceContract,
+ CanvasRasterLayerContractV2,
CanvasRegionalGuidanceLayerContract,
} from '@workbench/canvas-engine/api';
@@ -76,6 +77,81 @@ const contributingLayers = <T extends CanvasLayerContract>(
const isInpaintMaskWithContent = (layer: CanvasLayerContract): layer is CanvasInpaintMaskLayerContract =>
layer.type === 'inpaint_mask' && layer.mask.bitmap !== null;
+/**
+ * A raster layer whose regenerate region is enabled and whose source can both
+ * hold pixels and rasterize: the layer's OWN content alpha joins the inpaint
+ * mask. Invoke flushes paint uploads before planning, so a stroked layer always
+ * carries its bitmap; polygon shapes have no rasterizer and would fail the
+ * snapshot capture, so they never enter the plan.
+ */
+const isRegionRasterWithContent = (layer: CanvasLayerContract): layer is CanvasRasterLayerContractV2 =>
+ layer.type === 'raster' &&
+ layer.inpaint?.isEnabled === true &&
+ !(layer.source.type === 'shape' && layer.source.kind === 'polygon') &&
+ (layer.source.type !== 'paint' || layer.source.bitmap !== null);
+
+/** JSON with recursively sorted object keys, so equal sources always serialize identically. */
+const stableSourceKey = (value: unknown): string =>
+ JSON.stringify(value, (_key, entry: unknown) =>
+ entry && typeof entry === 'object' && !Array.isArray(entry)
+ ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => (a < b ? -1 : 1)))
+ : entry
+ );
+
+/**
+ * A region ref's pixel-identity fragment. Unlike the base plan — where
+ * parametric sources never reach a dedupe key — a region can sit on a text,
+ * shape, or gradient layer, so their pixel-determining fields must be part of
+ * the key or an edited layer would reuse the previous mask upload.
+ */
+const regionSourceRef = (source: CanvasLayerSourceContract): string => {
+ switch (source.type) {
+ case 'image':
+ case 'paint':
+ return `region:${sourceRefOf(source)}`;
+ default:
+ return `region:${stableSourceKey(source)}`;
+ }
+};
+
+/** The native content rect of a region raster's source (layer-local), mirroring the base composite. */
+const regionContentRect = (
+ layer: CanvasRasterLayerContractV2,
+ document: CanvasDocumentContractV3
+): { width: number; height: number; x: number; y: number } => {
+ const { source } = layer;
+ if (source.type === 'image') {
+ return { height: source.image.height, width: source.image.width, x: 0, y: 0 };
+ }
+ if (source.type === 'paint' && source.bitmap) {
+ const offset = source.offset ?? { x: 0, y: 0 };
+ return { height: source.bitmap.height, width: source.bitmap.width, x: offset.x, y: offset.y };
+ }
+ return { height: document.height, width: document.width, x: 0, y: 0 };
+};
+
+/** Projects a region-bearing raster layer into an inpaint-mask contribution (its alpha, full denoise). */
+const toRegionMaskRef = (
+ layer: CanvasRasterLayerContractV2,
+ document: CanvasDocumentContractV3
+): CompositeMaskLayerRef => {
+ const rect = regionContentRect(layer, document);
+ return {
+ attributeValue: DEFAULT_MASK_DENOISE_LIMIT,
+ contentOffset: { x: rect.x, y: rect.y },
+ contentSize: { height: rect.height, width: rect.width },
+ id: layer.id,
+ sourceRef: regionSourceRef(layer.source),
+ transform: {
+ rotation: layer.transform.rotation,
+ scaleX: layer.transform.scaleX,
+ scaleY: layer.transform.scaleY,
+ x: layer.transform.x,
+ y: layer.transform.y,
+ },
+ };
+};
+
const isControlLayerWithContent = (layer: CanvasLayerContract): layer is CanvasControlLayerContract =>
layer.type === 'control' && hasControlLayerContent(layer);
@@ -129,20 +205,28 @@ const deriveMaskKey = (kind: string, bbox: Rect, layers: CompositeMaskLayerRef[]
* - one `base-raster` entry (the initial image);
* - one `inpaint-mask` entry (grayscale denoise-limit mask) when enabled inpaint
* masks with content exist — an absent OR DISABLED `denoise` modifier resolves
- * to the legacy default (1.0, full denoise);
+ * to the legacy default (1.0, full denoise) — or when a contributing raster
+ * layer carries an enabled regenerate region (its own content alpha joins the
+ * mask at full denoise);
* - one `noise-mask` entry when at least one such mask carries an ENABLED
* `noise` modifier (absent and disabled are equivalent, mirroring legacy —
- * they must NOT be treated as noise 0).
+ * they must NOT be treated as noise 0). Regions never add noise.
*/
export const planComposites = (document: CanvasDocumentContractV3, bbox: Rect): CompositePlan => {
const entries: CompositeEntry[] = [planBaseRasterComposite(document, bbox)];
const maskLayers = contributingLayers(document, isInpaintMaskWithContent);
+ const regionRefs = contributingLayers(document, isRegionRasterWithContent).map((layer) =>
+ toRegionMaskRef(layer, document)
+ );
- if (maskLayers.length > 0) {
- const denoiseRefs = maskLayers.map((layer) =>
- toMaskLayerRef(layer, layer.denoise?.isEnabled ? layer.denoise.limit : DEFAULT_MASK_DENOISE_LIMIT)
- );
+ if (maskLayers.length > 0 || regionRefs.length > 0) {
+ const denoiseRefs = [
+ ...maskLayers.map((layer) =>
+ toMaskLayerRef(layer, layer.denoise?.isEnabled ? layer.denoise.limit : DEFAULT_MASK_DENOISE_LIMIT)
+ ),
+ ...regionRefs,
+ ];
entries.push({
bbox,
key: deriveMaskKey('inpaint-mask', bbox, denoiseRefs),
diff --git a/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts b/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts
index f6ebc4c90b..34228737ba 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts
@@ -106,8 +106,8 @@ describe('loadCanvasState', () => {
it('round-trips a layer regenerate region and drops a malformed one without failing the layer', () => {
const inpaint = {
+ fill: { color: '#e07575', style: 'diagonal' },
isEnabled: true,
- mask: { bitmap: null, fill: { color: '#e07575', style: 'diagonal' }, offset: { x: 4, y: -2 } },
name: 'Face',
};
const loaded = load(withNodes([{ ...createEmptyPaintLayer('Region', 'region'), inpaint }]));
diff --git a/invokeai/frontend/webv2/src/workbench/canvasMigration.ts b/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
index df2bd35766..505cbacd72 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
@@ -128,12 +128,13 @@ const zControlAdapter = z
return begin >= 0 && end <= 1 && begin < end;
})
.refine(({ kind, weight }) => weight >= (kind === 'z_image_control' ? 0 : -1) && weight <= 2);
+const zMaskFill = z.object({
+ color: z.string(),
+ style: z.enum(['solid', 'grid', 'crosshatch', 'diagonal', 'horizontal', 'vertical']),
+});
const zMask = z.object({
bitmap: zImageRef.nullable(),
- fill: z.object({
- color: z.string(),
- style: z.enum(['solid', 'grid', 'crosshatch', 'diagonal', 'horizontal', 'vertical']),
- }),
+ fill: zMaskFill,
offset: zCoordinate.optional(),
});
const zGeneratedImage = z.object({
@@ -207,7 +208,10 @@ const zCanvasLayer = z.discriminatedUnion('type', [
zLayerBase.extend({
// A pre-stack adjustments OBJECT is dropped rather than failing the document.
adjustments: zAdjustments.optional().catch(undefined),
- inpaint: z.object({ isEnabled: z.boolean(), mask: zMask, name: z.string().optional() }).optional().catch(undefined),
+ inpaint: z
+ .object({ fill: zMaskFill, isEnabled: z.boolean(), name: z.string().optional() })
+ .optional()
+ .catch(undefined),
filter: zFilter.optional(),
isTransparencyLocked: z.boolean().optional(),
source: zLayerSource,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
index ac3fe7c234..e159712b57 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
@@ -745,7 +745,7 @@ const LayerMenu = ({
model.prepare({
before: { inpaint: null, layerType: 'raster' },
config: {
- inpaint: { isEnabled: true, mask: { bitmap: null, fill: { ...DEFAULT_INPAINT_MASK_FILL } } },
+ inpaint: { fill: { ...DEFAULT_INPAINT_MASK_FILL }, isEnabled: true },
layerType: 'raster',
},
id: layer.id,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRegionSettings.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRegionSettings.tsx
index 2f8b4884e7..5e89c093b8 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRegionSettings.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRegionSettings.tsx
@@ -53,8 +53,8 @@ export const LayerRegionSettings = ({ engine, layer }: LayerRegionSettingsProps)
}
commitPrepared(t('widgets.layers.maskFill.fill'), (model) =>
model.prepare({
- before: { inpaint: { ...region, mask: { ...region.mask, fill: before } }, layerType: 'raster' },
- config: { inpaint: { ...region, mask: { ...region.mask, fill: next } }, layerType: 'raster' },
+ before: { inpaint: { ...region, fill: before }, layerType: 'raster' },
+ config: { inpaint: { ...region, fill: next }, layerType: 'raster' },
id: layer.id,
type: 'patch-config',
})
@@ -71,7 +71,7 @@ export const LayerRegionSettings = ({ engine, layer }: LayerRegionSettingsProps)
if (
!applyStructuralPreview(engine, {
config: {
- inpaint: { ...region, mask: { ...region.mask, fill: { ...region.mask.fill, color: hex } } },
+ inpaint: { ...region, fill: { ...region.fill, color: hex } },
layerType: 'raster',
},
id: layer.id,
@@ -80,7 +80,7 @@ export const LayerRegionSettings = ({ engine, layer }: LayerRegionSettingsProps)
) {
return;
}
- fillBeforeRef.current ??= region.mask.fill;
+ fillBeforeRef.current ??= region.fill;
},
[engine, layer.id, region]
);
@@ -90,7 +90,7 @@ export const LayerRegionSettings = ({ engine, layer }: LayerRegionSettingsProps)
if (!region) {
return;
}
- const before = fillBeforeRef.current ?? region.mask.fill;
+ const before = fillBeforeRef.current ?? region.fill;
fillBeforeRef.current = null;
commitFill({ ...before, color: hex }, before);
},
@@ -100,18 +100,18 @@ export const LayerRegionSettings = ({ engine, layer }: LayerRegionSettingsProps)
const handleStyleChange = useCallback(
({ value }: SelectValueChangeDetails) => {
const style = value[0] as CanvasMaskFillContract['style'] | undefined;
- if (region && style && style !== region.mask.fill.style) {
- commitFill({ ...region.mask.fill, style }, region.mask.fill);
+ if (region && style && style !== region.fill.style) {
+ commitFill({ ...region.fill, style }, region.fill);
}
},
[commitFill, region]
);
- const styleValue = useMemo(() => [region?.mask.fill.style ?? 'solid'], [region?.mask.fill.style]);
+ const styleValue = useMemo(() => [region?.fill.style ?? 'solid'], [region?.fill.style]);
if (!region) {
return null;
}
- const fill = region.mask.fill;
+ const fill = region.fill;
return (
<Stack gap="2">
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
index df8b8a4363..c77f12149d 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
@@ -444,7 +444,7 @@ describe('layerChildDropCommand id collisions', () => {
describe('layer regenerate region child row', () => {
const region = (overrides = {}) => ({
isEnabled: true,
- mask: { bitmap: null, fill: { color: '#e07575', style: 'diagonal' as const } },
+ fill: { color: '#e07575', style: 'diagonal' as const },
...overrides,
});
const rasterWithRegion = (overrides = {}) => layerContract('r1', 'raster', { inpaint: region(overrides) });