[repos] lgprotocol: import shared protocol definitions
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled

Add LGProtocol as a pinned submodule and consume its KVMFR protocol
definitions throughout the client, host, IDD, OBS, and profiler.

Keep Looking Glass framebuffer helpers local while removing duplicated
protocol headers and migrating users to KVMFR-scoped types.
This commit is contained in:
Geoffrey McRae
2026-09-01 20:58:25 +10:00
parent 8e43d41873
commit 8fbe3e7454
94 changed files with 619 additions and 2062 deletions

View File

@@ -33,7 +33,7 @@
#include "core/clipboard_files.h"
#include "common/countedbuffer.h"
#include "common/debug.h"
#include "common/KVMFRClipboard.h"
#include <LGProtocol/KVMFRClipboard.h>
struct DataOffer {
bool isSelfCopy;

View File

@@ -35,7 +35,7 @@
#include "app.h"
#include "egl_dynprocs.h"
#include "common/KVMFRClipboard.h"
#include <LGProtocol/KVMFRClipboard.h>
#include "common/locking.h"
#include "common/ringbuffer.h"
#include "interface/displayserver.h"

View File

@@ -32,7 +32,7 @@
#include "core/clipboard_files.h"
#include "common/array.h"
#include "common/debug.h"
#include "common/KVMFRClipboard.h"
#include <LGProtocol/KVMFRClipboard.h>
#include "common/locking.h"
struct X11ClipboardRead

View File

@@ -75,7 +75,7 @@ LG_RendererRotate;
typedef struct LG_RendererFormat
{
FrameType type; // frame type
KVMFRFrameType type; // frame type
bool hdr; // if the frame is HDR or not
bool hdrPQ; // if the HDR content is PQ mapped
bool hdrMetadata; // if the HDR static metadata is valid
@@ -286,7 +286,7 @@ typedef struct LG_RendererOps
/* optional display calibration update for hardware cursor composition
* Context: cursorThread */
void (*onMouseColorTransform)(LG_Renderer * renderer,
const LGColorTransform * transform);
const KVMFRColorTransform * transform);
/* updates the cursor-specific SDR white level reported by IddCx
* Context: cursorThread */
@@ -307,8 +307,8 @@ typedef struct LG_RendererOps
* when that update is consumed. A non-NULL releaseFn transfers ownership to
* the renderer on success and must be called exactly once when the imported
* frame can no longer be sampled. Context: frameThread */
bool (*onFrame)(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFD,
const FrameDamageRect * damage, int damageCount,
bool (*onFrame)(LG_Renderer * renderer, const KVMFRFrameBuffer * frame,
int dmaFD, const KVMFRFrameDamageRect * damage, int damageCount,
LG_RendererFrameToken frameToken,
LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle);

View File

@@ -202,17 +202,17 @@ LG_TransportFrameTiming;
typedef struct LG_TransportFrameFormat
{
uint32_t version;
FrameType type;
uint32_t screenWidth;
uint32_t screenHeight;
uint32_t dataWidth;
uint32_t dataHeight;
uint32_t frameWidth;
uint32_t frameHeight;
FrameRotation rotation;
uint32_t stride;
uint32_t pitch;
uint32_t version;
KVMFRFrameType type;
uint32_t screenWidth;
uint32_t screenHeight;
uint32_t dataWidth;
uint32_t dataHeight;
uint32_t frameWidth;
uint32_t frameHeight;
KVMFRFrameRotation rotation;
uint32_t stride;
uint32_t pitch;
bool hdr;
bool hdrPQ;
@@ -340,10 +340,10 @@ typedef struct LG_TransportFrame
// Backend-owned immutable metadata, valid until releaseFrame.
const LG_TransportFrameFormat * format;
const FrameBuffer * framebuffer;
int dmaFD;
const FrameDamageRect * damageRects;
uint32_t damageRectsCount;
const KVMFRFrameBuffer * framebuffer;
int dmaFD;
const KVMFRFrameDamageRect * damageRects;
uint32_t damageRectsCount;
/* A transport may keep the frame payload alive asynchronously after
* onFrame returns. The callback is idempotent and releases that ownership. */
@@ -369,19 +369,19 @@ typedef struct LG_TransportPointer
/* When setStatusListener is present, matches LG_VideoComponentStatus::epoch
* for the pointer endpoint which returned this payload; otherwise may be 0.
*/
uint64_t epoch;
LG_TransportPointerFlags flags;
int16_t x;
int16_t y;
CursorType type;
int16_t hx;
int16_t hy;
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t sdrWhiteLevel;
const uint8_t * shape;
const LGColorTransform * colorTransform;
uint64_t epoch;
LG_TransportPointerFlags flags;
int16_t x;
int16_t y;
KVMFRCursorType type;
int16_t hx;
int16_t hy;
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t sdrWhiteLevel;
const uint8_t * shape;
const KVMFRColorTransform * colorTransform;
}
LG_TransportPointer;

View File

@@ -104,8 +104,8 @@ struct EGL_Cursor
_Atomic(float) mapHDRContentPeak;
bool colorTransformUpdate;
LGColorTransform pendingColorTransform;
LGColorTransform activeColorTransform;
KVMFRColorTransform pendingColorTransform;
KVMFRColorTransform activeColorTransform;
GLuint colorLUT;
struct CursorTex norm;
@@ -344,7 +344,7 @@ bool egl_cursorSetShape(EGL_Cursor * cursor, const LG_RendererCursor type,
}
void egl_cursorSetColorTransform(EGL_Cursor * cursor,
const LGColorTransform * transform)
const KVMFRColorTransform * transform)
{
LG_LOCK(cursor->lock);
cursor->pendingColorTransform = *transform;

View File

@@ -44,7 +44,7 @@ bool egl_cursorSetShape(
const uint8_t * data);
void egl_cursorSetColorTransform(EGL_Cursor * cursor,
const LGColorTransform * transform);
const KVMFRColorTransform * transform);
void egl_cursorSetSize(EGL_Cursor * cursor, const float x, const float y);

View File

@@ -29,7 +29,7 @@ struct DesktopDamage
{
LG_RendererFrameToken frameToken;
int count;
FrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
KVMFRFrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
};
typedef struct EGL_Damage EGL_Damage;

View File

@@ -380,9 +380,10 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
return true;
}
bool egl_desktopUpdate(EGL_Desktop * desktop, const FrameBuffer * frame,
bool egl_desktopUpdate(EGL_Desktop * desktop,
const KVMFRFrameBuffer * frame,
LG_RendererFrameToken frameToken, int dmaFd,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{

View File

@@ -48,9 +48,9 @@ void egl_desktopSetNativeHDR(EGL_Desktop * desktop, bool nativeHDR,
void egl_desktopGetHDRMapping(EGL_Desktop * desktop, bool * enabled,
float * gain, float * contentPeak);
bool egl_desktopSetup (EGL_Desktop * desktop, const LG_RendererFormat format);
bool egl_desktopUpdate(EGL_Desktop * desktop, const FrameBuffer * frame,
bool egl_desktopUpdate(EGL_Desktop * desktop, const KVMFRFrameBuffer * frame,
LG_RendererFrameToken frameToken, int dmaFd,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle);
void egl_desktopRestart(EGL_Desktop * desktop);

View File

@@ -95,7 +95,8 @@ void egl_desktopRectsFree(EGL_DesktopRects ** rects_)
*rects_ = NULL;
}
inline static void rectToVertices(GLfloat * vertex, const FrameDamageRect * rect)
inline static void rectToVertices(GLfloat * vertex,
const KVMFRFrameDamageRect * rect)
{
vertex[0] = rect->x;
vertex[1] = rect->y;
@@ -108,7 +109,7 @@ inline static void rectToVertices(GLfloat * vertex, const FrameDamageRect * rect
}
void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
const FrameDamageRect * data, int count, int width, int height)
const KVMFRFrameDamageRect * data, int count, int width, int height)
{
if (count == 0)
{
@@ -120,7 +121,7 @@ void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
GLfloat vertices[vertexCount];
if (count < 0)
{
FrameDamageRect full = {
KVMFRFrameDamageRect full = {
.x = 0, .y = 0, .width = width, .height = height,
};
rects->count = 1;
@@ -237,7 +238,8 @@ inline static void matrixMultiply(const double matrix[6], double * nx, double *
*ny = matrix[1] * x + matrix[3] * y + matrix[5];
}
struct Rect egl_desktopToScreen(const double matrix[6], const struct FrameDamageRect * rect)
struct Rect egl_desktopToScreen(const double matrix[6],
const struct KVMFRFrameDamageRect * rect)
{
double x1, y1, x2, y2;
matrixMultiply(matrix, &x1, &y1, rect->x, rect->y);
@@ -270,7 +272,8 @@ void egl_screenToDesktopMatrix(double matrix[6], int frameWidth, int frameHeight
matrix[5] = (inverted[1] * inverted[4] - inverted[0] * inverted[5]) / det;
}
bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6],
bool egl_screenToDesktop(struct KVMFRFrameDamageRect * output,
const double matrix[6],
const struct Rect * rect, int width, int height)
{
double x1, y1, x2, y2;

View File

@@ -26,8 +26,8 @@
struct DamageRects
{
int count;
FrameDamageRect rects[];
int count;
KVMFRFrameDamageRect rects[];
};
typedef struct EGL_DesktopRects EGL_DesktopRects;
@@ -40,14 +40,16 @@ void egl_desktopRectsMatrix(float matrix[6], int width, int height, float transl
void egl_desktopToScreenMatrix(double matrix[6], int frameWidth, int frameHeight,
double translateX, double translateY, double scaleX, double scaleY, LG_RendererRotate rotate,
double windowWidth, double windowHeight);
struct Rect egl_desktopToScreen(const double matrix[6], const struct FrameDamageRect * rect);
struct Rect egl_desktopToScreen(const double matrix[6],
const struct KVMFRFrameDamageRect * rect);
void egl_screenToDesktopMatrix(double matrix[6], int frameWidth, int frameHeight,
double translateX, double translateY, double scaleX, double scaleY, LG_RendererRotate rotate,
double windowWidth, double windowHeight);
bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6],
bool egl_screenToDesktop(struct KVMFRFrameDamageRect * output,
const double matrix[6],
const struct Rect * rect, int width, int height);
void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
const FrameDamageRect * data, int count, int width, int height);
const KVMFRFrameDamageRect * data, int count, int width, int height);
void egl_desktopRectsRender(EGL_DesktopRects * rects);

View File

@@ -453,7 +453,7 @@ static void egl_addSwSurfaceDamage(
if (right <= x || bottom <= y)
return;
const FrameDamageRect rect = {
const KVMFRFrameDamageRect rect = {
.x = (uint32_t)x,
.y = (uint32_t)y,
.width = (uint32_t)(right - x),
@@ -697,7 +697,7 @@ static bool egl_onMouseShape(LG_Renderer * renderer, const LG_RendererCursor cur
}
static void egl_onMouseColorTransform(LG_Renderer * renderer,
const LGColorTransform * transform)
const KVMFRColorTransform * transform)
{
struct Inst * this = UPCAST(struct Inst, renderer);
egl_cursorSetColorTransform(this->cursor, transform);
@@ -832,8 +832,9 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
return egl_desktopSetup(this->desktop, format);
}
static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame,
int dmaFd, const FrameDamageRect * damageRects, int damageRectsCount,
static bool egl_onFrame(LG_Renderer * renderer,
const KVMFRFrameBuffer * frame, int dmaFd,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
LG_RendererFrameToken frameToken, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{
@@ -853,8 +854,9 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame,
const uint64_t elapsed = nanotime() - start;
/* Producer Copy already covers the interval before FrameBuffer::wp becomes
* ready. Exclude that overlapping wait from the client Import stage. */
/* Producer Copy already covers the interval before KVMFRFrameBuffer::wp
* becomes ready. Exclude that overlapping wait from the client Import
* stage. */
app_setFrameImportTiming(
elapsed > waitTimeNs ? elapsed - waitTimeNs : 0, waitTimeNs);
@@ -873,7 +875,7 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame,
else
{
memcpy(damage->rects + damage->count, damageRects,
damageRectsCount * sizeof(FrameDamageRect));
damageRectsCount * sizeof(KVMFRFrameDamageRect));
damage->count += damageRectsCount;
}
damage->frameToken = frameToken;
@@ -1327,8 +1329,8 @@ inline static EGLint egl_bufferAge(struct Inst * this)
return result;
}
static FrameDamageRect egl_expandDesktopDamage(
const struct Inst * this, const FrameDamageRect * rect)
static KVMFRFrameDamageRect egl_expandDesktopDamage(
const struct Inst * this, const KVMFRFrameDamageRect * rect)
{
int width, height;
egl_getDesktopSize(this, &width, &height);
@@ -1342,7 +1344,7 @@ static FrameDamageRect egl_expandDesktopDamage(
const uint32_t bottom = (uint32_t)min((uint64_t)height,
(uint64_t)rect->y + rect->height + DESKTOP_DAMAGE_MARGIN);
return (FrameDamageRect) {
return (KVMFRFrameDamageRect) {
.x = x,
.y = y,
.width = right > x ? right - x : 0,
@@ -1381,10 +1383,10 @@ static int egl_mergeSurfaceDamage(struct Rect * damage, int count)
if (count <= 1)
return count;
FrameDamageRect rects[count];
KVMFRFrameDamageRect rects[count];
for (int i = 0; i < count; ++i)
{
rects[i] = (FrameDamageRect) {
rects[i] = (KVMFRFrameDamageRect) {
.x = damage[i].x,
.y = damage[i].y,
.width = damage[i].w,
@@ -1422,7 +1424,7 @@ static void egl_requeueDesktopDamage(
else
{
memcpy(pending->rects + pending->count, damage->rects,
damage->count * sizeof(FrameDamageRect));
damage->count * sizeof(KVMFRFrameDamageRect));
pending->count += damage->count;
}
@@ -1505,7 +1507,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
struct DamageRects * accumulated = (struct DamageRects *)alloca(
sizeof(struct DamageRects) +
MAX_ACCUMULATED_DAMAGE * sizeof(struct FrameDamageRect)
MAX_ACCUMULATED_DAMAGE * sizeof(struct KVMFRFrameDamageRect)
);
accumulated->count = 0;
@@ -1533,7 +1535,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
for (int j = 0; j < damage->count; ++j)
{
const FrameDamageRect rect =
const KVMFRFrameDamageRect rect =
egl_expandDesktopDamage(this, damage->rects + j);
if (rect.width && rect.height)
accumulated->rects[accumulated->count++] = rect;
@@ -1732,7 +1734,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
for (int i = 0; i < desktopDamage->count; ++i)
{
const FrameDamageRect rect =
const KVMFRFrameDamageRect rect =
egl_expandDesktopDamage(this, desktopDamage->rects + i);
if (rect.width && rect.height)
damage[damageIdx++] = egl_desktopToScreen(matrix, &rect);

View File

@@ -140,7 +140,7 @@ void egl_hdrOverlaySetState(EGL_HDROverlay * this, bool active, bool pq,
}
static int convertDamage(EGL_HDROverlay * this, const struct Rect * damage,
int damageCount, FrameDamageRect * output)
int damageCount, KVMFRFrameDamageRect * output)
{
int count = 0;
for (int i = 0; i < damageCount; ++i)
@@ -152,7 +152,7 @@ static int convertDamage(EGL_HDROverlay * this, const struct Rect * damage,
if (x2 <= x1 || y2 <= y1)
continue;
output[count++] = (FrameDamageRect)
output[count++] = (KVMFRFrameDamageRect)
{
.x = x1,
.y = this->height - y2,
@@ -185,7 +185,7 @@ bool egl_hdrOverlayBegin(EGL_HDROverlay * this,
}
else
{
FrameDamageRect rects[damageCount];
KVMFRFrameDamageRect rects[damageCount];
const int count = convertDamage(this, damage, damageCount, rects);
egl_stateScissor(true);
@@ -227,7 +227,7 @@ void egl_hdrOverlayEnd(EGL_HDROverlay * this,
}
else
{
FrameDamageRect rects[damageCount];
KVMFRFrameDamageRect rects[damageCount];
const int count = convertDamage(this, damage, damageCount, rects);
egl_stateScissor(true);

View File

@@ -160,8 +160,8 @@ bool egl_textureUpdateRect(EGL_Texture * this,
}
bool egl_textureUpdateFromFrame(EGL_Texture * this,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs)
{
const struct EGL_TexUpdate update =
@@ -184,7 +184,7 @@ bool egl_textureUpdateFromFrame(EGL_Texture * this,
}
bool egl_textureUpdateFromDMA(EGL_Texture * this,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const int dmaFd, uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{

View File

@@ -67,9 +67,9 @@ typedef struct EGL_TexUpdate
/* EGL_TEXTYPE_FRAMEBUFFER */
struct
{
const FrameBuffer * frame;
const FrameDamageRect * rects;
int rectCount;
const KVMFRFrameBuffer * frame;
const KVMFRFrameDamageRect * rects;
int rectCount;
};
/* EGL_TEXTYPE_DMABUF */
@@ -141,12 +141,12 @@ bool egl_textureUpdateRect(EGL_Texture * texture,
const uint8_t * buffer, bool topDown);
bool egl_textureUpdateFromFrame(EGL_Texture * texture,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs);
bool egl_textureUpdateFromDMA(EGL_Texture * texture,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const int dmaFd, uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle);

View File

@@ -31,20 +31,20 @@ extern const EGL_TextureOps EGL_TextureBufferStream;
// internal functions
static uint64_t egl_texBufferDamageArea(const FrameDamageRect * rect)
static uint64_t egl_texBufferDamageArea(const KVMFRFrameDamageRect * rect)
{
return (uint64_t)rect->width * rect->height;
}
static FrameDamageRect egl_texBufferDamageUnion(
const FrameDamageRect * a, const FrameDamageRect * b)
static KVMFRFrameDamageRect egl_texBufferDamageUnion(
const KVMFRFrameDamageRect * a, const KVMFRFrameDamageRect * b)
{
const uint32_t left = min(a->x, b->x);
const uint32_t top = min(a->y, b->y);
const uint32_t right = max(a->x + a->width, b->x + b->width);
const uint32_t bottom = max(a->y + a->height, b->y + b->height);
return (FrameDamageRect)
return (KVMFRFrameDamageRect)
{
.x = left,
.y = top,
@@ -53,8 +53,8 @@ static FrameDamageRect egl_texBufferDamageUnion(
};
}
static bool egl_texBufferDamageTouches(const FrameDamageRect * a,
const FrameDamageRect * b)
static bool egl_texBufferDamageTouches(const KVMFRFrameDamageRect * a,
const KVMFRFrameDamageRect * b)
{
return a->x <= b->x + b->width && b->x <= a->x + a->width &&
a->y <= b->y + b->height && b->y <= a->y + a->height;
@@ -78,7 +78,7 @@ static void egl_texBufferDamageAdd(TextureBuffer * this, int index,
return;
}
FrameDamageRect rect =
KVMFRFrameDamageRect rect =
{
.x = update->x,
.y = update->y,
@@ -108,9 +108,9 @@ static void egl_texBufferDamageAdd(TextureBuffer * this, int index,
uint64_t bestCost = UINT64_MAX;
for (int i = 0; i < damage->count; ++i)
{
const FrameDamageRect merged =
const KVMFRFrameDamageRect merged =
egl_texBufferDamageUnion(&rect, &damage->rects[i]);
const uint64_t cost = egl_texBufferDamageArea(&merged) -
const uint64_t cost = egl_texBufferDamageArea(&merged) -
egl_texBufferDamageArea(&damage->rects[i]);
if (cost < bestCost)
{
@@ -479,8 +479,8 @@ EGL_TexStatus egl_texBufferStreamProcess(EGL_Texture * texture,
else
for (int i = 0; i < damage->count; ++i)
{
const FrameDamageRect * rect = &damage->rects[i];
const uintptr_t offset =
const KVMFRFrameDamageRect * rect = &damage->rects[i];
const uintptr_t offset =
(uintptr_t)rect->y * texture->format.pitch +
(uintptr_t)rect->x * texture->format.bpp;
glTexSubImage2D(GL_TEXTURE_2D,

View File

@@ -22,7 +22,7 @@
#include "texture.h"
#include "texture_util.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/LGMPConfig.h>
#include "common/locking.h"
#define EGL_TEX_BUFFER_MAX LGMP_Q_FRAME_BUFFER_LEN
@@ -30,9 +30,9 @@
typedef struct EGL_TexBufferDamage
{
bool full;
int count;
FrameDamageRect rects[EGL_TEX_BUFFER_DAMAGE_MAX];
bool full;
int count;
KVMFRFrameDamageRect rects[EGL_TEX_BUFFER_DAMAGE_MAX];
}
EGL_TexBufferDamage;

View File

@@ -26,8 +26,8 @@
struct TexDamage
{
int count;
FrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
int count;
KVMFRFrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
};
typedef struct TexFB
@@ -108,17 +108,17 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
else
{
memcpy(damage->rects + damage->count, update->rects,
update->rectCount * sizeof(FrameDamageRect));
update->rectCount * sizeof(KVMFRFrameDamageRect));
damage->count += update->rectCount;
if (texture->format.pixFmt == EGL_PF_BGR_32)
{
FrameDamageRect scaledDamageRects[damage->count];
KVMFRFrameDamageRect scaledDamageRects[damage->count];
for (int i = 0; i < damage->count; i++)
{
FrameDamageRect rect = damage->rects[i];
int originalX = rect.x;
int scaledX = originalX * 3 / 4;
KVMFRFrameDamageRect rect = damage->rects[i];
int originalX = rect.x;
int scaledX = originalX * 3 / 4;
rect.x = scaledX;
rect.width = (((originalX + rect.width) * 3 + 3) / 4) - scaledX;
scaledDamageRects[i] = rect;
@@ -175,7 +175,7 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
damage->count + update->rectCount <= LG_MAX_FRAME_DAMAGE_RECTS)
{
memcpy(damage->rects + damage->count, update->rects,
update->rectCount * sizeof(FrameDamageRect));
update->rectCount * sizeof(KVMFRFrameDamageRect));
damage->count += update->rectCount;
}
else

View File

@@ -124,17 +124,17 @@ struct Inst
float uiScale;
_Atomic(bool) frameUpdate;
LG_Lock formatLock;
LG_RendererFormat format;
GLuint intFormat;
GLuint vboFormat;
GLuint dataFormat;
size_t texSize;
size_t texPos;
bool texUploadError;
float scaleX, scaleY;
const FrameBuffer * frame;
LG_RendererFrameToken pendingFrameToken;
LG_Lock formatLock;
LG_RendererFormat format;
GLuint intFormat;
GLuint vboFormat;
GLuint dataFormat;
size_t texSize;
size_t texPos;
bool texUploadError;
float scaleX, scaleY;
const KVMFRFrameBuffer * frame;
LG_RendererFrameToken pendingFrameToken;
struct OpenGL_FrameRelease frameRelease;
uint64_t drawStart;
@@ -482,8 +482,8 @@ bool opengl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat format
return true;
}
bool opengl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFd,
const FrameDamageRect * damage, int damageCount,
bool opengl_onFrame(LG_Renderer * renderer, const KVMFRFrameBuffer * frame,
int dmaFd, const KVMFRFrameDamageRect * damage, int damageCount,
LG_RendererFrameToken frameToken, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{
@@ -1383,9 +1383,9 @@ static bool drawFrame(struct Inst * this,
LG_UNLOCK(this->frameLock);
return true;
}
const FrameBuffer * frame = this->frame;
const LG_RendererFrameToken pendingFrameToken = this->pendingFrameToken;
const struct OpenGL_FrameRelease release =
const KVMFRFrameBuffer * frame = this->frame;
const LG_RendererFrameToken pendingFrameToken = this->pendingFrameToken;
const struct OpenGL_FrameRelease release =
takePendingFrameLocked(this);
LG_LOCK(this->formatLock);

View File

@@ -23,7 +23,7 @@
#include "core/clipboard_files.h"
#include "core/clipboard.h"
#include "common/KVMFRClipboard.h"
#include <LGProtocol/KVMFRClipboard.h>
#include "common/debug.h"
#include "common/event.h"
#include "common/locking.h"

View File

@@ -167,8 +167,8 @@ static struct
}
l_testCapture;
static atomic_uint_least64_t l_testFrameSerial;
static _Atomic(FrameType) l_testFrameType;
static atomic_uint_least64_t l_testFrameSerial;
static _Atomic(KVMFRFrameType) l_testFrameType;
#endif
static void lgInit(void)
@@ -697,7 +697,7 @@ static void preSwapCallback(void * udata)
return;
}
const FrameType sourceType =
const KVMFRFrameType sourceType =
atomic_load_explicit(&l_testFrameType, memory_order_acquire);
const LG_TestCaptureHeader header = {
.magic = LG_TEST_CAPTURE_MAGIC,
@@ -1605,7 +1605,7 @@ int main_frameThread(void * unused)
(damageCount && !frame.damageRects);
for (uint32_t i = 0; !invalidDamage && i < damageCount; ++i)
{
const FrameDamageRect * rect = &frame.damageRects[i];
const KVMFRFrameDamageRect * rect = &frame.damageRects[i];
invalidDamage = !rect->width || !rect->height ||
rect->x > format->frameWidth ||
rect->y > format->dataHeight ||

View File

@@ -97,7 +97,7 @@ typedef struct RenderCommand
struct
{
LGColorTransform * data;
KVMFRColorTransform * data;
}
cursorColorTransform;
@@ -144,9 +144,9 @@ typedef struct RenderQueueSwSurface
int pitch;
uint8_t * data;
bool damageFull;
int damageCount;
FrameDamageRect damage[LG_MAX_FRAME_DAMAGE_RECTS];
bool damageFull;
int damageCount;
KVMFRFrameDamageRect damage[LG_MAX_FRAME_DAMAGE_RECTS];
bool updateQueued;
RenderCommand updateCommand;
@@ -218,9 +218,9 @@ typedef struct RenderQueueCursor
int pitch;
uint8_t * data;
uint64_t colorGeneration;
bool colorValid;
LGColorTransform colorTransform;
uint64_t colorGeneration;
bool colorValid;
KVMFRColorTransform colorTransform;
uint64_t whiteGeneration;
bool whiteValid;
@@ -237,9 +237,9 @@ typedef struct RenderQueueFormat
}
RenderQueueFormat;
static RenderQueueCursor l_cursor[RENDER_QUEUE_SOURCE_COUNT];
static RenderQueueFormat l_format[RENDER_QUEUE_SOURCE_COUNT];
static const LGColorTransform l_identityColorTransform;
static RenderQueueCursor l_cursor[RENDER_QUEUE_SOURCE_COUNT];
static RenderQueueFormat l_format[RENDER_QUEUE_SOURCE_COUNT];
static const KVMFRColorTransform l_identityColorTransform;
static bool sourceValid(RenderQueueSource source)
{
@@ -289,20 +289,20 @@ static bool commandValid(const RenderCommand * cmd)
return generationValid(cmd->source, cmd->generation) && cursorCurrent;
}
static uint64_t swSurfaceDamageArea(const FrameDamageRect * rect)
static uint64_t swSurfaceDamageArea(const KVMFRFrameDamageRect * rect)
{
return (uint64_t)rect->width * rect->height;
}
static FrameDamageRect swSurfaceDamageUnion(
const FrameDamageRect * a, const FrameDamageRect * b)
static KVMFRFrameDamageRect swSurfaceDamageUnion(
const KVMFRFrameDamageRect * a, const KVMFRFrameDamageRect * b)
{
const uint32_t left = min(a->x, b->x);
const uint32_t top = min(a->y, b->y);
const uint32_t right = max(a->x + a->width, b->x + b->width);
const uint32_t bottom = max(a->y + a->height, b->y + b->height);
return (FrameDamageRect)
return (KVMFRFrameDamageRect)
{
.x = left,
.y = top,
@@ -312,7 +312,7 @@ static FrameDamageRect swSurfaceDamageUnion(
}
static bool swSurfaceDamageTouches(
const FrameDamageRect * a, const FrameDamageRect * b)
const KVMFRFrameDamageRect * a, const KVMFRFrameDamageRect * b)
{
return a->x <= b->x + b->width && b->x <= a->x + a->width &&
a->y <= b->y + b->height && b->y <= a->y + a->height;
@@ -330,7 +330,7 @@ static bool swSurfaceDamagePending(const RenderQueueSwSurface * surface)
}
static void swSurfaceDamageAdd(RenderQueueSwSurface * surface,
const FrameDamageRect * damage)
const KVMFRFrameDamageRect * damage)
{
if (surface->damageFull)
return;
@@ -344,7 +344,7 @@ static void swSurfaceDamageAdd(RenderQueueSwSurface * surface,
return;
}
FrameDamageRect rect = *damage;
KVMFRFrameDamageRect rect = *damage;
for (;;)
{
for (int i = 0; i < surface->damageCount;)
@@ -367,9 +367,9 @@ static void swSurfaceDamageAdd(RenderQueueSwSurface * surface,
uint64_t bestCost = UINT64_MAX;
for (int i = 0; i < surface->damageCount; ++i)
{
const FrameDamageRect merged =
const KVMFRFrameDamageRect merged =
swSurfaceDamageUnion(&rect, &surface->damage[i]);
const uint64_t cost = swSurfaceDamageArea(&merged) -
const uint64_t cost = swSurfaceDamageArea(&merged) -
swSurfaceDamageArea(&surface->damage[i]);
if (cost < bestCost)
{
@@ -940,7 +940,7 @@ void renderQueue_sourceSwSurfaceDrawFill(RenderQueueSource source,
row += surface->pitch;
}
const FrameDamageRect damage =
const KVMFRFrameDamageRect damage =
{
.x = (uint32_t)x,
.y = (uint32_t)y,
@@ -1016,7 +1016,7 @@ void renderQueue_sourceSwSurfaceDrawBitmap(RenderQueueSource source,
dst += surface->pitch;
}
const FrameDamageRect damage =
const KVMFRFrameDamageRect damage =
{
.x = (uint32_t)x,
.y = (uint32_t)y,
@@ -1093,7 +1093,7 @@ void renderQueue_sourceCursorImage(RenderQueueSource source,
}
void renderQueue_sourceCursorColorTransform(RenderQueueSource source,
uint64_t generation, const LGColorTransform * transform)
uint64_t generation, const KVMFRColorTransform * transform)
{
if (!generationValid(source, generation) || !transform)
return;
@@ -1102,7 +1102,7 @@ void renderQueue_sourceCursorColorTransform(RenderQueueSource source,
if (!cmd)
return;
LGColorTransform * copy = malloc(sizeof(*copy));
KVMFRColorTransform * copy = malloc(sizeof(*copy));
if (!copy)
{
free(cmd);
@@ -1176,8 +1176,8 @@ static void uploadSwSurfaceDamage(RenderQueueSource source,
else
for (int i = 0; i < surface->damageCount; ++i)
{
const FrameDamageRect * damage = &surface->damage[i];
uint8_t * data = surface->data +
const KVMFRFrameDamageRect * damage = &surface->damage[i];
uint8_t * data = surface->data +
(size_t)damage->y * surface->pitch + (size_t)damage->x * 4;
RENDERER(swSurfaceDrawBitmap,
damage->x, damage->y, damage->width, damage->height,

View File

@@ -88,7 +88,7 @@ void renderQueue_sourceCursorImage(RenderQueueSource source,
int width, int height, int pitch, const void * data);
void renderQueue_sourceCursorColorTransform(RenderQueueSource source,
uint64_t generation, const LGColorTransform * transform);
uint64_t generation, const KVMFRColorTransform * transform);
void renderQueue_sourceCursorWhiteLevel(RenderQueueSource source,
uint64_t generation, uint32_t sdrWhiteLevel);

View File

@@ -959,6 +959,10 @@ target_include_directories(render-tests PRIVATE
"${PROJECT_TOP}/common/include"
)
target_link_libraries(render-tests
LGProtocol::LGProtocol
)
if(TARGET GTest::gtest_main)
target_link_libraries(render-tests GTest::gtest_main)
else()

View File

@@ -23,7 +23,7 @@
#include "test.h"
#include "common/debug.h"
#include "common/KVMFRClipboard.h"
#include <LGProtocol/KVMFRClipboard.h>
#include <fcntl.h>
#include <pthread.h>

View File

@@ -46,14 +46,14 @@ static void testRotations(void)
{ .x = 140, .y = 10, .w = 40, .h = 20 },
{ .x = 20, .y = 10, .w = 40, .h = 20 },
};
const FrameDamageRect damage =
const KVMFRFrameDamageRect damage =
{
.x = 10,
.y = 5,
.width = 20,
.height = 10,
};
const FrameDamageRect full =
const KVMFRFrameDamageRect full =
{
.width = 100,
.height = 50,
@@ -79,7 +79,7 @@ static void testFractional(void)
double matrix[6];
egl_desktopToScreenMatrix(matrix, 3, 2, 0.0, 0.0, 1.0, 1.0,
LG_ROTATE_0, 10.0, 7.0);
const FrameDamageRect damage =
const KVMFRFrameDamageRect damage =
{
.x = 1,
.width = 1,
@@ -90,7 +90,7 @@ static void testFractional(void)
egl_desktopToScreenMatrix(matrix, 100, 50, 0.1, -0.2, 0.5, 0.75,
LG_ROTATE_0, 10.0, 7.0);
const FrameDamageRect full =
const KVMFRFrameDamageRect full =
{
.width = 100,
.height = 50,
@@ -101,7 +101,7 @@ static void testFractional(void)
static void testRoundTrip(void)
{
const FrameDamageRect damage =
const KVMFRFrameDamageRect damage =
{
.x = 10,
.y = 5,
@@ -119,7 +119,7 @@ static void testRoundTrip(void)
(LG_RendererRotate)i, 200.0, 100.0);
const struct Rect screen = egl_desktopToScreen(forward, &damage);
FrameDamageRect result;
KVMFRFrameDamageRect result;
CHECK(egl_screenToDesktop(&result, inverse, &screen, 100, 50));
CHECK(result.x <= damage.x);
CHECK(result.y <= damage.y);
@@ -141,7 +141,7 @@ static void testClipping(void)
.w = 10,
.h = 10,
};
FrameDamageRect result;
KVMFRFrameDamageRect result;
CHECK(!egl_screenToDesktop(&result, matrix, &outside, 100, 50));
const struct Rect edge =

View File

@@ -126,7 +126,7 @@ void renderQueue_sourceCursorImage(RenderQueueSource source,
}
void renderQueue_sourceCursorColorTransform(RenderQueueSource source,
uint64_t generation, const LGColorTransform * transform)
uint64_t generation, const KVMFRColorTransform * transform)
{
(void)source;
(void)generation;

View File

@@ -20,8 +20,8 @@
#include "clipboard.h"
#include "common/KVMFRClipboard.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFRClipboard.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include <lgmp/client.h>

View File

@@ -20,8 +20,8 @@
#include "interface/transport.h"
#include "common/KVMFR.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFR.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include "common/option.h"
@@ -110,7 +110,7 @@ static bool allocMemory(TestState * state, uint32_t size, uint32_t alignment,
static bool newFrame(TestState * state, uint32_t serial, TestFrame * result)
{
const uint32_t size = sizeof(KVMFRFrame) + sizeof(FrameBuffer) +
const uint32_t size = sizeof(KVMFRFrame) + sizeof(KVMFRFrameBuffer) +
TEST_FRAME_DATA;
void * pointer;
CHECK(allocMemory(state, size, _Alignof(KVMFRFrame),
@@ -132,7 +132,8 @@ static bool newFrame(TestState * state, uint32_t serial, TestFrame * result)
result->wire->offset = sizeof(KVMFRFrame);
result->wire->sdrWhiteLevel = KVMFR_SDR_WHITE_LEVEL_DEFAULT;
FrameBuffer * framebuffer = (FrameBuffer *)((uint8_t *)result->wire +
KVMFRFrameBuffer * framebuffer =
(KVMFRFrameBuffer *)((uint8_t *)result->wire +
result->wire->offset);
atomic_store(&framebuffer->wp, TEST_FRAME_DATA);
return true;

View File

@@ -20,8 +20,8 @@
#include "../transports/LGMP/input.h"
#include "common/KVMFRInput.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFRInput.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include <lgmp/client.h>

View File

@@ -20,9 +20,9 @@
#include "interface/transport.h"
#include "common/KVMFR.h"
#include "common/KVMFRRecovery.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFR.h>
#include <LGProtocol/KVMFRRecovery.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include "common/option.h"
@@ -380,7 +380,7 @@ int main(void)
.subTimeout = TEST_TIMEOUT,
};
const uint32_t frameSize =
sizeof(KVMFRFrame) + sizeof(FrameBuffer) + sizeof(uint32_t);
sizeof(KVMFRFrame) + sizeof(KVMFRFrameBuffer) + sizeof(uint32_t);
CHECK(lgmpHostMemAllocAligned(host, frameSize, _Alignof(KVMFRFrame),
&frameMemory) == LGMP_OK);
KVMFRFrame * wireFrame = lgmpHostMemPtr(frameMemory);
@@ -404,7 +404,8 @@ int main(void)
wireFrame->readyTime = 400;
wireFrame->timingSerial = wireFrame->frameSerial;
wireFrame->timingValid = 1;
FrameBuffer * framebuffer = (FrameBuffer *)((uint8_t *)wireFrame +
KVMFRFrameBuffer * framebuffer =
(KVMFRFrameBuffer *)((uint8_t *)wireFrame +
wireFrame->offset);
atomic_store(&framebuffer->wp, sizeof(uint32_t));
CHECK(lgmpHostMemAlloc(host, sizeof(KVMFRFrame) - 1,

View File

@@ -73,26 +73,26 @@ struct Fake
uint8_t bitmap[64];
size_t bitmapSize;
unsigned int shapeCount;
LG_RendererCursor shapeType;
int shapeWidth;
int shapeHeight;
int shapePitch;
uint8_t shape[64];
size_t shapeSize;
unsigned int cursorCount;
bool cursorVisible;
int cursorX;
int cursorY;
int cursorHX;
int cursorHY;
unsigned int colorCount;
LGColorTransformFlags colorFlags;
float colorScalar;
float colorMatrix;
float colorLut;
unsigned int whiteCount;
uint32_t whiteLevel;
unsigned int shapeCount;
LG_RendererCursor shapeType;
int shapeWidth;
int shapeHeight;
int shapePitch;
uint8_t shape[64];
size_t shapeSize;
unsigned int cursorCount;
bool cursorVisible;
int cursorX;
int cursorY;
int cursorHX;
int cursorHY;
unsigned int colorCount;
KVMFRColorTransformFlags colorFlags;
float colorScalar;
float colorMatrix;
float colorLut;
unsigned int whiteCount;
uint32_t whiteLevel;
unsigned int hdrCount;
LG_RendererFormat hdr[8];
@@ -200,7 +200,7 @@ static bool mouseEvent(LG_Renderer * renderer, bool visible,
}
static void mouseColor(LG_Renderer * renderer,
const LGColorTransform * color)
const KVMFRColorTransform * color)
{
(void)renderer;
++f.colorCount;
@@ -436,7 +436,7 @@ static void testPayload(void)
11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26,
};
LGColorTransform color =
KVMFRColorTransform color =
{
.flags = LG_COLOR_TRANSFORM_MATRIX | LG_COLOR_TRANSFORM_LUT,
.matrix[0][0] = 2.0f,
@@ -540,7 +540,7 @@ static void testCache(void)
const uint64_t generation =
renderQueue_sourceBegin(RENDER_QUEUE_SOURCE_PRIMARY);
const uint8_t shape[] = { 1, 2, 3, 4 };
LGColorTransform color =
KVMFRColorTransform color =
{
.flags = LG_COLOR_TRANSFORM_MATRIX,
.matrix[0][0] = 1.5f,
@@ -637,7 +637,7 @@ static void testCursorReplacement(void)
const uint64_t generation =
renderQueue_sourceBegin(RENDER_QUEUE_SOURCE_PRIMARY);
const uint8_t shape[] = { 1, 2, 3, 4 };
LGColorTransform color =
KVMFRColorTransform color =
{
.flags = LG_COLOR_TRANSFORM_LUT,
.scalar = 2.0f,

View File

@@ -57,10 +57,10 @@ constexpr unsigned kFrameSerial = 4;
struct FormatCase
{
const char * name;
FrameType type;
bool hdr;
bool pq;
const char * name;
KVMFRFrameType type;
bool hdr;
bool pq;
};
struct DamageCase

View File

@@ -26,7 +26,7 @@
#include "core/clipboard_files.h"
#include "common/debug.h"
#include "common/KVMFRClipboard.h"
#include <LGProtocol/KVMFRClipboard.h>
#include <stdint.h>
#include <stdio.h>

View File

@@ -20,8 +20,8 @@
#include "clipboard.h"
#include "common/KVMFRClipboard.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFRClipboard.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include "common/event.h"
#include "common/locking.h"

View File

@@ -22,8 +22,8 @@
#include "kb.h"
#include "common/KVMFRInput.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFRInput.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include "common/event.h"
#include "common/locking.h"

View File

@@ -23,9 +23,9 @@
#include "clipboard.h"
#include "input.h"
#include "common/KVMFR.h"
#include "common/KVMFRRecovery.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/KVMFR.h>
#include <LGProtocol/KVMFRRecovery.h>
#include <LGProtocol/LGMPConfig.h>
#include "common/debug.h"
#include "common/event.h"
#include "common/ivshmem.h"
@@ -1808,10 +1808,11 @@ static bool lgmp_validateFrameMessage(LG_Transport * this,
const size_t messageSize = message->message.size;
if (frame->offset < sizeof(KVMFRFrame) ||
frame->offset > messageSize - sizeof(FrameBuffer) ||
frameDataSize > messageSize - frame->offset - sizeof(FrameBuffer) ||
frame->offset > messageSize - sizeof(KVMFRFrameBuffer) ||
frameDataSize > messageSize - frame->offset -
sizeof(KVMFRFrameBuffer) ||
(uintptr_t)((const uint8_t *)message->message.mem + frame->offset) %
_Alignof(FrameBuffer))
_Alignof(KVMFRFrameBuffer))
{
DEBUG_ERROR("LGMP frame payload contains invalid dimensions or offsets");
return false;
@@ -1876,10 +1877,10 @@ static int lgmp_getDMA(struct LG_Transport * this,
const size_t position = address - base;
if (position > this->lgmpSize ||
frameOffset > this->lgmpSize - position ||
sizeof(FrameBuffer) > this->lgmpSize - position - frameOffset)
sizeof(KVMFRFrameBuffer) > this->lgmpSize - position - frameOffset)
return -1;
const size_t offset = position + frameOffset + sizeof(FrameBuffer);
const size_t offset = position + frameOffset + sizeof(KVMFRFrameBuffer);
if (dataSize > this->lgmpSize - offset)
return -1;
@@ -2082,7 +2083,7 @@ static LG_TransportStatus lgmp_nextFrameLocked(LG_Transport * this,
memcpy(&lease->format, format, sizeof(lease->format));
result->format = &lease->format;
result->framebuffer = (const FrameBuffer *)
result->framebuffer = (const KVMFRFrameBuffer *)
((const uint8_t *)selected->sharedFrame + frame->offset);
result->dmaFD = -1;
if (useDMA)
@@ -2214,7 +2215,8 @@ static void lgmp_getFrameTiming(LG_Transport * this,
timing->prepareTime = lease->prepareTime;
}
/* The producer writes these immediately after publishing FrameBuffer::wp.
/* The producer writes these immediately after publishing
* KVMFRFrameBuffer::wp.
* nextFrame can observe the header earlier, so briefly observe the
* publication tail after onFrame consumes the framebuffer without sleeping
* the frame-acquisition thread. */

View File

@@ -47,11 +47,11 @@ enum TestDamageMode
struct TestFormat
{
const char * name;
FrameType type;
unsigned bytesPerPixel;
bool hdr;
bool hdrPQ;
const char * name;
KVMFRFrameType type;
unsigned bytesPerPixel;
bool hdr;
bool hdrPQ;
};
static const struct TestFormat testFormats[] =
@@ -66,7 +66,7 @@ static const struct TestFormat testFormats[] =
struct TestBuffer
{
FrameBuffer * framebuffer;
KVMFRFrameBuffer * framebuffer;
};
struct LG_Transport
@@ -89,7 +89,7 @@ struct LG_Transport
uint64_t framePrepareTime;
unsigned bufferIndex;
struct TestBuffer buffers[TEST_BUFFER_COUNT];
FrameDamageRect damage[LG_TRANSPORT_MAX_DAMAGE_RECTS];
KVMFRFrameDamageRect damage[LG_TRANSPORT_MAX_DAMAGE_RECTS];
LG_TransportFrameFormat format;
uint16_t pqLUT[TEST_PQ_LUT_SIZE + 1];
};
@@ -348,7 +348,7 @@ static bool test_create(LG_Transport ** result)
stride < 0 || (stride && stride < width) ||
bufferStride > UINT32_MAX / maxBytesPerPixel ||
frameRate < 1 || frameRate > 1000000000 || frameCount < 0 ||
bufferStride > (SIZE_MAX - sizeof(FrameBuffer)) /
bufferStride > (SIZE_MAX - sizeof(KVMFRFrameBuffer)) /
maxBytesPerPixel / (size_t)height)
{
DEBUG_ERROR(
@@ -373,7 +373,8 @@ static bool test_create(LG_Transport ** result)
bufferStride * this->height * maxBytesPerPixel;
for (unsigned i = 0; i < TEST_BUFFER_COUNT; ++i)
{
this->buffers[i].framebuffer = malloc(sizeof(FrameBuffer) + dataSize);
this->buffers[i].framebuffer =
malloc(sizeof(KVMFRFrameBuffer) + dataSize);
if (!this->buffers[i].framebuffer)
{
for (unsigned j = 0; j < i; ++j)
@@ -515,7 +516,8 @@ static void test_getColor(const struct LG_Transport * this,
*b = color;
}
static void test_generateFrame(struct LG_Transport * this, FrameBuffer * fb)
static void test_generateFrame(struct LG_Transport * this,
KVMFRFrameBuffer * fb)
{
uint8_t * data = framebuffer_get_data(fb);
if (this->stride)
@@ -653,13 +655,13 @@ static LG_TransportStatus test_nextFrame(LG_Transport * this, bool useDMA,
this->width - boxSize : 1;
const unsigned rangeY = this->height > boxSize ?
this->height - boxSize : 1;
this->damage[0] = (FrameDamageRect) {
this->damage[0] = (KVMFRFrameDamageRect) {
.x = ((this->serial - 1) * 7) % rangeX,
.y = ((this->serial - 1) * 5) % rangeY,
.width = boxSize,
.height = boxSize,
};
this->damage[1] = (FrameDamageRect) {
this->damage[1] = (KVMFRFrameDamageRect) {
.x = (this->serial * 7) % rangeX,
.y = (this->serial * 5) % rangeY,
.width = boxSize,
@@ -680,12 +682,12 @@ static LG_TransportStatus test_nextFrame(LG_Transport * this, bool useDMA,
case TEST_DAMAGE_MAX:
for (unsigned i = 2; i < ARRAY_LENGTH(this->damage); ++i)
this->damage[i] = (FrameDamageRect) {0};
this->damage[i] = (KVMFRFrameDamageRect) {0};
frame->damageRectsCount = ARRAY_LENGTH(this->damage);
break;
case TEST_DAMAGE_INVALID:
this->damage[0] = (FrameDamageRect) {
this->damage[0] = (KVMFRFrameDamageRect) {
.x = this->width, .y = 0, .width = 1, .height = 1
};
frame->damageRectsCount = 1;
@@ -697,7 +699,7 @@ static LG_TransportStatus test_nextFrame(LG_Transport * this, bool useDMA,
break;
case TEST_DAMAGE_ZERO:
this->damage[2] = (FrameDamageRect) {0};
this->damage[2] = (KVMFRFrameDamageRect) {0};
frame->damageRectsCount = 3;
break;