Blob Blame History Raw
From ecbfe4c719be7ed5919a7e6f66388bdb51948cbb Mon Sep 17 00:00:00 2001
From: Pranav Kant <pranavk@gnome.org>
Date: Mon, 8 Jun 2015 15:08:44 +0530
Subject: [PATCH 028/398] tilebuffer: ZoomFactor as member variable is
 superfluous

Change-Id: I9f533f577f959c9a715e5214be99ca59cb0d206c
(cherry picked from commit 16222190ec4cf6b83e7771a8d714a7dbb968c42b)
---
 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(-)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 2997feddf1d4..d790b2b43c08 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 0c798232326b..774806bc414d 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 7e2132f4d512..59660042f544 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)
-- 
2.12.0