Skip to content

Commit

Permalink
fix special cases resize when parallelism is in use
Browse files Browse the repository at this point in the history
  • Loading branch information
grz0zrg committed Sep 26, 2023
1 parent 5f693fb commit 6bc532b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ all:
$(CC) $(SRC7) $(INCS) $(STANDARD_FLAGS) $(DEFP) $(RELEASE_FLAGS) $(LIBS2) -o $(OUT7)

tiny:
$(CC) ../custom_backend/fbdev/fbg_fbdev.c ../src/fbgraphics.c simple_parallel_example.c $(INCS) $(STANDARD_FLAGS) $(DEFP) -fdata-sections -ffunction-sections -flto -DFBG_LIGHT -Os -lpthread -o $(OUT2) -Wl,--gc-sections,-flto
$(CC) ../custom_backend/fbdev/fbg_fbdev.c ../src/fbgraphics.c tiny.c $(INCS) $(STANDARD_FLAGS) -fdata-sections -ffunction-sections -flto -DWITHOUT_STB_IMAGE -DWITHOUT_JPEG -DWITHOUT_PNG -Os -o tiny -Wl,--gc-sections,-flto

debug:
$(CC) $(SRC1) $(INCS) $(STANDARD_FLAGS) $(DEBUG_FLAGS) $(LIBS1) -o $(OUT1)
Expand Down
39 changes: 39 additions & 0 deletions examples/tiny.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <sys/stat.h>
#include <signal.h>

#include "fbgraphics.h"
#include "fbg_fbdev.h" // insert any backends from ../custom_backend/backend_name folder

int keep_running = 1;

void int_handler(int dummy) {
keep_running = 0;
}

int main(int argc, char* argv[]) {
signal(SIGINT, int_handler);

// open "/dev/fb0" by default, use fbg_fbdevSetup("/dev/fb1", 0) if you want to use another framebuffer
// note : fbg_fbdevInit is the linux framebuffer backend, you can use a different backend easily by including the proper header and compiling with the appropriate backend file found in ../custom_backend/backend_name
struct _fbg *fbg = fbg_fbdevInit();
if (fbg == NULL) {
return 0;
}

do {
fbg_clear(fbg, 0); // can also be replaced by fbg_background(fbg, 0, 0, 0);

fbg_draw(fbg);

fbg_rect(fbg, fbg->width / 2 - 8, fbg->height / 2 - 8, 16, 16, 0, 255, 0);

fbg_pixel(fbg, fbg->width / 2, fbg->height / 2, 255, 0, 0);

fbg_flip(fbg);

} while (keep_running);

fbg_close(fbg);

return 0;
}
12 changes: 8 additions & 4 deletions src/fbgraphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ void fbg_resize(struct _fbg *fbg, int new_width, int new_height) {

fbg->size = new_size;

if (fbg->user_resize) {
fbg->user_resize(fbg, new_width, new_height);
}

#ifdef FBG_PARALLEL
if (fbg->tasks || create_fragments) {
if (!user_fragment_start) {
Expand All @@ -242,10 +246,10 @@ void fbg_resize(struct _fbg *fbg, int new_width, int new_height) {
fbg_createFragment(fbg, user_fragment_start, user_fragment, user_fragment_stop, parallel_tasks);
}
#endif
}

if (fbg->user_resize) {
fbg->user_resize(fbg, new_width, new_height);
} else {
if (fbg->user_resize) {
fbg->user_resize(fbg, new_width, new_height);
}
}
}

Expand Down

0 comments on commit 6bc532b

Please sign in to comment.