#include "ev-page-cache.h"
#include "ev-selection.h"
#include "ev-document-images.h"
+#include "ev-document-forms.h"
#include "ev-image.h"
#include "ev-form-field.h"
EvJob *job;
EvRenderContext *rc;
+ /* Region of the page that needs to be drawn */
+ GdkRegion *region;
+
/* Data we get from rendering */
cairo_surface_t *surface;
GList *link_mapping;
object_class->finalize = ev_pixbuf_cache_finalize;
object_class->dispose = ev_pixbuf_cache_dispose;
- signals[JOB_FINISHED] = g_signal_new ("job-finished",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EvPixbufCacheClass, job_finished),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ signals[JOB_FINISHED] =
+ g_signal_new ("job-finished",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EvPixbufCacheClass, job_finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
}
static void
cairo_surface_destroy (job_info->surface);
job_info->surface = NULL;
}
+ if (job_info->region) {
+ gdk_region_destroy (job_info->region);
+ job_info->region = NULL;
+ }
if (job_info->link_mapping) {
ev_link_mapping_free (job_info->link_mapping);
job_info->link_mapping = NULL;
job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
copy_job_to_job_info (job_render, job_info, pixbuf_cache);
- g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0);
+ g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
}
/* This checks a job to see if the job would generate the right sized pixbuf
*target_page = *job_info;
job_info->job = NULL;
+ job_info->region = NULL;
job_info->surface = NULL;
job_info->link_mapping = NULL;
job_info->image_mapping = NULL;
}
}
-
-
static void
ev_pixbuf_cache_update_range (EvPixbufCache *pixbuf_cache,
gint start_page,
add_job (EvPixbufCache *pixbuf_cache,
CacheJobInfo *job_info,
EvPageCache *page_cache,
+ GdkRegion *region,
gint width,
gint height,
gint page,
ev_render_context_set_scale (job_info->rc, scale);
}
+ if (job_info->region)
+ gdk_region_destroy (job_info->region);
+ job_info->region = region ? gdk_region_copy (region) : NULL;
+
/* Figure out what else we need for this job */
if (job_info->link_mapping == NULL)
include_links = TRUE;
include_text,
include_selection);
ev_job_queue_add_job (job_info->job, priority);
- g_signal_connect (job_info->job, "finished", G_CALLBACK (job_finished_cb), pixbuf_cache);
+ g_signal_connect (job_info->job, "finished",
+ G_CALLBACK (job_finished_cb),
+ pixbuf_cache);
}
static void
cairo_image_surface_get_height (job_info->surface) == height)
return;
- add_job (pixbuf_cache, job_info, page_cache,
+ add_job (pixbuf_cache, job_info, page_cache, NULL,
width, height, page, rotation, scale,
priority);
}
if (job_info->job &&
EV_JOB (job_info->job)->finished) {
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
- g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0);
+ g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
}
return job_info->surface;
if (job_info->job &&
EV_JOB (job_info->job)->finished) {
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
- g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0);
+ g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
}
return job_info->link_mapping;
if (job_info->job &&
EV_JOB (job_info->job)->finished) {
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
- g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0);
+ g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
}
return job_info->image_mapping;
}
+GList *
+ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache,
+ gint page)
+{
+ CacheJobInfo *job_info;
+
+ if (!EV_IS_DOCUMENT_FORMS (pixbuf_cache->document))
+ return NULL;
+
+ job_info = find_job_cache (pixbuf_cache, page);
+ if (job_info == NULL)
+ return NULL;
+
+ /* We don't need to wait for the idle to handle the callback */
+ if (job_info->job &&
+ EV_JOB (job_info->job)->finished) {
+ copy_job_to_job_info (EV_JOB_RENDER(job_info->job), job_info, pixbuf_cache);
+ g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
+ }
+
+ return job_info->form_field_mapping;
+}
+
static gboolean
new_selection_surface_needed (EvPixbufCache *pixbuf_cache,
CacheJobInfo *job_info,
if (job_info->job &&
EV_JOB (job_info->job)->finished) {
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
- g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0);
+ g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
}
return job_info->text_mapping;
}
void
-ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
+ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
+ GdkRegion *region,
gint page,
gint rotation,
- gfloat scale)
+ gdouble scale)
{
CacheJobInfo *job_info;
EvPageCache *page_cache;
ev_page_cache_get_size (page_cache, page, rotation, scale,
&width, &height);
- add_job (pixbuf_cache, job_info, page_cache,
+ add_job (pixbuf_cache, job_info, page_cache, region,
width, height, page, rotation, scale,
EV_JOB_PRIORITY_HIGH);
}
-GList *
-ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache,
- gint page)
-{
- CacheJobInfo *job_info;
-
- job_info = find_job_cache (pixbuf_cache, page);
- if (job_info == NULL)
- return NULL;
-
- if (job_info->job &&
- EV_JOB (job_info->job)->finished) {
- copy_job_to_job_info (EV_JOB_RENDER(job_info->job), job_info, pixbuf_cache);
- }
- return job_info->form_field_mapping;
-}
int page,
EvView *view);
static void job_finished_cb (EvPixbufCache *pixbuf_cache,
+ GdkRegion *region,
EvView *view);
static void page_changed_cb (EvPageCache *page_cache,
int new_page,
return NULL;
}
+static GdkRegion *
+ev_view_form_field_get_region (EvView *view,
+ EvFormField *field)
+{
+ EvRectangle field_area;
+ GdkRectangle view_area;
+ GList *forms_mapping;
+
+ forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
+ field->page);
+ ev_form_field_mapping_get_area (forms_mapping, field, &field_area);
+ doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+ view_area.x -= view->scroll_x;
+ view_area.y -= view->scroll_y;
+
+ return gdk_region_rectangle (&view_area);
+}
+
static gboolean
ev_view_forms_remove_widgets (EvView *view)
{
break;
case EV_FORM_FIELD_BUTTON_CHECK:
case EV_FORM_FIELD_BUTTON_RADIO: {
- gboolean state;
+ gboolean state;
+ GdkRegion *field_region;
+ field_region = ev_view_form_field_get_region (view, field);
+
state = ev_document_forms_form_field_button_get_state (EV_DOCUMENT_FORMS (view->document),
field);
ev_document_forms_form_field_button_set_state (EV_DOCUMENT_FORMS (view->document),
field, !state);
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
+ field_region,
field->page,
view->rotation,
view->scale);
+ gdk_region_destroy (field_region);
}
break;
}
if (field->changed) {
EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (field);
+ GdkRegion *field_region;
+
+ field_region = ev_view_form_field_get_region (view, field);
ev_document_forms_form_field_text_set_text (EV_DOCUMENT_FORMS (view->document),
field, field_text->text);
field->changed = FALSE;
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
+ field_region,
field->page,
view->rotation,
view->scale);
+ gdk_region_destroy (field_region);
}
}
if (field->changed) {
GList *l;
EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (field);
+ GdkRegion *field_region;
+
+ field_region = ev_view_form_field_get_region (view, field);
if (field_choice->is_editable) {
ev_document_forms_form_field_choice_set_text (EV_DOCUMENT_FORMS (view->document),
}
field->changed = FALSE;
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
+ field_region,
field->page,
view->rotation,
view->scale);
+ gdk_region_destroy (field_region);
}
}
static void
job_finished_cb (EvPixbufCache *pixbuf_cache,
+ GdkRegion *region,
EvView *view)
{
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ if (region) {
+ gdk_window_invalidate_region (view->layout.bin_window,
+ region, TRUE);
+ } else {
+ gtk_widget_queue_draw (GTK_WIDGET (view));
+ }
}
static void