lib: use a critical warning when unable to open a data file
PATCH 1/2 lib: use a critical warning when unable to open a data file
Signed-off-by Thomas Wood <[email protected]>
--- lib/igt_core.c | 5 +++++ tests/testdisplay.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-)
lib/igt_core.c +5 -0
@@ -1751,5 +1751,10 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,snprintf (path,sizeof (path),"%s/%s" , igt_srcdir, filename); fp =fopen (path,"r" ); } + +if (!fp) +igt_critical ("Could not open data file \"%s\": %s" , filename, +strerror (errno)); +return fp; }
tests/testdisplay.c +1 -4
@@ -262,11 +262,8 @@ static void paint_image(cairo_t *cr, const char *file) img_x = (width /2 ) - (img_w /2 ); fp =igt_fopen_data (file); -if (!fp) { -igt_warn ("data file \'%s\' missing: %s\n" , - file,strerror (errno)); +if (!fp)return ; - } image =cairo_image_surface_create_from_png_stream (&stdio_read_func, (void *)fp);
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 lib: load images from the data directory in igt_paint_image
Update igt_paint_image so that it can read images from the package data directory.
Signed-off-by Thomas Wood <[email protected]>
--- lib/Android.mk | 2 +- lib/Makefile.am | 3 ++- lib/igt_fb.c | 23 +++++++++++++++++------ tests/testdisplay.c | 35 ++--------------------------------- 4 files changed, 22 insertions(+), 41 deletions(-)
lib/Android.mk +1 -1
@@ -35,7 +35,7 @@ LOCAL_SHARED_LIBRARIES := libpciaccess \ ifeq ("${ANDROID_HAS_CAIRO}", "1") skip_lib_list := LOCAL_C_INCLUDES += $(ANDROID_BUILD_TOP)/external/cairo-1.12.16/src - LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=1 -DIGT_DATADIR=\".\" + LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=1 -DIGT_DATADIR=\".\" -DIGT_SRCDIR=\".\" else skip_lib_list := \ igt_kms.c \
lib/Makefile.am +2 -1
@@ -10,7 +10,8 @@ noinst_HEADERS = check-ndebug.h AM_CPPFLAGS = -I$(top_srcdir) AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(LIBUNWIND_CFLAGS) $(DEBUG_CFLAGS) \ - -DIGT_DATADIR=\""$(abs_top_srcdir)/tests"\" \ + -DIGT_SRCDIR=\""$(abs_top_srcdir)/tests"\" \ + -DIGT_DATADIR=\""$(pkgdatadir)"\" \ -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \ -pthread
lib/igt_fb.c +17 -6
@@ -338,6 +338,15 @@ void igt_paint_test_pattern(cairo_t *cr, int width, int height)igt_assert (!cairo_status (cr)); } +static cairo_status_t +stdio_read_func (void *closure,unsigned char * data,unsigned int size) +{ +if (fread (data,1 , size, (FILE *)closure) != size) +return CAIRO_STATUS_READ_ERROR ; + +return CAIRO_STATUS_SUCCESS ; +} +/** * igt_paint_image: * @cr: cairo drawing context
@@ -347,9 +356,8 @@ void igt_paint_test_pattern(cairo_t *cr, int width, int height)* @dst_width: width of the destination rectangle * @dst_height: height of the destination rectangle * -* This function can be used to draw a scaled version of the supplied png image. -* This is currently only used by the CR-code based testing in the "testdisplay" -* testcase. +* This function can be used to draw a scaled version of the supplied png image, +* which is loaded from the package data directory. */ void igt_paint_image (cairo_t *cr,const char *filename,int dst_x,int dst_y,int dst_width,int dst_height)
@@ -357,8 +365,11 @@ void igt_paint_image(cairo_t *cr, const char *filename,cairo_surface_t *image;int img_width, img_height;double scale_x, scale_y; +FILE * f; + + f =igt_fopen_data (filename); - image =cairo_image_surface_create_from_png (filename); + image =cairo_image_surface_create_from_png_stream (&stdio_read_func, f);igt_assert (cairo_surface_status (image) ==CAIRO_STATUS_SUCCESS ); img_width =cairo_image_surface_get_width (image);
@@ -605,10 +616,10 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, tiling, &fb); cr =igt_get_cairo_ctx (drm_fd, &fb); -igt_paint_image (cr,IGT_DATADIR "/1080p-left.png" , +igt_paint_image (cr,"1080p-left.png" , layout.left.x, layout.left.y, layout.left.width, layout.left.height); -igt_paint_image (cr,IGT_DATADIR "/1080p-right.png" , +igt_paint_image (cr,"1080p-right.png" , layout.right.x, layout.right.y, layout.right.width, layout.right.height);
tests/testdisplay.c +2 -33
@@ -239,21 +239,9 @@ paint_color_key(struct igt_fb *fb_info)munmap (fb_ptr, fb_info->size); } -static cairo_status_t -stdio_read_func (void * closure,unsigned char * data,unsigned int size) -{ -if (fread (data,1 , size, (FILE *)closure) != size) -return CAIRO_STATUS_READ_ERROR ; -return CAIRO_STATUS_SUCCESS ; -} -static void paint_image (cairo_t *cr,const char *file) { -int img_x, img_y, img_w, img_h, img_w_o, img_h_o; -double img_w_scale, img_h_scale; - -cairo_surface_t *image; -FILE * fp; +int img_x, img_y, img_w, img_h; img_y = height * (0.10 ); img_h = height *0.08 *4 ;
@@ -261,26 +249,7 @@ static void paint_image(cairo_t *cr, const char *file) img_x = (width /2 ) - (img_w /2 ); - fp =igt_fopen_data (file); -if (!fp) -return ; - image =cairo_image_surface_create_from_png_stream (&stdio_read_func, - (void *)fp); - - img_w_o =cairo_image_surface_get_width (image); - img_h_o =cairo_image_surface_get_height (image); - -cairo_translate (cr, img_x, img_y); - - img_w_scale = (double )img_w / (double )img_w_o; - img_h_scale = (double )img_h / (double )img_h_o; -cairo_scale (cr, img_w_scale, img_h_scale); - -cairo_set_source_surface (cr, image,0 ,0 ); -cairo_scale (cr,1 ,1 ); - -cairo_paint (cr); -cairo_surface_destroy (image); +igt_paint_image (cr, file, img_x, img_y, img_h, img_w); }static void paint_output_info (struct connector *c,struct igt_fb *fb)
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx