tests/testdisplay.c: Add a option '-g' to save images which intended to paint on screen during each mode setting.
PATCH 1/1 tests/testdisplay.c: Add a option '-g' to save images which intended to paint on screen during each mode setting.
That option will save all the images which are created and intended to paint on screen. The images will be saved in folder "saveimages" with PNG format.
tests/testdisplay.c +28 -1
@@ -64,6 +64,7 @@#include <stdlib.h> #include <signal.h> +#include <sys/stat.h> drmModeRes *resources;int drm_fd, modes;
@@ -72,6 +73,7 @@ int dump_info = 0, test_all_modes =0, test_preferred_mode = 0, force_mode = 0,int sleep_between_modes =5 ;uint32_t depth =24 , stride, bpp;int qr_code =0 ; +int save_image =0 ;drmModeModeInfo force_timing;
@@ -379,6 +381,8 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)cairo_text_extents_t name_extents, mode_extents;char name_buf[128 ], mode_buf[128 ];int i, x, y, modes_x, modes_y; +static int count =0 ; + count++;/* Get text extents for each string */ snprintf(name_buf, sizeof name_buf, "%s",
@@ -460,6 +464,25 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)if (qr_code)paint_image (cr,"./pass.png" ); + +if (save_image){ +char pngname[256 ]; +char *pos; + +readlink ("/proc/self/exe" , pngname,sizeof (pngname)); + pos =strrchr (pngname,'/' ); + *(pos +1 ) ='\0' ; + +strcat (pngname,"saveimages" ); + +//judge whether folder mkdir existed, if not create it. +if (access (pngname,0 ) ==-1 ) +if (mkdir ( pngname,0777 )) +fprintf (stderr,"error %d, %s\n" , errno,strerror (errno)); + +sprintf (pngname,"%s/%d_%s@%d.png" , pngname, count, c->mode.name, c->mode.vrefresh); +cairo_surface_write_to_png (cairo_get_target (cr), pngname ); + } }static void sighandler (int signo)
@@ -599,7 +622,7 @@ int update_display(void)return 1 ; } -static char optstr[] ="hiaf:s:d:p:mrt" ; +static char optstr[] ="hiaf:s:d:p:mrtg" ;static void usage (char *name) {
@@ -612,6 +635,7 @@ static void usage(char *name)fprintf (stderr,"\t-m\ttest the preferred mode\n" );fprintf (stderr,"\t-t\tuse a tiled framebuffer\n" );fprintf (stderr,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); +fprintf (stderr,"\t-g\tsave images which is intended to paint on the screen as png files in folder \"saveimages\"\n" );fprintf (stderr,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" );fprintf (stderr,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" );fprintf (stderr,"\t\ttest force mode\n" );
@@ -704,6 +728,9 @@ int main(int argc, char **argv)case 'r' : qr_code =1 ;break ; +case 'g' : + save_image =1 ; +break ;default :fprintf (stderr,"unknown option %c\n" , c);/* fall through */
Signature · 1 line
1.7.6.4
Quoted 50 lines · Yi Sun
That option will save all the images which are created and intended to paint on screen.
The images will be saved in folder "saveimages" with PNG format.Signed-off-by Yi Sun <[email protected]>tests/testdisplay.c +4
-0@@ -64,6 +64,7 @@#include <stdlib.h> #include <signal.h> +#include <sys/stat.h> drmModeRes *resources;int drm_fd, modes;@@ -72,6 +73,7 @@ int dump_info = 0, test_all_modes =0, test_preferred_mode =0 , force_mode =0 , int sleep_between_modes = 5;uint32_t depth =24 , stride, bpp;int qr_code =0 ; +int save_image =0 ;drmModeModeInfo force_timing;@@ -379,6 +381,8 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)cairo_text_extents_t name_extents, mode_extents;char name_buf[128 ], mode_buf[128 ];int i, x, y, modes_x, modes_y; +static int count =0 ; + count++;/* Get text extents for each string */ tests/testdisplay.c +8
-0snprintf(name_buf, sizeof name_buf, "%s",@@ -460,6 +464,25 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)if (qr_code)paint_image (cr,"./pass.png" ); + +if (save_image){ +char pngname[256 ]; +char *pos; + +readlink ("/proc/self/exe" , pngname,sizeof (pngname)); + pos =strrchr (pngname,'/' ); + *(pos +1 ) ='\0' ;
tests/testdisplay.c paint_output_info(cairo_t *cr, int l_width, int · line 485
Quoted 10 lines
tests/testdisplay.c +9
-0+ +strcat (pngname,"saveimages" ); + +//judge whether folder mkdir existed, if not create it. +if (access (pngname,0 ) ==-1 ) +if (mkdir ( pngname,0777 )) +fprintf (stderr,"error %d, %s\n" , errno,strerror (errno)); + +sprintf (pngname,"%s/%d_%s@%d.png" , pngname, count, c->mode.name, c->mode.vrefresh);
I think we've already decided we're willing to piss off the BSD folks, but just in case we haven't I googled around for a more portable way to do this. It seems argv[0] *may* be better, may not. In any case, this reminds me that maybe we should start noting things which won't work in non-linux operating systems.
I also find it comical that adding the argument, and writing the surface is like 5 lines, and the rest is all finding the damn executable path :-)
Quoted 36 lines
tests/testdisplay.c +2
-0+cairo_surface_write_to_png (cairo_get_target (cr), pngname ); + } }static void sighandler(int signo)
tests/testdisplay.c +2
-1@@ -599,7 +622,7 @@ int update_display(void)return 1 ; } -static char optstr[] ="hiaf:s:d:p:mrt" ; +static char optstr[] ="hiaf:s:d:p:mrtg" ;static void usage (char *name) {@@ -612,6 +635,7 @@ static void usage(char *name)fprintf (stderr,"\t-m\ttest the preferred mode\n" );fprintf (stderr,"\t-t\tuse a tiled framebuffer\n" );fprintf (stderr,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n"); + fprintf(stderr, "\t-g\tsave images which is intended to paint on the screen as png files in folder \"saveimages\"\n"); fprintf(stderr, "\t-f\t<clockMHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n");
fprintf(stderr,
"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n");tests/testdisplay.c +3
-0fprintf (stderr,"\t\ttest force mode\n" );@@ -704,6 +728,9 @@ int main(int argc, char **argv)case 'r' : qr_code =1 ;break ; +case 'g' : + save_image =1 ; +break ;default :fprintf (stderr,"unknown option %c\n" , c);/* fall through */
Quoted 4 lines · Yi Sun
That option will save all the images which are created and intended to paint on screen. The images will be saved in folder "saveimages" with PNG format.
Signed-off-by Yi Sun <[email protected]>
tbh I don't see the point of this. Care to elaborate a bit what you want to achieve with this?
-Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
We want to use the option to save the images which are intended to be painted on the screen. The images will be save in the folder "saveimages", and named like "[email protected]", "2_1920x1080@60" .....
That would be help for our automatic display testing. If some mode can't be lighten up in automatic display testing, we could check the image saved in the folder to see which mode setting failed manually.
Thanks
--Yi Sun
Quoted 22 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 06, 2012 3:09 PM
To: Sun, Yi
Cc: [email protected]; [email protected]; Jin, Gordon
Subject: Re: [PATCH]tests/testdisplay.c: Add a option '-g' to save images which intended to paint on screen during each mode setting.Quoted 1 line · Yi Sun
That option will save all the images which are created and intended to paint
on screen.
Quoted 3 lines
The images will be saved in folder "saveimages" with PNG format.
Signed-off-by Yi Sun <[email protected]>tbh I don't see the point of this. Care to elaborate a bit what you want to achieve with this?
-Daniel
--
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
Quoted 4 lines · Yi
We want to use the option to save the images which are intended to be painted on the screen. The images will be save in the folder "saveimages", and named like "[email protected]", "2_1920x1080@60" .....
That would be help for our automatic display testing. If some mode can't be lighten up in automatic display testing, we could check the image saved in the folder to see which mode setting failed manually.
I still don't see what you need the images for ... adding more output sounds sane, only lighting up a specific mode makes sense, but I have no idea what you need the actual pngs for. Maybe I'm a bit dense. -Daniel
Signature · 2 lines
Daniel Vetter [email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
Quoted 16 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, August 06, 2012 4:33 PM
To: Sun, Yi
Cc: [email protected]; Jin, Gordon
Subject: Re: [PATCH]tests/testdisplay.c: Add a option '-g' to save images which intended to paint on screen during each mode setting.Quoted 1 line · Yi
We want to use the option to save the images which are intended to be
painted on the screen.
Quoted 1 line
The images will be save in the folder "saveimages", and named like
"[email protected]", "2_1920x1080@60" .....
Quoted 2 lines
That would be help for our automatic display testing. If some mode can't be
Quoted 8 lines
lighten up in automatic display testing, we could check the image saved in the folder to see which mode setting failed manually.
I still don't see what you need the images for ... adding more output sounds sane, only lighting up a specific mode makes sense, but I have no idea what you need the actual pngs for. Maybe I'm a bit dense.
-Daniel
--
Oh, it seems that lighting up a specific mode is better than saving the surface into file. I'll try to rewrite it.
Thanks
--Sun, Yi
Quoted 2 lines
Daniel Vetter
[email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch