2021-06-06 01:26:18 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2021-08-04 09:48:32 +00:00
|
|
|
* Copyright © 2017-2021 The Looking Glass Authors
|
2021-06-06 01:26:18 +00:00
|
|
|
* https://looking-glass.io
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2017-12-05 09:33:05 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2019-03-30 01:26:06 +00:00
|
|
|
#include "app.h"
|
2019-04-11 01:12:59 +00:00
|
|
|
#include "common/KVMFR.h"
|
2019-10-01 13:17:20 +00:00
|
|
|
#include "common/framebuffer.h"
|
2018-07-27 22:41:15 +00:00
|
|
|
|
2017-12-05 09:33:05 +00:00
|
|
|
#define IS_LG_RENDERER_VALID(x) \
|
2017-12-12 15:22:47 +00:00
|
|
|
((x)->get_name && \
|
2017-12-17 11:21:59 +00:00
|
|
|
(x)->create && \
|
2017-12-12 15:22:47 +00:00
|
|
|
(x)->initialize && \
|
|
|
|
(x)->deinitialize && \
|
2020-08-11 04:30:44 +00:00
|
|
|
(x)->on_restart && \
|
2017-12-12 15:22:47 +00:00
|
|
|
(x)->on_resize && \
|
2017-12-12 16:08:13 +00:00
|
|
|
(x)->on_mouse_shape && \
|
2017-12-12 15:22:47 +00:00
|
|
|
(x)->on_mouse_event && \
|
2018-07-28 04:49:37 +00:00
|
|
|
(x)->render_startup && \
|
2021-08-01 08:18:08 +00:00
|
|
|
(x)->needs_render && \
|
2021-07-18 10:43:17 +00:00
|
|
|
(x)->render)
|
2017-12-05 09:33:05 +00:00
|
|
|
|
|
|
|
typedef struct LG_RendererParams
|
|
|
|
{
|
2021-08-08 04:39:40 +00:00
|
|
|
bool quickSplash;
|
2017-12-05 09:33:05 +00:00
|
|
|
}
|
|
|
|
LG_RendererParams;
|
|
|
|
|
2020-10-29 11:57:04 +00:00
|
|
|
typedef enum LG_RendererSupport
|
|
|
|
{
|
|
|
|
LG_SUPPORTS_DMABUF
|
|
|
|
}
|
|
|
|
LG_RendererSupport;
|
|
|
|
|
2021-01-15 01:40:59 +00:00
|
|
|
typedef enum LG_RendererRotate
|
|
|
|
{
|
2021-01-18 03:42:57 +00:00
|
|
|
LG_ROTATE_0,
|
|
|
|
LG_ROTATE_90,
|
|
|
|
LG_ROTATE_180,
|
|
|
|
LG_ROTATE_270
|
2021-01-15 01:40:59 +00:00
|
|
|
}
|
|
|
|
LG_RendererRotate;
|
|
|
|
|
2021-01-18 15:44:56 +00:00
|
|
|
// kept out of the enum so gcc doesn't warn when it's missing from a switch
|
|
|
|
// statement.
|
|
|
|
#define LG_ROTATE_MAX (LG_ROTATE_270+1)
|
|
|
|
|
2017-12-05 09:33:05 +00:00
|
|
|
typedef struct LG_RendererFormat
|
|
|
|
{
|
2021-01-15 01:40:59 +00:00
|
|
|
FrameType type; // frame type
|
|
|
|
unsigned int width; // image width
|
|
|
|
unsigned int height; // image height
|
|
|
|
unsigned int stride; // scanline width (zero if compresed)
|
|
|
|
unsigned int pitch; // scanline bytes (or compressed size)
|
|
|
|
unsigned int bpp; // bits per pixel (zero if compressed)
|
2021-01-18 15:44:56 +00:00
|
|
|
LG_RendererRotate rotate; // guest rotation
|
2017-12-05 09:33:05 +00:00
|
|
|
}
|
|
|
|
LG_RendererFormat;
|
|
|
|
|
|
|
|
typedef struct LG_RendererRect
|
|
|
|
{
|
2020-12-03 13:32:28 +00:00
|
|
|
bool valid;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int w;
|
|
|
|
int h;
|
2017-12-05 09:33:05 +00:00
|
|
|
}
|
|
|
|
LG_RendererRect;
|
|
|
|
|
2017-12-12 16:08:13 +00:00
|
|
|
typedef enum LG_RendererCursor
|
|
|
|
{
|
|
|
|
LG_CURSOR_COLOR ,
|
|
|
|
LG_CURSOR_MONOCHROME ,
|
|
|
|
LG_CURSOR_MASKED_COLOR
|
|
|
|
}
|
|
|
|
LG_RendererCursor;
|
|
|
|
|
2017-12-05 09:33:05 +00:00
|
|
|
typedef struct LG_Renderer
|
|
|
|
{
|
2021-08-08 04:39:40 +00:00
|
|
|
/* returns the friendly name of the renderer */
|
|
|
|
const char * (*get_name)(void);
|
|
|
|
|
|
|
|
/* called pre-creation to allow the renderer to register any options it may
|
|
|
|
* have */
|
|
|
|
void (*setup)(void);
|
|
|
|
|
|
|
|
/* creates an instance of the renderer
|
|
|
|
* Context: lg_run */
|
|
|
|
bool (*create)(void ** opaque, const LG_RendererParams params,
|
|
|
|
bool * needsOpenGL);
|
|
|
|
|
|
|
|
/* initializes the renderer for use
|
|
|
|
* Context: lg_run */
|
|
|
|
bool (*initialize)(void * opaque);
|
|
|
|
|
|
|
|
/* deinitializes & frees the renderer
|
|
|
|
* Context: lg_run & renderThread */
|
|
|
|
void (*deinitialize)(void * opaque);
|
|
|
|
|
|
|
|
/* returns true if the specified feature is supported
|
|
|
|
* Context: renderThread */
|
|
|
|
bool (*supports)(void * opaque, LG_RendererSupport support);
|
|
|
|
|
|
|
|
/* called when the renderer is to reset it's state
|
|
|
|
* Context: lg_run & frameThread */
|
|
|
|
void (*on_restart)(void * opaque);
|
|
|
|
|
|
|
|
/* called when the viewport has been resized
|
|
|
|
* Context: renderThrtead */
|
|
|
|
void (*on_resize)(void * opaque, const int width, const int height,
|
|
|
|
const double scale, const LG_RendererRect destRect,
|
|
|
|
LG_RendererRotate rotate);
|
|
|
|
|
|
|
|
/* called when the mouse shape has changed
|
|
|
|
* Context: cursorThread */
|
|
|
|
bool (*on_mouse_shape)(void * opaque, const LG_RendererCursor cursor,
|
|
|
|
const int width, const int height, const int pitch,
|
|
|
|
const uint8_t * data);
|
|
|
|
|
|
|
|
/* called when the mouse has moved or changed visibillity
|
|
|
|
* Context: cursorThread */
|
|
|
|
bool (*on_mouse_event)(void * opaque, const bool visible,
|
|
|
|
const int x, const int y);
|
|
|
|
|
|
|
|
/* called when the frame format has changed
|
|
|
|
* Context: frameThread */
|
|
|
|
bool (*on_frame_format)(void * opaque, const LG_RendererFormat format);
|
|
|
|
|
|
|
|
/* called when there is a new frame
|
|
|
|
* Context: frameThread */
|
|
|
|
bool (*on_frame)(void * opaque, const FrameBuffer * frame, int dmaFD,
|
|
|
|
const FrameDamageRect * damage, int damageCount);
|
|
|
|
|
|
|
|
/* called when the rederer is to startup
|
|
|
|
* Context: renderThread */
|
|
|
|
bool (*render_startup)(void * opaque, bool useDMA);
|
|
|
|
|
|
|
|
/* returns if the render method must be called even if nothing has changed.
|
|
|
|
* Context: renderThread */
|
|
|
|
bool (*needs_render)(void * opaque);
|
|
|
|
|
|
|
|
/* called to render the scene
|
|
|
|
* Context: renderThread */
|
|
|
|
bool (*render)(void * opaque, LG_RendererRotate rotate, const bool newFrame,
|
|
|
|
const bool invalidateWindow, void (*preSwap)(void * udata), void * udata);
|
2017-12-05 09:33:05 +00:00
|
|
|
}
|
2020-05-21 01:44:56 +00:00
|
|
|
LG_Renderer;
|