SDL_Surface *surface_screen;
SDL_Surface *surface_qemu;
+static double scale_factor = 1.0;
+static double screen_degree = 0.0;
+
#define SDL_THREAD
-#ifdef SDL_THREAD
static pthread_mutex_t sdl_mutex = PTHREAD_MUTEX_INITIALIZER;
+#ifdef SDL_THREAD
static pthread_cond_t sdl_cond = PTHREAD_COND_INITIALIZER;
static int sdl_thread_initialized = 0;
#endif
static void qemu_update(void)
{
- SDL_Surface *processing_screen;
- double angle = 0.0; //ROTATION_PORTRAIT
-
-//TODO: convert type define to angle value
- short rotaton_type = get_emul_rotation();
- if (rotaton_type == ROTATION_LANDSCAPE) {
- angle = 90.0;
- } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
- angle = 180.0;
- } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
- angle = 270.0;
+ SDL_Surface *processing_screen = NULL;
+
+ if (scale_factor != 1.0 || screen_degree != 0.0) {
+ //image processing
+ processing_screen = rotozoomSurface(surface_qemu, screen_degree, scale_factor, 1);
+ SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL);
+ } else {
+ SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL);
}
-
- processing_screen = rotozoomSurface(surface_qemu, angle, get_emul_win_scale(), 1);
-
- SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL);
SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
SDL_FreeSurface(processing_screen);
static void* run_qemu_update(void* arg)
{
while(1) {
- pthread_mutex_lock(&sdl_mutex);
+ pthread_mutex_lock(&sdl_mutex);
pthread_cond_wait(&sdl_cond, &sdl_mutex);
qemu_update();
- pthread_mutex_unlock(&sdl_mutex);
+ pthread_mutex_unlock(&sdl_mutex);
}
return NULL;
switch (ev->type) {
case SDL_VIDEORESIZE:
{
- SDL_ResizeEvent *rev = &ev->resize;
- SDL_Quit();
+ int w, h, temp;
+
+ //get current setting information and calculate screen size
+ scale_factor = get_emul_win_scale();
+ w = get_emul_lcd_width() * scale_factor;
+ h = get_emul_lcd_height() * scale_factor;
+
+ short rotaton_type = get_emul_rotation();
+ if (rotaton_type == ROTATION_PORTRAIT) {
+ screen_degree = 0.0;
+ } else if (rotaton_type == ROTATION_LANDSCAPE) {
+ screen_degree = 90.0;
+ temp = w;
+ w = h;
+ h = temp;
+ } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
+ screen_degree = 180.0;
+ } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
+ screen_degree = 270.0;
+ temp = w;
+ w = h;
+ h = temp;
+ }
+
+ pthread_mutex_lock(&sdl_mutex);
- surface_screen = SDL_SetVideoMode(rev->w, rev->h, SDL_BPP, SDL_FLAGS);
+ SDL_Quit(); //The returned surface is freed by SDL_Quit and must not be freed by the caller
+ surface_screen = SDL_SetVideoMode(w, h, SDL_BPP, SDL_FLAGS);
if (surface_screen == NULL) {
- ERR("Could not open SDL display (%dx%dx%d): %s\n", rev->w, rev->h, SDL_BPP, SDL_GetError());
+ ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, SDL_BPP, SDL_GetError());
}
+
+ pthread_mutex_unlock(&sdl_mutex);
+
break;
}
#endif
}
-void maruskin_sdl_resize(int w, int h)
+void maruskin_sdl_resize()
{
SDL_Event ev;
/* this fails if SDL is not initialized */
memset(&ev, 0, sizeof(ev));
ev.resize.type = SDL_VIDEORESIZE;
- ev.resize.w = w;
- ev.resize.h = h;
+
SDL_PushEvent(&ev);
}
void do_scale_event( double scale_factor ) {
INFO( "do_scale_event scale_factor:%lf", scale_factor);
- /*int rotation_type = get_emul_rotation();
- if (rotation_type == ROTATION_PORTRAIT || rotation_type == ROTATION_REVERSE_PORTRAIT) {
- maruskin_sdl_resize(get_emul_lcd_width() * scale_factor, get_emul_lcd_height() * scale_factor);
- } else if (rotation_type == ROTATION_LANDSCAPE || rotation_type == ROTATION_REVERSE_LANDSCAPE) {
- maruskin_sdl_resize(get_emul_lcd_height() * scale_factor, get_emul_lcd_width() * scale_factor);
- }*/
+ set_emul_win_scale(scale_factor);
+ //TODO: thread safe
//qemu refresh
- vga_hw_invalidate();
- vga_hw_update();
-
- set_emul_win_scale(scale_factor);
+ //vga_hw_invalidate();
+ //vga_hw_update();
}
void do_rotation_event( int rotation_type) {
INFO( "send to sendord(size: %d) 127.0.0.1:%d/tcp \n", buf_size, tizen_base_port + SDB_TCP_EMULD_INDEX);
- /*if (rotation_type == ROTATION_PORTRAIT || rotation_type == ROTATION_REVERSE_PORTRAIT) {
- maruskin_sdl_resize(get_emul_lcd_width(), get_emul_lcd_height());
- } else if (rotation_type == ROTATION_LANDSCAPE || rotation_type == ROTATION_REVERSE_LANDSCAPE) {
- maruskin_sdl_resize(get_emul_lcd_height(), get_emul_lcd_width());
- }*/
set_emul_rotation(rotation_type);
#ifdef _WIN32