mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
PICTUREFLOW: cambiado el modo en el que se realiza la animaci?n, ahora se utiliza un bucle con frame skiping
This commit is contained in:
parent
ed850ef374
commit
c3ed550793
@ -223,6 +223,7 @@ public:
|
|||||||
int step;
|
int step;
|
||||||
int frame;
|
int frame;
|
||||||
QTimer animateTimer;
|
QTimer animateTimer;
|
||||||
|
bool animating;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PictureFlowAbstractRenderer
|
class PictureFlowAbstractRenderer
|
||||||
@ -355,7 +356,7 @@ void PictureFlowState::reset()
|
|||||||
// ------------- PictureFlowAnimator ---------------------------------------
|
// ------------- PictureFlowAnimator ---------------------------------------
|
||||||
|
|
||||||
PictureFlowAnimator::PictureFlowAnimator():
|
PictureFlowAnimator::PictureFlowAnimator():
|
||||||
state(0), target(0), step(0), frame(0)
|
state(0), target(0), step(0), frame(0), animating(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +366,9 @@ void PictureFlowAnimator::start(int slide)
|
|||||||
if(!animateTimer.isActive() && state)
|
if(!animateTimer.isActive() && state)
|
||||||
{
|
{
|
||||||
step = (target < state->centerSlide.slideIndex) ? -1 : 1;
|
step = (target < state->centerSlide.slideIndex) ? -1 : 1;
|
||||||
animateTimer.start(10); //TODO comprobar rendimiento, originalmente era 30
|
animateTimer.setSingleShot(true);
|
||||||
|
animateTimer.start(0); //TODO comprobar rendimiento, originalmente era 30
|
||||||
|
animating = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,22 +378,23 @@ void PictureFlowAnimator::stop(int slide)
|
|||||||
target = slide;
|
target = slide;
|
||||||
frame = slide << 16;
|
frame = slide << 16;
|
||||||
animateTimer.stop();
|
animateTimer.stop();
|
||||||
|
animating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureFlowAnimator::update()
|
void PictureFlowAnimator::update()
|
||||||
{
|
{
|
||||||
if(!animateTimer.isActive())
|
/*if(!animateTimer.isActive())
|
||||||
return;
|
return;*/
|
||||||
if(step == 0)
|
if(step == 0)
|
||||||
return;
|
return;
|
||||||
if(!state)
|
if(!state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int speed = 16384/8; //TODO comprobar rendimiento, originalmente era /4
|
int speed = 16384/4; //TODO comprobar rendimiento, originalmente era /4
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// deaccelerate when approaching the target
|
// deaccelerate when approaching the target
|
||||||
const int max = 4 * 65536; //TODO cambiado de 2 * a 4 * comprobar rendimiento
|
const int max = 2 * 65536; //TODO cambiado de 2 * a 4 * comprobar rendimiento
|
||||||
|
|
||||||
int fi = frame;
|
int fi = frame;
|
||||||
fi -= (target << 16);
|
fi -= (target << 16);
|
||||||
@ -670,6 +674,8 @@ PictureFlow::ReflectionEffect reflectionEffect)
|
|||||||
color = bgcolor;
|
color = bgcolor;
|
||||||
result->setPixel(h+hofs + y, x,blendColor(color,bgcolor,80*(hte-y)/hte));
|
result->setPixel(h+hofs + y, x,blendColor(color,bgcolor,80*(hte-y)/hte));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -974,6 +980,8 @@ PictureFlow::PictureFlow(QWidget* parent,FlowType flowType): QWidget(parent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
framesSkip = 0;
|
||||||
|
|
||||||
d->state->reset();
|
d->state->reset();
|
||||||
d->state->reposition();
|
d->state->reposition();
|
||||||
|
|
||||||
@ -1222,14 +1230,38 @@ void PictureFlow::resizeEvent(QResizeEvent* event)
|
|||||||
triggerRender();
|
triggerRender();
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
#include <QTime>
|
||||||
void PictureFlow::updateAnimation()
|
void PictureFlow::updateAnimation() //bucle principal
|
||||||
{
|
{
|
||||||
|
QTime now;
|
||||||
|
now.start();
|
||||||
|
bool frameSkiped = false;
|
||||||
|
|
||||||
int old_center = d->state->centerIndex;
|
int old_center = d->state->centerIndex;
|
||||||
d->animator->update();
|
d->animator->update();
|
||||||
triggerRender();
|
if(framesSkip == 0)
|
||||||
|
render();//triggerRender();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
framesSkip--;
|
||||||
|
frameSkiped = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(d->state->centerIndex != old_center)
|
if(d->state->centerIndex != old_center)
|
||||||
emit centerIndexChanged(d->state->centerIndex);
|
emit centerIndexChanged(d->state->centerIndex);
|
||||||
|
if(d->animator->animating == true)
|
||||||
|
{
|
||||||
|
int difference = 10-now.elapsed();
|
||||||
|
if(difference >= 0 && !frameSkiped)
|
||||||
|
QTimer::singleShot(difference, this, SLOT(updateAnimation()));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QTimer::singleShot(0, this, SLOT(updateAnimation()));
|
||||||
|
if(!frameSkiped)
|
||||||
|
framesSkip = -( (difference - 10) / 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureFlow::setFlowType(FlowType flowType)
|
void PictureFlow::setFlowType(FlowType flowType)
|
||||||
|
@ -217,6 +217,7 @@ private:
|
|||||||
PictureFlowPrivate* d;
|
PictureFlowPrivate* d;
|
||||||
QImage mark;
|
QImage mark;
|
||||||
QVector<bool> marks;
|
QVector<bool> marks;
|
||||||
|
int framesSkip;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PICTUREFLOW_H
|
#endif // PICTUREFLOW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user