summaryrefslogtreecommitdiffstats
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-01-16 18:42:31 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-01-26 10:27:35 +0100
commitc3f1a33867a1e0b351922feb52d762bad73d718e (patch)
treed7035068c887aa9f4b5cbed07baa618cd2557686 /libreofficekit
parentlokdocview: add support for partial rendering (diff)
downloadcore-c3f1a33867a1e0b351922feb52d762bad73d718e.tar.gz
core-c3f1a33867a1e0b351922feb52d762bad73d718e.zip
lokdocview: reduce scope
Change-Id: I246ef656f1211cf760d4fcf408b83f39a1c56b56
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index ec61410873ea..519b9b32e2bb 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -160,55 +160,56 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
{
for (nColumn = 0; nColumn < nColumns; ++nColumn)
{
- int nTileWidthPixels, nTileHeightPixels;
- GdkPixbuf* pPixBuf;
- unsigned char* pBuffer;
- int nRowStride;
- GdkRectangle aTileRectangle;
+ GdkRectangle aTileRectangleTwips, aTileRectanglePixels;
gboolean bPaint = TRUE;
// Determine size of the tile: the rightmost/bottommost tiles may be smaller and we need the size to decide if we need to repaint.
if (nColumn == nColumns - 1)
- nTileWidthPixels = nDocumentWidthPixels - nColumn * nTileSizePixels;
+ aTileRectanglePixels.width = nDocumentWidthPixels - nColumn * nTileSizePixels;
else
- nTileWidthPixels = nTileSizePixels;
+ aTileRectanglePixels.width = nTileSizePixels;
if (nRow == nRows - 1)
- nTileHeightPixels = nDocumentHeightPixels - nRow * nTileSizePixels;
+ aTileRectanglePixels.height = nDocumentHeightPixels - nRow * nTileSizePixels;
else
- nTileHeightPixels = nTileSizePixels;
+ aTileRectanglePixels.height = nTileSizePixels;
// Determine size and position of the tile in document coordinates, so we can decide if we can skip painting for partial rendering.
- aTileRectangle.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
- aTileRectangle.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
- aTileRectangle.width = pixelToTwip(nTileWidthPixels) / pDocView->fZoom;
- aTileRectangle.height = pixelToTwip(nTileHeightPixels) / pDocView->fZoom;
- if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangle, NULL))
+ aTileRectangleTwips.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
+ aTileRectangleTwips.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
+ aTileRectangleTwips.width = pixelToTwip(aTileRectanglePixels.width) / pDocView->fZoom;
+ aTileRectangleTwips.height = pixelToTwip(aTileRectanglePixels.height) / pDocView->fZoom;
+ if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangleTwips, NULL))
bPaint = FALSE;
if (bPaint)
{
- pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileWidthPixels, nTileHeightPixels);
+ // Index of the current tile.
+ guint nTile = nRow * nColumns + nColumn;
+ GdkPixbuf* pPixBuf;
+ unsigned char* pBuffer;
+ int nRowStride;
+
+ pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, aTileRectanglePixels.width, aTileRectanglePixels.height);
pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
pDocView->pDocument->pClass->paintTile(pDocView->pDocument,
// Buffer and its size, depends on the position only.
pBuffer,
- nTileWidthPixels, nTileHeightPixels,
+ aTileRectanglePixels.width, aTileRectanglePixels.height,
&nRowStride,
// Position of the tile.
- aTileRectangle.x, aTileRectangle.y,
+ aTileRectangleTwips.x, aTileRectangleTwips.y,
// Size of the tile, depends on the zoom factor and the tile position only.
- aTileRectangle.width, aTileRectangle.height);
+ aTileRectangleTwips.width, aTileRectangleTwips.height);
(void) nRowStride;
- if (pDocView->pCanvas[nRow * nColumns + nColumn])
- gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nRow * nColumns + nColumn]));
- pDocView->pCanvas[nRow * nColumns + nColumn] = gtk_image_new();
- gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nRow * nColumns + nColumn]), pPixBuf);
+ if (pDocView->pCanvas[nTile])
+ gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nTile]));
+ pDocView->pCanvas[nTile] = gtk_image_new();
+ gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nTile]), pPixBuf);
g_object_unref(G_OBJECT(pPixBuf));
- gtk_widget_show(pDocView->pCanvas[nRow * nColumns + nColumn]);
- gtk_table_attach_defaults(GTK_TABLE(pDocView->pTable), pDocView->pCanvas[nRow * nColumns + nColumn], nColumn, nColumn + 1, nRow, nRow + 1);
+ gtk_widget_show(pDocView->pCanvas[nTile]);
gtk_table_attach(GTK_TABLE(pDocView->pTable),
- pDocView->pCanvas[nRow * nColumns + nColumn],
+ pDocView->pCanvas[nTile],
nColumn, nColumn + 1, nRow, nRow + 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
}