Blame SOURCES/0028-tilebuffer-ZoomFactor-as-member-variable-is-superflu.patch

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