[client] renderers: treat -1 as full damage and 0 as no overlay

This makes everything consistent.
This commit is contained in:
Quantum 2021-07-22 04:53:21 -04:00 committed by Geoffrey McRae
parent 4c60409aaf
commit 947eac52f6
4 changed files with 16 additions and 18 deletions

View File

@ -85,8 +85,8 @@ void app_registerOverlay(const struct LG_OverlayOps * ops, void * params);
/** /**
* render the overlay * render the overlay
* returns: * returns:
* -1 for no overlay * -1 for full output damage
* 0 for full output damage * 0 for no overlay
* >0 number of rects written into rects * >0 number of rects written into rects
*/ */
int app_renderOverlay(struct Rect * rects, int maxRects); int app_renderOverlay(struct Rect * rects, int maxRects);

View File

@ -1010,22 +1010,20 @@ bool egl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame)
struct Rect damage[KVMFR_MAX_DAMAGE_RECTS + 12]; struct Rect damage[KVMFR_MAX_DAMAGE_RECTS + 12];
int damageIdx = app_renderOverlay(damage, 10); int damageIdx = app_renderOverlay(damage, 10);
// if no overlay switch (damageIdx)
if (damageIdx == -1)
{ {
case 0: // no overlay
break;
case -1: // full damage
hasOverlay = true;
damageIdx = 0; damageIdx = 0;
} // fallthrough
else default:
{
ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
for (int i = 0; i < damageIdx; ++i) for (int i = 0; i < damageIdx; ++i)
damage[i].y = this->height - damage[i].y - damage[i].h; damage[i].y = this->height - damage[i].y - damage[i].h;
// if there were too many rects invalidate the entire window
if (damageIdx == 0)
hasOverlay = true;
} }
if (!hasOverlay && !this->hadOverlay) if (!hasOverlay && !this->hadOverlay)

View File

@ -686,7 +686,7 @@ bool opengl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame)
break; break;
} }
if (app_renderOverlay(NULL, 0) > -1) if (app_renderOverlay(NULL, 0) != 0)
{ {
ImGui_ImplOpenGL2_NewFrame(); ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplOpenGL2_RenderDrawData(igGetDrawData()); ImGui_ImplOpenGL2_RenderDrawData(igGetDrawData());

View File

@ -662,7 +662,7 @@ int app_renderOverlay(struct Rect * rects, int maxRects)
const int written = const int written =
overlay->ops->render(overlay->udata, false, rects, maxRects); overlay->ops->render(overlay->udata, false, rects, maxRects);
if (!totalDamage) if (totalDamage)
continue; continue;
if (written == -1) if (written == -1)