From f4aa0253c0f401b86bf1769e200b216cd2d8b66d Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 25 Oct 2016 15:44:03 +0900 Subject: [PATCH] implementation for SCREEN_PREROTATION_HINT Change-Id: I8c5e90ac2a4f2119af380c405e31cf9645ea7a25 --- src/tdm_macro.h | 2 +- tools/tdm_test_server.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/tdm_macro.h b/src/tdm_macro.h index 0dfd031..2bbadcf 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -149,7 +149,7 @@ extern "C" { /* don't using !,$,# */ #define TDM_DELIM "@^&*+-|,:~" #define TDM_ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1)) - +#define TDM_SWAP(a, b) ({ int t; t = a; a = b; b = t; }) #define TDM_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) struct tdm_type_name { diff --git a/tools/tdm_test_server.c b/tools/tdm_test_server.c index d59c6ce..b948a96 100644 --- a/tools/tdm_test_server.c +++ b/tools/tdm_test_server.c @@ -748,6 +748,7 @@ interpret_args(tdm_test_server *data) } } +static unsigned int tts_screen_prerotation_hint; static tdm_test_server tts_data; static int tts_buffer_key; #define TTS_BUFFER_KEY ((unsigned long)&tts_buffer_key) @@ -757,6 +758,8 @@ buffer_allocate(int width, int height, int format, int flags) { tdm_test_server_buffer *tb = calloc(1, sizeof *tb); TDM_EXIT_IF_FAIL(tb != NULL); + if (tts_screen_prerotation_hint % 180) + TDM_SWAP(width, height); tb->b = tbm_surface_internal_create_with_flags(width, height, format, flags); TDM_EXIT_IF_FAIL(tb->b != NULL); tdm_helper_clear_buffer(tb->b); @@ -846,6 +849,14 @@ main(int argc, char *argv[]) char temp[TDM_SERVER_REPLY_MSG_LEN]; int len = sizeof temp; tdm_error ret; + const char *value; + + value = (const char*)getenv("SCREEN_PREROTATION_HINT"); + if (value) { + char *end; + tts_screen_prerotation_hint = strtol(value, &end, 10); + printf("SCREEN_PREROTATION_HINT = %d", tts_screen_prerotation_hint); + } signal(SIGINT, exit_test); /* 2 */ signal(SIGTERM, exit_test); /* 15 */ @@ -1036,12 +1047,22 @@ layer_setup(tdm_test_server_layer *l, tbm_surface_h b) /* The size and format information should be same with buffer's */ tbm_surface_get_info(b, &info); - if (IS_RGB(info.format)) { - l->info.src_config.size.h = info.planes[0].stride >> 2; - l->info.src_config.size.v = info.height; + if (tts_screen_prerotation_hint % 180) { + if (IS_RGB(info.format)) { + l->info.src_config.size.h = info.height; + l->info.src_config.size.v = info.planes[0].stride >> 2; + } else { + l->info.src_config.size.h = info.height; + l->info.src_config.size.v = info.planes[0].stride; + } } else { - l->info.src_config.size.h = info.planes[0].stride; - l->info.src_config.size.v = info.height; + if (IS_RGB(info.format)) { + l->info.src_config.size.h = info.planes[0].stride >> 2; + l->info.src_config.size.v = info.height; + } else { + l->info.src_config.size.h = info.planes[0].stride; + l->info.src_config.size.v = info.height; + } } l->info.src_config.format = info.format; -- 2.7.4