Handle more pixel formats
parent
7acf2c7aef
commit
b744e2410e
|
@ -449,18 +449,20 @@ void wayvnc_process_frame(struct wayvnc* self)
|
||||||
|
|
||||||
void wayvnc_process_screen(struct wayvnc* self)
|
void wayvnc_process_screen(struct wayvnc* self)
|
||||||
{
|
{
|
||||||
uint32_t format = fourcc_from_gl_format(self->renderer.read_format);
|
uint32_t renderer_format =
|
||||||
|
fourcc_from_gl_format(self->renderer.read_format);
|
||||||
|
|
||||||
void* pixels = self->screencopy_backend.pixels;
|
void* pixels = self->screencopy_backend.pixels;
|
||||||
|
|
||||||
uint32_t width = self->capture_backend->frame_info.width;
|
uint32_t width = self->capture_backend->frame_info.width;
|
||||||
uint32_t height = self->capture_backend->frame_info.height;
|
uint32_t height = self->capture_backend->frame_info.height;
|
||||||
uint32_t stride = self->capture_backend->frame_info.stride;
|
uint32_t stride = self->capture_backend->frame_info.stride;
|
||||||
|
uint32_t frame_format = self->capture_backend->frame_info.fourcc_format;
|
||||||
|
|
||||||
struct nvnc_fb* fb = nvnc_fb_new(width, height, format);
|
struct nvnc_fb* fb = nvnc_fb_new(width, height, renderer_format);
|
||||||
void* addr = nvnc_fb_get_addr(fb);
|
void* addr = nvnc_fb_get_addr(fb);
|
||||||
|
|
||||||
render_framebuffer(&self->renderer, pixels, format, width, height,
|
render_framebuffer(&self->renderer, pixels, frame_format, width, height,
|
||||||
stride);
|
stride);
|
||||||
render_copy_pixels(&self->renderer, addr, 0, height);
|
render_copy_pixels(&self->renderer, addr, 0, height);
|
||||||
|
|
||||||
|
|
20
src/render.c
20
src/render.c
|
@ -21,6 +21,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
#include <libdrm/drm_fourcc.h>
|
||||||
|
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include <GLES2/gl2ext.h>
|
#include <GLES2/gl2ext.h>
|
||||||
|
@ -54,13 +55,20 @@
|
||||||
X_GL_EXTENSIONS
|
X_GL_EXTENSIONS
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
int gl_format_from_wl_shm(GLenum* result, enum wl_shm_format format)
|
int gl_format_from_fourcc(GLenum* result, uint32_t format)
|
||||||
{
|
{
|
||||||
*result = GL_BGRA_EXT;
|
switch (format) {
|
||||||
|
case DRM_FORMAT_XRGB8888:
|
||||||
|
case DRM_FORMAT_ARGB8888:
|
||||||
|
*result = GL_BGRA_EXT;
|
||||||
|
return 0;
|
||||||
|
case DRM_FORMAT_XBGR8888:
|
||||||
|
case DRM_FORMAT_ABGR8888:
|
||||||
|
*result = GL_RGBA;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Actually detect the format
|
return -1;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void* gl_load_single_extension(const char* name)
|
static inline void* gl_load_single_extension(const char* name)
|
||||||
|
@ -445,7 +453,7 @@ int render_framebuffer(struct renderer* self, const void* addr, uint32_t format,
|
||||||
glBindTexture(GL_TEXTURE_2D, tex);
|
glBindTexture(GL_TEXTURE_2D, tex);
|
||||||
|
|
||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
if (gl_format_from_wl_shm(&gl_format, format) < 0)
|
if (gl_format_from_fourcc(&gl_format, format) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / 4);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / 4);
|
||||||
|
|
Loading…
Reference in New Issue