mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
perf(ui): do not cache controlnet images unless required
This commit is contained in:
parent
ded8267505
commit
c354470cd1
@ -470,15 +470,26 @@ const updateControlNetLayerImageAttrs = (
|
|||||||
konvaImage: Konva.Image,
|
konvaImage: Konva.Image,
|
||||||
reduxLayer: ControlAdapterLayer
|
reduxLayer: ControlAdapterLayer
|
||||||
) => {
|
) => {
|
||||||
konvaImage.setAttrs({
|
let needsCache = false;
|
||||||
opacity: reduxLayer.opacity,
|
const newWidth = stage.width() / stage.scaleX();
|
||||||
scaleX: 1,
|
const newHeight = stage.height() / stage.scaleY();
|
||||||
scaleY: 1,
|
if (konvaImage.width() !== newWidth || konvaImage.height() !== newHeight) {
|
||||||
width: stage.width() / stage.scaleX(),
|
konvaImage.setAttrs({
|
||||||
height: stage.height() / stage.scaleY(),
|
opacity: reduxLayer.opacity,
|
||||||
visible: reduxLayer.isEnabled,
|
scaleX: 1,
|
||||||
});
|
scaleY: 1,
|
||||||
konvaImage.cache();
|
width: stage.width() / stage.scaleX(),
|
||||||
|
height: stage.height() / stage.scaleY(),
|
||||||
|
visible: reduxLayer.isEnabled,
|
||||||
|
});
|
||||||
|
needsCache = true;
|
||||||
|
}
|
||||||
|
if (konvaImage.opacity() !== reduxLayer.opacity) {
|
||||||
|
konvaImage.opacity(reduxLayer.opacity);
|
||||||
|
}
|
||||||
|
if (needsCache) {
|
||||||
|
konvaImage.cache();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderControlNetLayer = (stage: Konva.Stage, reduxLayer: ControlAdapterLayer) => {
|
const renderControlNetLayer = (stage: Konva.Stage, reduxLayer: ControlAdapterLayer) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user