Project
Loading...
Searching...
No Matches
GPUDisplayFrontend.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "GPUDisplayFrontend.h"
16#include "GPUDisplay.h"
17
18#ifdef _WIN32
20#elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11)
22#endif
23#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLFW
25#endif
26#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
28#endif
29#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
31#endif
32
33#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
35#else
36namespace o2::gpu
37{
39{
40};
41} // namespace o2::gpu
42#endif
43
44using namespace o2::gpu;
45
47
49{
50 GPUDisplayFrontend* me = reinterpret_cast<GPUDisplayFrontend*>(ptr);
51 int32_t retVal = me->FrontendMain();
52 if (retVal == -1) {
53 me->InitDisplay(true);
54 }
55 return ((void*)(size_t)retVal);
56}
57
65
74int32_t GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); }
76{
78 stopGUI();
79 mGUI.reset(nullptr);
80}
81bool GPUDisplayFrontend::EnableSendKey() { return true; }
82
84{
85#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
86 if (mGUI) {
87 mGUI->stop();
88 }
89#endif
90}
91
93{
94 int32_t retVal = 1;
95#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
96 if (!mGUI) {
97 mGUI.reset(new GPUDisplayGUIWrapper);
98 }
99 if (!mGUI->isRunning()) {
100 mGUI->start();
101 } else {
102 mGUI->focus();
103 }
104#endif
105 return retVal;
106}
107
109{
110 bool retVal = false;
111#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
112 retVal = mGUI && mGUI->isRunning();
113#endif
114 return retVal;
115}
116
118{
119#if !defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
120 if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
121 return new GPUDisplayFrontendGlfw;
122 } else
123#endif
124#ifdef _WIN32
125 if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) {
126 return new GPUDisplayFrontendWindows;
127 } else
128#elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11)
129 if (strcmp(type, "x11") == 0 || strcmp(type, "auto") == 0) {
130 return new GPUDisplayFrontendX11;
131 } else
132#endif
133#if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
134 if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
135 return new GPUDisplayFrontendGlfw;
136 } else
137#endif
138#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
139 if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) {
140 return new GPUDisplayFrontendWayland;
141 } else
142#endif
143#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
144 if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) {
145 return new GPUDisplayFrontendGlut;
146 } else
147#endif
148 {
149 GPUError("Requested frontend not available");
150 }
151 return nullptr;
152}
153
158
int32_t retVal
TBranch * ptr
StringRef key
std::unique_ptr< GPUDisplayGUIWrapper > mGUI
static void * FrontendThreadWrapper(void *)
static GPUDisplayFrontend * getFrontend(const char *type)
void ResizeScene(int32_t width, int32_t height)
int32_t InitDisplay(bool initFailure=false)
void HandleKey(uint8_t key)
void HandleSendKey(int32_t key)
int32_t & drawTextFontSize()
Definition GPUDisplay.h:77
int32_t InitDisplay(bool initFailure=false)
GPUDisplayBackend * backend() const
Definition GPUDisplay.h:66
void ResizeScene(int32_t width, int32_t height, bool init=false)
GLint GLsizei GLsizei height
Definition glcorearb.h:270
GLint GLsizei width
Definition glcorearb.h:270
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275