| 239 | } |
| 240 | |
| 241 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context* context, int allow_out_of_mem) |
| 242 | { |
| 243 | if (allow_out_of_mem) |
| 244 | // if it's ok to run out of memory, then don't bother aligning them; |
| 245 | // this gives better packing, but may fail due to OOM (even though |
| 246 | // the rectangles easily fit). @TODO a smarter approach would be to only |
| 247 | // quantize once we've hit OOM, then we could get rid of this parameter. |
| 248 | context->align = 1; |
| 249 | else { |
| 250 | // if it's not ok to run out of memory, then quantize the widths |
| 251 | // so that num_nodes is always enough nodes. |
| 252 | // |
| 253 | // I.e. num_nodes * align >= width |
| 254 | // align >= width / num_nodes |
| 255 | // align = ceil(width/num_nodes) |
| 256 | |
| 257 | context->align = (context->width + context->num_nodes - 1) / context->num_nodes; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | STBRP_DEF void stbrp_init_target(stbrp_context* context, int width, int height, stbrp_node* nodes, int num_nodes) |
| 262 | { |