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 sw = S.sourceImage.width * z
|
||||
local sh = S.sourceImage.height * z
|
||||
if S.useBgColor then
|
||||
gc.color = S.bgColor
|
||||
-- Use solid bg instead of checkerboard for performance
|
||||
gc.color = S.useBgColor and S.bgColor or Color(50, 50, 50)
|
||||
gc:fillRect(Rectangle(sx, sy, sw, sh))
|
||||
else
|
||||
drawCheckerboard(gc, sw, sh, z, sx, sy)
|
||||
end
|
||||
gc:drawImage(S.sourceImage,
|
||||
Rectangle(0, 0, S.sourceImage.width, S.sourceImage.height),
|
||||
Rectangle(sx, sy, sw, sh))
|
||||
|
|
@ -1581,18 +1578,28 @@ openPreviewWindow = function()
|
|||
previewTimer = Timer{
|
||||
interval = S.animSpeed / 1000.0,
|
||||
ontick = function()
|
||||
if S.previewMode ~= "static" then
|
||||
pvAnimFrame.value = pvAnimFrame.value + 1
|
||||
pcall(function() previewDlg:repaint() end)
|
||||
end
|
||||
end
|
||||
}
|
||||
previewTimer:start()
|
||||
|
||||
pvRefreshTimer = Timer{
|
||||
interval = 0.5,
|
||||
ontick = function()
|
||||
local prevImg = S.sourceImage
|
||||
refreshSource()
|
||||
refreshLockFile()
|
||||
-- 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
|
||||
local currentFile = app.sprite and app.sprite.filename or ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue