aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-02-08 19:06:09 +0100
committerdec05eba <dec05eba@protonmail.com>2024-02-08 19:06:09 +0100
commitd1c49f35a5cca15ee17939c7f2a87224f494c5b3 (patch)
tree11ffd7984b66653a7d7871fc25ab8a60e9028453 /src
parentad777a5136575c00a1cd013b5877a343304c4627 (diff)
Window capture: clear background with black color
Diffstat (limited to 'src')
-rw-r--r--src/capture/xcomposite_cuda.c1
-rw-r--r--src/capture/xcomposite_vaapi.c3
-rw-r--r--src/color_conversion.c43
3 files changed, 45 insertions, 2 deletions
diff --git a/src/capture/xcomposite_cuda.c b/src/capture/xcomposite_cuda.c
index 7e65efa..58af0be 100644
--- a/src/capture/xcomposite_cuda.c
+++ b/src/capture/xcomposite_cuda.c
@@ -272,6 +272,7 @@ static void gsr_capture_xcomposite_cuda_stop(gsr_capture *cap, AVCodecContext *v
static void gsr_capture_xcomposite_cuda_tick(gsr_capture *cap, AVCodecContext *video_codec_context, AVFrame **frame) {
gsr_capture_xcomposite_cuda *cap_xcomp = cap->priv;
+ cap_xcomp->params.egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
cap_xcomp->params.egl->glClear(GL_COLOR_BUFFER_BIT);
bool init_new_window = false;
diff --git a/src/capture/xcomposite_vaapi.c b/src/capture/xcomposite_vaapi.c
index 687eb2d..f9efef5 100644
--- a/src/capture/xcomposite_vaapi.c
+++ b/src/capture/xcomposite_vaapi.c
@@ -199,6 +199,7 @@ static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext *
gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv;
// TODO:
+ cap_xcomp->params.egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
cap_xcomp->params.egl->glClear(GL_COLOR_BUFFER_BIT);
bool init_new_window = false;
@@ -418,6 +419,8 @@ static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext *
return;
}
}
+
+ gsr_color_conversion_clear(&cap_xcomp->color_conversion);
}
}
diff --git a/src/color_conversion.c b/src/color_conversion.c
index 2bfb9c2..1d70b9e 100644
--- a/src/color_conversion.c
+++ b/src/color_conversion.c
@@ -362,7 +362,7 @@ void gsr_color_conversion_deinit(gsr_color_conversion *self) {
}
/* |source_pos| is in pixel coordinates and |source_size| */
-int gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_id, vec2i source_pos, vec2i source_size, vec2i texture_pos, vec2i texture_size, float rotation, bool external_texture) {
+void gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_id, vec2i source_pos, vec2i source_size, vec2i texture_pos, vec2i texture_size, float rotation, bool external_texture) {
/* TODO: Do not call this every frame? */
vec2i dest_texture_size = {0, 0};
self->params.egl->glBindTexture(GL_TEXTURE_2D, self->params.destination_textures[0]);
@@ -453,5 +453,44 @@ int gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_i
gsr_shader_use_none(&self->shaders[0]);
self->params.egl->glBindTexture(texture_target, 0);
self->params.egl->glBindFramebuffer(GL_FRAMEBUFFER, 0);
- return 0;
+}
+
+void gsr_color_conversion_clear(gsr_color_conversion *self) {
+ float color1[4];
+ float color2[4];
+
+ switch(self->params.destination_color) {
+ case GSR_DESTINATION_COLOR_BGR: {
+ color1[0] = 0.0f;
+ color1[1] = 0.0f;
+ color1[2] = 0.0f;
+ color1[3] = 1.0f;
+ break;
+ }
+ case GSR_DESTINATION_COLOR_NV12:
+ case GSR_DESTINATION_COLOR_P010: {
+ color1[0] = 0.0f;
+ color1[1] = 0.0f;
+ color1[2] = 0.0f;
+ color1[3] = 1.0f;
+
+ color2[0] = 0.5f;
+ color2[1] = 0.5f;
+ color2[2] = 0.0f;
+ color2[3] = 1.0f;
+ break;
+ }
+ }
+
+ self->params.egl->glBindFramebuffer(GL_FRAMEBUFFER, self->framebuffers[0]);
+ self->params.egl->glClearColor(color1[0], color1[1], color1[2], color1[3]);
+ self->params.egl->glClear(GL_COLOR_BUFFER_BIT);
+
+ if(self->params.num_destination_textures > 1) {
+ self->params.egl->glBindFramebuffer(GL_FRAMEBUFFER, self->framebuffers[1]);
+ self->params.egl->glClearColor(color2[0], color2[1], color2[2], color2[3]);
+ self->params.egl->glClear(GL_COLOR_BUFFER_BIT);
+ }
+
+ self->params.egl->glBindFramebuffer(GL_FRAMEBUFFER, 0);
}