42 #ifndef STB_INCLUDE_STB_RECT_PACK_H 43 #define STB_INCLUDE_STB_RECT_PACK_H 45 #define STB_RECT_PACK_VERSION 1 48 #define STBRP_DEF STATIC 50 #define STBRP_DEF extern 61 #ifdef STBRP_LARGE_RECTS 178 #ifdef STB_RECT_PACK_IMPLEMENTATION 181 #define STBRP_SORT qsort 186 #define STBRP_ASSERT assert 191 STBRP__INIT_skyline = 1
198 case STBRP__INIT_skyline:
214 if (allow_out_of_mem)
232 #ifndef STBRP_LARGE_RECTS 236 for (i=0; i < num_nodes-1; ++i)
237 nodes[i].
next = &nodes[i+1];
239 context->
init_mode = STBRP__INIT_skyline;
254 #ifdef STBRP_LARGE_RECTS 255 context->
extra[1].
y = (1<<30);
257 context->
extra[1].
y = 65535;
266 int min_y, visited_width, waste_area;
270 STBRP_ASSERT(
first->x <= x0);
271 STBRP_ASSERT(node->
next->
x > x0);
272 STBRP_ASSERT(node->
x <= x0);
285 waste_area += visited_width * (node->
y - min_y);
290 visited_width += node->
next->
x - x0;
292 visited_width += node->
next->
x - node->
x;
297 int under_width = node->
next->
x - node->
x;
298 if (under_width + visited_width >
width)
299 under_width =
width - visited_width;
300 waste_area += under_width * (min_y - node->
y);
301 visited_width += under_width;
306 *pwaste = waste_area;
318 int best_waste = (1<<30), best_x, best_y = (1 << 30);
319 stbrp__findresult fr;
325 STBRP_ASSERT(
width %
c->align == 0);
327 node =
c->active_head;
328 prev = &
c->active_head;
332 int y = stbrp__skyline_find_min_y(
c, node, node->
x,
width, &waste);
349 if (
y < best_y || (
y == best_y && waste < best_waste))
361 best_x = (best ==
NULL) ? 0 : (*best)->
x;
383 tail =
c->active_head;
384 node =
c->active_head;
385 prev = &
c->active_head;
393 STBRP_ASSERT(xpos >= 0);
396 while (node->
next->
x <= xpos)
402 STBRP_ASSERT(node->
next->
x > xpos && node->
x <= xpos);
403 y = stbrp__skyline_find_min_y(
c, node, xpos,
width, &waste);
409 if (
y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x))
412 STBRP_ASSERT(
y <= best_y);
433 stbrp__findresult
res = stbrp__skyline_find_best_pos(context,
width,
height);
467 *
res.prev_link = node;
490 static int rect_height_compare(
const void *
a,
const void *
b)
498 return (
p->w >
q->w) ? -1 : (
p->w <
q->w);
501 STBRP_DEF int rect_width_compare(
const void *
a,
const void *
b)
509 return (
p->h >
q->h) ? -1 : (
p->h <
q->h);
512 static int rect_original_order(
const void *
a,
const void *
b)
516 return (
p->was_packed <
q->was_packed) ? -1 : (
p->was_packed >
q->was_packed);
519 #ifdef STBRP_LARGE_RECTS 520 #define STBRP__MAXVAL 0xffffffff 522 #define STBRP__MAXVAL 0xffff 530 for (i=0; i < num_rects; ++i)
531 rects[i].was_packed = i;
534 STBRP_SORT(rects, num_rects,
sizeof(rects[0]), rect_height_compare);
536 for (i=0; i < num_rects; ++i)
538 stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].
w, rects[i].
h);
544 rects[i].
x = rects[i].
y = STBRP__MAXVAL;
549 STBRP_SORT(rects, num_rects,
sizeof(rects[0]), rect_original_order);
552 for (i=0; i < num_rects; ++i)
553 rects[i].was_packed = !(rects[i].
x == STBRP__MAXVAL && rects[i].
y == STBRP__MAXVAL);
stbrp_coord y
Definition: stb_rect_pack.h:96
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
const GLint * first
Definition: glext.h:6478
Definition: stb_rect_pack.h:143
int heuristic
Definition: stb_rect_pack.h:163
stbrp_coord x
Definition: stb_rect_pack.h:96
#define STBRP_DEF
Definition: stb_rect_pack.h:50
GLuint res
Definition: glext.h:10520
static overlayled_t * cur
Definition: led_overlay.c:18
stbrp_coord x
Definition: stb_rect_pack.h:153
#define next(ls)
Definition: llex.c:32
int height
Definition: stb_rect_pack.h:160
int width
Definition: stb_rect_pack.h:159
const GLubyte * c
Definition: glext.h:9812
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
Definition: stb_rect_pack.h:142
int id
Definition: stb_rect_pack.h:94
STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
unsigned short stbrp_coord
Definition: stb_rect_pack.h:64
int was_packed
Definition: stb_rect_pack.h:97
#define NULL
Pointer to 0.
Definition: gctypes.h:65
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
Definition: pixman-arm-neon-asm.h:469
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
stbrp_node * next
Definition: stb_rect_pack.h:154
stbrp_coord h
Definition: stb_rect_pack.h:95
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
int num_nodes
Definition: stb_rect_pack.h:164
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:6414
GLfloat GLfloat p
Definition: glext.h:9809
stbrp_node extra[2]
Definition: stb_rect_pack.h:167
stbrp_node * free_head
Definition: stb_rect_pack.h:166
Definition: stb_rect_pack.h:92
stbrp_coord y
Definition: stb_rect_pack.h:153
stbrp_node * active_head
Definition: stb_rect_pack.h:165
vu8 tail
Definition: keyboard.c:427
GLint GLint GLsizei width
Definition: glext.h:6293
Definition: stb_rect_pack.h:157
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6742
int align
Definition: stb_rect_pack.h:161
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:8390
Definition: stb_rect_pack.h:144
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844
Definition: stb_rect_pack.h:151
GLint GLint GLsizei GLsizei height
Definition: glext.h:6293
int init_mode
Definition: stb_rect_pack.h:162
stbrp_coord w
Definition: stb_rect_pack.h:95