[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: [okular] core: Fix issue where the tiles seemed to be deformed while rotating the page
From: Albert Astals Cid <tsdgeos () yahoo ! es>
Date: 2012-11-12 16:42:20
Message-ID: 1352738540.24561.YahooMailClassic () web171302 ! mail ! ir2 ! yahoo ! com
[Download RAW message or body]
Is this work done in the main thread?
Albert
--- El lun, 12/11/12, Mailson Menezes <mailson@gmail.com> escribió:
> De: Mailson Menezes <mailson@gmail.com>
> Asunto: [okular] core: Fix issue where the tiles seemed to be deformed while rotating the page
> Para: kde-commits@kde.org
> Fecha: lunes, 12 de noviembre, 2012 17:15
> Git commit
> b762e5f10e808590bf10e4c1068f5f11bd9abc7f by Mailson
> Menezes.
> Committed on 10/11/2012 at 18:50.
> Pushed by menezes into branch 'master'.
>
> Fix issue where the tiles seemed to be deformed while
> rotating the page
>
> Also, don't mark rotated pixmaps as dirty since we are
> already updating
> them
>
> M +52 -2
> core/tilesmanager.cpp
> M +9 -1
> core/tilesmanager_p.h
>
> http://commits.kde.org/okular/b762e5f10e808590bf10e4c1068f5f11bd9abc7f
>
> diff --git a/core/tilesmanager.cpp b/core/tilesmanager.cpp
> index b5d1672..af92392 100644
> --- a/core/tilesmanager.cpp
> +++ b/core/tilesmanager.cpp
> @@ -11,6 +11,7 @@
> #include <QPixmap>
> #include <QtCore/qmath.h>
> #include <QList>
> +#include <QPainter>
>
> #include "tile.h"
>
> @@ -159,8 +160,6 @@ void TilesManager::setRotation( Rotation
> rotation )
> return;
>
> d->rotation = rotation;
> -
> - markDirty();
> }
>
> Rotation TilesManager::rotation() const
> @@ -242,6 +241,7 @@ void TilesManager::Private::setPixmap(
> const QPixmap *pixmap, const NormalizedRe
> }
>
> NormalizedRect rotatedRect =
> TilesManager::toRotatedRect( tile.rect, rotation );
>
> tile.pixmap = new QPixmap(
> pixmap->copy( rotatedRect.geometry( width, height
> ).translated( -pixmapRect.topLeft() ) ) );
> + tile.rotation =
> rotation;
>
> totalPixels +=
> tile.pixmap->width()*tile.pixmap->height();
> }
> else
> @@ -295,6 +295,7 @@ void TilesManager::Private::setPixmap(
> const QPixmap *pixmap, const NormalizedRe
>
> delete tile.pixmap;
> }
>
> tile.pixmap = new QPixmap(
> pixmap->copy( tile.rect.geometry( width, height
> ).translated( -pixmapRect.topLeft() ) ) );
> + tile.rotation =
> rotation;
>
> totalPixels +=
> tile.pixmap->width()*tile.pixmap->height();
>
> tile.dirty = false;
> }
> @@ -363,6 +364,54 @@ void TilesManager::Private::tilesAt(
> const NormalizedRect &rect, TileNode &tile,
>
> rotatedRect = TilesManager::toRotatedRect(
> tile.rect, rotation );
> else
>
> rotatedRect = tile.rect;
> +
> + if ( tile.pixmap &&
> !allowEmpty && tile.rotation != rotation )
> + {
> + // Lazy tiles
> rotation
> + int angleToRotate
> = (rotation - tile.rotation)*90;
> + int xOffset = 0,
> yOffset = 0;
> + int w = 0, h =
> 0;
> + switch(
> angleToRotate )
> + {
> +
> case 0:
> +
> xOffset = 0;
> +
> yOffset = 0;
> +
> w = tile.pixmap->width();
> +
> h = tile.pixmap->height();
> +
> break;
> +
> case 90:
> +
> case -270:
> +
> xOffset = 0;
> +
> yOffset = -tile.pixmap->height();
> +
> w = tile.pixmap->height();
> +
> h = tile.pixmap->width();
> +
> break;
> +
> case 180:
> +
> case -180:
> +
> xOffset = -tile.pixmap->width();
> +
> yOffset = -tile.pixmap->height();
> +
> w = tile.pixmap->width();
> +
> h = tile.pixmap->height();
> +
> break;
> +
> case 270:
> +
> case -90:
> +
> xOffset = -tile.pixmap->width();
> +
> yOffset = 0;
> +
> w = tile.pixmap->height();
> +
> h = tile.pixmap->width();
> +
> break;
> + }
> + QPixmap
> *rotatedPixmap = new QPixmap( w, h );
> + QPainter p(
> rotatedPixmap );
> + p.rotate(
> angleToRotate );
> + p.translate(
> xOffset, yOffset );
> + p.drawPixmap( 0,
> 0, *tile.pixmap );
> + p.end();
> +
> + delete
> tile.pixmap;
> + tile.pixmap =
> rotatedPixmap;
> + tile.rotation =
> rotation;
> + }
> result.append( Tile(
> rotatedRect, tile.pixmap, tile.isValid() ) );
> }
> else
> @@ -561,6 +610,7 @@ NormalizedRect
> TilesManager::toRotatedRect( const NormalizedRect &rect,
> Rotation
>
> TileNode::TileNode()
> : pixmap( 0 )
> + , rotation( Rotation0 )
> , dirty ( true )
> , distance( -1 )
> , tiles( 0 )
> diff --git a/core/tilesmanager_p.h b/core/tilesmanager_p.h
> index c490201..61a57e6 100644
> --- a/core/tilesmanager_p.h
> +++ b/core/tilesmanager_p.h
> @@ -55,6 +55,14 @@ class TileNode
> QPixmap *pixmap;
>
> /**
> + * Rotation of this
> individual tile.
> + *
> + * A rotation to the
> page does not immediately rotates the pixmaps in
> + * cache. This
> operation happens when pixmaps are going to be used.
> + */
> + Rotation rotation;
> +
> + /**
> * Whether the tile needs
> to be repainted (after a zoom or rotation)
> * If a tile doesn't have
> a pixmap but all its children are updated
> * (dirty = false), the
> parent tile is also considered updated.
> @@ -162,7 +170,7 @@ class TilesManager
> int height() const;
>
> /**
> - * Inform the new
> rotation of the page and mark all tiles to repaint.
> + * Inform the new
> rotation of the page
> */
> void setRotation(
> Rotation rotation );
> Rotation rotation()
> const;
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic