mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-14 13:35:59 +01:00
Render pages in a thread
This commit is contained in:
parent
852868a462
commit
be0445110d
2 changed files with 11 additions and 8 deletions
|
@ -12,7 +12,7 @@ GTK_INC = $(shell pkg-config --cflags gtk+-2.0 poppler-glib)
|
||||||
GTK_LIB = $(shell pkg-config --libs gtk+-2.0 poppler-glib)
|
GTK_LIB = $(shell pkg-config --libs gtk+-2.0 poppler-glib)
|
||||||
|
|
||||||
INCS = -I. -I/usr/include ${GTK_INC}
|
INCS = -I. -I/usr/include ${GTK_INC}
|
||||||
LIBS = -L/usr/lib -lc ${GTK_LIB}
|
LIBS = -L/usr/lib -lc ${GTK_LIB} -lpthread
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CFLAGS = -std=c99 -pedantic -Wall $(INCS)
|
CFLAGS = -std=c99 -pedantic -Wall $(INCS)
|
||||||
|
|
17
zathura.c
17
zathura.c
|
@ -8,6 +8,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include <poppler/glib/poppler.h>
|
#include <poppler/glib/poppler.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
@ -186,7 +187,7 @@ void set_page(int);
|
||||||
GtkEventBox* createCompletionRow(GtkBox*, char*, char*, gboolean);
|
GtkEventBox* createCompletionRow(GtkBox*, char*, char*, gboolean);
|
||||||
|
|
||||||
/* thread declaration */
|
/* thread declaration */
|
||||||
void render(void*);
|
void* render(void*);
|
||||||
|
|
||||||
/* shortcut declarations */
|
/* shortcut declarations */
|
||||||
void sc_abort(Argument*);
|
void sc_abort(Argument*);
|
||||||
|
@ -555,18 +556,17 @@ set_page(int page)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* thread implementation */
|
/* thread implementation */
|
||||||
void
|
void*
|
||||||
render(void* parameter)
|
render(void* parameter)
|
||||||
{
|
{
|
||||||
if(!Zathura.PDF.document)
|
if(!Zathura.PDF.document)
|
||||||
return;
|
pthread_exit(NULL);
|
||||||
|
|
||||||
int page;
|
int page;
|
||||||
for(page = 0; page < Zathura.PDF.number_of_pages; page++)
|
for(page = 0; page < Zathura.PDF.number_of_pages; page++)
|
||||||
{
|
|
||||||
printf("Render page %d\n", page);
|
|
||||||
draw(page);
|
draw(page);
|
||||||
}
|
|
||||||
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* shortcut implementation */
|
/* shortcut implementation */
|
||||||
|
@ -1036,7 +1036,10 @@ cmd_open(int argc, char** argv)
|
||||||
Zathura.PDF.pages[i]->surface = NULL;
|
Zathura.PDF.pages[i]->surface = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
render(NULL);
|
/* render pages */
|
||||||
|
pthread_t render_thread;
|
||||||
|
pthread_create(&render_thread, NULL, render, NULL);
|
||||||
|
|
||||||
set_page(0);
|
set_page(0);
|
||||||
update_status();
|
update_status();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue