mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 13:52:57 +00:00
[client] egl: allow for partial texture updates
This commit is contained in:
parent
7ad3610276
commit
1fcdcc8725
4 changed files with 67 additions and 6 deletions
|
@ -108,6 +108,39 @@ bool egl_textureUpdate(EGL_Texture * this, const uint8_t * buffer)
|
|||
const struct EGL_TexUpdate update =
|
||||
{
|
||||
.type = EGL_TEXTYPE_BUFFER,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = this->format.width,
|
||||
.height = this->format.height,
|
||||
.pitch = this->format.pitch,
|
||||
.stride = this->format.stride,
|
||||
.buffer = buffer
|
||||
};
|
||||
|
||||
return this->ops.update(this, &update);
|
||||
}
|
||||
|
||||
bool egl_textureUpdateRect(EGL_Texture * this,
|
||||
int x, int y, int width, int height, int stride,
|
||||
const uint8_t * buffer)
|
||||
{
|
||||
x = clamp(x , 0, this->format.width );
|
||||
y = clamp(y , 0, this->format.height );
|
||||
width = clamp(width , x, this->format.width - x);
|
||||
height = clamp(height, y, this->format.height - y);
|
||||
|
||||
if (!width || !height)
|
||||
return true;
|
||||
|
||||
const struct EGL_TexUpdate update =
|
||||
{
|
||||
.type = EGL_TEXTYPE_BUFFER,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.pitch = stride / (stride / width),
|
||||
.stride = stride,
|
||||
.buffer = buffer
|
||||
};
|
||||
|
||||
|
@ -121,6 +154,12 @@ bool egl_textureUpdateFromFrame(EGL_Texture * this,
|
|||
const struct EGL_TexUpdate update =
|
||||
{
|
||||
.type = EGL_TEXTYPE_FRAMEBUFFER,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = this->format.width,
|
||||
.height = this->format.height,
|
||||
.pitch = this->format.pitch,
|
||||
.stride = this->format.stride,
|
||||
.frame = frame,
|
||||
.rects = damageRects,
|
||||
.rectCount = damageRectsCount,
|
||||
|
@ -134,8 +173,14 @@ bool egl_textureUpdateFromDMA(EGL_Texture * this,
|
|||
{
|
||||
const struct EGL_TexUpdate update =
|
||||
{
|
||||
.type = EGL_TEXTYPE_DMABUF,
|
||||
.dmaFD = dmaFd
|
||||
.type = EGL_TEXTYPE_DMABUF,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = this->format.width,
|
||||
.height = this->format.height,
|
||||
.pitch = this->format.pitch,
|
||||
.stride = this->format.stride,
|
||||
.dmaFD = dmaFd
|
||||
};
|
||||
|
||||
/* wait for completion */
|
||||
|
|
|
@ -42,6 +42,12 @@ typedef struct EGL_TexUpdate
|
|||
/* the type of this update */
|
||||
EGL_TexType type;
|
||||
|
||||
int x, y, width, height;
|
||||
|
||||
//pitch = row length in pixels
|
||||
//stride = row length in bytes
|
||||
int pitch, stride;
|
||||
|
||||
union
|
||||
{
|
||||
/* EGL_TEXTURE_BUFFER */
|
||||
|
@ -102,6 +108,10 @@ bool egl_textureSetup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt,
|
|||
|
||||
bool egl_textureUpdate(EGL_Texture * texture, const uint8_t * buffer);
|
||||
|
||||
bool egl_textureUpdateRect(EGL_Texture * texture,
|
||||
int x, int y, int width, int height, int stride,
|
||||
const uint8_t * buffer);
|
||||
|
||||
bool egl_textureUpdateFromFrame(EGL_Texture * texture,
|
||||
const FrameBuffer * frame, const FrameDamageRect * damageRects,
|
||||
int damageRectsCount);
|
||||
|
|
|
@ -111,11 +111,13 @@ static bool egl_texBufferUpdate(EGL_Texture * texture, const EGL_TexUpdate * upd
|
|||
DEBUG_ASSERT(update->type == EGL_TEXTYPE_BUFFER);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, this->tex[0]);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->format.pitch);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, update->pitch);
|
||||
glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0, 0, 0,
|
||||
texture->format.width,
|
||||
texture->format.height,
|
||||
0,
|
||||
update->x,
|
||||
update->y,
|
||||
update->width,
|
||||
update->height,
|
||||
texture->format.format,
|
||||
texture->format.dataType,
|
||||
update->buffer);
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
_a > _b ? _a : _b; })
|
||||
#endif
|
||||
|
||||
#ifndef clamp
|
||||
#define clamp(v,a,b) min(max(v, a), b)
|
||||
#endif
|
||||
|
||||
#define UPCAST(type, x) \
|
||||
(type *)((uintptr_t)(x) - offsetof(type, base))
|
||||
|
||||
|
|
Loading…
Reference in a new issue