DirectFB-1.4.9-libpng-1.5.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. From 83180b25e90721e717bf37c5332c22713508786e Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Sun, 20 Feb 2011 19:18:19 -0500
  4. Subject: [PATCH] png: add support for libpng 1.5.x
  5. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  6. ---
  7. .../idirectfbimageprovider_png.c | 56 ++++++++++++-------
  8. 1 files changed, 35 insertions(+), 21 deletions(-)
  9. diff --git a/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.c b/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.c
  10. index 6d65ea3..7d82c5c 100644
  11. --- a/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.c
  12. +++ b/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.c
  13. @@ -207,7 +207,7 @@ Construct( IDirectFBImageProvider *thiz,
  14. if (!data->png_ptr)
  15. goto error;
  16. - if (setjmp( data->png_ptr->jmpbuf )) {
  17. + if (setjmp( png_jmpbuf( data->png_ptr ))) {
  18. D_ERROR( "ImageProvider/PNG: Error reading header!\n" );
  19. goto error;
  20. }
  21. @@ -292,7 +292,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDirectFBImageProvider *thiz,
  22. rect = dst_data->area.wanted;
  23. }
  24. - if (setjmp( data->png_ptr->jmpbuf )) {
  25. + if (setjmp( png_jmpbuf( data->png_ptr ))) {
  26. D_ERROR( "ImageProvider/PNG: Error during decoding!\n" );
  27. if (data->stage < STAGE_IMAGE)
  28. @@ -327,6 +327,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDirectFBImageProvider *thiz,
  29. }
  30. else {
  31. CoreSurfaceBufferLock lock;
  32. + png_byte bit_depth = png_get_bit_depth( data->png_ptr, data->info_ptr );
  33. ret = dfb_surface_lock_buffer( dst_surface, CSBR_BACK, CSAID_CPU, CSAF_WRITE, &lock );
  34. if (ret)
  35. @@ -334,7 +335,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDirectFBImageProvider *thiz,
  36. switch (data->color_type) {
  37. case PNG_COLOR_TYPE_PALETTE:
  38. - if (dst_surface->config.format == DSPF_LUT8 && data->info_ptr->bit_depth == 8) {
  39. + if (dst_surface->config.format == DSPF_LUT8 && bit_depth == 8) {
  40. /*
  41. * Special indexed PNG to LUT8 loading.
  42. */
  43. @@ -377,7 +378,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDirectFBImageProvider *thiz,
  44. }
  45. else {
  46. if (data->color_type == PNG_COLOR_TYPE_GRAY) {
  47. - int num = 1 << data->info_ptr->bit_depth;
  48. + int num = 1 << bit_depth;
  49. for (x=0; x<num; x++) {
  50. int value = x * 255 / (num - 1);
  51. @@ -386,7 +387,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDirectFBImageProvider *thiz,
  52. }
  53. }
  54. - switch (data->info_ptr->bit_depth) {
  55. + switch (bit_depth) {
  56. case 8:
  57. for (y=0; y<data->height; y++) {
  58. u8 *S = data->image + data->pitch * y;
  59. @@ -441,7 +442,7 @@ IDirectFBImageProvider_PNG_RenderTo( IDirectFBImageProvider *thiz,
  60. default:
  61. D_ERROR( "ImageProvider/PNG: Unsupported indexed bit depth %d!\n",
  62. - data->info_ptr->bit_depth );
  63. + bit_depth );
  64. }
  65. dfb_scale_linear_32( image_argb, data->width, data->height,
  66. @@ -594,16 +595,26 @@ png_info_callback( png_structp png_read_ptr,
  67. NULL, NULL, NULL );
  68. if (png_get_valid( data->png_ptr, data->info_ptr, PNG_INFO_tRNS )) {
  69. + png_bytep trans;
  70. + png_color_16p trans_color;
  71. + int num_trans;
  72. +
  73. + png_get_tRNS( data->png_ptr, data->info_ptr, &trans, &num_trans, &trans_color );
  74. +
  75. data->color_keyed = true;
  76. /* generate color key based on palette... */
  77. if (data->color_type == PNG_COLOR_TYPE_PALETTE) {
  78. u32 key;
  79. - png_colorp palette = data->info_ptr->palette;
  80. - png_bytep trans = data->info_ptr->trans_alpha;
  81. - int num_colors = MIN( MAXCOLORMAPSIZE,
  82. - data->info_ptr->num_palette );
  83. - u8 cmap[3][num_colors];
  84. + png_colorp palette;
  85. + int num_colors;
  86. + u8 *cmap[3];
  87. +
  88. + png_get_PLTE( data->png_ptr, data->info_ptr, &palette, &num_colors );
  89. + num_colors = MIN( MAXCOLORMAPSIZE, num_colors );
  90. + cmap[0] = alloca (num_colors);
  91. + cmap[1] = alloca (num_colors);
  92. + cmap[2] = alloca (num_colors);
  93. for (i=0; i<num_colors; i++) {
  94. cmap[0][i] = palette[i].red;
  95. @@ -613,7 +624,7 @@ png_info_callback( png_structp png_read_ptr,
  96. key = FindColorKey( num_colors, &cmap[0][0] );
  97. - for (i=0; i<data->info_ptr->num_trans; i++) {
  98. + for (i=0; i<num_trans; i++) {
  99. if (!trans[i]) {
  100. palette[i].red = (key & 0xff0000) >> 16;
  101. palette[i].green = (key & 0x00ff00) >> 8;
  102. @@ -625,20 +636,23 @@ png_info_callback( png_structp png_read_ptr,
  103. }
  104. else {
  105. /* ...or based on trans rgb value */
  106. - png_color_16p trans = &data->info_ptr->trans_color;
  107. -
  108. - data->color_key = (((trans->red & 0xff00) << 8) |
  109. - ((trans->green & 0xff00)) |
  110. - ((trans->blue & 0xff00) >> 8));
  111. + data->color_key = (((trans_color->red & 0xff00) << 8) |
  112. + ((trans_color->green & 0xff00)) |
  113. + ((trans_color->blue & 0xff00) >> 8));
  114. }
  115. }
  116. switch (data->color_type) {
  117. case PNG_COLOR_TYPE_PALETTE: {
  118. - png_colorp palette = data->info_ptr->palette;
  119. - png_bytep trans = data->info_ptr->trans_alpha;
  120. - int num_trans = data->info_ptr->num_trans;
  121. - int num_colors = MIN( MAXCOLORMAPSIZE, data->info_ptr->num_palette );
  122. + png_colorp palette;
  123. + png_bytep trans;
  124. + png_color_16p trans_color;
  125. + int num_trans;
  126. + int num_colors;
  127. +
  128. + png_get_PLTE( data->png_ptr, data->info_ptr, &palette, &num_colors );
  129. + num_colors = MIN( MAXCOLORMAPSIZE, num_colors );
  130. + png_get_tRNS( data->png_ptr, data->info_ptr, &trans, &num_trans, &trans_color );
  131. for (i=0; i<num_colors; i++) {
  132. data->colors[i].a = (i < num_trans) ? trans[i] : 0xff;
  133. --
  134. 1.7.4.1
  135. From 7a2a36fada3ecdd7f48fcfd782a552598477a8f5 Mon Sep 17 00:00:00 2001
  136. From: Mike Frysinger <vapier@gentoo.org>
  137. Date: Sun, 20 Feb 2011 19:38:50 -0500
  138. Subject: [PATCH] tools: add support for libpng 1.5.x
  139. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  140. ---
  141. tools/directfb-csource.c | 20 +++++++++++++-------
  142. tools/mkdfiff.c | 2 +-
  143. tools/mkdgifft.cpp | 2 +-
  144. 3 files changed, 15 insertions(+), 9 deletions(-)
  145. diff --git a/tools/directfb-csource.c b/tools/directfb-csource.c
  146. index 8f2cbf0..487ea3c 100644
  147. --- a/tools/directfb-csource.c
  148. +++ b/tools/directfb-csource.c
  149. @@ -338,7 +338,7 @@ static DFBResult load_image (const char *filename,
  150. if (!png_ptr)
  151. goto cleanup;
  152. - if (setjmp (png_ptr->jmpbuf)) {
  153. + if (setjmp (png_jmpbuf (png_ptr))) {
  154. if (desc->preallocated[0].data) {
  155. free (desc->preallocated[0].data);
  156. desc->preallocated[0].data = NULL;
  157. @@ -405,17 +405,22 @@ static DFBResult load_image (const char *filename,
  158. }
  159. switch (src_format) {
  160. - case DSPF_LUT8:
  161. - if (info_ptr->num_palette) {
  162. + case DSPF_LUT8: {
  163. + png_colorp png_palette;
  164. + int num_palette;
  165. +
  166. + png_get_PLTE( png_ptr, info_ptr, &png_palette, &num_palette );
  167. +
  168. + if (num_palette) {
  169. png_byte *alpha;
  170. int i, num;
  171. - *palette_size = MIN (info_ptr->num_palette, 256);
  172. + *palette_size = MIN (num_palette, 256);
  173. for (i = 0; i < *palette_size; i++) {
  174. palette[i].a = 0xFF;
  175. - palette[i].r = info_ptr->palette[i].red;
  176. - palette[i].g = info_ptr->palette[i].green;
  177. - palette[i].b = info_ptr->palette[i].blue;
  178. + palette[i].r = png_palette[i].red;
  179. + palette[i].g = png_palette[i].green;
  180. + palette[i].b = png_palette[i].blue;
  181. }
  182. if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) {
  183. png_get_tRNS (png_ptr, info_ptr, &alpha, &num, NULL);
  184. @@ -424,6 +429,7 @@ static DFBResult load_image (const char *filename,
  185. }
  186. }
  187. break;
  188. + }
  189. case DSPF_RGB32:
  190. png_set_filler (png_ptr, 0xFF,
  191. #ifdef WORDS_BIGENDIAN
  192. diff --git a/tools/mkdfiff.c b/tools/mkdfiff.c
  193. index 68a3b4f..edb58a7 100644
  194. --- a/tools/mkdfiff.c
  195. +++ b/tools/mkdfiff.c
  196. @@ -97,7 +97,7 @@ load_image (const char *filename,
  197. if (!png_ptr)
  198. goto cleanup;
  199. - if (setjmp (png_ptr->jmpbuf)) {
  200. + if (setjmp (png_jmpbuf (png_ptr))) {
  201. if (desc->preallocated[0].data) {
  202. free (desc->preallocated[0].data);
  203. desc->preallocated[0].data = NULL;
  204. diff --git a/tools/mkdgifft.cpp b/tools/mkdgifft.cpp
  205. index 96e4220..d4b6bf4 100644
  206. --- a/tools/mkdgifft.cpp
  207. +++ b/tools/mkdgifft.cpp
  208. @@ -595,7 +595,7 @@ load_image (const char *filename,
  209. if (!png_ptr)
  210. goto cleanup;
  211. - if (setjmp (png_ptr->jmpbuf)) {
  212. + if (setjmp (png_jmpbuf (png_ptr))) {
  213. if (desc->preallocated[0].data) {
  214. free (desc->preallocated[0].data);
  215. desc->preallocated[0].data = NULL;
  216. --
  217. 1.7.4.1