Plasma Engine  2.0
Loading...
Searching...
No Matches
EngineProcessViewContext_linux.h
1
2#include <xcb/xcb.h>
3
4plEditorProcessViewWindow::~plEditorProcessViewWindow()
5{
6 if (m_hWnd.type == plWindowHandle::Type::XCB)
7 {
8 plGALDevice::GetDefaultDevice()->WaitIdle();
9
10 PL_ASSERT_DEV(m_iReferenceCount == 0, "The window is still being referenced, probably by a swapchain. Make sure to destroy all swapchains and call plGALDevice::WaitIdle before destroying a window.");
11 xcb_disconnect(m_hWnd.xcbWindow.m_pConnection);
12 m_hWnd.xcbWindow.m_pConnection = nullptr;
13 m_hWnd.type = plWindowHandle::Type::Invalid;
14 }
15}
16
17plResult plEditorProcessViewWindow::UpdateWindow(plWindowHandle parentWindow, plUInt16 uiWidth, plUInt16 uiHeight)
18{
19 if (m_hWnd.type == plWindowHandle::Type::Invalid)
20 {
21 // xcb_connect always returns a non-NULL pointer to a xcb_connection_t,
22 // even on failure. Callers need to use xcb_connection_has_error() to
23 // check for failure. When finished, use xcb_disconnect() to close the
24 // connection and free the structure.
25 int scr = 0;
26 m_hWnd.type = plWindowHandle::Type::XCB;
27 m_hWnd.xcbWindow.m_pConnection = xcb_connect(NULL, &scr);
28 if (auto err = xcb_connection_has_error(m_hWnd.xcbWindow.m_pConnection); err != 0)
29 {
30 plLog::Error("Could not connect to x11 via xcb. Error-Code '{}'", err);
31 xcb_disconnect(m_hWnd.xcbWindow.m_pConnection);
32 m_hWnd.xcbWindow.m_pConnection = nullptr;
33 m_hWnd.type = plWindowHandle::Type::Invalid;
34 return PL_FAILURE;
35 }
36
37 m_hWnd.xcbWindow.m_Window = parentWindow.xcbWindow.m_Window;
38 }
39
40 m_uiWidth = uiWidth;
41 m_uiHeight = uiHeight;
42 PL_ASSERT_DEV(parentWindow.type == plWindowHandle::Type::XCB && parentWindow.xcbWindow.m_Window != 0, "Invalid handle passed");
43 PL_ASSERT_DEV(m_hWnd.xcbWindow.m_Window == parentWindow.xcbWindow.m_Window, "Remote window handle should never change. Window must be destroyed and recreated.");
44
45 return PL_SUCCESS;
46}
void WaitIdle()
Waits for the GPU to be idle and destroys any pending resources and GPU objects.
Definition Device.cpp:1433
static void Error(plLogInterface *pInterface, const plFormatString &string)
An error that needs to be fixed as soon as possible.
Definition Log.cpp:375
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54