anbox-platform-sdk  1.23.0
Anbox Platform SDK API documentation
anbox::GraphicsProcessor Class Reference

GraphicsProcessor allows integration with the graphics engine inside Anbox. More...

#include <graphics_processor.h>

+ Collaboration diagram for anbox::GraphicsProcessor:

Public Member Functions

 GraphicsProcessor ()=default
 
virtual ~GraphicsProcessor ()=default
 
 GraphicsProcessor (const GraphicsProcessor &)=delete
 
GraphicsProcessoroperator= (const GraphicsProcessor &)=delete
 
virtual EGLDisplay create_display ()
 Create an EGL display. More...
 
virtual int initialize (AnboxGraphicsConfiguration *configuration)
 Initialize the graphics processor. More...
 
virtual void begin_frame ()
 Called from Anbox when a new frame is started. More...
 
virtual void finish_frame ()
 Called from Anbox when a frame was fully rendered. More...
 
virtual EGLSurface create_offscreen_surface (EGLDisplay display, EGLConfig config, const EGLint *attribs)
 Create an offscreen EGL surface for the given display, configuration and attributes. More...
 
virtual bool destroy_offscreen_surface (EGLDisplay display, EGLSurface surface)
 
virtual bool present (AnboxGraphicsBuffer *buffer, AnboxCallback *callback)
 Present the given buffer to a display or other output. More...
 
virtual bool present (AnboxGraphicsBuffer2 *buffer, AnboxCallback *callback)
 Present the given buffer to a display or other output. More...
 
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. More...
 

Detailed Description

GraphicsProcessor allows integration with the graphics engine inside Anbox.

Definition at line 28 of file graphics_processor.h.

Constructor & Destructor Documentation

◆ GraphicsProcessor() [1/2]

anbox::GraphicsProcessor::GraphicsProcessor ( )
default

◆ ~GraphicsProcessor()

virtual anbox::GraphicsProcessor::~GraphicsProcessor ( )
virtualdefault

◆ GraphicsProcessor() [2/2]

anbox::GraphicsProcessor::GraphicsProcessor ( const GraphicsProcessor )
delete

Member Function Documentation

◆ begin_frame()

virtual void anbox::GraphicsProcessor::begin_frame ( )
inlinevirtual

Called from Anbox when a new frame is started.

This function is called by Anbox from its render thread after the call to eglMakeCurrent to make the main rendering surface and context current. Any operation performed should be as fast as possible to not delay the frame for too long.

Definition at line 70 of file graphics_processor.h.

◆ create_buffer()

virtual bool anbox::GraphicsProcessor::create_buffer ( uint32_t  width,
uint32_t  height,
uint32_t  format,
uint32_t  usage,
AnboxGraphicsBuffer2 **  buffer 
)
inlinevirtual

Create a buffer with the given specifications.

Parameters
widthWidth of the buffer in pixels
heightHeight of the buffer in pixels
formatColor format of the buffer. See AnboxGraphicsBufferPixelFormat
usageUsage flags of the buffer. See AnboxGraphicsBufferUsage
bufferAllocated buffer object. See AnboxGraphicsBuffer2
Returns
true if the buffer was successfully created, false otherwise

Definition at line 199 of file graphics_processor.h.

◆ create_display()

virtual EGLDisplay anbox::GraphicsProcessor::create_display ( )
inlinevirtual

Create an EGL display.

This function is called by Anbox when it initializes the rendering pipeline to create an EGLDisplay to use for rendering. In case that a platform provides no implementation or EGL_NO_DISPLAY is returned Anbox will use EGL_DEFAULT_DISPLAY to create an EGLDisplay

Returns
EGLDisplay A valid EGLDisplay or EGL_NO_DISPLAY

Definition at line 45 of file graphics_processor.h.

◆ create_offscreen_surface()

virtual EGLSurface anbox::GraphicsProcessor::create_offscreen_surface ( EGLDisplay  display,
EGLConfig  config,
const EGLint *  attribs 
)
inlinevirtual

Create an offscreen EGL surface for the given display, configuration and attributes.

If not implemented Anbox will use eglCreatePbufferSurface as fallback.

Parameters
displayEGL display to create the surface for
configEGL configuration to create the surface for
attribsAttributes to used for the surface creation
Returns
Created EGLSurface or EGL_NO_SURFACE on error

Definition at line 92 of file graphics_processor.h.

◆ destroy_offscreen_surface()

virtual bool anbox::GraphicsProcessor::destroy_offscreen_surface ( EGLDisplay  display,
EGLSurface  surface 
)
inlinevirtual

Destroy a surface created with create_offscreen_surface.

If not implemented Anbox will use eglDestroySurface as fallback.

Parameters
displayEGL display the surface was created for
surfaceEGL surface to destroy
Returns
true, if the surface is successfully destroyed and false otherwise.

Definition at line 108 of file graphics_processor.h.

◆ finish_frame()

virtual void anbox::GraphicsProcessor::finish_frame ( )
inlinevirtual

Called from Anbox when a frame was fully rendered.

This function is called by Anbox from its render thread before its calling eglSwapBuffers on the main EGL surface. Any operation performed should be as fast as possible to not delay the frame for too long.

Definition at line 79 of file graphics_processor.h.

◆ initialize()

virtual int anbox::GraphicsProcessor::initialize ( AnboxGraphicsConfiguration configuration)
inlinevirtual

Initialize the graphics processor.

This function is called by Anbox when the rendering pipeline is initialized. The configuration structure is provided from Anbox and has to be filled out by the platform. Anbox initializes the provided structure with its defaults.

Parameters
configurationConfiguration initialized with default values from Anbox
Returns
0 on success, a negative error code otherwise.

Definition at line 57 of file graphics_processor.h.

◆ operator=()

GraphicsProcessor& anbox::GraphicsProcessor::operator= ( const GraphicsProcessor )
delete

◆ present() [1/2]

virtual bool anbox::GraphicsProcessor::present ( AnboxGraphicsBuffer buffer,
AnboxCallback callback 
)
inlinevirtual

Present the given buffer to a display or other output.

DEPRECATED: This variant of the present method is deprecated and should no longer be used. Instead use the variant which takes the AnboxGraphicsBuffer2 structure.

Used when graphics implementation is ANBOX_GRAPHICS_IMPLEMENTATION_TYPE_DIRECT_RENDERING or ANBOX_GRAPHICS_IMPLEMENTATION_TYPE_HOST_RENDERING

This method will be called by Anbox when Android has submitted a new buffer to be presented on the output managed by the platform. The buffer contains information about dimension, format and the handle to the buffer itself.

The buffer handle is opaque to Anbox and it's up to the platform to map it to something which it can handle. For all GPUs the handle is a file descriptor of a DMA buffer (see https://www.kernel.org/doc/html/latest/driver-api/dma-buf.html) which can imported into APIs like EGL or Vulkan for further processing. For software rendering the handle is a memfd (https://man7.org/linux/man-pages/man2/memfd_create.2.html) pointing to a shared memory region containing the buffer data.

When the platform has finished presenting the buffer it has to call the provided callback in order to return the buffer to Anbox for reuse. Not returning the buffer will cause the rendering pipeline to become stuck.

If present returns false it is expected that #callback is not called by the implementation.

Parameters
bufferBuffer to be presented on the output
callbackA callback to be called by the platform when the buffer has been presented
Returns
true if the buffer was accepted for presentation, false otherwise.

Definition at line 146 of file graphics_processor.h.

◆ present() [2/2]

virtual bool anbox::GraphicsProcessor::present ( AnboxGraphicsBuffer2 buffer,
AnboxCallback callback 
)
inlinevirtual

Present the given buffer to a display or other output.

Used when graphics implementation is ANBOX_GRAPHICS_IMPLEMENTATION_TYPE_DIRECT_RENDERING or ANBOX_GRAPHICS_IMPLEMENTATION_TYPE_HOST_RENDERING

This method will be called by Anbox when Android has submitted a new buffer to be presented on the output managed by the platform. The buffer contains information about dimension, format and the handle to the buffer itself.

The buffer handle is opaque to Anbox and it's up to the platform to map it to something which it can handle. For all GPUs the handle is a file descriptor of a DMA buffer (see https://www.kernel.org/doc/html/latest/driver-api/dma-buf.html) which can imported into APIs like EGL or Vulkan for further processing. For software rendering the handle is a memfd (https://man7.org/linux/man-pages/man2/memfd_create.2.html) pointing to a shared memory region containing the buffer data.

Passed buffer objects are reused by the caller so the given address for the AnboxGraphicsBuffer2 can be used as identifier for cache implementations.

When the platform has finished presenting the buffer it has to call the provided callback in order to return the buffer to Anbox for reuse. Not returning the buffer will cause the rendering pipeline to become stuck.

If present returns false it is expected that #callback is not called by the implementation.

Parameters
bufferBuffer to be presented on the output
callbackA callback to be called by the platform when the buffer has been presented
Returns
true if the buffer was accepted for presentation, false otherwise.

Definition at line 183 of file graphics_processor.h.


The documentation for this class was generated from the following file: