mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 04:26:00 +01:00
Save surface temporary in page_t
This commit is contained in:
parent
8bcb79ea94
commit
fdf0bd5649
3 changed files with 18 additions and 11 deletions
|
@ -386,6 +386,7 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id)
|
||||||
page->rendered = false;
|
page->rendered = false;
|
||||||
page->event_box = gtk_event_box_new();
|
page->event_box = gtk_event_box_new();
|
||||||
page->drawing_area = gtk_drawing_area_new();
|
page->drawing_area = gtk_drawing_area_new();
|
||||||
|
page->surface = NULL;
|
||||||
g_signal_connect(page->drawing_area, "expose-event", G_CALLBACK(page_expose_event), page);
|
g_signal_connect(page->drawing_area, "expose-event", G_CALLBACK(page_expose_event), page);
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(page->event_box), page->drawing_area);
|
gtk_container_add(GTK_CONTAINER(page->event_box), page->drawing_area);
|
||||||
|
|
|
@ -150,6 +150,7 @@ struct zathura_page_s
|
||||||
GtkWidget* event_box; /**> Widget wrapper for mouse events */
|
GtkWidget* event_box; /**> Widget wrapper for mouse events */
|
||||||
GtkWidget* drawing_area; /**> Drawing area */
|
GtkWidget* drawing_area; /**> Drawing area */
|
||||||
GStaticMutex lock; /**> Lock */
|
GStaticMutex lock; /**> Lock */
|
||||||
|
cairo_surface_t* surface; /** Cairo surface */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
27
render.c
27
render.c
|
@ -176,10 +176,7 @@ render(zathura_t* zathura, zathura_page_t* page)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw to gtk widget */
|
/* draw to gtk widget */
|
||||||
cairo_t* cairo = gdk_cairo_create(page->drawing_area->window);
|
page->surface = surface;
|
||||||
cairo_set_source_surface(cairo, surface, 0, 0);
|
|
||||||
cairo_paint(cairo);
|
|
||||||
cairo_destroy(cairo);
|
|
||||||
|
|
||||||
zathura_image_buffer_free(image_buffer);
|
zathura_image_buffer_free(image_buffer);
|
||||||
g_static_mutex_unlock(&(page->lock));
|
g_static_mutex_unlock(&(page->lock));
|
||||||
|
@ -209,22 +206,30 @@ gboolean
|
||||||
page_expose_event(GtkWidget* widget, GdkEventExpose* event, gpointer data)
|
page_expose_event(GtkWidget* widget, GdkEventExpose* event, gpointer data)
|
||||||
{
|
{
|
||||||
zathura_page_t* page = data;
|
zathura_page_t* page = data;
|
||||||
|
if (page == NULL) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
g_static_mutex_lock(&(page->lock));
|
g_static_mutex_lock(&(page->lock));
|
||||||
|
|
||||||
cairo_t* cairo = gdk_cairo_create(page->drawing_area->window);
|
cairo_t* cairo = gdk_cairo_create(page->drawing_area->window);
|
||||||
|
|
||||||
if (cairo == NULL) {
|
if (cairo == NULL) {
|
||||||
girara_error("Could not create blank page");
|
girara_error("Could not retreive cairo object");
|
||||||
g_static_mutex_unlock(&(page->lock));
|
g_static_mutex_unlock(&(page->lock));
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_set_source_rgb(cairo, 0, 0, 0);
|
if (page->surface == NULL) {
|
||||||
cairo_rectangle(cairo, 0, 0, page->width, page->height);
|
cairo_set_source_surface(cairo, page->surface, 0, 0);
|
||||||
cairo_fill(cairo);
|
cairo_paint(cairo);
|
||||||
cairo_destroy(cairo);
|
cairo_destroy(cairo);
|
||||||
|
|
||||||
|
cairo_surface_destroy(page->surface);
|
||||||
|
page->surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_static_mutex_unlock(&(page->lock));
|
g_static_mutex_unlock(&(page->lock));
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue