anbox-platform-sdk 1.28.0
Anbox Platform SDK API documentation
graphics_processor.h
Go to the documentation of this file.
1/*
2 * This file is part of Anbox Platform SDK
3 *
4 * Copyright 2021 Canonical Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef ANBOX_SDK_GRAPHICS_PROCESSOR_H_
20#define ANBOX_SDK_GRAPHICS_PROCESSOR_H_
21
23
30typedef void (*AnboxVsyncCallback)(uint64_t time_ns, void* user_data);
31
32namespace anbox {
37 public:
38 GraphicsProcessor() = default;
39 virtual ~GraphicsProcessor() = default;
42
53 virtual EGLDisplay create_display() { return EGL_NO_DISPLAY; }
54
65 virtual int initialize(AnboxGraphicsConfiguration* configuration) {
66 (void) configuration;
67 return 0;
68 };
69
78 virtual void begin_frame() { };
79
87 virtual void finish_frame() { };
88
100 virtual EGLSurface create_offscreen_surface(EGLDisplay display, EGLConfig config, const EGLint* attribs) {
101 (void) display;
102 (void) config;
103 (void) attribs;
104 return EGL_NO_SURFACE;
105 }
106
116 virtual bool destroy_offscreen_surface(EGLDisplay display, EGLSurface surface) {
117 (void) display;
118 (void) surface;
119 return false;
120 }
121
153 [[deprecated("Use GraphicsProcessor::present(AnboxGraphicsBuffer2* buffer, AnboxCallback* callback) instead")]]
154 virtual bool present(AnboxGraphicsBuffer* buffer, AnboxCallback* callback) {
155 (void) buffer;
156 (void) callback;
157 return false;
158 }
159
191 virtual bool present(AnboxGraphicsBuffer2* buffer, AnboxCallback* callback) {
192 (void) buffer;
193 (void) callback;
194 return false;
195 }
196
207 virtual bool create_buffer(uint32_t width, uint32_t height, uint32_t format,
208 uint32_t usage, AnboxGraphicsBuffer2** buffer) {
209 (void) width;
210 (void) height;
211 (void) format;
212 (void) usage;
213 (void) buffer;
214 return false;
215 }
216
228 virtual void set_vsync_callback(const AnboxVsyncCallback& callback,
229 void* user_data) {
230 vsync_callback_ = callback;
231 vsync_callback_user_data_ = user_data;
232 }
233
234 protected:
235 void signal_vsync(uint64_t time_ns) {
236 if (!vsync_callback_)
237 return;
238
239 vsync_callback_(time_ns, vsync_callback_user_data_);
240 }
241
242 private:
243 AnboxVsyncCallback vsync_callback_ = nullptr;
244 void* vsync_callback_user_data_ = nullptr;
245};
246} // namespace anbox
247
248#endif
GraphicsProcessor allows integration with the graphics engine inside Anbox.
virtual bool destroy_offscreen_surface(EGLDisplay display, EGLSurface surface)
virtual bool present(AnboxGraphicsBuffer2 *buffer, AnboxCallback *callback)
Present the given buffer to a display or other output.
virtual EGLSurface create_offscreen_surface(EGLDisplay display, EGLConfig config, const EGLint *attribs)
Create an offscreen EGL surface for the given display, configuration and attributes.
virtual EGLDisplay create_display()
Create an EGL display.
void signal_vsync(uint64_t time_ns)
virtual void begin_frame()
Called from Anbox when a new frame is started.
virtual bool create_buffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage, AnboxGraphicsBuffer2 **buffer)
Create a buffer with the given specifications.
virtual void set_vsync_callback(const AnboxVsyncCallback &callback, void *user_data)
Sets a callback which will be invoked whenever a new vsync is about to start.
virtual void finish_frame()
Called from Anbox when a frame was fully rendered.
virtual int initialize(AnboxGraphicsConfiguration *configuration)
Initialize the graphics processor.
GraphicsProcessor & operator=(const GraphicsProcessor &)=delete
GraphicsProcessor(const GraphicsProcessor &)=delete
virtual bool present(AnboxGraphicsBuffer *buffer, AnboxCallback *callback)
Present the given buffer to a display or other output.
virtual ~GraphicsProcessor()=default
void(* AnboxVsyncCallback)(uint64_t time_ns, void *user_data)
AnboxVsyncCallback is invoked to signal a new vsync is about to start.
Generic callback wrapper.
Definition types.h:314
Graphics buffer.
Definition types.h:292
Graphics buffer.
Definition types.h:273
AnboxDisplaySpec describes properties of the Anbox rendering pipeline the platform plugin can influen...
Definition types.h:1273