MCPcopy Create free account
hub / github.com/ddnet/ddnet / GotResized

Method GotResized

src/engine/client/graphics_threaded.cpp:2640–2686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2638}
2639
2640void CGraphics_Threaded::GotResized(int w, int h, int RefreshRate)
2641{
2642#if defined(CONF_VIDEORECORDER)
2643 if(IVideo::Current() && IVideo::Current()->IsRecording())
2644 return;
2645#endif
2646
2647 // if RefreshRate is -1 use the current config refresh rate
2648 if(RefreshRate == -1)
2649 RefreshRate = g_Config.m_GfxScreenRefreshRate;
2650
2651 // if the size change event is triggered, set all parameters and change the viewport
2652 auto PrevCanvasWidth = m_ScreenWidth;
2653 auto PrevCanvasHeight = m_ScreenHeight;
2654 m_pBackend->GetViewportSize(m_ScreenWidth, m_ScreenHeight);
2655
2656 AdjustViewport(false);
2657
2658 m_ScreenRefreshRate = RefreshRate;
2659
2660 g_Config.m_GfxScreenWidth = w;
2661 g_Config.m_GfxScreenHeight = h;
2662 g_Config.m_GfxScreenRefreshRate = m_ScreenRefreshRate;
2663
2664 auto OldDpi = m_ScreenHiDPIScale;
2665 m_ScreenHiDPIScale = m_ScreenWidth / (float)g_Config.m_GfxScreenWidth;
2666
2667 // A DPI change must notify the listeners, since e.g. video modes
2668 // currently depend on it.
2669 if(OldDpi != m_ScreenHiDPIScale)
2670 {
2671 for(auto &PropChangedListener : m_vPropChangeListeners)
2672 PropChangedListener();
2673 }
2674
2675 UpdateViewport(0, 0, m_ScreenWidth, m_ScreenHeight, true);
2676
2677 // kick the command buffer and wait
2678 KickCommandBuffer();
2679 WaitForIdle();
2680
2681 if(PrevCanvasWidth != m_ScreenWidth || PrevCanvasHeight != m_ScreenHeight)
2682 {
2683 for(auto &ResizeListener : m_vResizeListeners)
2684 ResizeListener();
2685 }
2686}
2687
2688bool CGraphics_Threaded::IsScreenKeyboardShown()
2689{

Callers 1

UpdateMethod · 0.80

Calls 2

GetViewportSizeMethod · 0.80
IsRecordingMethod · 0.45

Tested by

no test coverage detected