From e135c5e8b2994edf1d8ef0eb81e09516022706c3 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 11:10:11 +0000 Subject: [PATCH] refresh emulation: only update areas that are refreshed when refresh emulation is enabled, only the parts of the screen are actually updated that are being refreshed. This allows to debug refresh regions with the emulator. Reminder: activate refresh emulation by setting the environment variable EMULATE_READER_FLASH to the number of milliseconds that you want the inverse flash to endure. Suggested are now about 100 (msecs). --- ffi/framebuffer_SDL1_2.lua | 23 ++++++++++++++++++----- ffi/framebuffer_SDL2_0.lua | 22 ++++++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ffi/framebuffer_SDL1_2.lua b/ffi/framebuffer_SDL1_2.lua index b8fa82e19..d9f27da41 100644 --- a/ffi/framebuffer_SDL1_2.lua +++ b/ffi/framebuffer_SDL1_2.lua @@ -3,14 +3,25 @@ local SDL = require("ffi/SDL1_2") local BB = require("ffi/blitbuffer") local util = require("ffi/util") -local framebuffer = {} +local framebuffer = { + -- this blitbuffer will be used when we use refresh emulation + sdl_bb = nil, +} function framebuffer:init() if not self.dummy then SDL.open() - -- we present this buffer to the outside - self.bb = BB.new(SDL.screen.w, SDL.screen.h, BB.TYPE_BBRGB32, + local bb = BB.new(SDL.screen.w, SDL.screen.h, BB.TYPE_BBRGB32, SDL.screen.pixels, SDL.screen.pitch) + local flash = os.getenv("EMULATE_READER_FLASH") + if flash then + -- in refresh emulation mode, we use a shadow blitbuffer + -- and blit refresh areas from it. + self.sdl_bb = bb + self.bb = BB.new(SDL.screen.w, SDL.screen.h, BB.TYPE_BBRGB32) + else + self.bb = bb + end else self.bb = BB.new(600, 800) end @@ -46,10 +57,12 @@ function framebuffer:refreshFullImp(x, y, w, h) local flash = os.getenv("EMULATE_READER_FLASH") if flash then - bb:invertRect(x, y, w, h) + self.sdl_bb:invertRect(x, y, w, h) flip() util.usleep(tonumber(flash)*1000) - bb:invertRect(x, y, w, h) + self.sdl_bb:setRotation(bb:getRotation()) + self.sdl_bb:setInverse(bb:getInverse()) + self.sdl_bb:blitFrom(bb, x, y, x, y, w, h) end flip() diff --git a/ffi/framebuffer_SDL2_0.lua b/ffi/framebuffer_SDL2_0.lua index 95f7b0c37..9c40bedef 100644 --- a/ffi/framebuffer_SDL2_0.lua +++ b/ffi/framebuffer_SDL2_0.lua @@ -3,13 +3,25 @@ local SDL = require("ffi/SDL2_0") local BB = require("ffi/blitbuffer") local util = require("ffi/util") -local framebuffer = {} +local framebuffer = { + -- this blitbuffer will be used when we use refresh emulation + sdl_bb = nil, +} function framebuffer:init() if not self.dummy then SDL.open() -- we present this buffer to the outside - self.bb = BB.new(SDL.w, SDL.h, BB.TYPE_BBRGB32) + local bb = BB.new(SDL.w, SDL.h, BB.TYPE_BBRGB32) + local flash = os.getenv("EMULATE_READER_FLASH") + if flash then + -- in refresh emulation mode, we use a shadow blitbuffer + -- and blit refresh areas from it. + self.sdl_bb = bb + self.bb = BB.new(SDL.w, SDL.h, BB.TYPE_BBRGB32) + else + self.bb = bb + end else self.bb = BB.new(600, 800) end @@ -43,10 +55,12 @@ function framebuffer:refreshFullImp() local flash = os.getenv("EMULATE_READER_FLASH") if flash then - bb:invertRect(x, y, w, h) + self.sdl_bb:invertRect(x, y, w, h) render(bb) util.usleep(tonumber(flash)*1000) - bb:invertRect(x, y, w, h) + self.sdl_bb:setRotation(bb:getRotation()) + self.sdl_bb:setInverse(bb:getInverse()) + self.sdl_bb:blitFrom(bb, x, y, x, y, w, h) end render(bb) end