Move frame updating to screen.c

Replace screen_update() by a higher-level screen_update_frame() handling
the whole frame updating, so that scrcpy.c just call it without managing
implementation details.
This commit is contained in:
Romain Vimont
2018-02-09 11:14:47 +01:00
parent 7458d8271e
commit fe21d9dfb5
3 changed files with 12 additions and 17 deletions

View File

@@ -4,6 +4,7 @@
#include <string.h>
#include "icon.xpm"
#include "lockutil.h"
#include "tinyxpm.h"
#define DISPLAY_MARGINS 96
@@ -237,12 +238,18 @@ static void update_texture(struct screen *screen, const AVFrame *frame) {
frame->data[2], frame->linesize[2]);
}
SDL_bool screen_update(struct screen *screen, const AVFrame *frame) {
SDL_bool screen_update_frame(struct screen *screen, struct frames *frames) {
mutex_lock(frames->mutex);
const AVFrame *frame = frames_consume_rendered_frame(frames);
struct size new_frame_size = {frame->width, frame->height};
if (!prepare_for_frame(screen, new_frame_size)) {
mutex_unlock(frames->mutex);
return SDL_FALSE;
}
update_texture(screen, frame);
mutex_unlock(frames->mutex);
screen_render(screen);
return SDL_TRUE;
}