Kaydet (Commit) 16222190 authored tarafından Pranav Kant's avatar Pranav Kant Kaydeden (comit) Miklos Vajna

tilebuffer: ZoomFactor as member variable is superfluous

Change-Id: I9f533f577f959c9a715e5214be99ca59cb0d206c
üst 03655e67
......@@ -846,7 +846,7 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
{
//g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
Tile& currentTile = m_aTileBuffer.getTile(nRow, nColumn);
Tile& currentTile = m_aTileBuffer.getTile(nRow, nColumn, m_fZoom);
GdkPixbuf* pPixBuf = currentTile.getBuffer();
gdk_cairo_set_source_pixbuf (pcairo, pPixBuf,
......@@ -1262,7 +1262,10 @@ SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom ( LOKDocView* pDocView, float fZ
guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
pDocView->m_pImpl->m_aTileBuffer.setZoom(fZoom, nRows, nColumns);
pDocView->m_pImpl->m_aTileBuffer = TileBuffer(pDocView->m_pImpl->m_pDocument,
nTileSizePixels,
nRows,
nColumns);
gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
nDocumentWidthPixels,
nDocumentHeightPixels);
......
......@@ -51,17 +51,6 @@ void Tile::setPixbuf(GdkPixbuf *buffer)
TileBuffer class member functions
----------------------------------
*/
void TileBuffer::setZoom(float newZoomFactor, int rows, int columns)
{
m_fZoomFactor = newZoomFactor;
resetAllTiles();
// set new buffer width and height
m_nWidth = columns;
m_nHeight = rows;
}
void TileBuffer::resetAllTiles()
{
std::map<int, Tile>::iterator it = m_mTiles.begin();
......@@ -84,7 +73,7 @@ void TileBuffer::setInvalid(int x, int y)
}
}
Tile& TileBuffer::getTile(int x, int y)
Tile& TileBuffer::getTile(int x, int y, float aZoom)
{
int index = x * m_nWidth + y;
if(m_mTiles.find(index) == m_mTiles.end() || !m_mTiles[index].valid)
......@@ -99,16 +88,16 @@ Tile& TileBuffer::getTile(int x, int y)
unsigned char* pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
GdkRectangle aTileRectangle;
aTileRectangle.x = pixelToTwip(m_nTileSize, m_fZoomFactor) * y;
aTileRectangle.y = pixelToTwip(m_nTileSize, m_fZoomFactor) * x;
aTileRectangle.x = pixelToTwip(m_nTileSize, aZoom) * y;
aTileRectangle.y = pixelToTwip(m_nTileSize, aZoom) * x;
g_info ("Rendering (%d, %d)", x, y);
m_pLOKDocument->pClass->paintTile(m_pLOKDocument,
pBuffer,
m_nTileSize, m_nTileSize,
aTileRectangle.x, aTileRectangle.y,
pixelToTwip(m_nTileSize, m_fZoomFactor),
pixelToTwip(m_nTileSize, m_fZoomFactor));
pixelToTwip(m_nTileSize, aZoom),
pixelToTwip(m_nTileSize, aZoom));
//create a mapping for it
m_mTiles[index].setPixbuf(pPixBuf);
......
......@@ -88,24 +88,12 @@ class TileBuffer
int columns)
: m_pLOKDocument(document)
, m_nTileSize(tileSize)
, m_fZoomFactor(1)
, m_nWidth(columns)
, m_nHeight(rows)
{ }
~TileBuffer() {}
/**
Sets the zoom factor (m_fZoomFactor) for this tile buffer. Setting the
zoom factor invalidates whole of the tile buffer, destroys all tiles
contained within it, and sets new width, height values for tile
buffer. The width, height value of tile buffer is the width and height of
the table containing all possible tiles (rendered and non-rendered) that
this buffer can have.
@param zoomFactor the new zoom factor value to set
*/
void setZoom(float zoomFactor, int rows, int columns);
/**
Gets the underlying Tile object for given position. The position (0, 0)
points to the left top most tile of the buffer.
......@@ -137,8 +125,6 @@ class TileBuffer
LibreOfficeKitDocument *m_pLOKDocument;
/// The side of each squared tile in pixels.
int m_nTileSize;
/// The zoom factor that the tile buffer is currently rendered to.
float m_fZoomFactor;
/// Stores all the tiles cached by this tile buffer.
std::map<int, Tile> m_mTiles;
/// Width of the current tile buffer (number of columns)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment