[client] renderer: remove on_help from renderer interface

This commit is contained in:
Quantum 2021-07-23 02:38:24 -04:00 committed by Geoffrey McRae
parent 036f16b9ef
commit 5153d35bb5
9 changed files with 0 additions and 353 deletions

View File

@ -36,7 +36,6 @@
(x)->on_mouse_shape && \
(x)->on_mouse_event && \
(x)->on_alert && \
(x)->on_help && \
(x)->render_startup && \
(x)->render)
@ -114,7 +113,6 @@ typedef bool (* LG_RendererOnMouseEvent )(void * opaque, const bool visi
typedef bool (* LG_RendererOnFrameFormat)(void * opaque, const LG_RendererFormat format, bool useDMA);
typedef bool (* LG_RendererOnFrame )(void * opaque, const FrameBuffer * frame, int dmaFD, const FrameDamageRect * damage, int damageCount);
typedef void (* LG_RendererOnAlert )(void * opaque, const LG_MsgAlert alert, const char * message, bool ** closeFlag);
typedef void (* LG_RendererOnHelp )(void * opaque, const char * message);
typedef bool (* LG_RendererRenderStartup)(void * opaque);
typedef bool (* LG_RendererRender )(void * opaque, LG_RendererRotate rotate, const bool newFrame);
@ -134,7 +132,6 @@ typedef struct LG_Renderer
LG_RendererOnFrameFormat on_frame_format;
LG_RendererOnFrame on_frame;
LG_RendererOnAlert on_alert;
LG_RendererOnHelp on_help;
LG_RendererRenderStartup render_startup;
LG_RendererRender render;
}

View File

@ -21,9 +21,6 @@ make_object(
shader/cursor_mono.frag
shader/damage.vert
shader/damage.frag
shader/help.vert
shader/help.frag
shader/help_bg.frag
shader/alert.vert
shader/alert.frag
shader/alert_bg.frag
@ -46,7 +43,6 @@ add_library(renderer_EGL STATIC
model.c
desktop.c
cursor.c
help.c
draw.c
splash.c
alert.c

View File

@ -49,7 +49,6 @@
#include "cursor.h"
#include "splash.h"
#include "alert.h"
#include "help.h"
#define SPLASH_FADE_TIME 1000000
#define ALERT_TIMEOUT 2000000
@ -76,7 +75,6 @@ struct Inst
EGL_Cursor * cursor; // the mouse cursor
EGL_Splash * splash; // the splash screen
EGL_Alert * alert; // the alert display
EGL_Help * help; // the help display
EGL_Damage * damage; // the damage display
bool imgui; // if imgui was initialized
@ -113,8 +111,6 @@ struct Inst
const LG_Font * font;
LG_FontObj fontObj;
unsigned fontSize;
LG_FontObj helpFontObj;
unsigned helpFontSize;
struct CursorState cursorLast;
@ -219,29 +215,6 @@ static bool egl_update_font(struct Inst * this)
return true;
}
static bool egl_update_help_font(struct Inst * this)
{
unsigned size = round(14.0f * this->uiScale);
if (size == this->helpFontSize)
return true;
LG_FontObj fontObj;
if (!this->font->create(&fontObj, NULL, size))
{
DEBUG_ERROR("Failed to create a font instance");
return false;
}
if (this->help)
egl_help_set_font(this->help, fontObj);
if (this->helpFontObj)
this->font->destroy(this->helpFontObj);
this->helpFontObj = fontObj;
return true;
}
bool egl_create(void ** opaque, const LG_RendererParams params, bool * needsOpenGL)
{
// check if EGL is even available
@ -277,9 +250,6 @@ bool egl_create(void ** opaque, const LG_RendererParams params, bool * needsOpen
if (!egl_update_font(this))
return false;
if (!egl_update_help_font(this))
return false;
*needsOpenGL = false;
return true;
}
@ -302,16 +272,12 @@ void egl_deinitialize(void * opaque)
{
if (this->fontObj)
this->font->destroy(this->fontObj);
if (this->helpFontObj)
this->font->destroy(this->helpFontObj);
}
egl_desktop_free(&this->desktop);
egl_cursor_free (&this->cursor);
egl_splash_free (&this->splash);
egl_alert_free (&this->alert );
egl_help_free (&this->help );
egl_damage_free (&this->damage);
LG_LOCK_FREE(this->lock);
@ -493,7 +459,6 @@ void egl_on_resize(void * opaque, const int width, const int height, const doubl
egl_calc_mouse_state(this);
egl_update_font(this);
egl_update_help_font(this);
struct DesktopDamage * damage = malloc(sizeof(struct DesktopDamage));
if (!damage)
@ -634,12 +599,6 @@ void egl_on_alert(void * opaque, const LG_MsgAlert alert, const char * message,
this->showAlert = true;
}
void egl_on_help(void * opaque, const char * message)
{
struct Inst * this = (struct Inst *)opaque;
egl_help_set_text(this->help, message);
}
static void debugCallback(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length, const GLchar * message,
const void * userParam)
@ -905,12 +864,6 @@ bool egl_render_startup(void * opaque)
return false;
}
if (!egl_help_init(&this->help, this->font, this->helpFontObj))
{
DEBUG_ERROR("Failed to initialize the alert display");
return false;
}
if (!egl_damage_init(&this->damage))
{
DEBUG_ERROR("Failed to initialize the damage display");
@ -1008,7 +961,6 @@ bool egl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame)
}
}
hasOverlay |= egl_help_render(this->help, this->screenScaleX, this->screenScaleY);
hasOverlay |= egl_damage_render(this->damage, newFrame ? desktopDamage : NULL);
struct Rect damage[KVMFR_MAX_DAMAGE_RECTS + MAX_OVERLAY_RECTS + 2];
@ -1089,7 +1041,6 @@ struct LG_Renderer LGR_EGL =
.on_frame_format = egl_on_frame_format,
.on_frame = egl_on_frame,
.on_alert = egl_on_alert,
.on_help = egl_on_help,
.render_startup = egl_render_startup,
.render = egl_render
};

View File

@ -1,216 +0,0 @@
/**
* 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
*/
#include "help.h"
#include "common/debug.h"
#include "texture.h"
#include "shader.h"
#include "model.h"
#include <stdatomic.h>
#include <stdlib.h>
#include <string.h>
// these headers are auto generated by cmake
#include "help.vert.h"
#include "help.frag.h"
#include "help_bg.frag.h"
struct EGL_Help
{
const LG_Font * font;
LG_FontObj fontObj;
EGL_Texture * texture;
EGL_Shader * shader;
EGL_Shader * shaderBG;
EGL_Model * model;
_Atomic(LG_FontBitmap *) bmp;
bool shouldRender;
int iwidth, iheight;
float width, height;
// uniforms
GLint uScreen , uSize;
GLint uScreenBG, uSizeBG;
};
bool egl_help_init(EGL_Help ** help, const LG_Font * font, LG_FontObj fontObj)
{
*help = (EGL_Help *)malloc(sizeof(EGL_Help));
if (!*help)
{
DEBUG_ERROR("Failed to malloc EGL_Help");
return false;
}
memset(*help, 0, sizeof(EGL_Help));
(*help)->font = font;
(*help)->fontObj = fontObj;
if (!egl_texture_init(&(*help)->texture, NULL))
{
DEBUG_ERROR("Failed to initialize the help texture");
return false;
}
if (!egl_shader_init(&(*help)->shader))
{
DEBUG_ERROR("Failed to initialize the help shader");
return false;
}
if (!egl_shader_init(&(*help)->shaderBG))
{
DEBUG_ERROR("Failed to initialize the help bg shader");
return false;
}
if (!egl_shader_compile((*help)->shader,
b_shader_help_vert, b_shader_help_vert_size,
b_shader_help_frag, b_shader_help_frag_size))
{
DEBUG_ERROR("Failed to compile the help shader");
return false;
}
if (!egl_shader_compile((*help)->shaderBG,
b_shader_help_vert , b_shader_help_vert_size,
b_shader_help_bg_frag, b_shader_help_bg_frag_size))
{
DEBUG_ERROR("Failed to compile the help shader");
return false;
}
(*help)->uSize = egl_shader_get_uniform_location((*help)->shader , "size" );
(*help)->uScreen = egl_shader_get_uniform_location((*help)->shader , "screen");
(*help)->uSizeBG = egl_shader_get_uniform_location((*help)->shaderBG, "size" );
(*help)->uScreenBG = egl_shader_get_uniform_location((*help)->shaderBG, "screen");
if (!egl_model_init(&(*help)->model))
{
DEBUG_ERROR("Failed to initialize the fps model");
return false;
}
egl_model_set_default((*help)->model);
egl_model_set_texture((*help)->model, (*help)->texture);
atomic_init(&(*help)->bmp, NULL);
return true;
}
void egl_help_free(EGL_Help ** help)
{
if (!*help)
return;
egl_texture_free(&(*help)->texture );
egl_shader_free (&(*help)->shader );
egl_shader_free (&(*help)->shaderBG);
egl_model_free (&(*help)->model );
free(*help);
*help = NULL;
}
void egl_help_set_text(EGL_Help * help, const char * help_text)
{
LG_FontBitmap * bmp = NULL;
if (help_text)
{
bmp = help->font->render(help->fontObj, 0xffffff00, help_text);
if (!bmp)
DEBUG_ERROR("Failed to render help text");
} else
help->shouldRender = false;
bmp = atomic_exchange(&help->bmp, bmp);
if (bmp)
{
help->font->release(help->fontObj, bmp);
}
}
void egl_help_set_font(EGL_Help * help, LG_FontObj fontObj)
{
help->fontObj = fontObj;
}
bool egl_help_render(EGL_Help * help, const float scaleX, const float scaleY)
{
LG_FontBitmap * bmp = atomic_exchange(&help->bmp, NULL);
if (bmp)
{
if (help->iwidth != bmp->width || help->iheight != bmp->height)
{
help->iwidth = bmp->width;
help->iheight = bmp->height;
help->width = (float)bmp->width;
help->height = (float)bmp->height;
egl_texture_setup(
help->texture,
EGL_PF_BGRA,
bmp->width ,
bmp->height,
bmp->width * bmp->bpp,
false,
false
);
}
egl_texture_update
(
help->texture,
bmp->pixels
);
help->shouldRender = true;
help->font->release(help->fontObj, bmp);
}
if (!help->shouldRender)
return false;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// render the background first
egl_shader_use(help->shaderBG);
glUniform2f(help->uScreenBG, scaleX , scaleY );
glUniform2f(help->uSizeBG , help->width, help->height);
egl_model_render(help->model);
// render the texture over the background
egl_shader_use(help->shader);
glUniform2f(help->uScreen, scaleX , scaleY );
glUniform2f(help->uSize , help->width, help->height);
egl_model_render(help->model);
glDisable(GL_BLEND);
return true;
}

View File

@ -1,34 +0,0 @@
/**
* 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
*/
#pragma once
#include <stdbool.h>
#include "interface/font.h"
typedef struct EGL_Help EGL_Help;
bool egl_help_init(EGL_Help ** help, const LG_Font * font, LG_FontObj fontObj);
void egl_help_free(EGL_Help ** help);
void egl_help_set_text(EGL_Help * help, const char * help_text);
void egl_help_set_font(EGL_Help * help, LG_FontObj fontObj);
bool egl_help_render(EGL_Help * help, const float scaleX, const float scaleY);

View File

@ -1,11 +0,0 @@
#version 300 es
in highp vec2 uv;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
color = texture(sampler1, uv);
}

View File

@ -1,22 +0,0 @@
#version 300 es
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
uniform vec2 screen;
uniform vec2 size;
out highp vec2 uv;
void main()
{
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
gl_Position.xy *= screen.xy * size.xy;
gl_Position.x -= 1.0 - (screen.x * size.x);
gl_Position.y -= 1.0 - (screen.y * size.y);
gl_Position.x += screen.x * 10.0;
gl_Position.y += screen.y * 10.0;
uv = vertexUV;
}

View File

@ -1,8 +0,0 @@
#version 300 es
out highp vec4 color;
void main()
{
color = vec4(0.0, 0.0, 1.0, 0.5);
}

View File

@ -494,11 +494,6 @@ void opengl_on_alert(void * opaque, const LG_MsgAlert alert, const char * messag
ll_push(this->alerts, a);
}
void opengl_on_help(void * opaque, const char * message)
{
// TODO: Implement this.
}
void bitmap_to_texture(LG_FontBitmap * bitmap, GLuint texture)
{
glBindTexture(GL_TEXTURE_2D , texture );
@ -817,7 +812,6 @@ const LG_Renderer LGR_OpenGL =
.on_frame_format = opengl_on_frame_format,
.on_frame = opengl_on_frame,
.on_alert = opengl_on_alert,
.on_help = opengl_on_help,
.render_startup = opengl_render_startup,
.render = opengl_render
};