11.2 Creation

An empty display list can be created by the fz_new_display_list call.

/* 
   fz_new_display_list: Create an empty display list. 
 
   A display list contains drawing commands (text, images, etc.). 
   Use fz_new_list_device for populating the list. 
 
   mediabox: Bounds of the page (in points) represented by the display list. 
*/ 
fz_display_list *fz_new_display_list(fz_context *ctx, const fz_rect *mediabox);

Once created it can be populated by creating a display list device instance that writes to it.

/* 
   fz_new_list_device: Create a rendering device for a display list. 
 
   When the device is rendering a page it will populate the 
   display list with drawing commands (text, images, etc.). The 
   display list can later be reused to render a page many times 
   without having to re-interpret the page from the document file 
   for each rendering. Once the device is no longer needed, free 
   it with fz_drop_device. 
 
   list: A display list that the list device takes ownership of. 
*/ 
fz_device *fz_new_list_device(fz_context *ctx, fz_display_list *list);

Once you have created such a display list device, any calls made to that device (such as by calling fz_run_page or similar) will be recorded into the display list.

When you have finished writing to the display list (remembering to call fz_close_device), you dispose of the device as normal (by calling fz_drop_device). This leaves you holding the sole reference to the display list itself.

Writing to a display list is not thread safe. That is to say, do not attempt to write to a display list from more than one thread at a time. Similarly, do not attempt to read from display lists while write operations are ongoing.