2021-06-06 01:26:18 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
|
|
|
* Copyright (C) 2017-2021 The Looking Glass Authors
|
|
|
|
* 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-05-28 22:57:09 +00:00
|
|
|
(x)->on_alert && \
|
2021-01-30 09:38:52 +00:00
|
|
|
(x)->on_help && \
|
2018-07-28 04:49:37 +00:00
|
|
|
(x)->render_startup && \
|
2021-07-18 10:43:17 +00:00
|
|
|
(x)->render)
|
2017-12-05 09:33:05 +00:00
|
|
|
|
|
|
|
typedef struct LG_RendererParams
|
|
|
|
{
|
2018-11-19 17:38:11 +00:00
|
|
|
// TTF_Font * font;
|
|
|
|
// TTF_Font * alertFont;
|
2020-07-19 04:29:29 +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;
|
|
|
|
|
2019-05-21 05:03:59 +00:00
|
|
|
// returns the friendly name of the renderer
|
|
|
|
typedef const char * (* LG_RendererGetName)();
|
|
|
|
|
|
|
|
// called pre-creation to allow the renderer to register any options it might have
|
|
|
|
typedef void (* LG_RendererSetup)();
|
|
|
|
|
2021-01-27 08:38:34 +00:00
|
|
|
typedef bool (* LG_RendererCreate )(void ** opaque, const LG_RendererParams params, bool * needsOpenGL);
|
2021-01-26 10:46:30 +00:00
|
|
|
typedef bool (* LG_RendererInitialize )(void * opaque);
|
2020-10-12 08:43:29 +00:00
|
|
|
typedef void (* LG_RendererDeInitialize )(void * opaque);
|
2020-10-29 11:57:04 +00:00
|
|
|
typedef bool (* LG_RendererSupports )(void * opaque, LG_RendererSupport support);
|
2020-10-12 08:43:29 +00:00
|
|
|
typedef void (* LG_RendererOnRestart )(void * opaque);
|
2021-02-21 05:08:52 +00:00
|
|
|
typedef void (* LG_RendererOnResize )(void * opaque, const int width, const int height, const double scale, const LG_RendererRect destRect, LG_RendererRotate rotate);
|
2021-01-18 15:44:56 +00:00
|
|
|
typedef bool (* LG_RendererOnMouseShape )(void * opaque, const LG_RendererCursor cursor, const int width, const int height, const int pitch, const uint8_t * data);
|
2020-10-12 08:43:29 +00:00
|
|
|
typedef bool (* LG_RendererOnMouseEvent )(void * opaque, const bool visible , const int x, const int y);
|
2020-10-29 15:32:25 +00:00
|
|
|
typedef bool (* LG_RendererOnFrameFormat)(void * opaque, const LG_RendererFormat format, bool useDMA);
|
2021-07-11 01:20:08 +00:00
|
|
|
typedef bool (* LG_RendererOnFrame )(void * opaque, const FrameBuffer * frame, int dmaFD, const FrameDamageRect * damage, int damageCount);
|
2020-10-12 08:43:29 +00:00
|
|
|
typedef void (* LG_RendererOnAlert )(void * opaque, const LG_MsgAlert alert, const char * message, bool ** closeFlag);
|
2021-01-30 09:38:52 +00:00
|
|
|
typedef void (* LG_RendererOnHelp )(void * opaque, const char * message);
|
2021-01-26 10:46:30 +00:00
|
|
|
typedef bool (* LG_RendererRenderStartup)(void * opaque);
|
2021-07-21 07:26:48 +00:00
|
|
|
typedef bool (* LG_RendererRender )(void * opaque, LG_RendererRotate rotate, const bool newFrame);
|
2017-12-05 09:33:05 +00:00
|
|
|
|
|
|
|
typedef struct LG_Renderer
|
|
|
|
{
|
|
|
|
LG_RendererGetName get_name;
|
2019-05-21 05:03:59 +00:00
|
|
|
LG_RendererSetup setup;
|
|
|
|
|
2020-10-12 08:43:29 +00:00
|
|
|
LG_RendererCreate create;
|
|
|
|
LG_RendererInitialize initialize;
|
|
|
|
LG_RendererDeInitialize deinitialize;
|
2020-10-29 11:57:04 +00:00
|
|
|
LG_RendererSupports supports;
|
2020-10-12 08:43:29 +00:00
|
|
|
LG_RendererOnRestart on_restart;
|
|
|
|
LG_RendererOnResize on_resize;
|
|
|
|
LG_RendererOnMouseShape on_mouse_shape;
|
|
|
|
LG_RendererOnMouseEvent on_mouse_event;
|
|
|
|
LG_RendererOnFrameFormat on_frame_format;
|
|
|
|
LG_RendererOnFrame on_frame;
|
|
|
|
LG_RendererOnAlert on_alert;
|
2021-01-30 09:38:52 +00:00
|
|
|
LG_RendererOnHelp on_help;
|
2021-01-18 15:44:56 +00:00
|
|
|
LG_RendererRenderStartup render_startup;
|
2020-10-12 08:43:29 +00:00
|
|
|
LG_RendererRender render;
|
2017-12-05 09:33:05 +00:00
|
|
|
}
|
2020-05-21 01:44:56 +00:00
|
|
|
LG_Renderer;
|