Skip to content

Commit 1b15c5a

Browse files
committed
fixup! feat: replace custom bool type with bool type in stdbool.h
1 parent a17f98b commit 1b15c5a

File tree

11 files changed

+91
-94
lines changed

11 files changed

+91
-94
lines changed

lib/pandagl/include/pandagl/types.h

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#include <stdbool.h>
1717
#include <stddef.h>
1818

19-
#define PD_FALSE 0
20-
#define PD_TRUE 1
21-
2219
typedef enum pd_color_type_t {
2320
PD_COLOR_TYPE_UNSUPPORTED,
2421
PD_COLOR_TYPE_INDEX8, /**< 8位索引 */

lib/pandagl/src/background.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void pd_paint_background(pd_context_t *ctx, const pd_background_t *bg,
6868
width = read_rect.width;
6969
height = read_rect.height;
7070
/* 按比例进行缩放 */
71-
pd_canvas_zoom(&canvas, &buffer, PD_FALSE, width, height);
71+
pd_canvas_zoom(&canvas, &buffer, false, width, height);
7272
pd_canvas_quote(&canvas, &buffer, NULL);
7373
}
7474
/* 计算相对于绘制区域的坐标 */

lib/pandagl/src/boxshadow.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static bool pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx)
160160
right = rect.x + rect.width;
161161
gradient_init(&g, BLUR_WIDTH(ctx->shadow));
162162
if (!pd_rect_overlap(&ctx->paint->rect, &rect, &rect)) {
163-
return PD_FALSE;
163+
return false;
164164
}
165165
right -= rect.x;
166166
paint_rect.width = rect.width;
@@ -178,7 +178,7 @@ static bool pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx)
178178
*p = color;
179179
}
180180
}
181-
return PD_TRUE;
181+
return true;
182182
}
183183

184184
static bool pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx)
@@ -201,7 +201,7 @@ static bool pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx)
201201
left = rect.x;
202202
gradient_init(&g, BLUR_WIDTH(ctx->shadow));
203203
if (!pd_rect_overlap(&ctx->paint->rect, &rect, &rect)) {
204-
return PD_FALSE;
204+
return false;
205205
}
206206
left -= rect.x + 1;
207207
paint_rect.width = rect.width;
@@ -219,7 +219,7 @@ static bool pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx)
219219
*p = color;
220220
}
221221
}
222-
return PD_TRUE;
222+
return true;
223223
}
224224

225225
static bool pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx)
@@ -242,7 +242,7 @@ static bool pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx)
242242
bottom = rect.y + rect.height;
243243
gradient_init(&g, BLUR_WIDTH(ctx->shadow));
244244
if (!pd_rect_overlap(&ctx->paint->rect, &rect, &rect)) {
245-
return PD_FALSE;
245+
return false;
246246
}
247247
bottom -= rect.y;
248248
paint_rect.width = rect.width;
@@ -260,7 +260,7 @@ static bool pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx)
260260
*p = color;
261261
}
262262
}
263-
return PD_TRUE;
263+
return true;
264264
}
265265

266266
static bool pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx)
@@ -283,7 +283,7 @@ static bool pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx)
283283
top = rect.y;
284284
gradient_init(&g, BLUR_WIDTH(ctx->shadow));
285285
if (!pd_rect_overlap(&ctx->paint->rect, &rect, &rect)) {
286-
return PD_FALSE;
286+
return false;
287287
}
288288
top -= rect.y + 1;
289289
paint_rect.width = rect.width;
@@ -300,7 +300,7 @@ static bool pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx)
300300
*p = color;
301301
}
302302
}
303-
return PD_TRUE;
303+
return true;
304304
}
305305

306306
static bool pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx,
@@ -327,7 +327,7 @@ static bool pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx,
327327
pd_color_t *p;
328328

329329
if (!pd_rect_overlap(&ctx->paint->rect, circle_rect, &rect)) {
330-
return PD_FALSE;
330+
return false;
331331
}
332332
color = ctx->shadow->color;
333333
center_x = center_x + circle_rect->x - rect.x - 0.5;
@@ -370,7 +370,7 @@ static bool pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx,
370370
*p = color;
371371
}
372372
}
373-
return PD_TRUE;
373+
return true;
374374
}
375375

376376
static bool pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx)
@@ -610,7 +610,7 @@ int pd_paint_boxshadow(pd_context_t *ctx, const pd_boxshadow_t *shadow,
610610
sd_ctx.paint = &tmp;
611611
pd_canvas_init(&tmp.canvas);
612612
tmp.rect = ctx->rect;
613-
tmp.with_alpha = PD_TRUE;
613+
tmp.with_alpha = true;
614614
tmp.canvas.color_type = PD_COLOR_TYPE_ARGB;
615615
pd_canvas_create(&sd_ctx.paint->canvas, ctx->rect.width,
616616
ctx->rect.height);

lib/pandagl/src/canvas.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
void pd_canvas_init(pd_canvas_t *canvas)
1515
{
16-
canvas->quote.is_valid = PD_FALSE;
16+
canvas->quote.is_valid = false;
1717
canvas->quote.source = NULL;
1818
canvas->quote.top = 0;
1919
canvas->quote.left = 0;
@@ -30,7 +30,7 @@ void pd_canvas_init(pd_canvas_t *canvas)
3030
bool pd_canvas_is_valid(const pd_canvas_t *canvas)
3131
{
3232
if (!canvas) {
33-
return PD_FALSE;
33+
return false;
3434
}
3535
if (canvas->quote.is_valid) {
3636
return canvas->quote.source &&
@@ -67,7 +67,7 @@ int pd_canvas_quote(pd_canvas_t *self, pd_canvas_t *source,
6767
self->quote.top = 0;
6868
self->bytes = NULL;
6969
self->quote.source = NULL;
70-
self->quote.is_valid = PD_FALSE;
70+
self->quote.is_valid = false;
7171
return -1;
7272
}
7373
self->opacity = 1.0;
@@ -78,7 +78,7 @@ int pd_canvas_quote(pd_canvas_t *self, pd_canvas_t *source,
7878
self->color_type = source->color_type;
7979
self->bytes_per_pixel = source->bytes_per_pixel;
8080
self->bytes_per_row = source->bytes_per_row;
81-
self->quote.is_valid = PD_TRUE;
81+
self->quote.is_valid = true;
8282
self->quote.source = source;
8383
self->quote.left = quote_rect.x;
8484
self->quote.top = quote_rect.y;
@@ -103,7 +103,7 @@ void pd_canvas_destroy(pd_canvas_t *canvas)
103103
/* 解除引用 */
104104
if (canvas && canvas->quote.is_valid) {
105105
canvas->quote.source = NULL;
106-
canvas->quote.is_valid = PD_FALSE;
106+
canvas->quote.is_valid = false;
107107
return;
108108
}
109109
if (canvas->bytes) {

lib/pandagl/src/context.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pd_context_t* pd_context_create(pd_canvas_t *canvas, pd_rect_t *rect)
1616
{
1717
pd_context_t* paint = (pd_context_t*)malloc(sizeof(pd_context_t));
1818
paint->rect = *rect;
19-
paint->with_alpha = PD_FALSE;
19+
paint->with_alpha = false;
2020
pd_canvas_init(&paint->canvas);
2121
pd_canvas_quote(&paint->canvas, canvas, &paint->rect);
2222
return paint;

lib/pandagl/src/font/library.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static void pd_font_library_init_base(void)
691691
fontlib.font_families_type.val_destructor = destroy_font_family_node;
692692
fontlib.font_families = dict_create(&fontlib.font_families_type, NULL);
693693
rbtree_set_destroy_func(&fontlib.bitmap_cache, destroy_tree_node);
694-
fontlib.active = PD_TRUE;
694+
fontlib.active = true;
695695
}
696696

697697
static void pd_font_library_init_engine(void)
@@ -723,7 +723,7 @@ static void pd_font_library_destroy_base(void)
723723
if (!fontlib.active) {
724724
return;
725725
}
726-
fontlib.active = PD_FALSE;
726+
fontlib.active = false;
727727
while (fontlib.font_cache_num > 0) {
728728
--fontlib.font_cache_num;
729729
font_cache_destroy(fontlib.font_cache[fontlib.font_cache_num]);

lib/pandagl/src/image/jpeg.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void pd_jpeg_reader_on_init(j_decompress_ptr cinfo)
5151
{
5252
pd_jpeg_reader_t *jpeg_reader;
5353
jpeg_reader = (pd_jpeg_reader_t *)cinfo->src;
54-
jpeg_reader->start_of_file = PD_TRUE;
54+
jpeg_reader->start_of_file = true;
5555
}
5656

5757
static boolean pd_jpeg_reader_on_read(j_decompress_ptr cinfo)
@@ -76,7 +76,7 @@ static boolean pd_jpeg_reader_on_read(j_decompress_ptr cinfo)
7676
/* 设置数据缓存地址和大小,供 jpeg 解码器使用 */
7777
jpeg_reader->src.next_input_byte = jpeg_reader->buffer;
7878
jpeg_reader->src.bytes_in_buffer = size;
79-
jpeg_reader->start_of_file = PD_FALSE;
79+
jpeg_reader->start_of_file = false;
8080
return true;
8181
}
8282

@@ -173,7 +173,7 @@ pd_error_t pd_jpeg_reader_read_header(pd_image_reader_t *reader)
173173
if (setjmp(jpeg_reader->env)) {
174174
return PD_ERROR_IMAGE_HEADER_INVALID;
175175
}
176-
jpeg_read_header(cinfo, PD_TRUE);
176+
jpeg_read_header(cinfo, true);
177177
header->width = cinfo->image_width;
178178
header->height = cinfo->image_height;
179179
header->type = PD_JPEG_IMAGE;

lib/pandagl/src/rect.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,29 @@ pd_rect_t pd_rect_crop(const pd_rect_t *rect, int container_width,
4545
bool pd_rect_correct(pd_rect_t *rect, int container_width,
4646
int container_height)
4747
{
48-
bool overflow = PD_FALSE;
48+
bool overflow = false;
4949

5050
if (rect->x < 0) {
51-
overflow = PD_TRUE;
51+
overflow = true;
5252
rect->width += rect->x;
5353
rect->x = 0;
5454
}
5555
if (rect->y < 0) {
56-
overflow = PD_TRUE;
56+
overflow = true;
5757
rect->height += rect->y;
5858
rect->y = 0;
5959
}
6060

6161
if (rect->x + rect->width > container_width) {
62-
overflow = PD_TRUE;
62+
overflow = true;
6363
if (rect->x < container_width) {
6464
rect->width = container_width - rect->x;
6565
} else {
6666
rect->width = 0;
6767
}
6868
}
6969
if (rect->y + rect->height > container_height) {
70-
overflow = PD_TRUE;
70+
overflow = true;
7171
if (rect->y < container_height) {
7272
rect->height = container_height - rect->y;
7373
} else {
@@ -81,23 +81,23 @@ bool pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b)
8181
{
8282
if (a->x > b->x) {
8383
if (b->x + b->width <= a->x) {
84-
return PD_FALSE;
84+
return false;
8585
}
8686
} else {
8787
if (a->x + a->width <= b->x) {
88-
return PD_FALSE;
88+
return false;
8989
}
9090
}
9191
if (a->y > b->y) {
9292
if (b->y + b->height <= a->y) {
93-
return PD_FALSE;
93+
return false;
9494
}
9595
} else {
9696
if (a->y + a->height <= b->y) {
97-
return PD_FALSE;
97+
return false;
9898
}
9999
}
100-
return PD_TRUE;
100+
return true;
101101
}
102102

103103
bool pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b,
@@ -134,9 +134,9 @@ bool pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b,
134134
overlapping_rect->y = b->y;
135135
}
136136
if (overlapping_rect->width <= 0 || overlapping_rect->height <= 0) {
137-
return PD_FALSE;
137+
return false;
138138
}
139-
return PD_TRUE;
139+
return true;
140140
}
141141

142142
void pd_rect_merge(pd_rect_t *merged_rect, const pd_rect_t *a,
@@ -309,7 +309,7 @@ int pd_rects_remove(list_t *list, pd_rect_t *rect)
309309
if (!pd_rect_is_cover(p, rect)) {
310310
continue;
311311
}
312-
deletable = PD_TRUE;
312+
deletable = true;
313313
pd_rect_split(rect, p, child_rects);
314314
for (i = 0; i < 4; ++i) {
315315
if (child_rects[i].width <= 0 ||
@@ -321,7 +321,7 @@ int pd_rects_remove(list_t *list, pd_rect_t *rect)
321321
free(node->data);
322322
list_delete_node(list, node);
323323
node = prev;
324-
deletable = PD_FALSE;
324+
deletable = false;
325325
}
326326
p = malloc(sizeof(pd_rect_t));
327327
*p = child_rects[i];

0 commit comments

Comments
 (0)