Changeset 1365


Ignore:
Timestamp:
10/15/11 04:22:52 (20 months ago)
Author:
philmoz
Message:

Remove the code that is no longer needed from the 9/4 scaling of the CHDK OSD display. See http://chdk.setepontos.com/index.php?topic=6395.msg66961#msg66961.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/edgeoverlay.c

    r1203 r1365  
    3636static void get_viewport_size() 
    3737{ 
    38     // since screen_height is used in the drawing downwards, we should use it 
    39     // here too to calculate the buffer we need... 
    40  
    41 #if defined(CAM_USES_ASPECT_CORRECTION) 
    42     //nandoide sept-2009 get the viewport dimensions, not the screen dimensions, on sx200is they aren't the same. 
    4338    viewport_height = vid_get_viewport_height()-EDGE_HMARGIN*2; //don't trace bottom lines 
    4439    viewport_width = vid_get_viewport_width(); 
    4540    viewport_byte_width = vid_get_viewport_buffer_width() * 3; 
    46 #else 
    47     viewport_height = screen_height;//vid_get_viewport_height(); 
    48     viewport_width = screen_width; 
    49     viewport_byte_width = screen_width * 3; 
    50 #endif 
    5141 
    5242        viewport_xoffset = vid_get_viewport_xoffset(); 
     
    518508                    // If there is no edge based on the newest data, but there is one painted on the screen 
    519509                    // from previous calls, delete it from the screen. 
    520                     const int aspect_correct_x_off = ASPECT_VIEWPORT_XCORRECTION(x_off); 
     510                    const int aspect_correct_x_off = x_off; 
    521511                    const int bEdge = bv_get(edgebuf, y_edgebuf + x); 
    522512                    const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == conf.edge_overlay_color); 
     
    546536            for (x = x_min_c; x < x_max_c; ++x) 
    547537            { 
    548                 const int aspect_correct_x = ASPECT_VIEWPORT_XCORRECTION(x); 
     538                const int aspect_correct_x = x; 
    549539                if (draw_get_pixel(aspect_correct_x, y) == cl)  // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen 
    550540                    draw_pixel(aspect_correct_x, y, 0 ); 
     
    564554            for (x = x_min; x < x_max; ++x) 
    565555            { 
    566                 const int aspect_correct_x = ASPECT_VIEWPORT_XCORRECTION(x); 
     556                const int aspect_correct_x = x; 
    567557                if (draw_get_pixel(aspect_correct_x, y) == cl)  // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen 
    568558                    draw_pixel(aspect_correct_x, y, 0 ); 
  • trunk/core/gui.c

    r1350 r1365  
    20922092    gui_in_redraw = 1; 
    20932093    gui_mode_old = gui_mode; 
    2094  
    2095 #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009 
    2096     //the different modes arises because games are designed on a 360x240 basis and are difficult to downscale to 320x240 
    2097     if (gui_mode == GUI_MODE_REVERSI || gui_mode == GUI_MODE_SOKOBAN || gui_mode == GUI_MODE_4WINS || gui_mode == GUI_MODE_MASTERMIND) { 
    2098       draw_set_environment(aspect_xcorrection_games_360, aspect_ycorrection_games_360, GAMES_SCREEN_WIDTH, GAMES_SCREEN_HEIGHT); 
    2099    } else { //default 
    2100       draw_set_environment(NULL, NULL, vid_get_bitmap_screen_width(), vid_get_bitmap_screen_height()); 
    2101    } 
    2102 #endif 
    21032094 
    21042095#ifdef CAM_TOUCHSCREEN_UI 
     
    26272618    } 
    26282619 
    2629     #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009 
    2630       draw_set_environment(aspect_xcorrection_games_360, aspect_ycorrection_games_360, GAMES_SCREEN_WIDTH, GAMES_SCREEN_HEIGHT); 
    2631     #endif 
    26322620    gui_set_mode(GUI_MODE_REVERSI); 
    26332621    gui_reversi_init(); 
     
    26432631        return; 
    26442632    } 
    2645     #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009 
    2646       draw_set_environment(aspect_xcorrection_games_360, aspect_ycorrection_games_360, GAMES_SCREEN_WIDTH, GAMES_SCREEN_HEIGHT); 
    2647     #endif 
    26482633    if ( gui_sokoban_init() ) 
    26492634        gui_set_mode(GUI_MODE_SOKOBAN); 
     
    26582643        return; 
    26592644    } 
    2660     #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009 
    2661       draw_set_environment(aspect_xcorrection_games_360, aspect_ycorrection_games_360, GAMES_SCREEN_WIDTH, GAMES_SCREEN_HEIGHT); 
    2662     #endif 
    26632645    if ( gui_4wins_init() ) 
    26642646        gui_set_mode(GUI_MODE_4WINS); 
     
    26732655        return; 
    26742656    } 
    2675     #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009 
    2676      draw_set_environment(aspect_xcorrection_games_360, aspect_ycorrection_games_360, GAMES_SCREEN_WIDTH, GAMES_SCREEN_HEIGHT); 
    2677     #endif 
    2678    if ( gui_mastermind_init() ) 
     2657    if ( gui_mastermind_init() ) 
    26792658        gui_set_mode(GUI_MODE_MASTERMIND); 
    26802659} 
  • trunk/core/gui_draw.c

    r1355 r1365  
    2323} 
    2424 
    25 #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009  
    26  
    27 unsigned int (*aspect_xcorrection_proc)(unsigned int x); 
    28 unsigned int (*aspect_ycorrection_proc)(unsigned int y); 
    29  
    30 //------------------------------------------------------------------- 
    31 unsigned int aspect_xcorrection_std(unsigned int x) { 
    32    return (ASPECT_XCORRECTION(x)); 
    33 } 
    34 //------------------------------------------------------------------- 
    35 static unsigned int aspect_ycorrection_std(unsigned int y) { 
    36    return (ASPECT_YCORRECTION(y)); 
    37 } 
    38 //------------------------------------------------------------------- 
    39 unsigned int aspect_xcorrection_games_360(unsigned int x) { 
    40    return (ASPECT_GAMES_XCORRECTION(x)); 
    41 } 
    42 //------------------------------------------------------------------- 
    43 unsigned int aspect_ycorrection_games_360(unsigned int y) { 
    44    return (ASPECT_GAMES_YCORRECTION(y)); 
    45 } 
    46 //------------------------------------------------------------------- 
    47 void draw_set_aspect_xcorrection_proc(unsigned int (*xcorrection_proc)(unsigned int x)) { 
    48    aspect_xcorrection_proc = (xcorrection_proc)?xcorrection_proc:aspect_xcorrection_std; 
    49 } 
    50 //------------------------------------------------------------------- 
    51 void draw_set_aspect_ycorrection_proc(unsigned int (*ycorrection_proc)(unsigned int y)) { 
    52    aspect_ycorrection_proc = (ycorrection_proc)?ycorrection_proc:aspect_ycorrection_std; 
    53 } 
    54 //------------------------------------------------------------------- 
    55 void draw_set_environment(unsigned int (*xcorrection_proc)(unsigned int x),  
    56                                        unsigned int (*ycorrection_proc)(unsigned int y), 
    57                                        int screenx, int screeny ) { 
    58    screen_width=screenx; 
    59    screen_height=screeny; 
    60    draw_set_aspect_xcorrection_proc(xcorrection_proc); 
    61    draw_set_aspect_ycorrection_proc(ycorrection_proc); 
    62 } 
    63  
    64 #endif 
    65  
    6625//------------------------------------------------------------------- 
    6726#ifdef CAM_DETECT_SCREEN_ERASE 
     
    8645{ 
    8746    if (x >= screen_width || y >= screen_height) return 0; 
    88 #if CAM_USES_ASPECT_CORRECTION 
    89     return (frame_buffer[0][y * screen_buffer_width + aspect_xcorrection_proc(x)] == c) && 
    90            (frame_buffer[1][y * screen_buffer_width + aspect_xcorrection_proc(x)] == c); 
    91 #else 
    92     return (frame_buffer[0][y * screen_buffer_width + x] == c) && 
    93            (frame_buffer[1][y * screen_buffer_width + x] == c); 
    94 #endif 
     47    return (frame_buffer[0][y * screen_buffer_width + ASPECT_XCORRECTION(x)] == c) && 
     48           (frame_buffer[1][y * screen_buffer_width + ASPECT_XCORRECTION(x)] == c); 
    9549} 
    9650 
     
    11064    frame_buffer[1] = frame_buffer[0] + screen_buffer_size; 
    11165    draw_set_draw_proc(NULL); 
    112     #if CAM_USES_ASPECT_CORRECTION 
    113       draw_set_aspect_xcorrection_proc(NULL); 
    114       draw_set_aspect_ycorrection_proc(NULL); 
    115     #endif 
    11666 
    11767#ifdef CAM_DETECT_SCREEN_ERASE 
     
    12070} 
    12171 
    122 #if CAM_USES_ASPECT_CORRECTION 
    123  
    124 // nandoide: sept-2009: draw_pixel_xarray draws a horizontal line at height y, from xi to xf 
    125 // includes a correction of aspect ratio on x from buffer to screen 
    126 // can be used to optimize computations (offset calculus) in other primitives (rectangles, and so on...) and compensate tne increase in computation time  
    127 // of aspect ratio correction. 
    128 // sx200is: 
    129 //    we have a 720x240 efective memory buffer (in a 960x270 physical memory buffer) and a screen of 320x240 (!)  
    130 //   the drawing primitives work on screen coordinates (the other approach, less modular it's to paint on buffer coordinates, deforming on x direction, I think it would be harder to live with it 
    131 //   and requires a full bunch of changes of the actual software). 
    132 //   then we do paint a x coordinate transformed in buffer by a factor 720/320=9/4 and then we do correct (deform) x  to x*9/4 previously to save it on buffer 
    133 // other: 
    134 //     the default mapping is x=x (NOTE: I think important to check that on every model, and necessary in newer models. it seems to me very strange screen sizes of 360x240 for 4/3 and 480/240 for 16/9 (SX1S). 
    135  
    136 void draw_pixel_xarray(coord y, coord xi, coord xf, color cl) { 
    137     if (xi >= screen_width || y >= screen_height) return; 
    138     else { 
    139         unsigned int offsetx, offsetxf, offsetxi, offsety; 
    140         offsety=aspect_ycorrection_proc(y) * screen_buffer_width; 
    141         offsetxi = aspect_xcorrection_proc(xi); 
    142         xf++; 
    143         offsetxf= (xf >= screen_width) ? screen_buffer_width - 1 :  aspect_xcorrection_proc(xf); 
    144         for (offsetx=offsetxi; offsetx<=offsetxf-1; offsetx++) { 
    145            draw_pixel_proc(offsety+offsetx, cl); 
    146         } 
    147     } 
    148 } 
    149  
    150 #if  CAM_USES_ASPECT_YCORRECTION 
    151 //generalization for cases than we need to correct both coordinates: symetric algorithm 
    152 void draw_pixel_rectanglearray(coord yi, coord yf, coord xi, coord xf, color cl) { 
    153     if (xi >= screen_width || yi >= screen_height) return; 
    154     else { 
    155         unsigned int offsetx, offsetxf, offsetxi, offsety, offsetyf, offsetyi, offset; 
    156         offsetyi = aspect_ycorrection_proc(yi); 
    157         yf++; 
    158         offsetyf= (yf >= screen_height) ? screen_buffer_height - 1 :  aspect_ycorrection_proc(yf); 
    159         offsetxi = aspect_xcorrection_proc(xi); 
    160         xf++; 
    161         offsetxf= (xf >= screen_width) ? screen_buffer_width - 1 :  aspect_xcorrection_proc(xf); 
    162         for (offsety=offsetyi; offsety<=offsetyf-1; offsety++) { 
    163           offset=offsety*screen_buffer_width; 
    164           for (offsetx=offsetxi; offsetx<=offsetxf-1; offsetx++) { 
    165              draw_pixel_proc(offset+offsetx, cl); 
    166           } 
    167         } 
    168     } 
    169 } 
    170 #endif 
    171  
    172 // nandoide sept-2009: draw_pixel version that calls draw_pixel_xarray for calculations. It's necessary to paint more than a pixel. In other case we got holes due 
    173 // to the nature of discrete drawing algoritms and the aspect-ratio correction. 
    174 // so, we need paint a horizontal line from the point coordinate to the next point (x to x+1) 
    175 // it's a brute force algorithm and it's possible that we have aliasing problems ...  
    176 // but the display seems OK on sx200is ( good!) , due perhaps to the fact that the system makes a final reverse (bilinear?) resize 720 -> 320, to display the buffer data. 
    177  
    178 void draw_pixel(coord x, coord y, color cl) { 
    179   #if  CAM_USES_ASPECT_YCORRECTION 
    180     draw_pixel_rectanglearray(y, y, x, x, cl); 
    181   #else 
    182     draw_pixel_xarray(y, x, x, cl); 
    183   #endif 
    184 } 
    185  
    186 color draw_get_pixel(coord x, coord y) { 
    187     if (x >= screen_width || y >= screen_height) return 0; 
    188     return frame_buffer[0][y * screen_buffer_width + aspect_xcorrection_proc(x) ]; 
    189 } 
    190 #else 
    19172//------------------------------------------------------------------- 
    19273void draw_pixel(coord x, coord y, color cl) { 
    19374    if (x >= screen_width || y >= screen_height) return; 
    19475    else { 
    195         register unsigned int offset = y * screen_buffer_width + x; 
    196         draw_pixel_proc(offset, cl); 
     76        register unsigned int offset = y * screen_buffer_width + ASPECT_XCORRECTION(x); 
     77        draw_pixel_proc(offset,   cl); 
     78#if CAM_USES_ASPECT_CORRECTION 
     79        draw_pixel_proc(offset+1, cl);  // Draw second pixel if screen scaling is needed 
     80#endif 
    19781   } 
    19882} 
     
    20185color draw_get_pixel(coord x, coord y) { 
    20286    if (x >= screen_width || y >= screen_height) return 0; 
    203     return frame_buffer[0][y * screen_buffer_width + x]; 
    204 } 
    205 #endif 
     87    return frame_buffer[0][y * screen_buffer_width + ASPECT_XCORRECTION(x) ]; 
     88} 
    20689 
    20790//------------------------------------------------------------------- 
     
    237120void draw_hline(coord x, coord y, int len, color cl) 
    238121{ 
    239     #if CAM_USES_ASPECT_CORRECTION &&  !CAM_USES_ASPECT_YCORRECTION 
    240       draw_pixel_xarray(y, x, x+len, cl); 
    241     #else 
    242       for (; len>=0; len--, x++) { 
    243           draw_pixel(x, y, cl); 
    244       } 
    245     #endif 
     122    if (x >= screen_width || y >= screen_height) return; 
     123    if (x < 0) { len += x; x = 0; } 
     124    if ((x + len) > screen_width) len = screen_width - x; 
     125    register unsigned int offset = y * screen_buffer_width + ASPECT_XCORRECTION(x); 
     126    len = ASPECT_XCORRECTION(len);      // Scale the line length if needed 
     127    for (; len>=0; len--, offset++) 
     128        draw_pixel_proc(offset, cl); 
    246129} 
    247130 
    248131void draw_vline(coord x, coord y, int len, color cl) 
    249132{ 
    250     for (; len>=0; len--, y++) { 
     133    if ((x < 0) || (x >= screen_width) || (y >= screen_height)) return; 
     134    if (y < 0) { len += y; y = 0; } 
     135    if ((y + len) > screen_height) len = screen_height - y; 
     136    for (; len>=0; len--, y++) 
    251137      draw_pixel(x, y, cl); 
    252     } 
    253138} 
    254139//------------------------------------------------------------------- 
     
    276161    if (yMin>=screen_height) yMin=screen_height-1; 
    277162 
    278     for (y=yMin+(round<<1); y<=yMax-(round<<1); ++y) { 
     163    for (y=yMin+(round<<1); y<=yMax-(round<<1); ++y) 
     164    { 
    279165      draw_pixel(xMin, y, cl); 
    280166      draw_pixel(xMax, y, cl); 
    281167    } 
    282     #if CAM_USES_ASPECT_CORRECTION &&  !CAM_USES_ASPECT_YCORRECTION 
    283       draw_pixel_xarray(yMin, xMin+1+round, xMax-1-round, cl); 
    284       draw_pixel_xarray(yMax, xMin+1+round, xMax-1-round, cl); 
    285     #else 
    286       for (x=xMin+1+round; x<=xMax-1-round; ++x) { 
    287           draw_pixel(x, yMin, cl); 
    288           draw_pixel(x, yMax, cl); 
    289       } 
    290     #endif 
     168 
     169    draw_hline(xMin+1+round, yMin, (xMax-1-round) - (xMin+1+round) + 1, cl); 
     170    draw_hline(xMin+1+round, yMax, (xMax-1-round) - (xMin+1+round) + 1, cl); 
    291171} 
    292172 
     
    331211    register unsigned int x, y; 
    332212 
    333     for (y=yMin+1; y<=yMax-1; ++y) { 
    334       #if CAM_USES_ASPECT_CORRECTION &&  !CAM_USES_ASPECT_YCORRECTION 
    335         draw_pixel_xarray(y, xMin+1, xMax-1, cl>>8); 
    336       #else   
    337         for (x=xMin+1; x<=xMax-1; ++x) { 
    338           draw_pixel(x, y, cl>>8); 
    339         } 
    340       #endif 
     213    cl = cl >> 8; 
     214    for (y=yMin+1; y<=yMax-1; ++y) 
     215    { 
     216        draw_hline(xMin+1, y, (xMax-1) - (xMin+1) + 1, cl); 
    341217    } 
    342218} 
  • trunk/core/gui_draw.h

    r1355 r1365  
    733733#endif 
    734734 
    735 #if CAM_USES_ASPECT_CORRECTION //nandoide sept-2009 
    736 void draw_set_aspect_xcorrection_proc(unsigned int (*xcorrection_proc)(unsigned int x)); 
    737 void draw_set_aspect_ycorrection_proc(unsigned int (*ycorrection_proc)(unsigned int y)); 
    738 unsigned int aspect_xcorrection_games_360(unsigned int x); 
    739 unsigned int aspect_ycorrection_games_360(unsigned int y); 
    740 void draw_set_environment(unsigned int (*xcorrection_proc)(unsigned int x), 
    741                                        unsigned int (*ycorrection_proc)(unsigned int y), 
    742                                        int screenx, int screeny ); 
    743 #endif 
    744  
    745735//------------------------------------------------------------------- 
    746736#endif 
  • trunk/core/gui_grid.c

    r804 r1365  
    8686    if (gptr) { 
    8787      gptr->type=type; 
    88       #if CAM_USES_ASPECT_CORRECTION //nandoide sep-2009 
    89         gptr->x0=ASPECT_GRID_XCORRECTION(nums[0]);  gptr->y0=ASPECT_GRID_YCORRECTION(nums[1]); 
    90         gptr->x1=ASPECT_GRID_XCORRECTION(nums[2]);  gptr->y1=ASPECT_GRID_YCORRECTION(nums[3]); 
    91       #else 
    92         gptr->x0=nums[0];  gptr->y0=nums[1]; 
    93         gptr->x1=nums[2];  gptr->y1=nums[3]; 
    94       #endif 
     88      gptr->x0=nums[0];  gptr->y0=nums[1]; 
     89      gptr->x1=nums[2];  gptr->y1=nums[3]; 
    9590      gptr->clf=nums[4]; gptr->clb=nums[5]; 
    9691      if (!head) head=gptr; 
  • trunk/core/motion_detector.c

    r1088 r1365  
    559559        } 
    560560 
    561         xoffset = ASPECT_VIEWPORT_XCORRECTION(vid_get_viewport_xoffset());      // used when image size != viewport size 
     561        xoffset = vid_get_viewport_xoffset();   // used when image size != viewport size 
    562562        yoffset = vid_get_viewport_yoffset();   // used when image size != viewport size 
    563563 
  • trunk/include/camera.h

    r1352 r1365  
    9696#define ZEBRA_HMARGIN0              0 
    9797 
    98 // aspect corrections 
    99 #define CAM_USES_ASPECT_CORRECTION  0           // if true, camera uses a modified graphics primitives to draw with exact display aspect-ratio. 
    100                                                 // Could slow the graphics output (but not perceived on sx200is), but adds rectangle drawing optimizations to compensate. 
    101                                                 // To extend to other cameras see sx200is camera.h comments in  and comments on core gui_draw.c 
    102 #define CAM_USES_ASPECT_YCORRECTION 0 
    103  
    104 // menu, alt (default) 
    105 #define ASPECT_XCORRECTION(x)  ( ((x)<<1) )     // see comments on 200is 
    106 #define ASPECT_YCORRECTION(y)  ( (y) )          // no correction the same for coordinate y. I think there are no cameras actually needing both corrections. 
    107 // viewport, defaults used if there is no aspect correction 
    108 #define ASPECT_VIEWPORT_XCORRECTION(x) ( (x) )  // see comments on 200is 
    109 #define ASPECT_VIEWPORT_YCORRECTION(y) ( (y) )  // no correction 
     98// Older cameras had a screen/bitmap buffer that was 360 pixels wide (or 480 for wide screen models) 
     99// CHDK was built around this 360 pixel wide display model 
     100// Newer cameras have a 720 pixel wide bitmap (960 for wide screen cameras) 
     101// To accomadate this the CHDK co-ordinate system assumes a 360/480 wide buffer and the 
     102// pixel drawing routines draw every pixel twice to scale the image up to the actual buffer size 
     103// Define CAM_USES_ASPECT_CORRECTION with a value of 1 to enable this scaled display 
     104#define CAM_USES_ASPECT_CORRECTION  0 
    110105 
    111106#define EDGE_HMARGIN                0           // define sup and inf screen margins on edge overlay without overlay.  Necessary to save memory buffer space. sx200is needs values other than 0 
     
    153148                                                // This reduces the file size by approx 45% 
    154149 
    155 // Games definitions 
    156 #define GAMES_SCREEN_WIDTH            360        // Logical screen width for games 
    157 #define GAMES_SCREEN_HEIGHT            240       // Logical screen height for games 
    158 #define ASPECT_GAMES_XCORRECTION(x)    ((x)<<1)  // Aspect ratio correction for games. Default for games is 360x240 logical screen. Physical camera screen is 
    159 #define ASPECT_GAMES_YCORRECTION(y)    (y)       // 720x240 so x*2 needed for X axis correction, no correction for Y. 
    160  
    161 // Grid definitions 
    162 #define ASPECT_GRID_XCORRECTION(x)    (x)        // Aspect ratio correction for grids. Grids are designed on a 360x240 logical screen size which matches the 
    163 #define ASPECT_GRID_YCORRECTION(y)    (y)        // default CHDK logical screen size so no correction needed. 
    164  
    165150#undef  PARAM_CAMERA_NAME                        // parameter number for GetParameterData to get camera name 
    166151 
     
    200185//========================================================== 
    201186 
     187// For newer cameras where the screen bitmap is double the width we need to scale 
     188// the CHDK horizontal (X) co-ordinates 
     189#if CAM_USES_ASPECT_CORRECTION 
     190#define ASPECT_XCORRECTION(x)   ((x)<<1)    // See comments for CAM_USES_ASPECT_CORRECTION above 
     191#else 
     192#define ASPECT_XCORRECTION(x)   (x)         // See comments for CAM_USES_ASPECT_CORRECTION above 
     193#endif 
    202194 
    203195// curves only work in 10bpp for now 
  • trunk/platform/ixus310_elph500hs/platform_camera.h

    r1352 r1365  
    7979    #undef CAM_USES_ASPECT_CORRECTION 
    8080    #define CAM_USES_ASPECT_CORRECTION  1       //camera uses the modified graphics primitives to map screens an viewports to buffers more sized 
    81     #undef GAMES_SCREEN_WIDTH 
    82     #define GAMES_SCREEN_WIDTH          480     // Logical screen width for games 
    8381 
    8482    #undef EDGE_HMARGIN 
Note: See TracChangeset for help on using the changeset viewer.