From 3d01e663646c47ca0e0b1e7a1e0d573941f13971 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Fri, 22 Nov 2024 01:17:57 +0100 Subject: [PATCH] Rename graphics buffer --- gfx/render/{buffer.lua => windowbuffer.lua} | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) rename gfx/render/{buffer.lua => windowbuffer.lua} (85%) diff --git a/gfx/render/buffer.lua b/gfx/render/windowbuffer.lua similarity index 85% rename from gfx/render/buffer.lua rename to gfx/render/windowbuffer.lua index 8e329b6..a8e1d00 100644 --- a/gfx/render/buffer.lua +++ b/gfx/render/windowbuffer.lua @@ -24,6 +24,7 @@ function WindowBuffer.wrapWindow(w, defaultC, defaultFg, defaultBg, clearColor) end function obj.flush() end + function obj.flushPartial() end function obj.getSize() return w.getSize() end @@ -145,8 +146,6 @@ function WindowBuffer.new(width, height, clearC, clearFg, clearBg) end end - -- TODO: Implement partial flush; obj.flush(win, offsetX, offsetY, width, height) - function obj.flush(win, offsetX, offsetY) for i=1,height do local line = buffer[i] @@ -157,6 +156,16 @@ function WindowBuffer.new(width, height, clearC, clearFg, clearBg) 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 end @@ -219,12 +228,14 @@ function WindowBuffer.shallowChild(windowBuffer, width, height, offsetX, offsetY function obj.clear() for i=1,height do for j=1,width do - windowBuffer._setPixel(clearC, clearFg, clearBg) + windowBuffer._setPixel(j + offsetX, i + offsetY, clearC, clearFg, clearBg) end end end - obj.flush = windowBuffer.flush() + -- Reconsider implementation? + obj.flush = windowBuffer.flush + obj.flushPartial = windowBuffer.flushPartial return obj end