Skip to content

Display and control your Android device

Render only the frame area of the texture

Romain Vimont2a3bd72cf5cb
diff --git a/app/src/screen.c b/app/src/screen.c
index 7c4e3f66..3e6bad71 100644
--- a/app/src/screen.c
+++ b/app/src/screen.c
@@ -292,12 +292,23 @@ sc_screen_render(struct sc_screen *screen, bool update_content_rect) {
};
enum sc_orientation orientation = screen->orientation;
+ const SDL_FRect *srcrect = NULL;
+ SDL_FRect frame_rect;
+ if (!screen->is_icon_active) {
+ struct sc_size frame_size = sc_texture_get_frame_size(&screen->tex);
+ frame_rect.x = 0;
+ frame_rect.y = 0;
+ frame_rect.w = frame_size.width;
+ frame_rect.h = frame_size.height;
+ srcrect = &frame_rect;
+ }
+
bool ok = false;
if (orientation == SC_ORIENTATION_0) {
// always align to a physical pixel
geometry.x = (int32_t) geometry.x;
geometry.y = (int32_t) geometry.y;
- ok = SDL_RenderTexture(renderer, texture, NULL, &geometry);
+ ok = SDL_RenderTexture(renderer, texture, srcrect, &geometry);
} else {
unsigned cw_rotation = sc_orientation_get_rotation(orientation);
double angle = 90 * cw_rotation;
@@ -320,8 +331,8 @@ sc_screen_render(struct sc_screen *screen, bool update_content_rect) {
// always align to a physical pixel
dstrect->x = (int32_t) dstrect->x;
dstrect->y = (int32_t) dstrect->y;
- ok = SDL_RenderTextureRotated(renderer, texture, NULL, dstrect, angle,
- NULL, flip);
+ ok = SDL_RenderTextureRotated(renderer, texture, srcrect, dstrect,
+ angle, NULL, flip);
}
if (!ok) {
diff --git a/app/src/texture.c b/app/src/texture.c
index a05fa97e..a18fc686 100644
--- a/app/src/texture.c
+++ b/app/src/texture.c
@@ -63,6 +63,12 @@ sc_texture_get(struct sc_texture *tex) {
return tex->interop->texture;
}
+struct sc_size
+sc_texture_get_frame_size(struct sc_texture *tex) {
+ assert(tex->interop && tex->interop->texture);
+ return tex->interop->frame_size;
+}
+
bool
sc_texture_update(struct sc_texture *tex, const AVFrame *frame) {
struct sc_interop *interop = tex->interop;
diff --git a/app/src/texture.h b/app/src/texture.h
index 926b2781..6b536d68 100644
--- a/app/src/texture.h
+++ b/app/src/texture.h
@@ -9,6 +9,7 @@
#include <libavutil/hwcontext.h>
#include <SDL3/SDL.h>
+#include "coords.h"
#include "interop/interop.h"
#include "opengl.h"
@@ -32,6 +33,9 @@ sc_texture_destroy(struct sc_texture *tex);
SDL_Texture *
sc_texture_get(struct sc_texture *tex);
+struct sc_size
+sc_texture_get_frame_size(struct sc_texture *tex);
+
bool
sc_texture_update(struct sc_texture *tex, const AVFrame *frame);