mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-04 06:12:04 +00:00
[client] round overlay damage outward
Expand ImGui window damage to include its border and round both logical window bounds and framebuffer-scaled bounds outward. This prevents a one-pixel strip of stale desktop content when an overlay window is resized at fractional positions or display scales.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include "kb.h"
|
#include "kb.h"
|
||||||
|
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
|
#include "common/rects.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
#include "interface/overlay.h"
|
#include "interface/overlay.h"
|
||||||
#include "overlays.h"
|
#include "overlays.h"
|
||||||
@@ -1073,12 +1074,7 @@ render_again:
|
|||||||
buffer, MAX_OVERLAY_RECTS);
|
buffer, MAX_OVERLAY_RECTS);
|
||||||
|
|
||||||
for (int i = 0; i < written; ++i)
|
for (int i = 0; i < written; ++i)
|
||||||
{
|
rectScaleOutward(buffer + i, g_state.windowScale);
|
||||||
buffer[i].x *= g_state.windowScale;
|
|
||||||
buffer[i].y *= g_state.windowScale;
|
|
||||||
buffer[i].w *= g_state.windowScale;
|
|
||||||
buffer[i].h *= g_state.windowScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// It is an error to run out of rectangles, because we will not be able to
|
// It is an error to run out of rectangles, because we will not be able to
|
||||||
// correctly calculate the damage of the next frame.
|
// correctly calculate the damage of the next frame.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "overlay_utils.h"
|
#include "overlay_utils.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "common/open.h"
|
#include "common/open.h"
|
||||||
@@ -41,13 +42,19 @@
|
|||||||
|
|
||||||
void overlayGetImGuiRect(struct Rect * rect)
|
void overlayGetImGuiRect(struct Rect * rect)
|
||||||
{
|
{
|
||||||
ImVec2 pos = igGetWindowPos();
|
const ImVec2 pos = igGetWindowPos();
|
||||||
ImVec2 size = igGetWindowSize();
|
const ImVec2 size = igGetWindowSize();
|
||||||
|
const float border = igGetStyle()->WindowBorderSize;
|
||||||
|
const float margin = border > 1.0f ? border : 1.0f;
|
||||||
|
const int left = (int)floorf(pos.x - margin);
|
||||||
|
const int top = (int)floorf(pos.y - margin);
|
||||||
|
const int right = (int)ceilf(pos.x + size.x + margin);
|
||||||
|
const int bottom = (int)ceilf(pos.y + size.y + margin);
|
||||||
|
|
||||||
rect->x = pos.x;
|
rect->x = left;
|
||||||
rect->y = pos.y;
|
rect->y = top;
|
||||||
rect->w = size.x;
|
rect->w = right - left;
|
||||||
rect->h = size.y;
|
rect->h = bottom - top;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 * overlayGetScreenSize(void)
|
ImVec2 * overlayGetScreenSize(void)
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ extern void (*rectCopyUnaligned)(
|
|||||||
uint8_t *restrict dst, const uint8_t *restrict src,
|
uint8_t *restrict dst, const uint8_t *restrict src,
|
||||||
int ystart, int yend, int dx, int dstPitch, int srcPitch, int width);
|
int ystart, int yend, int dx, int dstPitch, int srcPitch, int width);
|
||||||
|
|
||||||
|
void rectScaleOutward(struct Rect * rect, double scale);
|
||||||
|
|
||||||
void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, int bpp,
|
void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, int bpp,
|
||||||
FrameBuffer * frame, int dstPitch, int height,
|
FrameBuffer * frame, int dstPitch, int height,
|
||||||
const uint8_t * src, int srcPitch);
|
const uint8_t * src, int srcPitch);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/cpuinfo.h"
|
#include "common/cpuinfo.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
|
||||||
@@ -38,6 +39,19 @@ struct Edge
|
|||||||
int delta;
|
int delta;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void rectScaleOutward(struct Rect * rect, double scale)
|
||||||
|
{
|
||||||
|
const int left = (int)floor(rect->x * scale);
|
||||||
|
const int top = (int)floor(rect->y * scale);
|
||||||
|
const int right = (int)ceil(((double)rect->x + rect->w) * scale);
|
||||||
|
const int bottom = (int)ceil(((double)rect->y + rect->h) * scale);
|
||||||
|
|
||||||
|
rect->x = left;
|
||||||
|
rect->y = top;
|
||||||
|
rect->w = right - left;
|
||||||
|
rect->h = bottom - top;
|
||||||
|
}
|
||||||
|
|
||||||
inline static bool rectIntersects(const FrameDamageRect * r1,
|
inline static bool rectIntersects(const FrameDamageRect * r1,
|
||||||
const FrameDamageRect * r2)
|
const FrameDamageRect * r2)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user