[client] all: unify the LG splash screen into an overlay

This commit is contained in:
Geoffrey McRae 2022-05-27 02:07:20 +10:00
parent 8974ae4fb5
commit 5de175c1f3
13 changed files with 200 additions and 427 deletions

View file

@ -139,6 +139,7 @@ set(SOURCES
src/overlay_utils.c src/overlay_utils.c
src/render_queue.c src/render_queue.c
src/overlay/splash.c
src/overlay/alert.c src/overlay/alert.c
src/overlay/fps.c src/overlay/fps.c
src/overlay/graphs.c src/overlay/graphs.c

View file

@ -25,6 +25,8 @@
#include "common/types.h" #include "common/types.h"
#define TICK_RATE 25
struct LG_OverlayOps struct LG_OverlayOps
{ {
/* internal name of the overlay for debugging */ /* internal name of the overlay for debugging */
@ -63,7 +65,7 @@ struct LG_OverlayOps
int (*render)(void * udata, bool interactive, struct Rect * windowRects, int (*render)(void * udata, bool interactive, struct Rect * windowRects,
int maxRects); int maxRects);
/* called 25 times a second by the application /* called TICK_RATE times a second by the application
* *
* Note: This may not run in the same context as `render`! * Note: This may not run in the same context as `render`!
* *

View file

@ -55,10 +55,6 @@ build_shaders(
shader/cursor_mono.frag shader/cursor_mono.frag
shader/damage.vert shader/damage.vert
shader/damage.frag shader/damage.frag
shader/splash_bg.vert
shader/splash_bg.frag
shader/splash_logo.vert
shader/splash_logo.frag
shader/basic.vert shader/basic.vert
shader/ffx_cas.frag shader/ffx_cas.frag
shader/ffx_fsr1_easu.frag shader/ffx_fsr1_easu.frag
@ -87,7 +83,6 @@ add_library(renderer_EGL STATIC
desktop_rects.c desktop_rects.c
cursor.c cursor.c
draw.c draw.c
splash.c
damage.c damage.c
framebuffer.c framebuffer.c
postprocess.c postprocess.c

View file

@ -45,11 +45,9 @@
#include "damage.h" #include "damage.h"
#include "desktop.h" #include "desktop.h"
#include "cursor.h" #include "cursor.h"
#include "splash.h"
#include "postprocess.h" #include "postprocess.h"
#include "util.h" #include "util.h"
#define SPLASH_FADE_TIME 1000000
#define MAX_BUFFER_AGE 3 #define MAX_BUFFER_AGE 3
#define DESKTOP_DAMAGE_COUNT 4 #define DESKTOP_DAMAGE_COUNT 4
#define MAX_ACCUMULATED_DAMAGE ((KVMFR_MAX_DAMAGE_RECTS + MAX_OVERLAY_RECTS + 2) * MAX_BUFFER_AGE) #define MAX_ACCUMULATED_DAMAGE ((KVMFR_MAX_DAMAGE_RECTS + MAX_OVERLAY_RECTS + 2) * MAX_BUFFER_AGE)
@ -77,15 +75,11 @@ struct Inst
EGL_Desktop * desktop; // the desktop EGL_Desktop * desktop; // the desktop
EGL_Cursor * cursor; // the mouse cursor EGL_Cursor * cursor; // the mouse cursor
EGL_Splash * splash; // the splash screen
EGL_Damage * damage; // the damage display EGL_Damage * damage; // the damage display
bool imgui; // if imgui was initialized bool imgui; // if imgui was initialized
LG_RendererFormat format; LG_RendererFormat format;
bool formatValid; bool formatValid;
bool start;
uint64_t waitFadeTime;
bool waitDone;
int width, height; int width, height;
float uiScale; float uiScale;
@ -284,7 +278,6 @@ static void egl_deinitialize(LG_Renderer * renderer)
egl_desktopFree(&this->desktop); egl_desktopFree(&this->desktop);
egl_cursorFree (&this->cursor); egl_cursorFree (&this->cursor);
egl_splashFree (&this->splash);
egl_damageFree (&this->damage); egl_damageFree (&this->damage);
LG_LOCK_FREE(this->lock); LG_LOCK_FREE(this->lock);
@ -323,7 +316,6 @@ static void egl_onRestart(LG_Renderer * renderer)
eglDestroyContext(this->display, this->frameContext); eglDestroyContext(this->display, this->frameContext);
this->frameContext = NULL; this->frameContext = NULL;
this->start = false;
INTERLOCKED_SECTION(this->desktopDamageLock, { INTERLOCKED_SECTION(this->desktopDamageLock, {
this->desktopDamage[this->desktopDamageIdx].count = -1; this->desktopDamage[this->desktopDamageIdx].count = -1;
@ -592,8 +584,6 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int d
} }
ringbuffer_push(this->importTimings, &(float){ (nanotime() - start) * 1e-6f }); ringbuffer_push(this->importTimings, &(float){ (nanotime() - start) * 1e-6f });
this->start = true;
INTERLOCKED_SECTION(this->desktopDamageLock, { INTERLOCKED_SECTION(this->desktopDamageLock, {
struct DesktopDamage * damage = this->desktopDamage + this->desktopDamageIdx; struct DesktopDamage * damage = this->desktopDamage + this->desktopDamageIdx;
if (damage->count == -1 || damageRectsCount == 0 || if (damage->count == -1 || damageRectsCount == 0 ||
@ -928,12 +918,6 @@ static bool egl_renderStartup(LG_Renderer * renderer, bool useDMA)
return false; return false;
} }
if (!egl_splashInit(&this->splash))
{
DEBUG_ERROR("Failed to initialize the splash screen");
return false;
}
if (!egl_damageInit(&this->damage)) if (!egl_damageInit(&this->damage))
{ {
DEBUG_ERROR("Failed to initialize the damage display"); DEBUG_ERROR("Failed to initialize the damage display");
@ -954,8 +938,8 @@ static bool egl_renderStartup(LG_Renderer * renderer, bool useDMA)
static bool egl_needsRender(LG_Renderer * renderer) static bool egl_needsRender(LG_Renderer * renderer)
{ {
struct Inst * this = UPCAST(struct Inst, renderer); //struct Inst * this = UPCAST(struct Inst, renderer);
return !this->waitDone; return false;
} }
inline static EGLint egl_bufferAge(struct Inst * this) inline static EGLint egl_bufferAge(struct Inst * this)
@ -1012,7 +996,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
{ {
struct Inst * this = UPCAST(struct Inst, renderer); struct Inst * this = UPCAST(struct Inst, renderer);
EGLint bufferAge = egl_bufferAge(this); EGLint bufferAge = egl_bufferAge(this);
bool renderAll = invalidateWindow || !this->start || this->hadOverlay || bool renderAll = invalidateWindow || this->hadOverlay ||
bufferAge <= 0 || bufferAge > MAX_BUFFER_AGE || bufferAge <= 0 || bufferAge > MAX_BUFFER_AGE ||
this->showSpice; this->showSpice;
@ -1089,7 +1073,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
} }
++this->overlayHistoryIdx; ++this->overlayHistoryIdx;
if (this->start && this->destRect.w > 0 && this->destRect.h > 0) if (this->destRect.w > 0 && this->destRect.h > 0)
{ {
if (egl_desktopRender(this->desktop, if (egl_desktopRender(this->desktop,
this->destRect.w, this->destRect.h, this->destRect.w, this->destRect.h,
@ -1097,14 +1081,6 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
this->scaleX , this->scaleY , this->scaleX , this->scaleY ,
this->scaleType , rotate, renderAll ? NULL : accumulated)) this->scaleType , rotate, renderAll ? NULL : accumulated))
{ {
if (!this->waitFadeTime)
{
if (!this->params.quickSplash)
this->waitFadeTime = microtime() + SPLASH_FADE_TIME;
else
this->waitDone = true;
}
if (!this->showSpice) if (!this->showSpice)
cursorState = egl_cursorRender(this->cursor, cursorState = egl_cursorRender(this->cursor,
(this->format.rotate + rotate) % LG_ROTATE_MAX, (this->format.rotate + rotate) % LG_ROTATE_MAX,
@ -1116,35 +1092,6 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
renderLetterBox(this); renderLetterBox(this);
if (!this->waitDone)
{
float a = 1.0f;
if (!this->waitFadeTime)
a = 1.0f;
else
{
uint64_t t = microtime();
if (t > this->waitFadeTime)
this->waitDone = true;
else
{
uint64_t delta = this->waitFadeTime - t;
a = 1.0f / SPLASH_FADE_TIME * delta;
}
}
if (!this->waitDone)
{
egl_splashRender(this->splash, a, this->splashRatio);
hasOverlay = true;
}
}
else if (!this->start)
{
egl_splashRender(this->splash, 1.0f, this->splashRatio);
hasOverlay = true;
}
hasOverlay |= egl_damageRender(this->damage, rotate, newFrame ? desktopDamage : NULL); hasOverlay |= egl_damageRender(this->damage, rotate, newFrame ? desktopDamage : NULL);
hasOverlay |= invalidateWindow; hasOverlay |= invalidateWindow;
@ -1271,8 +1218,6 @@ static void egl_spiceShow(LG_Renderer * renderer, bool show)
struct Inst * this = UPCAST(struct Inst, renderer); struct Inst * this = UPCAST(struct Inst, renderer);
this->showSpice = show; this->showSpice = show;
egl_desktopSpiceShow(this->desktop, show); egl_desktopSpiceShow(this->desktop, show);
if (show)
this->start = true;
} }
struct LG_RendererOps LGR_EGL = struct LG_RendererOps LGR_EGL =

View file

@ -1,178 +0,0 @@
/**
* Looking Glass
* Copyright © 2017-2022 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 "splash.h"
#include "common/debug.h"
#include "draw.h"
#include "texture.h"
#include "shader.h"
#include "model.h"
#include <GLES3/gl3.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
// these headers are auto generated by cmake
#include "splash_bg.vert.h"
#include "splash_bg.frag.h"
#include "splash_logo.vert.h"
#include "splash_logo.frag.h"
struct EGL_Splash
{
EGL_Shader * bgShader;
EGL_Model * bg;
EGL_Shader * logoShader;
EGL_Model * logo;
// uniforms
GLint uScale;
};
bool egl_splashInit(EGL_Splash ** splash)
{
*splash = malloc(sizeof(**splash));
if (!*splash)
{
DEBUG_ERROR("Failed to malloc EGL_Splash");
return false;
}
memset(*splash, 0, sizeof(**splash));
if (!egl_shaderInit(&(*splash)->bgShader))
{
DEBUG_ERROR("Failed to initialize the splash bgShader");
return false;
}
if (!egl_shaderCompile((*splash)->bgShader,
b_shader_splash_bg_vert, b_shader_splash_bg_vert_size,
b_shader_splash_bg_frag, b_shader_splash_bg_frag_size))
{
DEBUG_ERROR("Failed to compile the splash bgShader");
return false;
}
if (!egl_modelInit(&(*splash)->bg))
{
DEBUG_ERROR("Failed to intiailize the splash bg model");
return false;
}
egl_modelSetDefault((*splash)->bg, false);
if (!egl_shaderInit(&(*splash)->logoShader))
{
DEBUG_ERROR("Failed to initialize the splash logoShader");
return false;
}
if (!egl_shaderCompile((*splash)->logoShader,
b_shader_splash_logo_vert, b_shader_splash_logo_vert_size,
b_shader_splash_logo_frag, b_shader_splash_logo_frag_size))
{
DEBUG_ERROR("Failed to compile the splash logoShader");
return false;
}
(*splash)->uScale = egl_shaderGetUniform((*splash)->logoShader, "scale");
if (!egl_modelInit(&(*splash)->logo))
{
DEBUG_ERROR("Failed to intiailize the splash model");
return false;
}
/* build the splash model */
#define P(x) ((1.0f/800.0f)*(float)(x))
egl_drawTorusArc((*splash)->logo, 30, P( 0 ), P(0), P(102), P(98), 0.0f, -M_PI);
egl_drawTorus ((*splash)->logo, 30, P(-100), P(8), P(8 ), P(4 ));
egl_drawTorus ((*splash)->logo, 30, P( 100), P(8), P(8 ), P(4 ));
egl_drawTorus ((*splash)->logo, 60, P(0), P(0), P(83), P(79));
egl_drawTorus ((*splash)->logo, 60, P(0), P(0), P(67), P(63));
static const GLfloat lines[][12] =
{
{
P( -2), P(-140), 0.0f,
P( -2), P(-100), 0.0f,
P( 2), P(-140), 0.0f,
P( 2), P(-100), 0.0f
},
{
P(-26), P(-144), 0.0f,
P(-26), P(-140), 0.0f,
P( 26), P(-144), 0.0f,
P( 26), P(-140), 0.0f
},
{
P(-40), P(-156), 0.0f,
P(-40), P(-152), 0.0f,
P( 40), P(-156), 0.0f,
P( 40), P(-152), 0.0f
}
};
egl_modelAddVerts((*splash)->logo, lines[0], NULL, 4);
egl_modelAddVerts((*splash)->logo, lines[1], NULL, 4);
egl_modelAddVerts((*splash)->logo, lines[2], NULL, 4);
egl_drawTorusArc((*splash)->logo, 10, P(-26), P(-154), P(10), P(14), M_PI , -M_PI / 2.0);
egl_drawTorusArc((*splash)->logo, 10, P( 26), P(-154), P(10), P(14), M_PI / 2.0f, -M_PI / 2.0);
#undef P
return true;
}
void egl_splashFree(EGL_Splash ** splash)
{
if (!*splash)
return;
egl_modelFree(&(*splash)->bg );
egl_modelFree(&(*splash)->logo);
egl_shaderFree(&(*splash)->bgShader );
egl_shaderFree(&(*splash)->logoShader);
free(*splash);
*splash = NULL;
}
void egl_splashRender(EGL_Splash * splash, float alpha, float scaleY)
{
glEnable(GL_BLEND);
glBlendColor(0, 0, 0, alpha);
glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
egl_shaderUse(splash->bgShader);
egl_modelRender(splash->bg);
egl_shaderUse(splash->logoShader);
glUniform1f(splash->uScale, scaleY);
egl_modelRender(splash->logo);
glDisable(GL_BLEND);
}

View file

@ -1,30 +0,0 @@
/**
* Looking Glass
* Copyright © 2017-2022 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>
typedef struct EGL_Splash EGL_Splash;
bool egl_splashInit(EGL_Splash ** splash);
void egl_splashFree(EGL_Splash ** splash);
void egl_splashRender(EGL_Splash * splash, float alpha, float scaleY);

View file

@ -45,8 +45,6 @@
#define SPICE_TEXTURE 2 #define SPICE_TEXTURE 2
#define TEXTURE_COUNT 3 #define TEXTURE_COUNT 3
#define FADE_TIME 1000000
static struct Option opengl_options[] = static struct Option opengl_options[] =
{ {
{ {
@ -147,11 +145,6 @@ struct Inst
GLsync fences[BUFFER_COUNT]; GLsync fences[BUFFER_COUNT];
GLuint textures[TEXTURE_COUNT]; GLuint textures[TEXTURE_COUNT];
bool start;
bool waiting;
uint64_t waitFadeTime;
bool waitDone;
LG_Lock mouseLock; LG_Lock mouseLock;
LG_RendererCursor mouseCursor; LG_RendererCursor mouseCursor;
int mouseWidth; int mouseWidth;
@ -182,7 +175,6 @@ static enum ConfigStatus configure(struct Inst * this);
static void updateMouseShape(struct Inst * this); static void updateMouseShape(struct Inst * this);
static bool drawFrame(struct Inst * this); static bool drawFrame(struct Inst * this);
static void drawMouse(struct Inst * this); static void drawMouse(struct Inst * this);
static void renderWait(struct Inst * this);
const char * opengl_getName(void) const char * opengl_getName(void)
{ {
@ -222,10 +214,7 @@ bool opengl_create(LG_Renderer ** renderer, const LG_RendererParams params,
bool opengl_initialize(LG_Renderer * renderer) bool opengl_initialize(LG_Renderer * renderer)
{ {
struct Inst * this = UPCAST(struct Inst, renderer); // struct Inst * this = UPCAST(struct Inst, renderer);
this->waiting = true;
this->waitDone = false;
return true; return true;
} }
@ -268,10 +257,7 @@ void opengl_deinitialize(LG_Renderer * renderer)
void opengl_onRestart(LG_Renderer * renderer) void opengl_onRestart(LG_Renderer * renderer)
{ {
struct Inst * this = UPCAST(struct Inst, renderer); // struct Inst * this = UPCAST(struct Inst, renderer);
this->waiting = true;
this->start = false;
} }
static void setupModelView(struct Inst * this) static void setupModelView(struct Inst * this)
@ -401,7 +387,6 @@ bool opengl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFd
atomic_store_explicit(&this->frameUpdate, true, memory_order_release); atomic_store_explicit(&this->frameUpdate, true, memory_order_release);
LG_UNLOCK(this->frameLock); LG_UNLOCK(this->frameLock);
this->start = true;
return true; return true;
} }
@ -490,8 +475,8 @@ bool opengl_renderStartup(LG_Renderer * renderer, bool useDMA)
static bool opengl_needsRender(LG_Renderer * renderer) static bool opengl_needsRender(LG_Renderer * renderer)
{ {
struct Inst * this = UPCAST(struct Inst, renderer); // struct Inst * this = UPCAST(struct Inst, renderer);
return !this->waitDone; return false;
} }
bool opengl_render(LG_Renderer * renderer, LG_RendererRotate rotate, const bool newFrame, bool opengl_render(LG_Renderer * renderer, LG_RendererRotate rotate, const bool newFrame,
@ -501,18 +486,6 @@ bool opengl_render(LG_Renderer * renderer, LG_RendererRotate rotate, const bool
setupModelView(this); setupModelView(this);
if (this->start && this->waiting)
{
this->waiting = false;
if (!this->params.quickSplash)
this->waitFadeTime = microtime() + FADE_TIME;
else
{
glDisable(GL_MULTISAMPLE);
this->waitDone = true;
}
}
switch(configure(this)) switch(configure(this))
{ {
case CONFIG_STATUS_ERROR: case CONFIG_STATUS_ERROR:
@ -528,10 +501,6 @@ bool opengl_render(LG_Renderer * renderer, LG_RendererRotate rotate, const bool
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
if (this->waiting)
renderWait(this);
else
{
if (this->spiceShow) if (this->spiceShow)
glCallList(this->spiceList); glCallList(this->spiceList);
else else
@ -541,10 +510,6 @@ bool opengl_render(LG_Renderer * renderer, LG_RendererRotate rotate, const bool
drawMouse(this); drawMouse(this);
} }
if (!this->waitDone)
renderWait(this);
}
if (app_renderOverlay(NULL, 0) != 0) if (app_renderOverlay(NULL, 0) != 0)
{ {
ImGui_ImplOpenGL2_NewFrame(); ImGui_ImplOpenGL2_NewFrame();
@ -564,105 +529,6 @@ bool opengl_render(LG_Renderer * renderer, LG_RendererRotate rotate, const bool
return true; return true;
} }
static void drawTorus(float x, float y, float inner, float outer,
unsigned int pts)
{
glBegin(GL_QUAD_STRIP);
for (unsigned int i = 0; i <= pts; ++i)
{
float angle = (i / (float)pts) * M_PI * 2.0f;
glVertex2f(x + (inner * cos(angle)), y + (inner * sin(angle)));
glVertex2f(x + (outer * cos(angle)), y + (outer * sin(angle)));
}
glEnd();
}
static void drawTorusArc(float x, float y, float inner, float outer,
unsigned int pts, float s, float e)
{
glBegin(GL_QUAD_STRIP);
for (unsigned int i = 0; i <= pts; ++i)
{
float angle = s + ((i / (float)pts) * e);
glVertex2f(x + (inner * cos(angle)), y + (inner * sin(angle)));
glVertex2f(x + (outer * cos(angle)), y + (outer * sin(angle)));
}
glEnd();
}
static void renderWait(struct Inst * this)
{
float a;
if (this->waiting)
a = 1.0f;
else
{
if (this->waitDone)
return;
uint64_t t = microtime();
if (t > this->waitFadeTime)
{
glDisable(GL_MULTISAMPLE);
this->waitDone = true;
return;
}
uint64_t delta = this->waitFadeTime - t;
a = 1.0f / FADE_TIME * delta;
}
glEnable(GL_BLEND);
glPushMatrix();
glLoadIdentity();
glTranslatef(this->window.x / 2.0f, this->window.y / 2.0f, 0.0f);
//draw the background gradient
glBegin(GL_TRIANGLE_FAN);
glColor4f(0.234375f, 0.015625f, 0.425781f, a);
glVertex2f(0, 0);
glColor4f(0, 0, 0, a);
for (unsigned int i = 0; i <= 100; ++i)
{
float angle = (i / (float)100) * M_PI * 2.0f;
glVertex2f(cos(angle) * this->window.x, sin(angle) * this->window.y);
}
glEnd();
// draw the logo
glColor4f(1.0f, 1.0f, 1.0f, a);
glScalef (2.0f, 2.0f, 1.0f);
drawTorus ( 0, 0, 40, 42, 60);
drawTorus ( 0, 0, 32, 34, 60);
drawTorus (-50, -3, 2, 4, 30);
drawTorus ( 50, -3, 2, 4, 30);
drawTorusArc( 0, 0, 51, 49, 60, 0.0f, M_PI);
glBegin(GL_QUADS);
glVertex2f(-1 , 50);
glVertex2f(-1 , 76);
glVertex2f( 1 , 76);
glVertex2f( 1 , 50);
glVertex2f(-14, 76);
glVertex2f(-14, 78);
glVertex2f( 14, 78);
glVertex2f( 14, 76);
glVertex2f(-21, 83);
glVertex2f(-21, 85);
glVertex2f( 21, 85);
glVertex2f( 21, 83);
glEnd();
drawTorusArc(-14, 83, 5, 7, 10, M_PI , M_PI / 2.0f);
drawTorusArc( 14, 83, 5, 7, 10, M_PI * 1.5f, M_PI / 2.0f);
//FIXME: draw the diagonal marks on the circle
glPopMatrix();
glDisable(GL_BLEND);
}
static void * opengl_createTexture(LG_Renderer * renderer, static void * opengl_createTexture(LG_Renderer * renderer,
int width, int height, uint8_t * data) int width, int height, uint8_t * data)
{ {
@ -811,8 +677,6 @@ static void opengl_spiceShow(LG_Renderer * renderer, bool show)
{ {
struct Inst * this = UPCAST(struct Inst, renderer); struct Inst * this = UPCAST(struct Inst, renderer);
this->spiceShow = show; this->spiceShow = show;
if (show)
this->start = true;
} }
const LG_RendererOps LGR_OpenGL = const LG_RendererOps LGR_OpenGL =

View file

@ -1066,6 +1066,7 @@ void app_useSpiceDisplay(bool enable)
{ {
purespice_connectChannel(PS_CHANNEL_DISPLAY); purespice_connectChannel(PS_CHANNEL_DISPLAY);
renderQueue_spiceShow(true); renderQueue_spiceShow(true);
overlaySplash_show(false);
} }
else else
{ {

View file

@ -192,7 +192,7 @@ static int renderThread(void * unused)
} }
LGTimer * tickTimer; LGTimer * tickTimer;
if (!lgCreateTimer(40, tickTimerFn, NULL, &tickTimer)) if (!lgCreateTimer(1000 / TICK_RATE, tickTimerFn, NULL, &tickTimer))
{ {
lgTimerDestroy(fpsTimer); lgTimerDestroy(fpsTimer);
DEBUG_ERROR("Failed to create the tick timer"); DEBUG_ERROR("Failed to create the tick timer");
@ -779,6 +779,8 @@ int main_frameThread(void * unused)
break; break;
} }
overlaySplash_show(false);
if (frame->flags & FRAME_FLAG_REQUEST_ACTIVATION) if (frame->flags & FRAME_FLAG_REQUEST_ACTIVATION)
g_state.ds->requestActivation(); g_state.ds->requestActivation();
@ -821,7 +823,10 @@ int main_frameThread(void * unused)
RENDERER(onRestart); RENDERER(onRestart);
if (g_state.state != APP_STATE_SHUTDOWN) if (g_state.state != APP_STATE_SHUTDOWN)
{
overlaySplash_show(true);
app_useSpiceDisplay(true); app_useSpiceDisplay(true);
}
if (g_state.useDMA) if (g_state.useDMA)
{ {
@ -1719,6 +1724,7 @@ int main(int argc, char * argv[])
gl_dynProcsInit(); gl_dynProcsInit();
g_state.overlays = ll_new(); g_state.overlays = ll_new();
app_registerOverlay(&LGOverlaySplash, NULL);
app_registerOverlay(&LGOverlayConfig, NULL); app_registerOverlay(&LGOverlayConfig, NULL);
app_registerOverlay(&LGOverlayAlert , NULL); app_registerOverlay(&LGOverlayAlert , NULL);
app_registerOverlay(&LGOverlayFPS , NULL); app_registerOverlay(&LGOverlayFPS , NULL);

171
client/src/overlay/splash.c Normal file
View file

@ -0,0 +1,171 @@
/**
* Looking Glass
* Copyright © 2017-2022 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 "interface/overlay.h"
#include "cimgui.h"
#include "../overlays.h"
#include "../main.h"
#include "overlay_utils.h"
#include "resources/lg-logo.svg.h"
#include <math.h>
#include <GL/gl.h>
static bool l_show;
static bool l_fadeDone;
static float l_alpha;
static OverlayImage l_logo;
static bool splash_init(void ** udata, const void * params)
{
l_show = true;
l_fadeDone = false;
l_alpha = 1.0f;
overlayLoadSVG(b_lg_logo_svg, b_lg_logo_svg_size, &l_logo, 200, 200);
return true;
}
static void splash_free(void * udata)
{
overlayFreeImage(&l_logo);
}
static void drawRadialGradient(ImDrawList * list, int x, int y, int w, int h,
int steps, ImU32 innerColor, ImU32 outerColor)
{
const ImVec2 uv = list->_Data->TexUvWhitePixel;
ImDrawList_PrimReserve(list, steps * 3, steps + 2);
for(int i = 0; i < steps; ++i)
{
ImDrawList_PrimWriteIdx(list, list->_VtxCurrentIdx);
ImDrawList_PrimWriteIdx(list, list->_VtxCurrentIdx + i + 1);
ImDrawList_PrimWriteIdx(list, list->_VtxCurrentIdx + i + 2);
}
ImDrawList_PrimWriteVtx(list,
(ImVec2){x, y},
uv,
innerColor);
for (unsigned int i = 0; i < steps + 1; ++i)
{
float angle = (i / (float)steps) * M_PI * 2.0f;
ImDrawList_PrimWriteVtx(list,
(ImVec2){
x + cos(angle) * w,
y + sin(angle) * h
},
uv,
outerColor);
}
}
static int splash_render(void * udata, bool interactive, struct Rect * windowRects,
int maxRects)
{
if (!l_show && l_fadeDone)
return 0;
const float alpha = l_fadeDone ? 1.0f : l_alpha;
ImVec2 * screen = overlayGetScreenSize();
ImDrawList * list = igGetBackgroundDrawList_Nil();
struct Rect rect = {
.x = 0,
.y = 0,
.w = screen->x,
.h = screen->y
};
struct Rect logoRect = {
.x = screen->x / 2 - l_logo.width / 2,
.y = screen->y / 2 - l_logo.height / 2,
.w = l_logo.width,
.h = l_logo.height
};
const ImU32 innerColor = igColorConvertFloat4ToU32((ImVec4){
0.234375f, 0.015625f, 0.425781f, alpha});
const ImU32 outerColor = igColorConvertFloat4ToU32((ImVec4){
0.0f, 0.0f, 0.0f, alpha});
const ImU32 imageColor = igColorConvertFloat4ToU32((ImVec4){
1.0f, 1.0f, 1.0f, alpha});
drawRadialGradient(list,
screen->x / 2, screen->y / 2,
screen->x , screen->y ,
12,
innerColor,
outerColor);
ImDrawList_AddImage(
list,
l_logo.tex,
(ImVec2){
logoRect.x,
logoRect.y
},
(ImVec2){
logoRect.x + logoRect.w,
logoRect.y + logoRect.h
},
(ImVec2){ 0, 0 },
(ImVec2){ 1, 1 },
imageColor);
*windowRects = rect;
return 1;
}
static bool splash_tick(void * udata, unsigned long long tickCount)
{
if (!l_show && l_alpha > 0.0f)
{
l_alpha -= 1.0f / TICK_RATE;
if (l_alpha <= 0.0f)
l_fadeDone = true;
return true;
}
return false;
}
struct LG_OverlayOps LGOverlaySplash =
{
.name = "splash",
.init = splash_init,
.free = splash_free,
.render = splash_render,
.tick = splash_tick,
};
void overlaySplash_show(bool show)
{
if (l_show == show)
return;
l_show = show;
app_invalidateOverlay(true);
}

View file

@ -33,6 +33,7 @@ struct Overlay
struct Rect lastRects[MAX_OVERLAY_RECTS]; struct Rect lastRects[MAX_OVERLAY_RECTS];
}; };
extern struct LG_OverlayOps LGOverlaySplash;
extern struct LG_OverlayOps LGOverlayAlert; extern struct LG_OverlayOps LGOverlayAlert;
extern struct LG_OverlayOps LGOverlayFPS; extern struct LG_OverlayOps LGOverlayFPS;
extern struct LG_OverlayOps LGOverlayGraphs; extern struct LG_OverlayOps LGOverlayGraphs;
@ -64,6 +65,7 @@ typedef enum LG_UserStatus
} }
LGUserStatus; LGUserStatus;
void overlaySplash_show(bool show);
void overlayStatus_set(LGUserStatus, bool value); void overlayStatus_set(LGUserStatus, bool value);
#endif #endif

View file

@ -15,6 +15,7 @@ function(build_resources)
endfunction() endfunction()
build_resources( build_resources(
lg-logo.svg
status/spice.svg status/spice.svg
status/recording.svg status/recording.svg
) )

View file

@ -4,15 +4,8 @@
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="2.20719in" height="2.69741in" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="2.20719in" height="2.69741in" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 2207 2697" viewBox="0 0 2207 2697"
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css">
<![CDATA[
.fil0 {fill:white}
]]>
</style>
</defs>
<g id="Layer_x0020_1"> <g id="Layer_x0020_1">
<metadata id="CorelCorpID_0Corel-Layer"/> <metadata id="CorelCorpID_0Corel-Layer"/>
<path class="fil0" d="M1104 0c-483,0 -874,391 -874,874 0,483 391,874 874,874 483,0 874,-391 874,-874 0,-483 -392,-874 -874,-874zm-448 2642l895 0c-9,-31 -38,-79 -140,-82l0 0 -637 0c-12,1 -93,11 -118,82zm926 56l-960 0 -30 0 3 -30c14,-153 177,-163 177,-163l2 0 298 0 0 -581c-563,-17 -1016,-481 -1016,-1048 0,-3 0,-5 0,-8 -32,-14 -55,-47 -55,-84 0,-51 41,-92 92,-92 51,0 92,41 92,92 0,38 -22,70 -55,84 0,3 0,5 0,8 0,537 437,974 974,974 537,0 974,-437 974,-974 0,-3 0,-5 0,-8 -32,-14 -55,-47 -55,-84 0,-51 41,-92 92,-92 51,0 92,41 92,92 0,38 -22,70 -55,84 0,3 0,5 0,8 0,569 -455,1033 -1021,1048l0 581 279 0 1 0c210,7 198,167 198,167l-2 26 -26 0zm68 -1916l0 0c-12,-13 -32,-13 -45,-1l-32 30c-13,12 -13,32 -1,45l0 0c12,13 32,13 45,1l32 -30c13,-12 13,-32 1,-45zm-112 266l0 0c-12,-13 -32,-13 -45,-1l-206 193c-13,12 -13,32 -1,45l0 0c12,13 32,13 45,1l206 -193c13,-12 13,-32 1,-45zm14 -175l0 0c-12,-13 -32,-13 -45,-1l-206 193c-13,12 -13,32 -1,45l0 0c12,13 32,13 45,1l206 -193c13,-12 13,-32 1,-45zm-846 -158l0 0c-12,-12 -12,-32 0,-45l200 -200c12,-12 32,-12 45,0l0 0c12,12 12,32 0,45l-200 200c-12,12 -32,12 -45,0zm43 115l0 0c-12,-12 -12,-32 0,-45l134 -134c12,-12 32,-12 45,0l0 0c12,12 12,32 0,45l-134 134c-12,12 -32,12 -45,0zm-137 -21l0 0c-12,-12 -12,-32 0,-45l31 -31c12,-12 32,-12 45,0l0 0c12,12 12,32 0,45l-31 31c-12,12 -32,12 -45,0zm1503 11c-21,0 -37,-17 -37,-37 0,-21 17,-37 37,-37 21,0 37,17 37,37 0,21 -17,37 -37,37zm-2023 0c-21,0 -37,-17 -37,-37 0,-21 17,-37 37,-37 21,0 37,17 37,37 0,21 -17,37 -37,37zm1012 -665c-397,0 -720,323 -720,720 0,397 323,720 720,720 397,0 720,-323 720,-720 0,-397 -323,-720 -720,-720zm0 1375c-361,0 -655,-294 -655,-655 0,-361 294,-655 655,-655 361,0 655,294 655,655 0,361 -294,655 -655,655zm0 154c-446,0 -810,-363 -810,-810 0,-446 363,-810 810,-810 446,0 810,363 810,810 0,446 -363,810 -810,810z"/> <path style="fill:#FFFFFF;" d="M1104 0c-483,0 -874,391 -874,874 0,483 391,874 874,874 483,0 874,-391 874,-874 0,-483 -392,-874 -874,-874zm-448 2642l895 0c-9,-31 -38,-79 -140,-82l0 0 -637 0c-12,1 -93,11 -118,82zm926 56l-960 0 -30 0 3 -30c14,-153 177,-163 177,-163l2 0 298 0 0 -581c-563,-17 -1016,-481 -1016,-1048 0,-3 0,-5 0,-8 -32,-14 -55,-47 -55,-84 0,-51 41,-92 92,-92 51,0 92,41 92,92 0,38 -22,70 -55,84 0,3 0,5 0,8 0,537 437,974 974,974 537,0 974,-437 974,-974 0,-3 0,-5 0,-8 -32,-14 -55,-47 -55,-84 0,-51 41,-92 92,-92 51,0 92,41 92,92 0,38 -22,70 -55,84 0,3 0,5 0,8 0,569 -455,1033 -1021,1048l0 581 279 0 1 0c210,7 198,167 198,167l-2 26 -26 0zm68 -1916l0 0c-12,-13 -32,-13 -45,-1l-32 30c-13,12 -13,32 -1,45l0 0c12,13 32,13 45,1l32 -30c13,-12 13,-32 1,-45zm-112 266l0 0c-12,-13 -32,-13 -45,-1l-206 193c-13,12 -13,32 -1,45l0 0c12,13 32,13 45,1l206 -193c13,-12 13,-32 1,-45zm14 -175l0 0c-12,-13 -32,-13 -45,-1l-206 193c-13,12 -13,32 -1,45l0 0c12,13 32,13 45,1l206 -193c13,-12 13,-32 1,-45zm-846 -158l0 0c-12,-12 -12,-32 0,-45l200 -200c12,-12 32,-12 45,0l0 0c12,12 12,32 0,45l-200 200c-12,12 -32,12 -45,0zm43 115l0 0c-12,-12 -12,-32 0,-45l134 -134c12,-12 32,-12 45,0l0 0c12,12 12,32 0,45l-134 134c-12,12 -32,12 -45,0zm-137 -21l0 0c-12,-12 -12,-32 0,-45l31 -31c12,-12 32,-12 45,0l0 0c12,12 12,32 0,45l-31 31c-12,12 -32,12 -45,0zm1503 11c-21,0 -37,-17 -37,-37 0,-21 17,-37 37,-37 21,0 37,17 37,37 0,21 -17,37 -37,37zm-2023 0c-21,0 -37,-17 -37,-37 0,-21 17,-37 37,-37 21,0 37,17 37,37 0,21 -17,37 -37,37zm1012 -665c-397,0 -720,323 -720,720 0,397 323,720 720,720 397,0 720,-323 720,-720 0,-397 -323,-720 -720,-720zm0 1375c-361,0 -655,-294 -655,-655 0,-361 294,-655 655,-655 361,0 655,294 655,655 0,361 -294,655 -655,655zm0 154c-446,0 -810,-363 -810,-810 0,-446 363,-810 810,-810 446,0 810,363 810,810 0,446 -363,810 -810,810z"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB