Thoughts about threaded rendering



Hi,

here is a proposal on how to integrate the planned threaded rendering
with our current interfaces. Very much a work in progress... but I guess
it shows the concept...

Marco

----------------------------------------------------------------------

Some changes are necessary to the backend interfaces. Note that
these are really initial concept interfaces: they are not
well thought, methods are missing and I'm ignoring important
problems like sizing.
While we are at it, there are a few issues I'd like to solve with
the interfaces, but I'm omitting them here, for simplicity.

In the backend we have now three types of objects, which
implements generic interfaces: EvThumbnail, EvPage and EvDocument.

GObject *ev_thumbnail_new (EvDocument *document,
                           int         suggested_width,
                           int         page_number);
GObject *ev_page_new	  (EvDocument *document,
			   double      scale
		     	   int         page_number);
GObject *ev_document_new  (void);

EvDocument interface
--------------------

gboolean ev_document_load            (EvDocument   *document,
                                      const char   *uri,
                                      GError      **error);
gboolean ev_document_save            (EvDocument   *document,
                                      const char   *uri,
                                      GError      **error);
char    *ev_document_get_title       (EvDocument   *document);
int      ev_document_get_n_pages     (EvDocument   *document);

EvDocumentSecurity interface
----------------------------

Not affected?

EvDocumentMisc interface
------------------------

Not affected?

EvThumbnail interface
---------------------

/* Signals */

void       (* render_completed)    (EvThumbnail *thumbnail);

/* Methods */

GdkPixbuf *ev_thumbnail_get_pixbuf   (EvThumbnail *thumbnail);
void       ev_thumbnail_start_render (EvThumbnail *thumbnail);

EvPage interface
----------------

/* Signals */

void       (* render_completed)    (EvPage *page);

/* Methods */

void    ev_page_set_rotation    (EvPage       *page,
				 int           rotation);
void    ev_page_set_scale       (EvPage       *page,
				 int           scale);
void    ev_page_get_size        (EvPage       *page,
                                 int          *width,
                                 int          *height);
char   *ev_page_get_text        (EvPage       *page,
                                 GdkRectangle *rect);
EvLink *ev_page_get_link        (EvPage       *page,
                                 int           x,
                                 int           y);
void	ev_page_draw		(EvPage       *page,
				 GdkDrawable  *page
				 GdkRegion    *region);
void    ev_page_start_render	(EvPage       *page);

EvPageFind interface
--------------------

/* Methods */

gboolean  ev_page_find_has_results    (EvPageFind   *page_find);
int       ev_page_find_get_n_results  (EvPageFind   *page_find);
gboolean  ev_page_find_get_result     (EvPageFind   *page_find,
                                       int           n_result,
                                       GdkRectangle *rectangle);




In the shell we use a separate thread to render pages and thumbnails
asyncronously.

EvRenderer
----------

typedef enum
{
	EV_RENDERER_PRIORITY_HIGH,
	EV_RENDERER_PRIORITY_LOW
} EvRendererPriority;

void ev_renderer_start_render (GObject            *object,
			       EvRendererPriority  priority);

object here can be a page or a thumbnail. It would probably
be a good idea to have a EvRenderable interface that both
objects can implement.

The internal implementation is done using GAsyncQueue(s).
Jhonatan has some thoughts/code on it.

So, how this works in practice... First I create my page
object and set his properties.

page = ev_page_new (document, 0.8, 10);
ev_page_set_rotation (page, 90);

Then I add it to renderer queue:

ev_renderer_start_render (renderer, EV_RENDERER_PRIORITY_HIGH);

Finally, when render is completed (the render_completed signal
has been emitted) I can:

ev_page_draw (page, drawable, region);





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]