[Libreoffice-commits] core.git: Branch 'feature/gsoc-tiled-rendering' - libreofficekit/source
Pranav Kant
pranavk at gnome.org
Mon Jun 8 02:48:03 PDT 2015
libreofficekit/source/gtk/lokdocview.cxx | 7 +++++--
libreofficekit/source/gtk/tilebuffer.cxx | 21 +++++----------------
libreofficekit/source/gtk/tilebuffer.hxx | 14 --------------
3 files changed, 10 insertions(+), 32 deletions(-)
New commits:
commit 9ec97fe89d34f94d07e9c5e483485510e28a21ea
Author: Pranav Kant <pranavk at gnome.org>
Date: Mon Jun 8 15:08:44 2015 +0530
tilebuffer: ZoomFactor as member variable is superfluous
Change-Id: I9f533f577f959c9a715e5214be99ca59cb0d206c
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 31fefc7..64955f7 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -846,7 +846,7 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
{
//g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
- Tile& currentTile = m_aTileBuffer.getTile(nRow, nColumn);
+ Tile& currentTile = m_aTileBuffer.getTile(nRow, nColumn, m_fZoom);
GdkPixbuf* pPixBuf = currentTile.getBuffer();
gdk_cairo_set_source_pixbuf (pcairo, pPixBuf,
@@ -1262,7 +1262,10 @@ SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom ( LOKDocView* pDocView, float fZ
guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
- pDocView->m_pImpl->m_aTileBuffer.setZoom(fZoom, nRows, nColumns);
+ pDocView->m_pImpl->m_aTileBuffer = TileBuffer(pDocView->m_pImpl->m_pDocument,
+ nTileSizePixels,
+ nRows,
+ nColumns);
gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
nDocumentWidthPixels,
nDocumentHeightPixels);
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx
index 0c79823..774806b 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -51,17 +51,6 @@ void Tile::setPixbuf(GdkPixbuf *buffer)
TileBuffer class member functions
----------------------------------
*/
-void TileBuffer::setZoom(float newZoomFactor, int rows, int columns)
-{
- m_fZoomFactor = newZoomFactor;
-
- resetAllTiles();
-
- // set new buffer width and height
- m_nWidth = columns;
- m_nHeight = rows;
-}
-
void TileBuffer::resetAllTiles()
{
std::map<int, Tile>::iterator it = m_mTiles.begin();
@@ -84,7 +73,7 @@ void TileBuffer::setInvalid(int x, int y)
}
}
-Tile& TileBuffer::getTile(int x, int y)
+Tile& TileBuffer::getTile(int x, int y, float aZoom)
{
int index = x * m_nWidth + y;
if(m_mTiles.find(index) == m_mTiles.end() || !m_mTiles[index].valid)
@@ -99,16 +88,16 @@ Tile& TileBuffer::getTile(int x, int y)
unsigned char* pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
GdkRectangle aTileRectangle;
- aTileRectangle.x = pixelToTwip(m_nTileSize, m_fZoomFactor) * y;
- aTileRectangle.y = pixelToTwip(m_nTileSize, m_fZoomFactor) * x;
+ aTileRectangle.x = pixelToTwip(m_nTileSize, aZoom) * y;
+ aTileRectangle.y = pixelToTwip(m_nTileSize, aZoom) * x;
g_info ("Rendering (%d, %d)", x, y);
m_pLOKDocument->pClass->paintTile(m_pLOKDocument,
pBuffer,
m_nTileSize, m_nTileSize,
aTileRectangle.x, aTileRectangle.y,
- pixelToTwip(m_nTileSize, m_fZoomFactor),
- pixelToTwip(m_nTileSize, m_fZoomFactor));
+ pixelToTwip(m_nTileSize, aZoom),
+ pixelToTwip(m_nTileSize, aZoom));
//create a mapping for it
m_mTiles[index].setPixbuf(pPixBuf);
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
index 7e2132f..5966004 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -88,7 +88,6 @@ class TileBuffer
int columns)
: m_pLOKDocument(document)
, m_nTileSize(tileSize)
- , m_fZoomFactor(1)
, m_nWidth(columns)
, m_nHeight(rows)
{ }
@@ -96,17 +95,6 @@ class TileBuffer
~TileBuffer() {}
/**
- Sets the zoom factor (m_fZoomFactor) for this tile buffer. Setting the
- zoom factor invalidates whole of the tile buffer, destroys all tiles
- contained within it, and sets new width, height values for tile
- buffer. The width, height value of tile buffer is the width and height of
- the table containing all possible tiles (rendered and non-rendered) that
- this buffer can have.
-
- @param zoomFactor the new zoom factor value to set
- */
- void setZoom(float zoomFactor, int rows, int columns);
- /**
Gets the underlying Tile object for given position. The position (0, 0)
points to the left top most tile of the buffer.
@@ -137,8 +125,6 @@ class TileBuffer
LibreOfficeKitDocument *m_pLOKDocument;
/// The side of each squared tile in pixels.
int m_nTileSize;
- /// The zoom factor that the tile buffer is currently rendered to.
- float m_fZoomFactor;
/// Stores all the tiles cached by this tile buffer.
std::map<int, Tile> m_mTiles;
/// Width of the current tile buffer (number of columns)
More information about the Libreoffice-commits
mailing list