f325b2
From 0ad2976627386e126ae310d85aa6d771b3df1353 Mon Sep 17 00:00:00 2001
f325b2
From: Pranav Kant <pranavk@gnome.org>
f325b2
Date: Thu, 4 Jun 2015 22:09:57 +0530
f325b2
Subject: [PATCH 017/398] lokdocview, tilebuffer: clean up
f325b2
f325b2
Improve documentation, style fixes
f325b2
f325b2
Change-Id: I5000e32e90cd8e3b75e8df2907673efc303a55fd
f325b2
(cherry picked from commit c074cfa4d48736d1703949ccfe1a6c534a2742ae)
f325b2
---
f325b2
 libreofficekit/source/gtk/lokdocview.cxx |  59 ++++++++++-------
f325b2
 libreofficekit/source/gtk/tilebuffer.cxx | 104 +++++++++++++++++-------------
f325b2
 libreofficekit/source/gtk/tilebuffer.hxx | 107 +++++++++++++++++++++++++------
f325b2
 3 files changed, 182 insertions(+), 88 deletions(-)
f325b2
f325b2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
index cfa71a357f22..2181dc9a21b1 100644
f325b2
--- a/libreofficekit/source/gtk/lokdocview.cxx
f325b2
+++ b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
@@ -1,4 +1,4 @@
f325b2
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
f325b2
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
f325b2
 /*
f325b2
  * This file is part of the LibreOffice project.
f325b2
  *
f325b2
@@ -177,12 +177,12 @@ struct LOKDocView_Impl
f325b2
     /// Implementation of the timeout handler, invoked by handleTimeout().
f325b2
     gboolean handleTimeoutImpl();
f325b2
     /**
f325b2
-     * Renders the document to a number of tiles.
f325b2
+     * Renders the document to a number of visible tiles.
f325b2
      *
f325b2
      * This method is invoked only manually, not when some Gtk signal is
f325b2
      * emitted.
f325b2
      *
f325b2
-     * @param pPartial if 0, then the full document is rendered, otherwise only
f325b2
+     * @param pPartial if 0, then the full visible document is rendered, otherwise only
f325b2
      * the tiles that intersect with pPartial.
f325b2
      */
f325b2
     void renderDocument(GdkRectangle* pPartial);
f325b2
@@ -665,7 +665,7 @@ void LOKDocView_Impl::setTilesInvalid(const GdkRectangle& rRectangle)
f325b2
 
f325b2
     for (int i = aStart.x; i < aEnd.x; i++)
f325b2
         for (int j = aStart.y; j < aEnd.y; j++)
f325b2
-            m_pTileBuffer->tile_buffer_set_invalid(i, j);
f325b2
+            m_pTileBuffer->setInvalid(i, j);
f325b2
 }
f325b2
 
f325b2
 void LOKDocView_Impl::renderHandle(cairo_t* pCairo, const GdkRectangle& rCursor, cairo_surface_t* pHandle, GdkRectangle& rRectangle)
f325b2
@@ -801,7 +801,8 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
f325b2
             GdkRectangle aTileRectangleTwips, aTileRectanglePixels;
f325b2
             bool bPaint = true;
f325b2
 
f325b2
-            // Determine size of the tile: the rightmost/bottommost tiles may be smaller and we need the size to decide if we need to repaint.
f325b2
+            // Determine size of the tile: the rightmost/bottommost tiles may
f325b2
+            // be smaller, and we need the size to decide if we need to repaint.
f325b2
             if (nColumn == nColumns - 1)
f325b2
                 aTileRectanglePixels.width = nDocumentWidthPixels - nColumn * nTileSizePixels;
f325b2
             else
f325b2
@@ -811,7 +812,8 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
f325b2
             else
f325b2
                 aTileRectanglePixels.height = nTileSizePixels;
f325b2
 
f325b2
-            // Determine size and position of the tile in document coordinates, so we can decide if we can skip painting for partial rendering.
f325b2
+            // Determine size and position of the tile in document coordinates,
f325b2
+            // so we can decide if we can skip painting for partial rendering.
f325b2
             aTileRectangleTwips.x = pixelToTwip(nTileSizePixels, m_fZoom) * nColumn;
f325b2
             aTileRectangleTwips.y = pixelToTwip(nTileSizePixels, m_fZoom) * nRow;
f325b2
             aTileRectangleTwips.width = pixelToTwip(aTileRectanglePixels.width, m_fZoom);
f325b2
@@ -824,12 +826,14 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
f325b2
 
f325b2
             if (bPaint)
f325b2
             {
f325b2
-                //                g_info("gettile: (%d %d)", nRow, nColumn);
f325b2
+                g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
f325b2
 
f325b2
-                Tile& currentTile = m_pTileBuffer->tile_buffer_get_tile(nRow, nColumn);
f325b2
-                GdkPixbuf* pPixBuf = currentTile.tile_get_buffer();
f325b2
+                Tile& currentTile = m_pTileBuffer->getTile(nRow, nColumn);
f325b2
+                GdkPixbuf* pPixBuf = currentTile.getBuffer();
f325b2
 
f325b2
-                gdk_cairo_set_source_pixbuf (pcairo, pPixBuf, twipToPixel(aTileRectangleTwips.x, m_fZoom), twipToPixel(aTileRectangleTwips.y, m_fZoom));
f325b2
+                gdk_cairo_set_source_pixbuf (pcairo, pPixBuf,
f325b2
+                                             twipToPixel(aTileRectangleTwips.x, m_fZoom),
f325b2
+                                             twipToPixel(aTileRectangleTwips.y, m_fZoom));
f325b2
                 cairo_paint(pcairo);
f325b2
             }
f325b2
         }
f325b2
@@ -942,7 +946,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
f325b2
         }
f325b2
         else
f325b2
         {
f325b2
-            m_pTileBuffer->tile_buffer_reset_all_tiles();
f325b2
+            m_pTileBuffer->resetAllTiles();
f325b2
             renderDocument(0);
f325b2
         }
f325b2
     }
f325b2
@@ -1148,21 +1152,28 @@ static void lok_docview_init( GTypeInstance* pInstance, gpointer )
f325b2
     gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
f325b2
                                            pDocView->m_pImpl->m_pDrawingArea );
f325b2
 
f325b2
-    g_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
+    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
                      "expose-event",
f325b2
-                     GTK_SIGNAL_FUNC(LOKDocView_Impl::on_exposed), pDocView);
f325b2
-    g_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
+                     G_CALLBACK(LOKDocView_Impl::on_exposed), pDocView);
f325b2
+    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
                      "expose-event",
f325b2
-                     GTK_SIGNAL_FUNC(LOKDocView_Impl::renderOverlay), pDocView);
f325b2
+                     G_CALLBACK(LOKDocView_Impl::renderOverlay), pDocView);
f325b2
     gtk_widget_add_events(pDocView->m_pImpl->m_pDrawingArea,
f325b2
-                          GDK_BUTTON_PRESS_MASK
f325b2
-                          | GDK_BUTTON_RELEASE_MASK
f325b2
-                          | GDK_BUTTON_MOTION_MASK);
f325b2
-    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea), "button-press-event", G_CALLBACK(LOKDocView_Impl::signalButton), pDocView);
f325b2
-    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea), "button-release-event", G_CALLBACK(LOKDocView_Impl::signalButton), pDocView);
f325b2
-    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea), "motion-notify-event", G_CALLBACK(LOKDocView_Impl::signalMotion), pDocView);
f325b2
-
f325b2
-    gtk_signal_connect(GTK_OBJECT(pDocView), "destroy", GTK_SIGNAL_FUNC(LOKDocView_Impl::destroy), 0);
f325b2
+                           GDK_BUTTON_PRESS_MASK
f325b2
+                          |GDK_BUTTON_RELEASE_MASK
f325b2
+                          |GDK_BUTTON_MOTION_MASK);
f325b2
+
f325b2
+    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
+                     "button-press-event",
f325b2
+                     G_CALLBACK(LOKDocView_Impl::signalButton), pDocView);
f325b2
+    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
+                     "button-release-event",
f325b2
+                     G_CALLBACK(LOKDocView_Impl::signalButton), pDocView);
f325b2
+    g_signal_connect(G_OBJECT(pDocView->m_pImpl->m_pDrawingArea),
f325b2
+                     "motion-notify-event",
f325b2
+                     G_CALLBACK(LOKDocView_Impl::signalMotion), pDocView);
f325b2
+
f325b2
+    g_signal_connect(G_OBJECT(pDocView), "destroy", G_CALLBACK(LOKDocView_Impl::destroy), 0);
f325b2
 }
f325b2
 
f325b2
 SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
f325b2
@@ -1253,7 +1264,7 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZo
f325b2
     guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
f325b2
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
f325b2
 
f325b2
-    pDocView->m_pImpl->m_pTileBuffer->tile_buffer_set_zoom(fZoom, nRows, nColumns);
f325b2
+    pDocView->m_pImpl->m_pTileBuffer->setZoom(fZoom, nRows, nColumns);
f325b2
 
f325b2
     if ( pDocView->m_pImpl->m_pDocument )
f325b2
         pDocView->m_pImpl->renderDocument(0);
f325b2
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx
f325b2
index 3e5e01f8d686..338038078ab3 100644
f325b2
--- a/libreofficekit/source/gtk/tilebuffer.cxx
f325b2
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
f325b2
@@ -1,4 +1,4 @@
f325b2
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
f325b2
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
f325b2
 /*
f325b2
  * This file is part of the LibreOffice project.
f325b2
  *
f325b2
@@ -9,6 +9,10 @@
f325b2
 
f325b2
 #include "tilebuffer.hxx"
f325b2
 
f325b2
+/* ------------------
f325b2
+   Utility functions
f325b2
+   ------------------
f325b2
+*/
f325b2
 float pixelToTwip(float fInput, float zoom)
f325b2
 {
f325b2
     return (fInput / DPI / zoom) * 1440.0f;
f325b2
@@ -19,84 +23,96 @@ float twipToPixel(float fInput, float zoom)
f325b2
     return fInput / 1440.0f * DPI * zoom;
f325b2
 }
f325b2
 
f325b2
-GdkPixbuf* Tile::tile_get_buffer()
f325b2
+/* ----------------------------
f325b2
+   Tile class member functions
f325b2
+   ----------------------------
f325b2
+*/
f325b2
+GdkPixbuf* Tile::getBuffer()
f325b2
 {
f325b2
     return m_pBuffer;
f325b2
 }
f325b2
 
f325b2
-void Tile::tile_release()
f325b2
+void Tile::release()
f325b2
 {
f325b2
     g_object_unref (m_pBuffer);
f325b2
     m_pBuffer = NULL;
f325b2
 }
f325b2
 
f325b2
-void TileBuffer::tile_buffer_set_zoom(float newZoomFactor, int rows, int columns)
f325b2
+void Tile::setPixbuf(GdkPixbuf *buffer)
f325b2
+{
f325b2
+    m_pBuffer = buffer;
f325b2
+}
f325b2
+
f325b2
+/* ----------------------------------
f325b2
+   TileBuffer class member functions
f325b2
+   ----------------------------------
f325b2
+*/
f325b2
+void TileBuffer::setZoom(float newZoomFactor, int rows, int columns)
f325b2
 {
f325b2
     m_fZoomFactor = newZoomFactor;
f325b2
 
f325b2
-    tile_buffer_reset_all_tiles();
f325b2
+    resetAllTiles();
f325b2
 
f325b2
     // set new buffer width and height
f325b2
     m_nWidth = columns;
f325b2
     m_nHeight = rows;
f325b2
 }
f325b2
 
f325b2
-void TileBuffer::tile_buffer_reset_all_tiles()
f325b2
+void TileBuffer::resetAllTiles()
f325b2
 {
f325b2
     std::map<int, Tile>::iterator it = m_mTiles.begin();
f325b2
     for (; it != m_mTiles.end(); it++)
f325b2
-        {
f325b2
-            it->second.tile_release();
f325b2
-        }
f325b2
+    {
f325b2
+        it->second.release();
f325b2
+    }
f325b2
     m_mTiles.clear();
f325b2
 }
f325b2
 
f325b2
-void TileBuffer::tile_buffer_set_invalid(int x, int y)
f325b2
+void TileBuffer::setInvalid(int x, int y)
f325b2
 {
f325b2
     int index = x * m_nWidth + y;
f325b2
-    g_info("setting invalid : %d %d",x, y);
f325b2
+    g_info("Setting tile invalid (%d, %d)", x, y);
f325b2
     if (m_mTiles.find(index) != m_mTiles.end())
f325b2
-        {
f325b2
-            m_mTiles[index].valid = 0;
f325b2
-            m_mTiles[index].tile_release();
f325b2
-            m_mTiles.erase(index);
f325b2
-        }
f325b2
+    {
f325b2
+        m_mTiles[index].valid = 0;
f325b2
+        m_mTiles[index].release();
f325b2
+        m_mTiles.erase(index);
f325b2
+    }
f325b2
 }
f325b2
 
f325b2
-Tile& TileBuffer::tile_buffer_get_tile(int x, int y)
f325b2
+Tile& TileBuffer::getTile(int x, int y)
f325b2
 {
f325b2
     int index = x * m_nWidth + y;
f325b2
     if(m_mTiles.find(index) == m_mTiles.end() || !m_mTiles[index].valid)
f325b2
-        {
f325b2
+    {
f325b2
 
f325b2
-            GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, m_nTileSize, m_nTileSize);
f325b2
-            if (!pPixBuf){
f325b2
-                g_info ("error allocating memory to pixbuf");
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
-
f325b2
-            g_info ("rendering (%d %d)", x, y);
f325b2
-            m_pLOKDocument->pClass->paintTile(m_pLOKDocument,
f325b2
-                                              // Buffer and its size, depends on the position only.
f325b2
-                                              pBuffer,
f325b2
-                                              m_nTileSize, m_nTileSize,
f325b2
-                                              // Position of the tile.
f325b2
-                                              aTileRectangle.x, aTileRectangle.y,
f325b2
-                                              // Size of the tile, depends on the zoom factor and the tile position only.
f325b2
-                                              pixelToTwip(m_nTileSize, m_fZoomFactor), pixelToTwip(m_nTileSize, m_fZoomFactor));
f325b2
-
f325b2
-            //create a mapping for it
f325b2
-            m_mTiles[index].tile_set_pixbuf(pPixBuf);
f325b2
-            m_mTiles[index].valid = 1;
f325b2
+        GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, m_nTileSize, m_nTileSize);
f325b2
+        if (!pPixBuf)
f325b2
+        {
f325b2
+            g_info ("Error allocating memory to pixbuf");
f325b2
+            return m_mTiles[index];
f325b2
         }
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
+
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
+
f325b2
+        //create a mapping for it
f325b2
+        m_mTiles[index].setPixbuf(pPixBuf);
f325b2
+        m_mTiles[index].valid = 1;
f325b2
+    }
f325b2
+
f325b2
     return m_mTiles[index];
f325b2
 }
f325b2
 
f325b2
-void Tile::tile_set_pixbuf(GdkPixbuf *buffer)
f325b2
-{
f325b2
-    m_pBuffer = buffer;
f325b2
-}
f325b2
+
f325b2
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
f325b2
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
index 15b276f238aa..7e2132f4d512 100644
f325b2
--- a/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
@@ -1,4 +1,4 @@
f325b2
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
f325b2
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
f325b2
 /*
f325b2
  * This file is part of the LibreOffice project.
f325b2
  *
f325b2
@@ -24,32 +24,60 @@ const int DPI = 96;
f325b2
 // Lets use a square of side 256 pixels for each tile.
f325b2
 const int nTileSizePixels = 256;
f325b2
 
f325b2
+/**
f325b2
+   Converts the pixel value to zoom independent twip value.
f325b2
+
f325b2
+   @param fInput value to convert
f325b2
+   @param zoom the current zoom level
f325b2
+
f325b2
+   @return the pixels value corresponding to given twip value
f325b2
+*/
f325b2
 float pixelToTwip(float fInput, float zoom);
f325b2
 
f325b2
+/**
f325b2
+   Converts the zoom independent twip value pixel value.
f325b2
+
f325b2
+   @param fInput value to convert
f325b2
+   @param zoom the current zoom level
f325b2
+
f325b2
+   @return the twip value corresponding to given pixel value
f325b2
+*/
f325b2
 float twipToPixel(float fInput, float zoom);
f325b2
 
f325b2
-/*
f325b2
-  This class represents a single tile in the tile buffer.
f325b2
-  TODO: Extend it to support features like double buffering
f325b2
+/**
f325b2
+   This class represents a single tile in the tile buffer.
f325b2
+   It encloses a reference to GdkPixBuf containing the pixel data of the tile.
f325b2
 */
f325b2
 class Tile
f325b2
 {
f325b2
  public:
f325b2
- Tile() : valid(0) {}
f325b2
-    ~Tile() {
f325b2
-    }
f325b2
+    Tile() : valid(0) {}
f325b2
+    ~Tile() { }
f325b2
 
f325b2
-    GdkPixbuf* tile_get_buffer();
f325b2
-    void tile_release();
f325b2
-    void tile_set_pixbuf(GdkPixbuf*);
f325b2
+    /**
f325b2
+       Tells if this tile is valid or not. Initialised to 0 (invalid) during
f325b2
+       object creation.
f325b2
+    */
f325b2
     bool valid;
f325b2
- private:
f325b2
+
f325b2
+    /// Function to get the pointer to enclosing GdkPixbuf
f325b2
+    GdkPixbuf* getBuffer();
f325b2
+    /// Destroys the enclosing GdkPixbuf object pointed to by m_pBuffer
f325b2
+    void release();
f325b2
+    /// Used to set the pixel buffer of this object
f325b2
+    void setPixbuf(GdkPixbuf*);
f325b2
+
f325b2
+private:
f325b2
+    /// Pixel buffer data for this tile
f325b2
     GdkPixbuf *m_pBuffer;
f325b2
 };
f325b2
 
f325b2
-/*
f325b2
-  TileBuffer is the buffer caching all the recently rendered tiles.
f325b2
-  The buffer is set to invalid when zoom factor changes.
f325b2
+/**
f325b2
+   This class represents the tile buffer which is responsible for managing,
f325b2
+   reusing and caching all the already rendered tiles. If the given tile is not
f325b2
+   present in the buffer, call to LOK Document's (m_pLOKDocument) paintTile
f325b2
+   method is made which fetches the rendered tile from LO core and store it in
f325b2
+   buffer for future reuse.
f325b2
 */
f325b2
 class TileBuffer
f325b2
 {
f325b2
@@ -67,19 +95,58 @@ class TileBuffer
f325b2
 
f325b2
     ~TileBuffer() {}
f325b2
 
f325b2
-    void tile_buffer_set_zoom(float zoomFactor, int rows, int columns);
f325b2
-    Tile& tile_buffer_get_tile(int x, int y);
f325b2
-    void tile_buffer_update();
f325b2
-    void tile_buffer_reset_all_tiles();
f325b2
-    void tile_buffer_set_invalid(int x, int y);
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
+       If the tile is not cached by the tile buffer, it makes a paintTile call
f325b2
+       to LO core asking to render the given tile. It then stores the tile for
f325b2
+       future reuse.
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
+
f325b2
+       @return the tile at the mentioned position (x, y)
f325b2
+     */
f325b2
+    Tile& getTile(int x, int y);
f325b2
+    /// Destroys all the tiles in the tile buffer; also frees the memory allocated
f325b2
+    /// for all the Tile objects.
f325b2
+    void resetAllTiles();
f325b2
+    /**
f325b2
+       Marks the tile as invalid. The tile (0, 0) is the left topmost tile in
f325b2
+       the tile buffer.
f325b2
+
f325b2
+       @param x the position of tile along x-axis
f325b2
+       @param y the position of tile along y-axis
f325b2
+     */
f325b2
+    void setInvalid(int x, int y);
f325b2
+
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
+    /// 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
-    //TODO: Also set width and height when document size changes
f325b2
+    /// Width of the current tile buffer (number of columns)
f325b2
     int m_nWidth;
f325b2
+    /// Height of the current tile buffer (numbero of rows)
f325b2
     int m_nHeight;
f325b2
 };
f325b2
 
f325b2
 #endif // INCLUDED_TILEBUFFER_HXX
f325b2
+
f325b2
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
f325b2
-- 
f325b2
2.12.0
f325b2