kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0029-tilebuffer-tileSize-as-member-variable-is-superfluou.patch

f325b2
From f72510427d6076b304ed14879b00eb253367e161 Mon Sep 17 00:00:00 2001
f325b2
From: Pranav Kant <pranavk@gnome.org>
f325b2
Date: Mon, 8 Jun 2015 15:24:12 +0530
f325b2
Subject: [PATCH 029/398] tilebuffer: tileSize as member variable is
f325b2
 superfluous
f325b2
f325b2
Change-Id: I1eae8c96c12ba4d272341f45fee6c1fd66ab9e28
f325b2
(cherry picked from commit 2afe94dbfc85cbcde1399267379a466d527998a4)
f325b2
---
f325b2
 libreofficekit/source/gtk/lokdocview.cxx |  4 +---
f325b2
 libreofficekit/source/gtk/tilebuffer.cxx | 12 ++++++------
f325b2
 libreofficekit/source/gtk/tilebuffer.hxx |  7 ++-----
f325b2
 3 files changed, 9 insertions(+), 14 deletions(-)
f325b2
f325b2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
index d790b2b43c08..0124704d6784 100644
f325b2
--- a/libreofficekit/source/gtk/lokdocview.cxx
f325b2
+++ b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
@@ -274,7 +274,7 @@ LOKDocView_Impl::CallbackData::CallbackData(int nType, const std::string& rPaylo
f325b2
 LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
f325b2
     : m_pDocView(pDocView),
f325b2
       m_pDrawingArea(gtk_drawing_area_new()),
f325b2
-      m_aTileBuffer(TileBuffer(0,0,0,0)),
f325b2
+      m_aTileBuffer(TileBuffer(0,0,0)),
f325b2
       m_fZoom(1),
f325b2
       m_pOffice(0),
f325b2
       m_pDocument(0),
f325b2
@@ -1236,7 +1236,6 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_doc_view_open_document( LOKDocView* pDocView,
f325b2
 
f325b2
 
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
@@ -1263,7 +1262,6 @@ SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom ( LOKDocView* pDocView, float fZ
f325b2
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
f325b2
 
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
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx
f325b2
index 774806bc414d..1d6a8b66ec80 100644
f325b2
--- a/libreofficekit/source/gtk/tilebuffer.cxx
f325b2
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
f325b2
@@ -79,7 +79,7 @@ Tile& TileBuffer::getTile(int x, int y, float aZoom)
f325b2
     if(m_mTiles.find(index) == m_mTiles.end() || !m_mTiles[index].valid)
f325b2
     {
f325b2
 
f325b2
-        GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, m_nTileSize, m_nTileSize);
f325b2
+        GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileSizePixels, nTileSizePixels);
f325b2
         if (!pPixBuf)
f325b2
         {
f325b2
             g_info ("Error allocating memory to pixbuf");
f325b2
@@ -88,16 +88,16 @@ Tile& TileBuffer::getTile(int x, int y, float aZoom)
f325b2
 
f325b2
         unsigned char* pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
f325b2
         GdkRectangle aTileRectangle;
f325b2
-        aTileRectangle.x = pixelToTwip(m_nTileSize, aZoom) * y;
f325b2
-        aTileRectangle.y = pixelToTwip(m_nTileSize, aZoom) * x;
f325b2
+        aTileRectangle.x = pixelToTwip(nTileSizePixels, aZoom) * y;
f325b2
+        aTileRectangle.y = pixelToTwip(nTileSizePixels, 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
+                                          nTileSizePixels, nTileSizePixels,
f325b2
                                           aTileRectangle.x, aTileRectangle.y,
f325b2
-                                          pixelToTwip(m_nTileSize, aZoom),
f325b2
-                                          pixelToTwip(m_nTileSize, aZoom));
f325b2
+                                          pixelToTwip(nTileSizePixels, aZoom),
f325b2
+                                          pixelToTwip(nTileSizePixels, 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 59660042f544..ea8e52452c8d 100644
f325b2
--- a/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
@@ -83,11 +83,9 @@ class TileBuffer
f325b2
 {
f325b2
  public:
f325b2
  TileBuffer(LibreOfficeKitDocument *document,
f325b2
-            int tileSize,
f325b2
             int rows,
f325b2
             int columns)
f325b2
      : m_pLOKDocument(document)
f325b2
-        , m_nTileSize(tileSize)
f325b2
         , m_nWidth(columns)
f325b2
         , m_nHeight(rows)
f325b2
     {  }
f325b2
@@ -104,10 +102,11 @@ class TileBuffer
f325b2
 
f325b2
        @param x the tile along the x-axis of the buffer
f325b2
        @param y the tile along the y-axis of the buffer
f325b2
+       @param aZoom This function needs the zoom factor to draw the tile using paintTile()
f325b2
 
f325b2
        @return the tile at the mentioned position (x, y)
f325b2
      */
f325b2
-    Tile& getTile(int x, int y);
f325b2
+    Tile& getTile(int x, int y, float aZoom);
f325b2
     /// Destroys all the tiles in the tile buffer; also frees the memory allocated
f325b2
     /// for all the Tile objects.
f325b2
     void resetAllTiles();
f325b2
@@ -123,8 +122,6 @@ class TileBuffer
f325b2
  private:
f325b2
     /// Contains the reference to the LOK Document that this tile buffer is for.
f325b2
     LibreOfficeKitDocument *m_pLOKDocument;
f325b2
-    /// The side of each squared tile in pixels.
f325b2
-    int m_nTileSize;
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