mirror of
https://dev.lirent.ru/Vatrog/vm-vgpu-streamer.git
synced 2026-07-09 21:36:37 +03:00
feat: add graphics-context sensors to producer contract
Append three host-readable sensor groups to the producer block, ABI
frozen by offset asserts (producer still fits page 0):
- cursor Tier-1 (hotspot, glyph dims, shape identity), published under
the existing cursor_seq gate
- content_change_ns: monotonic stamp of the last scene-content change
- display geometry on its own cache line under a geom_seq seqlock:
virtual-desktop bbox, captured-output origin, DPI, refresh
Source the cursor from each backend's existing grab metadata instead of
polling GetCursorInfo in the present pump: DDA from the duplication frame
info pointer position (no extra calls), NvFBC visibility from the grab
info plus one GetCursorInfo per frame for position, GDI from
GetCursorInfo. Position sampling now rides the frame rate, not the pump
tick.
Sample display geometry once at startup and re-sample only on backend
session recreate or a captured-mode change. Drop per-tick cursor
sampling (cursor_sample_pos) from the present loop.
Add src/stream/win32/geometry.{c,h}.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include "cursor.h"
|
||||
#include "vgpu_stream.h" /* VGPU_CURSOR_ID_* */
|
||||
|
||||
/* Max supported cursor glyph; buffers are pre-arena'd in ctx (no heap here). */
|
||||
#define VGPU_CURSOR_MAX 256
|
||||
@@ -85,6 +86,42 @@ static void extract(vgpu_ctx* ctx, HCURSOR hc) {
|
||||
if (ii.hbmMask) DeleteObject(ii.hbmMask);
|
||||
}
|
||||
|
||||
int cursor_resolve_id(HCURSOR hc) {
|
||||
/* System-cursor table loaded once (IDC_* are stable per session). Lazy: built on first
|
||||
* call, then a linear handle compare. UNKNOWN for custom/unrecognized cursors. */
|
||||
static const struct { LPCTSTR idc; int id; } kSpec[] = {
|
||||
{ IDC_ARROW, VGPU_CURSOR_ID_ARROW },
|
||||
{ IDC_IBEAM, VGPU_CURSOR_ID_IBEAM },
|
||||
{ IDC_WAIT, VGPU_CURSOR_ID_WAIT },
|
||||
{ IDC_CROSS, VGPU_CURSOR_ID_CROSS },
|
||||
{ IDC_HAND, VGPU_CURSOR_ID_HAND },
|
||||
{ IDC_SIZENS, VGPU_CURSOR_ID_SIZENS },
|
||||
{ IDC_SIZEWE, VGPU_CURSOR_ID_SIZEWE },
|
||||
{ IDC_SIZENWSE, VGPU_CURSOR_ID_SIZENWSE },
|
||||
{ IDC_SIZENESW, VGPU_CURSOR_ID_SIZENESW },
|
||||
{ IDC_SIZEALL, VGPU_CURSOR_ID_SIZEALL },
|
||||
{ IDC_NO, VGPU_CURSOR_ID_NO },
|
||||
{ IDC_APPSTARTING, VGPU_CURSOR_ID_APPSTARTING },
|
||||
};
|
||||
enum { N = (int)(sizeof kSpec / sizeof kSpec[0]) };
|
||||
static HCURSOR cache[N];
|
||||
static int loaded = 0;
|
||||
if (!loaded) {
|
||||
for (int i = 0; i < N; i++) cache[i] = LoadCursor(NULL, kSpec[i].idc);
|
||||
loaded = 1;
|
||||
}
|
||||
if (!hc) return VGPU_CURSOR_ID_UNKNOWN;
|
||||
for (int i = 0; i < N; i++)
|
||||
if (cache[i] == hc) return kSpec[i].id;
|
||||
return VGPU_CURSOR_ID_UNKNOWN;
|
||||
}
|
||||
|
||||
void cursor_apply_shape(vgpu_ctx* ctx, HCURSOR hc) {
|
||||
extract(ctx, hc);
|
||||
ctx->cursor.cursor_id = cursor_resolve_id(hc);
|
||||
ctx->cursor.handle = hc;
|
||||
}
|
||||
|
||||
int cursor_sample(vgpu_ctx* ctx) {
|
||||
vgpu_cursor_t* cur = &ctx->cursor;
|
||||
CURSORINFO ci; ci.cbSize = sizeof ci;
|
||||
@@ -99,21 +136,13 @@ int cursor_sample(vgpu_ctx* ctx) {
|
||||
|| (ci.hCursor != cur->handle);
|
||||
if (vis && ci.hCursor && ci.hCursor != cur->handle) {
|
||||
extract(ctx, ci.hCursor);
|
||||
cur->cursor_id = cursor_resolve_id(ci.hCursor);
|
||||
cur->handle = ci.hCursor;
|
||||
}
|
||||
cur->visible = vis; cur->x = x; cur->y = y;
|
||||
return changed;
|
||||
}
|
||||
|
||||
void cursor_sample_pos(vgpu_ctx* ctx) {
|
||||
vgpu_cursor_t* cur = &ctx->cursor;
|
||||
CURSORINFO ci; ci.cbSize = sizeof ci;
|
||||
if (!GetCursorInfo(&ci)) { cur->visible = 0; return; }
|
||||
cur->visible = (ci.flags & CURSOR_SHOWING) != 0;
|
||||
cur->x = ci.ptScreenPos.x;
|
||||
cur->y = ci.ptScreenPos.y;
|
||||
}
|
||||
|
||||
void cursor_draw(vgpu_ctx* ctx, uint8_t* dst, uint32_t W, uint32_t H) {
|
||||
vgpu_cursor_t* cur = &ctx->cursor;
|
||||
if (!cur->visible || cur->gw == 0) return;
|
||||
|
||||
Reference in New Issue
Block a user