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

Change-Id: I1eae8c96c12ba4d272341f45fee6c1fd66ab9e28
(cherry picked from commit 2afe94dbfc85cbcde1399267379a466d527998a4)
---
 libreofficekit/source/gtk/lokdocview.cxx |  4 +---
 libreofficekit/source/gtk/tilebuffer.cxx | 12 ++++++------
 libreofficekit/source/gtk/tilebuffer.hxx |  7 ++-----
 3 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d790b2b43c08..0124704d6784 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -274,7 +274,7 @@ LOKDocView_Impl::CallbackData::CallbackData(int nType, const std::string& rPaylo
 LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
     : m_pDocView(pDocView),
       m_pDrawingArea(gtk_drawing_area_new()),
-      m_aTileBuffer(TileBuffer(0,0,0,0)),
+      m_aTileBuffer(TileBuffer(0,0,0)),
       m_fZoom(1),
       m_pOffice(0),
       m_pDocument(0),
@@ -1236,7 +1236,6 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_doc_view_open_document( LOKDocView* pDocView,
 
 
         pDocView->m_pImpl->m_aTileBuffer = TileBuffer(pDocView->m_pImpl->m_pDocument,
-                                                      nTileSizePixels,
                                                       nRows,
                                                       nColumns);
         gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
@@ -1263,7 +1262,6 @@ SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom ( LOKDocView* pDocView, float fZ
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
 
     pDocView->m_pImpl->m_aTileBuffer = TileBuffer(pDocView->m_pImpl->m_pDocument,
-                                                  nTileSizePixels,
                                                   nRows,
                                                   nColumns);
     gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx
index 774806bc414d..1d6a8b66ec80 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -79,7 +79,7 @@ Tile& TileBuffer::getTile(int x, int y, float aZoom)
     if(m_mTiles.find(index) == m_mTiles.end() || !m_mTiles[index].valid)
     {
 
-        GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, m_nTileSize, m_nTileSize);
+        GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileSizePixels, nTileSizePixels);
         if (!pPixBuf)
         {
             g_info ("Error allocating memory to pixbuf");
@@ -88,16 +88,16 @@ Tile& TileBuffer::getTile(int x, int y, float aZoom)
 
         unsigned char* pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
         GdkRectangle aTileRectangle;
-        aTileRectangle.x = pixelToTwip(m_nTileSize, aZoom) * y;
-        aTileRectangle.y = pixelToTwip(m_nTileSize, aZoom) * x;
+        aTileRectangle.x = pixelToTwip(nTileSizePixels, aZoom) * y;
+        aTileRectangle.y = pixelToTwip(nTileSizePixels, aZoom) * x;
 
         g_info ("Rendering (%d, %d)", x, y);
         m_pLOKDocument->pClass->paintTile(m_pLOKDocument,
                                           pBuffer,
-                                          m_nTileSize, m_nTileSize,
+                                          nTileSizePixels, nTileSizePixels,
                                           aTileRectangle.x, aTileRectangle.y,
-                                          pixelToTwip(m_nTileSize, aZoom),
-                                          pixelToTwip(m_nTileSize, aZoom));
+                                          pixelToTwip(nTileSizePixels, aZoom),
+                                          pixelToTwip(nTileSizePixels, 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 59660042f544..ea8e52452c8d 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -83,11 +83,9 @@ class TileBuffer
 {
  public:
  TileBuffer(LibreOfficeKitDocument *document,
-            int tileSize,
             int rows,
             int columns)
      : m_pLOKDocument(document)
-        , m_nTileSize(tileSize)
         , m_nWidth(columns)
         , m_nHeight(rows)
     {  }
@@ -104,10 +102,11 @@ class TileBuffer
 
        @param x the tile along the x-axis of the buffer
        @param y the tile along the y-axis of the buffer
+       @param aZoom This function needs the zoom factor to draw the tile using paintTile()
 
        @return the tile at the mentioned position (x, y)
      */
-    Tile& getTile(int x, int y);
+    Tile& getTile(int x, int y, float aZoom);
     /// Destroys all the tiles in the tile buffer; also frees the memory allocated
     /// for all the Tile objects.
     void resetAllTiles();
@@ -123,8 +122,6 @@ class TileBuffer
  private:
     /// Contains the reference to the LOK Document that this tile buffer is for.
     LibreOfficeKitDocument *m_pLOKDocument;
-    /// The side of each squared tile in pixels.
-    int m_nTileSize;
     /// 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