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

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