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#include "GPULogging.h"
34#include <cstring>
35
36#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
38#else
39namespace o2::gpu
40{
42{
43};
44} // namespace o2::gpu
45#endif
46
47using namespace o2::gpu;
48
50
52{
53 GPUDisplayFrontend* me = reinterpret_cast<GPUDisplayFrontend*>(ptr);
54 int32_t retVal = me->FrontendMain();
55 if (retVal == -1) {
56 me->InitDisplay(true);
57 }
58 return ((void*)(size_t)retVal);
59}
60
68
77int32_t GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); }
79{
81 stopGUI();
82 mGUI.reset(nullptr);
83}
84bool GPUDisplayFrontend::EnableSendKey() { return true; }
85
87{
88#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
89 if (mGUI) {
90 mGUI->stop();
91 }
92#endif
93}
94
96{
97 int32_t retVal = 1;
98#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
99 if (!mGUI) {
100 mGUI.reset(new GPUDisplayGUIWrapper);
101 }
102 if (!mGUI->isRunning()) {
103 mGUI->start();
104 } else {
105 mGUI->focus();
106 }
107#endif
108 return retVal;
109}
110
112{
113 bool retVal = false;
114#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
115 retVal = mGUI && mGUI->isRunning();
116#endif
117 return retVal;
118}
119
121{
122#if !defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
123 if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
124 return new GPUDisplayFrontendGlfw;
125 } else
126#endif
127#ifdef _WIN32
128 if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) {
129 return new GPUDisplayFrontendWindows;
130 } else
131#elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11)
132 if (strcmp(type, "x11") == 0 || strcmp(type, "auto") == 0) {
133 return new GPUDisplayFrontendX11;
134 } else
135#endif
136#if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
137 if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) {
138 return new GPUDisplayFrontendGlfw;
139 } else
140#endif
141#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
142 if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) {
143 return new GPUDisplayFrontendWayland;
144 } else
145#endif
146#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
147 if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) {
148 return new GPUDisplayFrontendGlut;
149 } else
150#endif
151 {
152 GPUError("Requested frontend not available");
153 }
154 return nullptr;
155}
156
161
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:76
int32_t InitDisplay(bool initFailure=false)
GPUDisplayBackend * backend() const
Definition GPUDisplay.h:65
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