libreofficekit/source/gtk/lokdocview.cxx | 41 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 11 deletions(-)
New commits: commit 4a95948e8b7bdc7d40e58d0b2efa22b49f2867ec Author: Pranav Kant <[email protected]> Date: Wed Jul 15 23:39:09 2015 +0530 lokdocview: [WIP] Trying to draw in a separate thread But it seems that this code is not able to correctly handle and paint the cairo contexts. Change-Id: I663d6ea4500ea8b132cb0371750f9970dd08ecb7 diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 0a5eca4..75e370b 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -715,11 +715,16 @@ renderGraphicHandle(LOKDocView* pDocView, } } - -static gboolean -renderDocument(LOKDocView* pDocView, cairo_t* pCairo) +static void +renderDocument(GTask*, + gpointer source_object, + gpointer task_data, + GCancellable*) { + LOKDocView* pDocView = LOK_DOC_VIEW(source_object); LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + cairo_t* pCairo = static_cast<cairo_t*>(task_data); + GdkRectangle aVisibleArea; long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom); long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom); @@ -773,14 +778,17 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo) } } } - - return FALSE; } -static gboolean -renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) +static void +renderOverlay(GTask*, + gpointer source_object, + gpointer task_data, + GCancellable*) { + LOKDocView* pDocView = LOK_DOC_VIEW(source_object); LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); + cairo_t* pCairo = static_cast<cairo_t*>(task_data); if (priv->m_bEdit && priv->m_bCursorVisible && priv->m_bCursorOverlayVisible && !isEmptyRectangle(priv->m_aVisibleCursor)) { @@ -850,8 +858,6 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) renderGraphicHandle(pDocView, pCairo, priv->m_aGraphicSelection, priv->m_pGraphicHandle); g_free (handleGraphicPath); } - - return FALSE; } static gboolean @@ -1144,12 +1150,25 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va } } +static void +lokCairoFree(gpointer cairo) +{ + cairo_t* pCairo = static_cast<cairo_t*>(cairo); + cairo_destroy(pCairo); +} + + static gboolean lok_doc_view_draw (GtkWidget* pWidget, cairo_t* pCairo) { LOKDocView *pDocView = LOK_DOC_VIEW (pWidget); + GTask* taskDocument = g_task_new(pDocView, NULL, NULL, NULL); + GTask* taskOverlay = g_task_new(pDocView, NULL, NULL, NULL); + + g_task_set_task_data(taskDocument, cairo_reference(pCairo), lokCairoFree); + g_task_set_task_data(taskOverlay, cairo_reference(pCairo), lokCairoFree); - renderDocument (pDocView, pCairo); - renderOverlay (pDocView, pCairo); + g_task_run_in_thread(taskDocument, renderDocument); + g_task_run_in_thread(taskDocument, renderOverlay); return FALSE; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
