Rename graphics buffer

This commit is contained in:
Gabriel Tofvesson 2024-11-22 01:17:57 +01:00
parent 609013a9fa
commit 3d01e66364

View File

@ -24,6 +24,7 @@ function WindowBuffer.wrapWindow(w, defaultC, defaultFg, defaultBg, clearColor)
end end
function obj.flush() end function obj.flush() end
function obj.flushPartial() end
function obj.getSize() function obj.getSize()
return w.getSize() return w.getSize()
end end
@ -145,8 +146,6 @@ function WindowBuffer.new(width, height, clearC, clearFg, clearBg)
end end
end end
-- TODO: Implement partial flush; obj.flush(win, offsetX, offsetY, width, height)
function obj.flush(win, offsetX, offsetY) function obj.flush(win, offsetX, offsetY)
for i=1,height do for i=1,height do
local line = buffer[i] local line = buffer[i]
@ -157,6 +156,16 @@ function WindowBuffer.new(width, height, clearC, clearFg, clearBg)
end end
end end
function obj.flushPartial(win, winOffsetX, winOffsetY, baseX, baseY, flushWidth, flushHeight)
for i=baseY,baseY+flushHeight do
local line = buffer[i]
for j=baseX,baseX+flushWidth do
local entry = line[j]
win._writePixel(j + winOffsetX, i + winOffsetY, entry.c, entry.fg, entry.bg)
end
end
end
return obj return obj
end end
@ -219,12 +228,14 @@ function WindowBuffer.shallowChild(windowBuffer, width, height, offsetX, offsetY
function obj.clear() function obj.clear()
for i=1,height do for i=1,height do
for j=1,width do for j=1,width do
windowBuffer._setPixel(clearC, clearFg, clearBg) windowBuffer._setPixel(j + offsetX, i + offsetY, clearC, clearFg, clearBg)
end end
end end
end end
obj.flush = windowBuffer.flush() -- Reconsider implementation?
obj.flush = windowBuffer.flush
obj.flushPartial = windowBuffer.flushPartial
return obj return obj
end end