vft_debug.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright 2020 NXP
  6. * All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining
  9. * a copy of this software and associated documentation files (the
  10. * 'Software'), to deal in the Software without restriction, including
  11. * without limitation the rights to use, copy, modify, merge, publish,
  12. * distribute, sub license, and/or sell copies of the Software, and to
  13. * permit persons to whom the Software is furnished to do so, subject
  14. * to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the
  17. * next paragraph) shall be included in all copies or substantial
  18. * portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  21. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23. * IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
  24. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. *
  28. *****************************************************************************/
  29. //#define ENABLE_DEBUG_TRACE
  30. #ifdef ENABLE_DEBUG_TRACE
  31. /* With debug configuration */
  32. /* Macros */
  33. #define TRACE_DBG(x) printf x
  34. #define TRACE_BIN(x) // printf x /* Tracer for binary layout */
  35. #define TRACE_WRN(x) printf x
  36. #define TRACE_INFO(x) printf x
  37. #define TRACE_ERR(x) printf x
  38. #define DBG_ARY(obj, param, count) \
  39. dbg_float_ary(#param, &obj->param[0], count, &g_offset);
  40. #define DBG_INT_ARY(obj, param, count) \
  41. dbg_int_ary(#param, obj->param, count, &g_offset);
  42. #define DBG_FIELD(obj, param) \
  43. dbg_int_param(#param, obj->param, &g_offset)
  44. #define DBG_READ_32B(name, value, offset) \
  45. dbg_int_param_no_offset_update(name, value, offset)
  46. extern int g_offset;
  47. #define VFT_DBG_FONT_FACE_DESC(a,b) vft_dbg_font_face_desc(a,b)
  48. #define VFT_DBG_GLYPH_TABLE(a,b) vft_dbg_glyph_table(a,b)
  49. #define VFT_DBG_KERN_TABLE(a,b) vft_dbg_kern_table(a,b)
  50. #define VFT_DBG_PATH_TABLE(a,b) vft_dbg_path_table(a,b)
  51. static int g_offset = 0; /* Dummy just to solve build errors */
  52. #define DBG_TRACE(x)
  53. #define DBG_INC_OFFSET(x) g_offset += (x);
  54. #define DBG_OFFSET() (g_offset)
  55. /* Prorotypes */
  56. void vft_dbg_font_face_desc(font_face_desc_t* font_face, int offset);
  57. void vft_dbg_glyph_desc(glyph_desc_t* g, int offset);
  58. void vft_dbg_kern_desc(kern_desc_t* kern_desc, int num_kern_entries, int offset);
  59. void vfg_dbg_path_data(path_desc_t* path_data_desc, int offset);
  60. void vft_dbg_matrix(char *name, vg_lite_matrix_t *mat);
  61. void vft_dbg_path_table(font_face_desc_t* font_face, int offset);
  62. void vft_dbg_kern_table(font_face_desc_t* font_face, int offset);
  63. void vft_dbg_glyph_table(font_face_desc_t* font_face, int offset);
  64. void dbg_float_ary_no_offset_update(char *name, float *ary,
  65. int count, int disk_offset);
  66. void dbg_int_ary_no_offset_update(char *name, uint32_t *ary,
  67. int count, int disk_offset);
  68. void dbg_int_param_no_offset_update(char *name, uint32_t value, int disk_offset);
  69. #else
  70. /** Without -debug configuration */
  71. /* Macros */
  72. #define TRACE_DBG(x)
  73. #define TRACE_BIN(x)
  74. #define TRACE_WRN(x) printf x
  75. #define TRACE_INFO(x)
  76. #define TRACE_ERR(x) printf x
  77. #define DBG_READ_32B(a,b,c)
  78. #define DBG_TRACE(x)
  79. #define vft_dbg_glyph_desc(g,offset)
  80. #define dbg_float_ary_no_offset_update(a, b, c,d)
  81. #define dbg_int_ary_no_offset_update(a, b, c,d)
  82. #define vft_dbg_path_bounds(a,b,c)
  83. #define vft_dbg_path(a,b,c)
  84. #define VFT_DBG_FONT_FACE_DESC(a,b)
  85. #define VFT_DBG_GLYPH_TABLE(a,b)
  86. #define VFT_DBG_KERN_TABLE(a,b)
  87. #define VFT_DBG_PATH_TABLE(a,b)
  88. #define DBG_INC_OFFSET(x)
  89. #define DBG_OFFSET() (0)
  90. #endif
  91. #define TRACE_BIN_FIELD_STR(x) TRACE_BIN(("BIN: %08x: "#x"=%s\n",offset,_desc.x));
  92. #define TRACE_BIN_FIELD_UINT16(x) TRACE_BIN(("BIN: %08x: "#x"=%hu\n",offset,_desc.x)); offset += 2;
  93. #define TRACE_BIN_FIELD_UINT32(x) TRACE_BIN(("BIN: %08x: "#x"=%u\n",offset,_desc.x)); offset += 4;
  94. #define TRACE_BIN_FIELD_FLOAT(x) TRACE_BIN(("BIN: %08x: "#x"=%f\n",offset,_desc.x)); offset += 4;