Fix Sta mode 100% CPU: skip checkerboard, skip idle repaints
- Replace pixel-by-pixel checkerboard with solid bg in Sta mode - Animation timer skips repaint in static mode (no animation) - Refresh timer only repaints Sta when source image actually changes
This commit is contained in:
parent
83645dbeae
commit
b2a333405a
|
|
@ -1425,12 +1425,9 @@ openPreviewWindow = function()
|
||||||
local sy = S.previewStaScrollY
|
local sy = S.previewStaScrollY
|
||||||
local sw = S.sourceImage.width * z
|
local sw = S.sourceImage.width * z
|
||||||
local sh = S.sourceImage.height * z
|
local sh = S.sourceImage.height * z
|
||||||
if S.useBgColor then
|
-- Use solid bg instead of checkerboard for performance
|
||||||
gc.color = S.bgColor
|
gc.color = S.useBgColor and S.bgColor or Color(50, 50, 50)
|
||||||
gc:fillRect(Rectangle(sx, sy, sw, sh))
|
gc:fillRect(Rectangle(sx, sy, sw, sh))
|
||||||
else
|
|
||||||
drawCheckerboard(gc, sw, sh, z, sx, sy)
|
|
||||||
end
|
|
||||||
gc:drawImage(S.sourceImage,
|
gc:drawImage(S.sourceImage,
|
||||||
Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height),
|
Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height),
|
||||||
Rectangle(sx, sy, sw, sh))
|
Rectangle(sx, sy, sw, sh))
|
||||||
|
|
@ -1581,8 +1578,10 @@ openPreviewWindow = function()
|
||||||
previewTimer = Timer{
|
previewTimer = Timer{
|
||||||
interval = S.animSpeed / 1000.0,
|
interval = S.animSpeed / 1000.0,
|
||||||
ontick = function()
|
ontick = function()
|
||||||
pvAnimFrame.value = pvAnimFrame.value + 1
|
if S.previewMode ~= "static" then
|
||||||
pcall(function() previewDlg:repaint() end)
|
pvAnimFrame.value = pvAnimFrame.value + 1
|
||||||
|
pcall(function() previewDlg:repaint() end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
previewTimer:start()
|
previewTimer:start()
|
||||||
|
|
@ -1590,9 +1589,17 @@ openPreviewWindow = function()
|
||||||
pvRefreshTimer = Timer{
|
pvRefreshTimer = Timer{
|
||||||
interval = 0.5,
|
interval = 0.5,
|
||||||
ontick = function()
|
ontick = function()
|
||||||
|
local prevImg = S.sourceImage
|
||||||
refreshSource()
|
refreshSource()
|
||||||
refreshLockFile()
|
refreshLockFile()
|
||||||
pcall(function() previewDlg:repaint() end)
|
-- In static mode, only repaint if source image changed
|
||||||
|
if S.previewMode == "static" then
|
||||||
|
if S.sourceImage ~= prevImg then
|
||||||
|
pcall(function() previewDlg:repaint() end)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
pcall(function() previewDlg:repaint() end)
|
||||||
|
end
|
||||||
|
|
||||||
-- Auto-detect file change
|
-- Auto-detect file change
|
||||||
local currentFile = app.sprite and app.sprite.filename or ""
|
local currentFile = app.sprite and app.sprite.filename or ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue