terom@17: #ifndef RENDER_SLICES_H terom@17: #define RENDER_SLICES_H terom@17: terom@17: #include "render.h" terom@17: terom@17: #define RENDER_SLICES_MAX 2 terom@17: terom@17: struct render_slices; terom@17: terom@17: struct render_slice_info { terom@17: // our index terom@17: size_t index; terom@17: terom@17: // the render info terom@17: struct render *render_info; terom@17: terom@17: // where to put the pixel data terom@17: unsigned char *render_buf; terom@17: }; terom@17: terom@17: /* terom@17: * Split the given render operation into multiple slices that can be rendered terom@17: * induvidually. terom@17: * terom@17: * A segment is a single row of a slice. The raw pixel data for each segment terom@17: * should be stored into the render_buf item in that slice's render_slice_info. terom@17: * When a full segment has been stored into the render_buf, you should call terom@17: * render_slices_segment_done with that slice's index as an argument, and then terom@17: * proceed based on its return code. terom@17: * terom@17: * Returns a struct render_slices handle which can be used to operate on the terom@17: * slices, or NULL on failure. terom@17: */ terom@17: struct render_slices *render_slices_alloc (struct render *render); terom@17: terom@17: /* terom@17: * Get the number of slices that need to be rendered, which is also the valid terom@17: * range of index values for render_slices_get_slice_info. terom@17: */ terom@17: int render_slices_get_count (struct render_slices *ctx); terom@17: terom@17: /* terom@17: * Get the struct render_slice_info corresponding to the given index. This terom@17: * the information required to render the segment. The index is used as an terom@17: * argument to render_slices_segment_done. terom@17: */ terom@17: struct render_slice_info *render_slices_get_slice_info (struct render_slices *ctx, int index); terom@17: terom@17: /* terom@17: * You may call render_slices_segment_done again for any slice now, including terom@17: * those which returned ~SLICE_CONTINUE earlier. terom@17: */ terom@17: #define SLICE_CONTINUE 0x01 terom@17: terom@17: /* terom@17: * You may call render_slices_process_row next. terom@17: */ terom@17: #define SLICE_PROCESS_ROW 0x02 terom@17: terom@19: // XXX: you can't modify the slice's row buffer until these return SLICE_CONTINUE terom@19: terom@17: /* terom@17: * The render_buf for the render_slice_info with the given index value contains terom@17: * the full information for the next row of the render_info render. Returns a terom@18: * bitwise-OR of the SLICE_* flags, or -1 for an error: terom@17: * terom@17: * Valid return values: terom@17: * zero terom@17: * Do not call segment_done for this index, or process_row right now. terom@17: * Information for some slice needed to complete the next row is missing, terom@17: * and the other segments must call segment_done first. terom@17: * terom@17: * SLICE_PROCESS_ROW terom@17: * Do not call segment_done for this index or any others, but do call terom@17: * process_row as soon as possible, and then continue once it returns terom@17: * (see render_slices_process_row). terom@17: * terom@17: * SLICE_CONTINUE & SLICE_PROCESS_ROW terom@17: * You should call process_row next, but you can also call segment_done terom@17: * for all segments that returned ~SLICE_CONTINUE earlier. terom@17: * terom@17: * -1 - An error occured. Rendering must be aborted. terom@17: * terom@17: */ terom@17: int render_slices_segment_done (struct render_slices *ctx, int index); terom@17: terom@17: /* terom@17: * Process a completed row and generate output in the PNG format (how that is terom@17: * handled depends on the render given to render_slices_alloc/init). Returns a terom@18: * bitwise-OR of the SLICE_* flags, or -1 for an error: terom@17: * terom@17: * Valid return values : terom@17: * zero terom@17: * The PNG is done - you don't need to call segment_done or process_row terom@17: * anymore, doing so will result in an error. You don't need to deinit terom@17: * ctx, but you may need to free it. terom@17: * terom@17: * SLICE_CONTINUE terom@17: * You may call render_slices_segment_done again for those slices that terom@17: * returned ~SLICE_CONTINUE earlier. terom@17: * terom@17: * SLICE_CONTINUE & SLICE_PROCESS_ROW terom@17: * In addition to calling render_slices_segment_done again, you may also terom@17: * call render_slices_process_row again. terom@17: * terom@17: * -1 - An error occured. Rendering must be aborted. terom@17: */ terom@17: int render_slices_process_row (struct render_slices *ctx); terom@17: terom@17: /* terom@18: * Signifiy that the render has been completed. This will flush out buffered terom@18: * output data. terom@18: */ terom@18: int render_slices_done (struct render_slices *ctx); terom@18: terom@18: /* terom@17: * Free a render_slices. The rendering may or may not be complete. terom@17: */ terom@17: void render_slices_free (struct render_slices *ctx); terom@17: terom@17: #endif /* RENDER_SLICES_H */