From 4c9ab40793a1003c9f561eab1450a8dc26dbdebc Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Wed, 30 Jan 2013 14:11:21 +0900 Subject: [PATCH] display: do not need anti-aliasing on x1.0 do not need anti-aliasing on x1.0 for sdl. Signed-off-by: GiWoong Kim --- tizen/src/maru_sdl.c | 25 +++-- tizen/src/maru_sdl_rotozoom.h | 181 ++++++++++++++++++++++------------ 2 files changed, 139 insertions(+), 67 deletions(-) diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 91864ddfa9..e15ebac1f0 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -412,7 +412,8 @@ static void qemu_update(void) #endif if (current_scale_factor < 0.5) { - /* process by sdl_gfx */ + /* image processing via sdl_gfx for rich interpolating */ + // workaround // set color key 'magenta' surface_qemu->format->colorkey = 0xFF00FF; @@ -425,16 +426,28 @@ static void qemu_update(void) SDL_FreeSurface(temp_surface); } - else if (current_scale_factor != 1.0 || current_screen_degree != 0.0) + else if (current_scale_factor < 1.0) { - //image processing + /* image processing with simple algorithm for uniformly interpolation */ processing_screen = maru_rotozoom( - surface_qemu, processing_screen, (int)current_screen_degree); + surface_qemu, processing_screen, + (int)current_screen_degree, TRUE); + SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL); } - else //as-is + else /* current_scale_factor == 1.0 */ { - SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL); + if (current_screen_degree != 0.0) { + /* image processing */ + processing_screen = maru_rotozoom( + surface_qemu, processing_screen, + (int)current_screen_degree, FALSE); + + SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL); + } else { + /* as-is */ + SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL); + } } /* draw multi-touch finger points */ diff --git a/tizen/src/maru_sdl_rotozoom.h b/tizen/src/maru_sdl_rotozoom.h index 9d236e11e9..88a4c15d44 100644 --- a/tizen/src/maru_sdl_rotozoom.h +++ b/tizen/src/maru_sdl_rotozoom.h @@ -39,10 +39,12 @@ #define G_CHANNEL_MASK 0x0000ff00 #define B_CHANNEL_MASK 0x000000ff -SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle); +SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, + int angle, bool interpolate); -static inline void interpolate_pixel_cpy(unsigned int *dst, unsigned int *src_addr, unsigned int src_w, unsigned int src_h, int x, int y) +static inline void interpolate_pixel_cpy(unsigned int *dst, + unsigned int *src_addr, unsigned int src_w, unsigned int src_h, int x, int y) { #if 0 int i, j, n, m; @@ -101,9 +103,9 @@ static inline void interpolate_pixel_cpy(unsigned int *dst, unsigned int *src_ad *dst = 0xff000000 | ((sum_r / 5) & R_CHANNEL_MASK) | ((sum_g / 5) & G_CHANNEL_MASK) | ((sum_b / 5) & B_CHANNEL_MASK); #endif - unsigned int sum_r = 0; //0x00ff0000 - unsigned int sum_g = 0; //0x0000ff00 - unsigned int sum_b = 0; //0x000000ff + unsigned int sum_r = 0; /* 0x00ff0000 */ + unsigned int sum_g = 0; /* 0x0000ff00 */ + unsigned int sum_b = 0; /* 0x000000ff */ unsigned int c00 = (x * src_w) + y; unsigned int c01 = (y + 1 >= src_w) ? c00 : c00 + 1; @@ -123,7 +125,8 @@ static inline void interpolate_pixel_cpy(unsigned int *dst, unsigned int *src_ad ((sum_g >> 2) & G_CHANNEL_MASK) | ((sum_b >> 2) & B_CHANNEL_MASK); } -SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle) +SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, + int angle, bool interpolate) { #define PRECISION 4096 #define SHIFT 12 @@ -139,7 +142,7 @@ SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle) unsigned int *in = NULL; unsigned int *out = NULL; -// unsigned int *row = NULL; + unsigned int *row = NULL; switch(angle) { case 90: @@ -162,74 +165,130 @@ SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle) SDL_LockSurface(rz_src); - switch(angle) { - case 0: /* portrait */ - out = (unsigned int *) rz_dst->pixels; - - for (i = 0; i < dst_height; i++, out += dst_width) { - row_index = (i * sy) >> SHIFT; -// row = in + (row_index * rz_src->w); - - for (j = 0; j < dst_width; j++) { - col_index = (sx * j) >> SHIFT; - //out[j] = row[col_index]; - interpolate_pixel_cpy(&out[j], in, - rz_src->w, rz_src->h, row_index, col_index); + if (interpolate == true) { + switch(angle) { + case 0: /* portrait */ + out = (unsigned int *) rz_dst->pixels; + + for (i = 0; i < dst_height; i++, out += dst_width) { + row_index = (i * sy) >> SHIFT; + + for (j = 0; j < dst_width; j++) { + col_index = (sx * j) >> SHIFT; + interpolate_pixel_cpy(&out[j], in, + rz_src->w, rz_src->h, row_index, col_index); + } } - } - break; + break; - case 90: /* landscape */ - for (i = 0; i < dst_height; i++) { - row_index = (i * sy) >> SHIFT; -// row = in + (row_index * rz_src->w); + case 90: /* landscape */ + for (i = 0; i < dst_height; i++) { + row_index = (i * sy) >> SHIFT; - out = ((unsigned int *) rz_dst->pixels) + i; + out = ((unsigned int *) rz_dst->pixels) + i; - for (j = 0; j < dst_width; j++, out += dst_height) { - col_index = (sx * j) >> SHIFT; - //out[0] = row[rz_src->w - col_index - 1]; - interpolate_pixel_cpy(&out[0], in, - rz_src->w, rz_src->h, row_index, rz_src->w - col_index - 1); + for (j = 0; j < dst_width; j++, out += dst_height) { + col_index = (sx * j) >> SHIFT; + interpolate_pixel_cpy(&out[0], in, + rz_src->w, rz_src->h, row_index, rz_src->w - col_index - 1); + } } - } - break; + break; - case 180: /* reverse portrait */ - out = (unsigned int *) rz_dst->pixels; + case 180: /* reverse portrait */ + out = (unsigned int *) rz_dst->pixels; - for (i = 0; i < dst_height; i++, out += dst_width) { - row_index = ((dst_height - i - 1) * sy) >> SHIFT; -// row = in + (row_index * rz_src->w); + for (i = 0; i < dst_height; i++, out += dst_width) { + row_index = ((dst_height - i - 1) * sy) >> SHIFT; - for (j = 0; j < dst_width; j++) { - col_index = (sx * j) >> SHIFT; - //out[dst_width - j - 1] = row[col_index]; - interpolate_pixel_cpy(&out[dst_width - j - 1], in, - rz_src->w, rz_src->h, row_index, col_index); + for (j = 0; j < dst_width; j++) { + col_index = (sx * j) >> SHIFT; + interpolate_pixel_cpy(&out[dst_width - j - 1], in, + rz_src->w, rz_src->h, row_index, col_index); + } } - } - break; + break; - case 270: /* reverse landscape */ - for (i = 0; i < dst_height; i++) { - row_index = ((dst_height - i - 1) * sy) >> SHIFT; -// row = in + (row_index * rz_src->w); + case 270: /* reverse landscape */ + for (i = 0; i < dst_height; i++) { + row_index = ((dst_height - i - 1) * sy) >> SHIFT; - out = ((unsigned int *) rz_dst->pixels) + i; + out = ((unsigned int *) rz_dst->pixels) + i; - for (j = 0; j < dst_width; j++, out += dst_height) { - col_index = (sx * j) >> SHIFT; - //out[0] = row[col_index]; - interpolate_pixel_cpy(&out[0], in, - rz_src->w, rz_src->h, row_index, col_index); + for (j = 0; j < dst_width; j++, out += dst_height) { + col_index = (sx * j) >> SHIFT; + interpolate_pixel_cpy(&out[0], in, + rz_src->w, rz_src->h, row_index, col_index); + } } - } - break; + break; - default: - fprintf(stdout, "not supported angle factor (angle=%d)\n", angle); - return NULL; + default: + fprintf(stdout, "not supported angle factor (angle=%d)\n", angle); + return NULL; + } + } else { + switch(angle) { + case 0: /* portrait */ + out = (unsigned int *) rz_dst->pixels; + + for (i = 0; i < dst_height; i++, out += dst_width) { + row_index = (i * sy) >> SHIFT; + row = in + (row_index * rz_src->w); + + for (j = 0; j < dst_width; j++) { + col_index = (sx * j) >> SHIFT; + out[j] = row[col_index]; + } + } + break; + + case 90: /* landscape */ + for (i = 0; i < dst_height; i++) { + row_index = (i * sy) >> SHIFT; + row = in + (row_index * rz_src->w); + + out = ((unsigned int *) rz_dst->pixels) + i; + + for (j = 0; j < dst_width; j++, out += dst_height) { + col_index = (sx * j) >> SHIFT; + out[0] = row[rz_src->w - col_index - 1]; + } + } + break; + + case 180: /* reverse portrait */ + out = (unsigned int *) rz_dst->pixels; + + for (i = 0; i < dst_height; i++, out += dst_width) { + row_index = ((dst_height - i - 1) * sy) >> SHIFT; + row = in + (row_index * rz_src->w); + + for (j = 0; j < dst_width; j++) { + col_index = (sx * j) >> SHIFT; + out[dst_width - j - 1] = row[col_index]; + } + } + break; + + case 270: /* reverse landscape */ + for (i = 0; i < dst_height; i++) { + row_index = ((dst_height - i - 1) * sy) >> SHIFT; + row = in + (row_index * rz_src->w); + + out = ((unsigned int *) rz_dst->pixels) + i; + + for (j = 0; j < dst_width; j++, out += dst_height) { + col_index = (sx * j) >> SHIFT; + out[0] = row[col_index]; + } + } + break; + + default: + fprintf(stdout, "not supported angle factor (angle=%d)\n", angle); + return NULL; + } } SDL_UnlockSurface(rz_src); -- 2.34.1