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#else
21#include <pthread.h>
22#endif
23
24#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
26#endif
27#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLFW
29#endif
30#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
32#endif
33#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
35#endif
37
38#include "GPULogging.h"
39#include <cstring>
40
41#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
43#else
44namespace o2::gpu
45{
47{
48};
49} // namespace o2::gpu
50#endif
51
52using namespace o2::gpu;
53
55
57{
58 GPUDisplayFrontend* me = reinterpret_cast<GPUDisplayFrontend*>(ptr);
59 int32_t retVal = me->FrontendMain();
60 if (retVal == -1) {
61 me->InitDisplay(true);
62 }
63 return ((void*)(size_t)retVal);
64}
65
73
82int32_t GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); }
84{
86 stopGUI();
87 mGUI.reset(nullptr);
88}
89bool GPUDisplayFrontend::EnableSendKey() { return true; }
90
92{
93#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
94 if (mGUI) {
95 mGUI->stop();
96 }
97#endif
98}
99
101{
102 int32_t retVal = 1;
103#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
104 if (!mGUI) {
105 mGUI.reset(new GPUDisplayGUIWrapper);
106 }
107 if (!mGUI->isRunning()) {
108 mGUI->start();
109 } else {
110 mGUI->focus();
111 }
112#endif
113 return retVal;
114}
115
117{
118 bool retVal = false;
119#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
120 retVal = mGUI && mGUI->isRunning();
121#endif
122 return retVal;
123}
124
126{ // clang-format off
127#if !defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
128 if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
129 return new GPUDisplayFrontendGlfw;
130 } else
131#endif
132#ifdef _WIN32
133 if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) {
134 return new GPUDisplayFrontendWindows;
135 } else
136#elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11)
137 if (strcmp(type, "x11") == 0 || strcmp(type, "auto") == 0) {
138 return new GPUDisplayFrontendX11;
139 } else
140#endif
141#if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
142 if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
143 return new GPUDisplayFrontendGlfw;
144 } else
145#endif
146#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
147 if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) {
148 return new GPUDisplayFrontendWayland;
149 } else
150#endif
151#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
152 if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) {
153 return new GPUDisplayFrontendGlut;
154 } else
155#endif
156 if (strcmp(type, "none") == 0) {
157 return new GPUDisplayFrontendNone;
158 } else {
159 GPUError("Requested frontend not available");
160 }
161 return nullptr;
162} // clang-format on
163
168
173
175{
176#ifndef _WIN32
177 static pthread_t hThread;
178 if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) {
179 GPUError("Coult not Create frontend Thread...");
180 return (1);
181 }
182#else
183 HANDLE hThread;
184 if ((hThread = CreateThread(nullptr, nullptr, &OpenGLWrapper, this, nullptr, nullptr)) == nullptr) {
185 GPUError("Coult not Create GL Thread...");
186 return (1);
187 }
188#endif
189 return (0);
190}
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:81
int32_t InitDisplay(bool initFailure=false)
GPUDisplayBackend * backend() const
Definition GPUDisplay.h:69
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