This commit is contained in:
John Preston 2015-12-16 16:35:25 +03:00
commit 322eef660e
4 changed files with 33 additions and 6 deletions

View File

@ -315,7 +315,7 @@ QPixmap _prepareFrame(const ClipFrameRequest &request, const QImage &original, Q
if (fill) p.fillRect(0, 0, cache.width() / factor, cache.height() / factor, st::black);
if (smooth && badSize) p.setRenderHint(QPainter::SmoothPixmapTransform);
QRect to((request.outerw - request.framew) / (2 * factor), (request.outerh - request.frameh) / (2 * factor), request.framew / factor, request.frameh / factor);
QRect from(0, 0, original.width() / factor, original.height() / factor);
QRect from(0, 0, original.width(), original.height());
p.drawImage(to, original, from, Qt::ColorOnly);
}
if (request.rounded) {
@ -351,6 +351,9 @@ ClipReader::ClipReader(const FileLocation &location, const QByteArray &data) : _
}
void ClipReader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, bool rounded) {
if (_clipManagers.size() <= _threadIndex) error();
if (_state == ClipError) return;
int32 factor(cIntRetinaFactor());
_request.factor = factor;
_request.framew = framew * factor;
@ -380,7 +383,10 @@ QPixmap ClipReader::current(int32 framew, int32 frameh, int32 outerw, int32 oute
result = _current = QPixmap();
result = _current = _prepareFrame(_request, current, _cacheForResize, true);
if (_clipManagers.size() <= _threadIndex) error();
if (_state != ClipError) {
_clipManagers.at(_threadIndex)->update(this);
}
return result;
}
@ -409,9 +415,12 @@ ClipState ClipReader::state() const {
}
void ClipReader::stop() {
if (_clipManagers.size() <= _threadIndex) error();
if (_state != ClipError) {
_clipManagers.at(_threadIndex)->stop(this);
_width = _height = 0;
}
}
void ClipReader::error() {
_private = 0;
@ -761,3 +770,20 @@ void ClipReadManager::process() {
_processingInThread = 0;
}
ClipReadManager::~ClipReadManager() {
{
QMutexLocker lock(&_readerPointersMutex);
for (ReaderPointers::iterator i = _readerPointers.begin(), e = _readerPointers.end(); i != e; ++i) {
if (i.value()) {
i.key()->_private = 0;
}
}
_readerPointers.clear();
for (Readers::iterator i = _readers.begin(), e = _readers.end(); i != e; ++i) {
delete i.key();
}
_readers.clear();
}
}

View File

@ -560,6 +560,7 @@ public:
void start(ClipReader *reader);
void update(ClipReader *reader);
void stop(ClipReader *reader);
~ClipReadManager();
signals:

View File

@ -45,7 +45,7 @@ public:
typedef QHash<PeerId, History*> Map;
Map map;
Histories() : unreadFull(0), unreadMuted(0), _a_typings(animation(this, &Histories::step_typings)) {
Histories() : _a_typings(animation(this, &Histories::step_typings)), unreadFull(0), unreadMuted(0) {
}
void regSendAction(History *history, UserData *user, const MTPSendMessageAction &action);

View File

@ -83,8 +83,8 @@ NotifyWindow::NotifyWindow(HistoryItem *msg, int32 x, int32 y, int32 fwdCount) :
, hiding(false)
, _index(0)
, a_opacity(0)
, a_y(y + st::notifyHeight + st::notifyDeltaY)
, a_func(anim::linear)
, a_y(y + st::notifyHeight + st::notifyDeltaY)
, _a_appearance(animation(this, &NotifyWindow::step_appearance)) {
updateNotifyDisplay();