[Libreoffice-commits] core.git: Branch 'feature/gsoc-tiled-rendering' - libreofficekit/source

Pranav Kant pranavk at gnome.org
Mon Jun 8 02:56:55 PDT 2015


 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(-)

New commits:
commit a13c07936338639de2581dd83e20ac9d0e2434b5
Author: Pranav Kant <pranavk at gnome.org>
Date:   Mon Jun 8 15:24:12 2015 +0530

    tilebuffer: tileSize as member variable is superfluous
    
    Change-Id: I1eae8c96c12ba4d272341f45fee6c1fd66ab9e28

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 64955f7..5f768e7 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 774806b..1d6a8b6 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 5966004..ea8e524 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)


More information about the Libreoffice-commits mailing list