2021-07-22 04:42:54 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2024-02-01 06:16:31 +00:00
|
|
|
* Copyright © 2017-2024 The Looking Glass Authors
|
2021-07-22 04:42:54 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _H_I_OVERLAY_
|
|
|
|
#define _H_I_OVERLAY_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2021-07-22 07:27:30 +00:00
|
|
|
|
2021-07-22 04:42:54 +00:00
|
|
|
#include "common/types.h"
|
|
|
|
|
2022-05-26 16:07:20 +00:00
|
|
|
#define TICK_RATE 25
|
|
|
|
|
2021-07-22 04:42:54 +00:00
|
|
|
struct LG_OverlayOps
|
|
|
|
{
|
|
|
|
/* internal name of the overlay for debugging */
|
|
|
|
const char * name;
|
|
|
|
|
2021-08-04 20:40:06 +00:00
|
|
|
/* called very early to allow for option registration, optional */
|
|
|
|
void (*earlyInit)(void);
|
|
|
|
|
2021-07-22 04:42:54 +00:00
|
|
|
/* called when the overlay is registered */
|
2021-08-04 20:40:06 +00:00
|
|
|
bool (*init)(void ** udata, const void * params);
|
2021-07-22 04:42:54 +00:00
|
|
|
|
|
|
|
/* final free */
|
|
|
|
void (*free)(void * udata);
|
|
|
|
|
2021-08-01 11:13:59 +00:00
|
|
|
/* return true if realtime rendering is required when in jitRender mode
|
|
|
|
* optional, if omitted assumes false */
|
|
|
|
bool (*needs_render)(void * udata, bool interactive);
|
|
|
|
|
2022-01-08 04:37:44 +00:00
|
|
|
/* return true if the overlay currently requires overlay mode
|
|
|
|
* optional, if omitted assumes false */
|
|
|
|
bool (*needs_overlay)(void * udata);
|
|
|
|
|
2021-07-22 04:42:54 +00:00
|
|
|
/* perform the actual drawing/rendering
|
|
|
|
*
|
2021-07-22 04:50:10 +00:00
|
|
|
* `interactive` is true if the application is currently in overlay interaction
|
2021-07-22 04:42:54 +00:00
|
|
|
* mode.
|
|
|
|
*
|
2021-07-22 08:33:50 +00:00
|
|
|
* `windowRects` is an array of window rects that were rendered using screen
|
|
|
|
* coordinates. Will be `NULL` if the information is not required.
|
|
|
|
*
|
|
|
|
* `maxRects` is the length of `windowRects`, or 0 if `windowRects` is `NULL`
|
|
|
|
*
|
|
|
|
* returns the number of rects written to `windowRects`, or -1 if there is not
|
|
|
|
* enough room left.
|
2021-07-22 04:42:54 +00:00
|
|
|
*/
|
2021-07-22 08:33:50 +00:00
|
|
|
int (*render)(void * udata, bool interactive, struct Rect * windowRects,
|
|
|
|
int maxRects);
|
2021-07-22 04:42:54 +00:00
|
|
|
|
2022-05-26 16:07:20 +00:00
|
|
|
/* called TICK_RATE times a second by the application
|
2022-01-08 03:06:35 +00:00
|
|
|
*
|
|
|
|
* Note: This may not run in the same context as `render`!
|
|
|
|
*
|
|
|
|
* return true if the frame needs to be rendered
|
|
|
|
* optional, if omitted assumes false
|
|
|
|
*/
|
|
|
|
bool (*tick)(void * udata, unsigned long long tickCount);
|
|
|
|
|
2021-07-22 04:42:54 +00:00
|
|
|
/* TODO: add load/save settings capabillity */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ASSERT_LG_OVERLAY_VALID(x) \
|
2021-08-13 23:51:36 +00:00
|
|
|
DEBUG_ASSERT((x)->name ); \
|
|
|
|
DEBUG_ASSERT((x)->init ); \
|
|
|
|
DEBUG_ASSERT((x)->free ); \
|
|
|
|
DEBUG_ASSERT((x)->render);
|
2021-07-22 04:42:54 +00:00
|
|
|
|
|
|
|
#endif
|