[Title] refine some code
authorgiwoong.kim <giwoong.kim@samsung.com>
Fri, 31 Aug 2012 10:58:52 +0000 (19:58 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Fri, 31 Aug 2012 10:58:52 +0000 (19:58 +0900)
[Type] enhancement
[Module] Emulator / sdl
[Priority] minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/maru_sdl.c
tizen/src/maru_sdl_rotozoom.h

index 3ca6385a6965fa1c925410352fcef329b6b36da2..80b78e0aa7543ad0e6908dff8017ab6eed443f26 100644 (file)
@@ -246,6 +246,7 @@ static void _sdl_init(void)
     }
 }
 
+#if 0
 static int point_degree = 0;
 static void draw_outline_circle(int cx, int cy, int r, int num_segments)
 {
@@ -297,6 +298,7 @@ static void draw_fill_circle(int cx, int cy, int r)
     glDisable(GL_POINT_SMOOTH);
     glDisable(GL_BLEND);
 }
+#endif
 
 static void qemu_update(void)
 {
@@ -317,6 +319,7 @@ static void qemu_update(void)
     if (surface_qemu != NULL) {
         int i;
 
+#if 0
         if (sdl_opengl == 1)
         { //gl surface
             glEnable(GL_TEXTURE_2D);
@@ -373,6 +376,7 @@ static void qemu_update(void)
         }
         else
         { //sdl surface
+#endif
             if (current_scale_factor < 0.5)
             {
                 /* process by sdl_gfx */
@@ -419,7 +423,6 @@ static void qemu_update(void)
                 }
             } //end  of draw multi-touch
         }
-    }
 
     SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
 }
index de362cae9c3669db5decb71a51f05cbd7b8bc368..e6e7c33cded3875b22153d72cbef6cdac27d6a4d 100644 (file)
@@ -42,7 +42,7 @@
 SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle);
 
 
-static 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;
@@ -119,8 +119,8 @@ static void interpolate_pixel_cpy(unsigned int *dst, unsigned int *src_addr, uns
     sum_b = (src_addr[c00] & B_CHANNEL_MASK) + (src_addr[c01] & B_CHANNEL_MASK) +
         (src_addr[c10] & B_CHANNEL_MASK) + (src_addr[c11] & B_CHANNEL_MASK);
 
-    *dst = 0xff000000 | ((sum_r / 4) & R_CHANNEL_MASK) |
-        ((sum_g / 4) & G_CHANNEL_MASK) | ((sum_b / 4) & B_CHANNEL_MASK);
+    *dst = 0xff000000 | ((sum_r >> 2) & R_CHANNEL_MASK) |
+        ((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)
@@ -137,6 +137,7 @@ SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle)
     unsigned int row_index = 0;
     unsigned int col_index = 0;
 
+    unsigned int *in = NULL;
     unsigned int *out = NULL;
     unsigned int *row = NULL;
 
@@ -157,68 +158,70 @@ SDL_Surface *maru_rotozoom(SDL_Surface *rz_src, SDL_Surface *rz_dst, int angle)
     sx = (rz_src->w) * PRECISION / dst_width;
     sy = (rz_src->h) * PRECISION / dst_height;
 
+    in = (unsigned int *) rz_src->pixels;
+
     SDL_LockSurface(rz_src);
 
     switch(angle) {
-        case 0:
+        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    = ((unsigned int *) rz_src->pixels) + (row_index * rz_src->w);
+                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], ((unsigned int *) rz_src->pixels),
+                    interpolate_pixel_cpy(&out[j], in,
                         rz_src->w, rz_src->h, row_index, col_index);
                 }
             }
             break;
 
-        case 90: //landscape
+        case 90: /* landscape */
             for (i = 0; i < dst_height; i++) {
                 row_index  = (i * sy) >> SHIFT;
-                row = ((unsigned int *) rz_src->pixels) + (row_index * rz_src->w);
+                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];
-                    interpolate_pixel_cpy(&out[0], ((unsigned int *) rz_src->pixels),
+                    interpolate_pixel_cpy(&out[0], in,
                         rz_src->w, rz_src->h, row_index, rz_src->w - col_index - 1);
                 }
             }
             break;
 
-        case 180:
+        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 = ((unsigned int *) rz_src->pixels) + (row_index * rz_src->w);
+                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];
-                    interpolate_pixel_cpy(&out[dst_width - j - 1], ((unsigned int *) rz_src->pixels),
+                    interpolate_pixel_cpy(&out[dst_width - j - 1], in,
                         rz_src->w, rz_src->h, row_index, col_index);
                 }
             }
             break;
 
-        case 270: //reverse landscape
+        case 270: /* reverse landscape */
             for (i = 0; i < dst_height; i++) {
                 row_index = ((dst_height - i - 1) * sy) >> SHIFT;
-                row = ((unsigned int *) rz_src->pixels) + (row_index * rz_src->w);
+                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];
-                    interpolate_pixel_cpy(&out[0], ((unsigned int *) rz_src->pixels),
+                    interpolate_pixel_cpy(&out[0], in,
                         rz_src->w, rz_src->h, row_index, col_index);
                 }
             }