From d7754aee7758fe37327803208e05f9c84231a4d0 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 3 Jun 2019 14:32:59 -0230 Subject: [PATCH] Dialogs drawn outside the underlying basedialog area no longer leave parts around. There is still some work TODO for TIA mode; that is coming next. --- src/common/FrameBufferSDL2.cxx | 20 ++++---------------- src/common/FrameBufferSDL2.hxx | 11 ++--------- src/emucore/FrameBuffer.cxx | 6 ++++-- src/emucore/FrameBuffer.hxx | 10 ++-------- src/gui/DialogContainer.cxx | 2 ++ 5 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index d0b488be1..5b8607df6 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -306,11 +306,7 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode) Logger::log(msg, 0); return false; } - - // Always clear the (double-buffered) renderer surface - SDL_RenderClear(myRenderer); - SDL_RenderPresent(myRenderer); - SDL_RenderClear(myRenderer); + clear(); SDL_RendererInfo renderinfo; if(SDL_GetRendererInfo(myRenderer, &renderinfo) >= 0) @@ -352,15 +348,6 @@ string FrameBufferSDL2::about() const return out.str(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBufferSDL2::invalidate() -{ - ASSERT_MAIN_THREAD; - - - SDL_RenderClear(myRenderer); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSDL2::showCursor(bool show) { @@ -436,6 +423,7 @@ void FrameBufferSDL2::readPixels(uInt8* pixels, uInt32 pitch, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSDL2::clear() { - invalidate(); - renderToScreen(); + ASSERT_MAIN_THREAD; + + SDL_RenderClear(myRenderer); } diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index f1b23d8fa..b3b8da615 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -112,7 +112,7 @@ class FrameBufferSDL2 : public FrameBuffer void updateWindowedPos() override; /** - Clear the frame buffer + Clear the frame buffer. */ void clear() override; @@ -143,13 +143,6 @@ class FrameBufferSDL2 : public FrameBuffer */ bool setVideoMode(const string& title, const VideoMode& mode) override; - /** - This method is called to invalidate the contents of the entire - framebuffer (ie, mark the current content as invalid, and erase it on - the next drawing pass). - */ - void invalidate() override; - /** This method is called to create a surface with the given attributes. @@ -189,7 +182,7 @@ class FrameBufferSDL2 : public FrameBuffer // Used by mapRGB (when palettes are created) SDL_PixelFormat* myPixelFormat; - // center setting of curent window + // Center setting of current window bool myCenter; // last position of windowed window diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 929872bc2..8b9fba6ed 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -944,7 +944,8 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight) { // Windowed and fullscreen mode differ only in screen size myWindowedModeList.add( - VideoMode(baseWidth, baseHeight, baseWidth, baseHeight, VideoMode::Stretch::None) + VideoMode(baseWidth, baseHeight, baseWidth, baseHeight, + VideoMode::Stretch::None) ); for(uInt32 i = 0; i < myFullscreenDisplays.size(); ++i) { @@ -1069,10 +1070,11 @@ FrameBuffer::VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, { case Stretch::Preserve: case Stretch::Fill: - case Stretch::None: screen.w = iw; screen.h = ih; break; + case Stretch::None: + break; // Do not change image or screen rects whatsoever } } diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 8f3104045..563405a1a 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -73,7 +73,8 @@ class FrameBuffer friend ostream& operator<<(ostream& os, const VideoMode& vm) { os << "image=" << vm.image << " screen=" << vm.screen - << " stretch= " << (vm.stretch == Stretch::Preserve ? "preserve" : "fill") + << " stretch=" << (vm.stretch == Stretch::Preserve ? "preserve" : + vm.stretch == Stretch::Fill ? "fill" : "none") << " desc=" << vm.description << " zoom=" << vm.zoom << " fsIndex= " << vm.fsIndex; return os; @@ -391,13 +392,6 @@ class FrameBuffer virtual bool setVideoMode(const string& title, const FrameBuffer::VideoMode& mode) = 0; - /** - This method is called to invalidate the contents of the entire - framebuffer (ie, mark the current content as invalid, and erase it on - the next drawing pass). - */ - virtual void invalidate() = 0; - /** This method is called to create a surface with the given attributes. diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index b256bcf34..6db3afafa 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -94,6 +94,8 @@ bool DialogContainer::draw(bool full) // If the top dialog is dirty, then all below it must be redrawn too bool dirty = needsRedraw(); + if(dirty) + myOSystem.frameBuffer().clear(); myDialogStack.applyAll([&](Dialog*& d){ if(dirty)