23#include <wx/dcclient.h>
72#include <wx/display.h>
84[[maybe_unused]]
static const wxChar
traceDrawPanel[] = wxT(
"KICAD_DRAW_PANEL" );
172 float dpiScale =
static_cast<float>( GetContentScaleFactor() );
181 wxLogTrace(
traceRhi, wxS(
"DrawPanel: deferred PrepareForExternalRendering "
190 static_cast<uint32_t
>( cs.x ),
191 static_cast<uint32_t
>( cs.y ),
203 const wxPoint& aPosition,
const wxSize& aSize,
205 wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ),
229 SetDoubleBuffered(
false );
233 if(
Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
234 ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
236 ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
238 SetLayoutDirection( wxLayout_LeftToRight );
245 wxWindow* ancestor = aParentWindow->GetParent();
248 ancestor = ancestor->GetParent();
267 SetBackgroundStyle( wxBG_STYLE_CUSTOM );
269 EnableScrolling(
false,
false );
277 const wxEventType events[] = {
305 for( wxEventType eventType : events )
319 wxLogTrace(
traceRhi, wxS(
"DrawPanel: destructor windowId=%u backend=%d" ),
344 wxScrolledCanvas::SetFocus();
353 std::optional<wxPaintDC> dc;
378 showMessageLater(
_(
"Could not use Metal, switching to OpenGL" ), aDetail,
false );
380 showMessageLater(
_(
"Could not use Vulkan, falling back to software rendering" ), aDetail,
false );
384 wxLogTrace(
traceRhi, wxS(
"DrawPanel: leaving the RHI canvas for backend %d" ),
static_cast<int>(
GAL_FALLBACK ) );
399 galModern->DestroyBuffers();
474 showMessageLater(
_(
"The graphics driver was reset and OpenGL could not be restored" ),
475 _(
"Restart KiCad to use accelerated graphics again." ),
false );
479 showMessageLater(
_(
"Could not use OpenGL, falling back to software rendering" ),
480 wxString( aError.what() ),
false );
489 catch( std::exception& recoveryErr )
491 showMessageLater(
_(
"Graphics error during recovery" ), wxString( recoveryErr.what() ),
true );
495 showMessageLater(
_(
"Graphics error during recovery" ),
_(
"Unknown exception during backend switch" ),
511 if(
m_gal->IsContextLocked() )
515 if( !IsShownOnScreen() )
519 if( !
m_gal->IsResetSettled() )
525 wxLogTrace(
traceGalContext, wxS(
"Rebuilding canvas %p after GPU reset, repeated %d" ),
this,
528 bool rebuilt =
false;
543 static bool s_notified =
false;
545 wxLogTrace(
traceGalContext, wxS(
"Canvas %p falling back to software rendering" ),
this );
552 showMessageLater(
_(
"The graphics driver keeps resetting, falling back to software rendering" ),
553 wxEmptyString,
false );
567 [parent, aTitle, aDetail, aError]()
584 auto packet = std::make_unique<KIGFX::FRAME_PACKET>();
587 packet->drawDesc.reuseStaticFBO =
true;
590 galModern->PopulateCameraUBOs( packet->drawDesc );
591 galModern->PopulateCursorUBO( packet->drawDesc );
596 packet->staticChanged =
true;
597 packet->dynamicChanged =
true;
601 packet->inputSerial =
s_inputSerial.load( std::memory_order_relaxed );
610 wxLogTrace(
traceRhi, wxS(
"DrawPanel: DoRePaint SKIP (mutex locked)" ) );
614 std::lock_guard<std::mutex> lock(
m_refreshMutex, std::adopt_lock );
622 wxLogTrace(
traceRhi, wxS(
"DrawPanel: DoRePaint SKIP (hidden) windowId=%u" ),
m_windowId );
643 abandonRhiCanvas(
_(
"The graphics device was lost and could not be restored." ) );
648 if( !
m_gal->IsInitialized() || !
m_gal->IsVisible() ||
m_gal->IsContextLocked() )
650 wxLogTrace(
traceRhi, wxS(
"DrawPanel: DoRePaint SKIP (init=%d vis=%d locked=%d)" ),
651 m_gal->IsInitialized(),
m_gal->IsVisible(),
m_gal->IsContextLocked() );
657 wxLogTrace(
traceRhi, wxS(
"DrawPanel: DoRePaint SKIP (already drawing)" ) );
672 if(
Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
675#ifdef KICAD_GAL_PROFILE
676 latencyProbeZoomToRender.Checkpoint(
"do-repaint-start");
681 ( *m_PaintEventCounter )++;
690 PROF_TIMER cntCtx(
"view-context-create",
false);
691 PROF_TIMER cntCtxDestroy(
"view-context-destroy",
false);
692 PROF_TIMER cntRedraw(
"view-redraw-rects",
false);
694 bool isDirty =
false;
709 bool viewDirty =
m_view->IsDirty();
711 bool hasPendingItemUpdates =
m_view->HasPendingItemUpdates();
716 if( aAllowSkip && !viewDirty && !cursorMoved && !hasPendingItemUpdates )
722 if( hasPendingItemUpdates )
730 catch( std::out_of_range& err )
734 wxLogTrace(
traceDrawPanel, wxS(
"Out of Range error: %s" ), err.what() );
736 catch( std::runtime_error& err )
741 wxLogTrace(
traceDrawPanel, wxS(
"Runtime error during UpdateItems: %s" ),
747 viewDirty =
m_view->IsDirty();
752 if( aAllowSkip && !viewDirty && !cursorMoved )
768 m_view->SyncRetainedScene();
774 &&
m_view->IsCameraDirtyOnly()
775 && !
m_gal->HasStaticRebuildPending()
776 &&
m_gal->GetGridSources().empty();
781 m_gal->DrawCursor( cursorPos );
799 m_gal->DrawCursor( cursorPos );
801 if( galModern->SyncScene() )
810 auto packet = std::make_unique<KIGFX::FRAME_PACKET>();
812 packet->drawDesc.reuseStaticFBO =
false;
816 galModern->PopulateCameraUBOs( packet->drawDesc );
817 galModern->PopulateCursorUBO( packet->drawDesc );
824 packet->staticDrawDesc.reuseStaticFBO =
false;
825 packet->dynamicDrawDesc.reuseDynamicFBO =
false;
826 galModern->PopulateCameraUBOs( packet->staticDrawDesc );
827 galModern->PopulateCameraUBOs( packet->dynamicDrawDesc );
829 packet->staticChanged =
true;
830 packet->dynamicChanged =
true;
844 packet->inputSerial =
s_inputSerial.load( std::memory_order_relaxed );
867 throw std::runtime_error(
"Could not make the OpenGL context current" );
885 m_gal->ClearScreen();
892 m_gal->ClearScreen();
896 if(
m_gal->HasStaticRebuildPending() )
909 ||
m_gal->RefillsNonCachedTargets() )
921 m_gal->DrawCursor( cursorPos );
923 #ifdef KICAD_GAL_PROFILE
924 latencyProbeZoomToRender.Checkpoint(
"do-repaint-pre-ctx-destroy");
928 cntCtxDestroy.
Start();
932 cntCtxDestroy.
Stop();
934#ifdef KICAD_GAL_PROFILE
935 latencyProbeZoomToRender.Checkpoint(
"do-repaint-ctx-done");
949 auto packet = std::make_unique<KIGFX::FRAME_PACKET>();
951 packet->drawDesc = galModern->GetDrawDesc();
956 galModern->PopulateCursorUBO( packet->drawDesc );
958 packet->staticDrawDesc = galModern->GetStaticDrawDesc();
959 packet->dynamicDrawDesc = galModern->GetDynamicDrawDesc();
962 packet->staticDrawDesc.supersampleFactor = packet->drawDesc.supersampleFactor;
963 packet->dynamicDrawDesc.supersampleFactor = packet->drawDesc.supersampleFactor;
965 packet->staticChanged = galModern->TakeStaticChanged();
966 packet->dynamicChanged =
true;
968 if( packet->staticChanged )
979 packet->inputSerial =
s_inputSerial.load( std::memory_order_relaxed );
990 catch( std::exception& err )
992 wxLogTrace(
traceDrawPanel, wxS(
"DoRePaint exception: %s" ), err.what() );
1007#ifdef KICAD_GAL_PROFILE
1020#ifdef KICAD_GAL_PROFILE
1021 wxLogTrace(
traceGalProfile,
"%s", latencyProbeZoomToRender.to_string() );
1022 latencyProbeRepaintToMotion.Reset();
1023 latencyProbeRepaintToMotion.Checkpoint(
"repaint-done");
1036 wxSize clientSize = GetClientSize();
1038 if( clientSize.x > 0 && clientSize.y > 0 &&
m_view
1052 m_gal->ComputeWorldScreenMatrix();
1062 double scale = 1.0 / std::max( fabs( vsize.
x / screenSize.
x ),
1063 fabs( vsize.
y / screenSize.
y ) );
1067 if( !std::isfinite(
scale ) )
1077 double margin_scale_factor = aMarginScale.value_or( GetClientSize().y < 768 ? 1.10 : 1.04 );
1106 wxSize size = GetClientSize();
1111 return wxSize( std::max( 10, size.x +
pad ), std::max( 10, size.y +
pad ) );
1118 if(
m_gal->IsContextLocked() )
1124 if( !
m_gal->IsContextValid() )
1138 if( !aForce &&
ToVECTOR2I( clientSize ) ==
m_gal->GetScreenPixelSize() )
1141 m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
1143 wxWindow* backendWindow =
dynamic_cast<wxWindow*
>(
m_gal );
1151 static_cast<float>( GetContentScaleFactor() ) );
1156 float dpiScale =
static_cast<float>( GetContentScaleFactor() );
1158 static_cast<uint32_t
>( clientSize.y ),
1168 m_view->MarkGeometryDirty();
1178 std::vector<wxRect> rects;
1179 int infobarsBottom = 0;
1181 for( wxWindow* child : GetChildren() )
1183 if(
dynamic_cast<WX_INFOBAR*
>( child ) && child->IsShown() )
1185 rects.push_back( child->GetRect() );
1186 infobarsBottom = std::max( infobarsBottom, child->GetRect().GetBottom() + 1 );
1196 inset = infobarsBottom;
1208 cairoGal->SetOverlayExclusions( rects );
1220 const auto now = std::chrono::steady_clock::now();
1228 m_refreshRate = reported >= 24.0 && reported <= 1000.0 ?
static_cast<float>( reported ) : 0.0f;
1238 auto now = std::chrono::steady_clock::now();
1240 bool galInitialized =
m_gal &&
m_gal->IsInitialized();
1246 int minPeriodMs = 3;
1248 if( galInitialized &&
m_gal->GetSwapInterval() == 0 )
1251 int refreshHz = displayHz > 0.0f ?
KiROUND( displayHz ) : 60;
1255 minPeriodMs = 1000 / refreshHz;
1258 if(
delta >= minPeriodMs )
1273 wxLogTrace(
traceRhi, wxS(
"DrawPanel: ForceRefresh windowId=%u drawEnabled=%d "
1274 "IsShown=%d IsShownOnScreen=%d galInit=%d" ),
1366 m_view->UpdateAllLayersColor();
1372 m_view->ClearTopLayers();
1373 m_view->SetTopLayer( aLayer );
1374 m_view->UpdateAllLayersOrder();
1381 return static_cast<GAL_TYPE>( aStoredCanvasType );
1397 bool grid_visibility =
m_gal ?
m_gal->GetGridVisibility() :
true;
1398 double worldUnitLength =
m_gal ?
m_gal->GetWorldUnitLength() : 0.0;
1417 if( errormsg.empty() )
1426 showMessageLater(
_(
"Could not use OpenGL, falling back to software rendering" ), errormsg,
1459 wxLogTrace(
traceRhi, wxS(
"DrawPanel: render thread acquired" ) );
1480 galModern->SetPersistentTargets(
true );
1490 wxLogTrace(
traceRhi, wxS(
"DrawPanel: windowId=%u swapchainCtrl created" ),
m_windowId );
1518 catch( std::runtime_error& err )
1537 showMessageLater(
_(
"Could not use OpenGL, falling back to software rendering" ),
1538 wxString( err.what() ),
false );
1540 catch( std::runtime_error& )
1551 showMessageLater(
_(
"Error switching GAL backend" ), wxString( err.what() ),
true );
1572 if( worldUnitLength > 0.0 )
1573 m_gal->SetWorldUnitLength( worldUnitLength );
1579 galModern->
SetDpiScale(
static_cast<float>( GetContentScaleFactor() ) );
1584 wxSize clientSize = GetClientSize();
1587 clientSize.x = std::max( 10, clientSize.x +
pad );
1588 clientSize.y = std::max( 10, clientSize.y +
pad );
1589 m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
1592 m_gal->SetGridOrigin( grid_origin );
1594 if( grid_size.
x > 0 && grid_size.
y > 0 )
1595 m_gal->SetGridSize( grid_size );
1597 m_gal->SetGridVisibility( grid_visibility );
1618 for( wxWindow* child : GetChildren() )
1620 if( child !=
dynamic_cast<wxWindow*
>(
m_gal ) )
1630 wxLogTrace(
traceRhi, wxS(
"DrawPanel: backend %d view centre (%.17g, %.17g) scale %.17g screen %dx%d" ),
1632 m_gal->GetScreenPixelSize().x,
m_gal->GetScreenPixelSize().y );
1648 :
dynamic_cast<wxWindow*
>(
m_gal );
1674 catch(
const std::runtime_error& e )
1706 if( shouldSetFocus )
1726 if( shouldSetFocus )
1753 wxLogTrace(
traceRhi, wxS(
"DrawPanel: onIdle refresh windowId=%u IsShown=%d "
1754 "IsShownOnScreen=%d" ),
1786 wxLogTrace(
traceRhi, wxS(
"DrawPanel: onShowEvent windowId=%u show=%d IsShown=%d "
1787 "IsShownOnScreen=%d galInit=%d" ),
1788 m_windowId, aEvent.IsShown(), IsShown(), IsShownOnScreen(),
1815 m_gal->SetNativeCursorStyle( aCursor, hidpi );
1818#if wxCHECK_VERSION( 3, 3, 0 )
BASE_SCREEN class implementation.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
VECTOR2D m_ScrollCenter
Current scroll center point in logical units.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
static const WX_CURSOR_TYPE GetCursor(KICURSOR aCursorType, bool aHiDPI=false)
Get a cursor bundle (wx 3.3+) or appropriate cursor (older versions)
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
double GetContentScaleFactor() const override
Get the content scale factor, which may be different from the scale factor on some platforms.
FRAME_T GetFrameType() const
The base class for create windows for drawing purpose.
static bool CanvasFailed(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas)
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
static void SetCanvasFailed(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas)
Keep every frame off a canvas for this session without changing the saved preference.
std::unique_ptr< PROF_COUNTER > m_PaintEventCounter
EDA_DRAW_FRAME * m_edaFrame
Parent EDA_DRAW_FRAME (if available)
static GAL_TYPE CanvasAfterFailure(GAL_TYPE aFailedCanvasType)
Return the canvas that takes over from one that could not be used.
virtual void OnShow()
Called when the window is shown for the first time.
void onLostFocus(wxFocusEvent &aEvent)
static constexpr GAL_TYPE GAL_FALLBACK
std::unique_ptr< KIGFX::PAINTER > m_painter
Contains information about how to draw items using GAL.
RHI_NATIVE_WINDOW_HANDLE m_cachedNativeHandle
Fetching the handle forces a display-server flush, so it is cached between realizations and fetched a...
bool m_rebuiltAfterReset
The GAL was rebuilt after a GPU reset and has not completed a frame yet.
void onSize(wxSizeEvent &aEvent)
bool m_pendingResize
Set when a size change could not be applied because the GL context was unavailable.
bool m_needIdleRefresh
True when canvas needs to be refreshed from idle handler.
bool IsDialogPreview() const
std::unique_ptr< KIGFX::SWAPCHAIN_CONTROLLER > m_swapchainCtrl
bool abandonRhiCanvas(const wxString &aDetail)
Leave the RHI canvas for GAL_FALLBACK after its device could not be created or restored.
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
int m_overlayInsetTop
Rows at the top of the panel left to the infobars where the backend window would hide them.
bool m_stealsFocus
Flag to indicate whether the panel should take focus at certain times (when moused over,...
virtual BOX2I GetDefaultViewBBox() const
Return the bounding box of the view that should be used if model is not valid.
KIGFX::GAL_DISPLAY_OPTIONS & m_options
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
KIGFX::RHI_LINE_PIPELINE_KIND m_linePipelineKind
Fixed in the constructor from the parent frame's editor.
static KIGFX::VC_SETTINGS GetVcSettings()
Gets a populated View Controls settings object dervived from our program settings.
static void NoteInput()
Count an input so the frame that answers it is never held back by the display-rate limit.
std::unique_ptr< KIGFX::FRAME_MAILBOX > m_frameMailbox
Delivers frame packets to the render thread.
virtual void SetTopLayer(int aLayer)
Move the selected layer to the top, so it is displayed above all others.
KIGFX::FRAME_DRAW_DESC m_lastFullStaticDesc
Draw descriptors of the last full redraw, reused by frames that need no new geometry.
void presentFrame()
Present the most recently submitted frame packet.
void ClearDebugOverlay()
Clear the contents of the debug overlay and removes it from the VIEW.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the KIGFX::VIEW instance used in the panel.
static int ScreenSizePad(GAL_TYPE aBackend)
Return how many pixels larger than the client area a backend's GAL is made.
void ForceRefresh()
Force a redraw.
bool recoverFromGalError(const std::exception &aErr)
void ResizeGal(bool aForce=false)
Resize the GAL to the current client size of this panel.
bool m_drawing
True if GAL is currently redrawing the view.
KIGFX::GAL * m_gal
Interface for drawing objects on a 2D-surface.
EDA_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_OPENGL)
Create a drawing panel that is contained inside aParentWindow.
std::chrono::steady_clock::time_point m_lastRepaintStart
Timestamp of the last repaint start.
void onRefreshTimer(wxTimerEvent &aEvent)
float displayRefreshRate()
Refresh rate in Hz of the display showing the canvas, or 0 when unknown.
void releaseCachedNativeWindowHandle()
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
virtual void onPaint(wxPaintEvent &WXUNUSED(aEvent))
bool m_lostFocus
Flag to indicate that focus should be regained on the next mouse event.
std::unique_ptr< KIGFX::RHI_DEVICE_PROXY > m_deviceProxy
The UI thread's access to the device.
static bool IsAccelerated(GAL_TYPE aCanvasType)
True for a canvas drawn on the GPU, which keeps cached layers between frames.
wxSize backendScreenSize() const
The padded size of the backend window, which sits below the top overlay inset.
std::chrono::steady_clock::time_point m_lastRepaintEnd
Timestamp of the last repaint end.
std::shared_ptr< KIGFX::VIEW_OVERLAY > m_debugOverlay
Optional overlay for drawing transient debug objects.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
bool m_needsExternalRenderingSetup
True until the first paint completes the deferred GTK drawing suppression.
wxTimer m_refreshTimer
Timer to prevent too-frequent refreshing.
TOOL_DISPATCHER * m_eventDispatcher
Processes and forwards events to tools.
wxWindow * m_parent
Pointer to the parent window.
@ GAL_TYPE_OPENGL
OpenGL implementation.
@ GAL_TYPE_MODERN
RHI implementation, Vulkan or Metal on macOS.
@ GAL_TYPE_CAIRO
Cairo implementation.
@ GAL_TYPE_NONE
GAL not used (the legacy wxDC engine is used)
virtual void beforeRedraw()
Hook for subclasses to update view items whose inputs nothing else tracks.
KIGFX::FRAME_DRAW_DESC m_lastFullDynamicDesc
void teardownModernRenderInfra()
Stop the RHI render thread and release its swapchain, mailbox and buffers.
virtual void prepareGridSources()
Hook for subclasses to push per-frame grid sources onto the GAL.
KIGFX::VIEW * m_view
Stores view settings (scale, center, etc.) and items to be drawn.
bool m_MouseCapturedLost
used on wxMSW: true after a wxEVT_MOUSE_CAPTURE_LOST was received false after the mouse is recaptured...
KIGFX::WX_VIEW_CONTROLS * m_viewControls
Control for VIEW (moving, zooming, etc.)
const RHI_NATIVE_WINDOW_HANDLE & getCachedNativeWindowHandle()
Return the native window handle for RHI surface creation, or an invalid handle until the window is re...
void onIdle(wxIdleEvent &aEvent)
void UpdateTouchpadGestureHandler()
Apply the current native touchpad gesture preference to the active backend window.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void UpdateOverlayExclusions()
Tell the backend which areas of this panel are covered by an overlaid infobar.
float m_refreshRate
What displayRefreshRate() last asked the window system.
void onEnter(wxMouseEvent &aEvent)
void submitCachedScene()
Submit the last full scene again with the current camera and cursor, keeping all targets.
uint32_t m_windowId
Routes this window's work on the render thread.
void showMessageLater(const wxString &aTitle, const wxString &aDetail, bool aError)
Show a recovery message once the current event finishes.
std::unique_ptr< KIPLATFORM::UI::TOUCHPAD_GESTURE_HANDLER > m_touchpadGestureHandler
uint64_t m_staticEpoch
Content generations of the static and dynamic pools last submitted, see FRAME_PACKET.
void RequestRefresh()
Make sure a refresh gets done on the next idle event if it hasn't already.
int m_contextBindFailures
Consecutive frames dropped because the GL context could not be made current.
std::shared_ptr< KIGFX::RENDER_THREAD > m_renderThread
The render thread that owns the RHI device, shared by every canvas, see GAL_MODERN::AcquireRenderThre...
std::mutex m_refreshMutex
Blocks multiple calls to the draw.
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
void StartDrawing()
Begin drawing if it was stopped previously.
static GAL_TYPE ResolveStoredCanvasType(int aStoredCanvasType)
Convert a stored canvas type setting into a backend that can actually be used.
bool DoRePaint(bool aAllowSkip=true)
Repaint the canvas, and fix scrollbar cursors.
void OnEvent(wxEvent &aEvent)
Used to forward events to the canvas from popups, etc.
bool m_recoveryAttempted
Set after a GPU recovery attempt to prevent infinite retry loops.
bool m_drawingEnabled
Flag that determines if VIEW may use GAL for redrawing the screen.
std::shared_ptr< KIGFX::VIEW_OVERLAY > DebugOverlay()
Create an overlay for rendering debug graphics.
KIGFX::AUTOMATIC_FIT m_automaticFit
What the last ZoomToFit() left, refitted on a resize until the view is zoomed or panned.
void onShowEvent(wxShowEvent &aEvent)
bool handleContextLoss()
Replace a GAL whose context was destroyed by a GPU reset.
static constexpr bool GAL_FALLBACK_AVAILABLE
GAL_TYPE m_backend
Currently used GAL.
std::chrono::steady_clock::time_point m_refreshRateAsked
void ZoomToFit(const BOX2I &aBox, std::optional< double > aMarginScale=std::nullopt)
Scale and centre the view on aBox, and fit it again whenever the canvas changes size until something ...
VECTOR2D m_lastCursorPosition
Last cursor position sent to GAL for drawing.
bool m_hasLastFullDrawDesc
bool GetScreenshot(wxImage &aDstImage)
Capture the current canvas contents into aDstImage.
EDA_DRAW_FRAME * GetParentEDAFrame() const
Returns parent EDA_DRAW_FRAME, if available or NULL otherwise.
bool m_refreshDeferred
The refresh timer was armed by Refresh() for a repaint it postponed.
GAL that turns drawing commands into instanced primitives for the RHI device.
void SetCentringPad(int aPad)
The other canvases lay the view out this many pixels larger than the client area.
void SetRenderThread(RENDER_THREAD *aThread)
Render thread used for fence-based synchronization.
static uint32_t AllocateWindowId()
static std::shared_ptr< RENDER_THREAD > AcquireRenderThread(bool aEnableValidation)
Return the render thread every RHI canvas in the process shares, starting it on first use and replaci...
void SetDpiScale(float aScale)
Backing-store scale factor, 2.0 on Retina.
Abstract interface for drawing on a 2D-surface.
Raised when a GPU buffer allocation is predicted to exceed the available video memory.
OpenGL implementation of the Graphics Abstraction Layer.
static wxString CheckFeatures(GAL_DISPLAY_OPTIONS &aOptions)
Check OpenGL features.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void ClearHighContrastLayers()
Clear the list of active layers.
virtual const COLOR4D & GetGridColor()=0
Return current grid color settings.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
void SetLayerIsHighContrast(int aLayerId, bool aEnabled=true)
Set the specified layer as high-contrast.
virtual const COLOR4D & GetCursorColor()=0
Return current cursor color settings.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
static const wxEventType EVT_REFRESH_MOUSE
Event that forces mouse move event in the dispatcher (eg.
virtual COMMON_SETTINGS * GetCommonSettings() const
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
void Start()
Start or restart the counter.
RAII class that sets an value at construction and resets it to the original value at destruction.
A modified version of the wxInfoBar class that allows us to:
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static RHI_NATIVE_WINDOW_HANDLE GetNativeWindowHandle(wxWindow *aWindow)
static constexpr int MAX_CONTEXT_BIND_RETRIES
Frames to drop before giving up on the GL context and letting the backend recover.
static void ApplyAntialiasingMode(KIGFX::FRAME_DRAW_DESC &aDesc, KIGFX::GAL_ANTIALIASING_MODE aMode)
static std::atomic< uint64_t > s_inputSerial
static KIGFX::RHI_LINE_PIPELINE_KIND DetermineLinePipelineKind(const EDA_DRAW_FRAME *aFrame)
@ FRAME_SCH_SYMBOL_EDITOR
const wxChar *const traceGalContext
Flag to enable debug output of GAL context binding.
const wxChar *const traceRhi
Flag to enable debug output of the RHI rendering backend.
static const wxChar traceDrawPanel[]
Flag to enable drawing panel debugging output.
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
GAL_CONTEXT_LOSS
State of a canvas' rendering context after a GPU reset.
@ REPEATED
Contexts keep being lost; stop using this backend.
@ RECOVERABLE
Context was lost; rebuild the canvas.
@ ALL
All except INITIAL_ADD.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
KICOMMON_API bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
KICOMMON_API bool IsModalDialogFocused()
PGM_BASE & Pgm()
The global program "get" accessor.
RHI_DISPLAY_TYPE
Matches KIPLATFORM::UI::NATIVE_DISPLAY_TYPE as reported by GetNativeWindowHandles().
int canvas_type
EDA_DRAW_PANEL_GAL::GAL_TYPE_* value, see gal_options_panel.cpp.
GPU geometry of one frame, built by GAL_MODERN after EndDrawing() and passed through the FRAME_MAILBO...
RHI_LINE_PIPELINE_KIND linePipelineKind
uint32_t supersampleFactor
Layer FBO scale that the present blit downsamples.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
MOUSE_DRAG_ACTION m_dragLeft
bool m_horizontalPan
Enable horizontal panning with the horizontal scroll/trackpad input.
bool m_scrollReversePanH
Whether to invert the scroll wheel movement for horizontal pan.
bool m_autoPanSettingEnabled
Flag for turning on autopanning.
bool m_focusFollowSchPcb
Flag for automatic focus switching between Schematic and PCB editors.
float m_autoPanAcceleration
How fast does panning accelerate when approaching the window boundary.
MOUSE_DRAG_ACTION m_dragMiddle
int m_zoomSpeed
Zoom speed for the non-accelerating zoom controller.
int m_scrollModifierZoom
What modifier key to enable zoom with the (vertical) scroll wheel.
int m_scrollModifierPanH
What modifier key to enable horizontal pan with the (vertical) scroll wheel.
bool m_warpCursor
If the cursor is allowed to be warped.
MOUSE_DRAG_ACTION m_dragRight
bool m_scrollReverseZoom
Whether to invert the scroll wheel movement for zoom.
int m_motionPanModifier
What modifier key pans the view when the mouse moves with it held.
bool m_zoomAcceleration
Enable the accelerating zoom controller.
bool m_zoomSpeedAuto
When true, ignore zoom_speed and pick a platform-specific default.
int m_scrollModifierPanV
What modifier key to enable vertical with the (vertical) scroll wheel.
Platform-agnostic wrapper for a native window handle.
RHI_DISPLAY_TYPE displayType
bool IsValid() const
A handle is usable only once the window is realized.
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
VECTOR2< double > VECTOR2D
VECTOR2I ToVECTOR2I(const wxSize &aSize)
WX_VIEW_CONTROLS class definition.