summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-11-13 15:54:00 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-11-23 14:25:58 +0000
commitb0f5416d7ee7c988d316df7ffa0318fa6514e4de (patch)
treec196c9966ee53499559806050bb2f01195d91c23 /libreofficekit
parente34f290eec4f3c8d42724f1602029f5680aecde6 (diff)
Do all svp text rendering with cairo
enabling us to delete a whole pile of foo For android we patch cairo, which is internal in that case, to swap the rgb components so that cairo then matches the OpenGL GL_RGBA format so we can use it there where we don't have GL_BGRA support. Change-Id: I25e34889c7b7263438b143dd2a2ad882fb0f190a
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx22
-rw-r--r--libreofficekit/source/gtk/tilebuffer.cxx9
-rw-r--r--libreofficekit/source/gtk/tilebuffer.hxx17
3 files changed, 26 insertions, 22 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index eebf6bc361e2..fe1a12ca2693 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -967,7 +967,7 @@ paintTileCallback(GObject* sourceObject, GAsyncResult* res, gpointer userData)
GError* error;
error = nullptr;
- GdkPixbuf* pPixBuf = static_cast<GdkPixbuf*>(paintTileFinish(pDocView, res, &error));
+ cairo_surface_t* pSurface = static_cast<cairo_surface_t*>(paintTileFinish(pDocView, res, &error));
if (error != nullptr)
{
if (error->domain == LOK_TILEBUFFER_ERROR &&
@@ -980,11 +980,11 @@ paintTileCallback(GObject* sourceObject, GAsyncResult* res, gpointer userData)
return;
}
- buffer->m_mTiles[index].setPixbuf(pPixBuf);
+ buffer->m_mTiles[index].setSurface(pSurface);
buffer->m_mTiles[index].valid = true;
gdk_threads_add_idle(queueDraw, GTK_WIDGET(pDocView));
- g_object_unref(pPixBuf);
+ cairo_surface_destroy(pSurface);
}
@@ -1045,8 +1045,8 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
Tile& currentTile = priv->m_pTileBuffer->getTile(nRow, nColumn, task, priv->lokThreadPool);
- GdkPixbuf* pPixBuf = currentTile.getBuffer();
- gdk_cairo_set_source_pixbuf (pCairo, pPixBuf,
+ cairo_surface_t* pSurface = currentTile.getBuffer();
+ cairo_set_source_surface(pCairo, pSurface,
twipToPixel(aTileRectangleTwips.x, priv->m_fZoom),
twipToPixel(aTileRectangleTwips.y, priv->m_fZoom));
cairo_paint(pCairo);
@@ -1667,17 +1667,18 @@ paintTileInThread (gpointer data)
buffer->m_mTiles[index].valid)
return;
- GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileSizePixels, nTileSizePixels);
- if (!pPixBuf)
+ cairo_surface_t *pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nTileSizePixels, nTileSizePixels);
+ if (cairo_surface_status(pSurface) != CAIRO_STATUS_SUCCESS)
{
+ cairo_surface_destroy(pSurface);
g_task_return_new_error(task,
LOK_TILEBUFFER_ERROR,
LOK_TILEBUFFER_MEMORY,
- "Error allocating memory to GdkPixbuf");
+ "Error allocating Surface");
return;
}
- unsigned char* pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
+ unsigned char* pBuffer = cairo_image_surface_get_data(pSurface);
GdkRectangle aTileRectangle;
aTileRectangle.x = pixelToTwip(nTileSizePixels, pLOEvent->m_fPaintTileZoom) * pLOEvent->m_nPaintTileY;
aTileRectangle.y = pixelToTwip(nTileSizePixels, pLOEvent->m_fPaintTileZoom) * pLOEvent->m_nPaintTileX;
@@ -1696,6 +1697,7 @@ paintTileInThread (gpointer data)
aTileRectangle.x, aTileRectangle.y,
pixelToTwip(nTileSizePixels, pLOEvent->m_fPaintTileZoom),
pixelToTwip(nTileSizePixels, pLOEvent->m_fPaintTileZoom));
+ cairo_surface_mark_dirty(pSurface);
// Its likely that while the tilebuffer has changed, one of the paint tile
// requests has passed the previous check at start of this function, and has
@@ -1711,7 +1713,7 @@ paintTileInThread (gpointer data)
return;
}
- g_task_return_pointer(task, pPixBuf, g_object_unref);
+ g_task_return_pointer(task, pSurface, (GDestroyNotify)cairo_surface_destroy);
}
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx
index 675384c4582e..bded6b1ad853 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -28,18 +28,19 @@ float twipToPixel(float fInput, float zoom)
Tile class member functions
----------------------------
*/
-GdkPixbuf* Tile::getBuffer()
+cairo_surface_t* Tile::getBuffer()
{
return m_pBuffer;
}
-void Tile::setPixbuf(GdkPixbuf *buffer)
+void Tile::setSurface(cairo_surface_t *buffer)
{
if (m_pBuffer == buffer)
return;
- g_clear_object(&m_pBuffer);
+ if (m_pBuffer)
+ cairo_surface_destroy(m_pBuffer);
if (buffer != nullptr)
- g_object_ref(buffer);
+ cairo_surface_reference(buffer);
m_pBuffer = buffer;
}
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
index c8f401d38c0a..3d84dfb184e7 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -61,7 +61,8 @@ class Tile
Tile() : valid(false), m_pBuffer(nullptr) {}
~Tile()
{
- g_clear_object(&m_pBuffer);
+ if (m_pBuffer)
+ cairo_surface_destroy(m_pBuffer);
}
/**
@@ -70,14 +71,14 @@ class Tile
*/
bool valid;
- /// Function to get the pointer to enclosing GdkPixbuf
- GdkPixbuf* getBuffer();
+ /// Function to get the pointer to enclosing cairo_surface_t
+ cairo_surface_t* getBuffer();
/// Used to set the pixel buffer of this object
- void setPixbuf(GdkPixbuf*);
+ void setSurface(cairo_surface_t*);
private:
/// Pixel buffer data for this tile
- GdkPixbuf *m_pBuffer;
+ cairo_surface_t *m_pBuffer;
};
/**
@@ -95,9 +96,9 @@ class TileBuffer
: m_pLOKDocument(document)
, m_nWidth(columns)
{
- GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileSizePixels, nTileSizePixels);
- m_DummyTile.setPixbuf(pPixBuf);
- g_object_unref(pPixBuf);
+ cairo_surface_t *pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nTileSizePixels, nTileSizePixels);
+ m_DummyTile.setSurface(pSurface);
+ cairo_surface_destroy(pSurface);
}
~TileBuffer() {}