From 3ca7026aa0e9ec0e8896e0890081551f72777f1e Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 20 May 2016 12:06:08 +0200 Subject: [PATCH] More robust checks for OpenGL canvas visibility. --- common/draw_panel_gal.cpp | 2 +- include/gal/cairo/cairo_gal.h | 5 +++++ include/gal/graphics_abstraction_layer.h | 5 ++++- include/gal/opengl/opengl_gal.h | 7 ++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index aa72e8ea6b..94654e5684 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -479,7 +479,7 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent ) void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent ) { - if( IsShownOnScreen() ) + if( m_gal && m_gal->IsVisible() ) { m_onShowTimer.Stop(); OnShow(); diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index 1f395f7201..bc378d4b3d 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -85,6 +85,11 @@ public: virtual ~CAIRO_GAL(); + ///> @copydoc GAL::IsVisible() + bool IsVisible() const override { + return IsShownOnScreen(); + } + // --------------- // Drawing methods // --------------- diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 8a2ecaa119..20f8130ba6 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -66,9 +66,12 @@ public: GAL(); virtual ~GAL(); - /// @brief Returns the initalization status for the canvas. + /// @brief Returns the initalization status for the canvas. virtual bool IsInitialized() const { return true; } + /// @brief Returns true if the GAL canvas is visible on the screen. + virtual bool IsVisible() const { return true; } + // --------------- // Drawing methods // --------------- diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index 7fd63c43be..71619a914e 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -83,9 +83,14 @@ public: virtual ~OPENGL_GAL(); - /// @copydoc GAL::IsInitialized() + /// @copydoc GAL::IsInitialized() virtual bool IsInitialized() const { return IsShownOnScreen(); } + ///> @copydoc GAL::IsVisible() + bool IsVisible() const override { + return IsShownOnScreen(); + } + // --------------- // Drawing methods // ---------------