display-list.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef MUPDF_FITZ_DISPLAY_LIST_H
  2. #define MUPDF_FITZ_DISPLAY_LIST_H
  3. #include "mupdf/fitz/system.h"
  4. #include "mupdf/fitz/context.h"
  5. #include "mupdf/fitz/geometry.h"
  6. #include "mupdf/fitz/device.h"
  7. /*
  8. Display list device -- record and play back device commands.
  9. */
  10. /*
  11. fz_display_list is a list containing drawing commands (text,
  12. images, etc.). The intent is two-fold: as a caching-mechanism
  13. to reduce parsing of a page, and to be used as a data
  14. structure in multi-threading where one thread parses the page
  15. and another renders pages.
  16. Create a display list with fz_new_display_list, hand it over to
  17. fz_new_list_device to have it populated, and later replay the
  18. list (once or many times) by calling fz_run_display_list. When
  19. the list is no longer needed drop it with fz_drop_display_list.
  20. */
  21. typedef struct fz_display_list_s fz_display_list;
  22. /*
  23. fz_new_display_list: Create an empty display list.
  24. A display list contains drawing commands (text, images, etc.).
  25. Use fz_new_list_device for populating the list.
  26. mediabox: Bounds of the page (in points) represented by the display list.
  27. */
  28. fz_display_list *fz_new_display_list(fz_context *ctx, const fz_rect *mediabox);
  29. /*
  30. fz_new_list_device: Create a rendering device for a display list.
  31. When the device is rendering a page it will populate the
  32. display list with drawing commands (text, images, etc.). The
  33. display list can later be reused to render a page many times
  34. without having to re-interpret the page from the document file
  35. for each rendering. Once the device is no longer needed, free
  36. it with fz_drop_device.
  37. list: A display list that the list device takes ownership of.
  38. */
  39. fz_device *fz_new_list_device(fz_context *ctx, fz_display_list *list);
  40. /*
  41. fz_run_display_list: (Re)-run a display list through a device.
  42. list: A display list, created by fz_new_display_list and
  43. populated with objects from a page by running fz_run_page on a
  44. device obtained from fz_new_list_device.
  45. dev: Device obtained from fz_new_*_device.
  46. ctm: Transform to apply to display list contents. May include
  47. for example scaling and rotation, see fz_scale, fz_rotate and
  48. fz_concat. Set to fz_identity if no transformation is desired.
  49. area: Only the part of the contents of the display list
  50. visible within this area will be considered when the list is
  51. run through the device. This does not imply for tile objects
  52. contained in the display list.
  53. cookie: Communication mechanism between caller and library
  54. running the page. Intended for multi-threaded applications,
  55. while single-threaded applications set cookie to NULL. The
  56. caller may abort an ongoing page run. Cookie also communicates
  57. progress information back to the caller. The fields inside
  58. cookie are continually updated while the page is being run.
  59. */
  60. void fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, const fz_matrix *ctm, const fz_rect *area, fz_cookie *cookie);
  61. /*
  62. fz_keep_display_list: Keep a reference to a display list.
  63. Does not throw exceptions.
  64. */
  65. fz_display_list *fz_keep_display_list(fz_context *ctx, fz_display_list *list);
  66. /*
  67. fz_drop_display_list: Drop a reference to a display list, freeing it
  68. if the reference count reaches zero.
  69. Does not throw exceptions.
  70. */
  71. void fz_drop_display_list(fz_context *ctx, fz_display_list *list);
  72. /*
  73. fz_bound_display_list: Return the bounding box of the page recorded in a display list.
  74. */
  75. fz_rect *fz_bound_display_list(fz_context *ctx, fz_display_list *list, fz_rect *bounds);
  76. /*
  77. Create a new image from a display list.
  78. w, h: The conceptual width/height of the image.
  79. transform: The matrix that needs to be applied to the given
  80. list to make it render to the unit square.
  81. list: The display list.
  82. */
  83. fz_image *fz_new_image_from_display_list(fz_context *ctx, float w, float h, fz_display_list *list);
  84. /*
  85. Check for a display list being empty
  86. list: The list to check.
  87. Returns true if empty, false otherwise.
  88. */
  89. int fz_display_list_is_empty(fz_context *ctx, const fz_display_list *list);
  90. #endif