mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-10 16:59:55 +00:00
fixed clipreader lags, threads count increased to 8
This commit is contained in:
parent
cbb0219812
commit
78866622b9
@ -83,7 +83,7 @@ enum {
|
||||
LocalEncryptKeySize = 256, // 2048 bit
|
||||
|
||||
AnimationTimerDelta = 7,
|
||||
ClipThreadsCount = 4,
|
||||
ClipThreadsCount = 8,
|
||||
AverageGifSize = 320 * 240,
|
||||
WaitBeforeGifPause = 200, // wait 200ms for gif draw before pausing it
|
||||
ContextBotRequestDelay = 400, // wait 400ms before context bot realtime request
|
||||
|
@ -1400,6 +1400,7 @@ void StickerPanInner::mousePressEvent(QMouseEvent *e) {
|
||||
|
||||
_pressedSel = _selected;
|
||||
textlnkDown(textlnkOver());
|
||||
_linkDown = _linkOver;
|
||||
_previewTimer.start(QApplication::startDragTime());
|
||||
}
|
||||
|
||||
@ -1407,8 +1408,9 @@ void StickerPanInner::mouseReleaseEvent(QMouseEvent *e) {
|
||||
_previewTimer.stop();
|
||||
|
||||
int32 pressed = _pressedSel;
|
||||
TextLinkPtr down(textlnkDown());
|
||||
TextLinkPtr down(_linkDown);
|
||||
_pressedSel = -1;
|
||||
_linkDown.reset();
|
||||
textlnkDown(TextLinkPtr());
|
||||
|
||||
_lastMousePos = e->globalPos();
|
||||
@ -1419,7 +1421,7 @@ void StickerPanInner::mouseReleaseEvent(QMouseEvent *e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_selected < 0 || _selected != pressed || textlnkOver() != down) return;
|
||||
if (_selected < 0 || _selected != pressed || _linkOver != down) return;
|
||||
if (_showingContextItems) {
|
||||
int32 row = _selected / MatrixRowShift, col = _selected % MatrixRowShift;
|
||||
if (row < _contextRows.size() && col < _contextRows.at(row).items.size()) {
|
||||
@ -1512,9 +1514,10 @@ void StickerPanInner::clearSelection(bool fast) {
|
||||
if (_selected >= 0) {
|
||||
int32 srow = _selected / MatrixRowShift, scol = _selected % MatrixRowShift;
|
||||
t_assert(srow >= 0 && srow < _contextRows.size() && scol >= 0 && scol < _contextRows.at(srow).items.size());
|
||||
if (textlnkOver()) {
|
||||
_contextRows.at(srow).items.at(scol)->linkOut(textlnkOver());
|
||||
textlnkOver(TextLinkPtr());
|
||||
if (_linkOver) {
|
||||
_contextRows.at(srow).items.at(scol)->linkOut(_linkOver);
|
||||
_linkOver = TextLinkPtr();
|
||||
textlnkOver(_linkOver);
|
||||
}
|
||||
setCursor(style::cur_default);
|
||||
}
|
||||
@ -1591,8 +1594,6 @@ void StickerPanInner::refreshStickers() {
|
||||
}
|
||||
|
||||
void StickerPanInner::refreshSavedGifs() {
|
||||
clearSelection(true);
|
||||
|
||||
if (_showingSavedGifs) {
|
||||
clearContextRows();
|
||||
if (_showingContextItems) {
|
||||
@ -1655,6 +1656,7 @@ void StickerPanInner::contextBotChanged() {
|
||||
}
|
||||
|
||||
void StickerPanInner::clearContextRows() {
|
||||
clearSelection(true);
|
||||
for (ContextRows::const_iterator i = _contextRows.cbegin(), e = _contextRows.cend(); i != e; ++i) {
|
||||
for (ContextItems::const_iterator j = i->items.cbegin(), end = i->items.cend(); j != end; ++j) {
|
||||
(*j)->setPosition(-1, 0);
|
||||
@ -1984,23 +1986,23 @@ void StickerPanInner::updateSelected() {
|
||||
if (col < contextItems.size()) {
|
||||
sel = row * MatrixRowShift + col;
|
||||
contextItems.at(col)->getState(lnk, cursor, sx, sy);
|
||||
} else {
|
||||
row = col = -1;
|
||||
}
|
||||
} else {
|
||||
row = col = -1;
|
||||
}
|
||||
if (_selected != sel || textlnkOver() != lnk) {
|
||||
int32 srow = (_selected >= 0) ? (_selected / MatrixRowShift) : -1;
|
||||
int32 scol = (_selected >= 0) ? (_selected % MatrixRowShift) : -1;
|
||||
if (srow >= 0 && scol >= 0 && textlnkOver()) {
|
||||
if (_selected != sel) {
|
||||
if (srow >= 0 && scol >= 0) {
|
||||
t_assert(srow >= 0 && srow < _contextRows.size() && scol >= 0 && scol < _contextRows.at(srow).items.size());
|
||||
_contextRows.at(srow).items.at(scol)->linkOut(textlnkOver());
|
||||
}
|
||||
if ((textlnkOver() && !lnk) || (!textlnkOver() && lnk)) {
|
||||
setCursor(lnk ? style::cur_pointer : style::cur_default);
|
||||
Ui::repaintContextItem(_contextRows.at(srow).items.at(scol));
|
||||
}
|
||||
_selected = sel;
|
||||
textlnkOver(lnk);
|
||||
if (row >= 0 && col >= 0 && textlnkOver()) {
|
||||
if (row >= 0 && col >= 0) {
|
||||
t_assert(row >= 0 && row < _contextRows.size() && col >= 0 && col < _contextRows.at(row).items.size());
|
||||
_contextRows.at(row).items.at(col)->linkOver(textlnkOver());
|
||||
Ui::repaintContextItem(_contextRows.at(row).items.at(col));
|
||||
}
|
||||
if (_pressedSel >= 0 && _selected >= 0 && _pressedSel != _selected) {
|
||||
_pressedSel = _selected;
|
||||
@ -2009,6 +2011,24 @@ void StickerPanInner::updateSelected() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_linkOver != lnk) {
|
||||
if (_linkOver && srow >= 0 && scol >= 0) {
|
||||
t_assert(srow >= 0 && srow < _contextRows.size() && scol >= 0 && scol < _contextRows.at(srow).items.size());
|
||||
_contextRows.at(srow).items.at(scol)->linkOut(_linkOver);
|
||||
Ui::repaintContextItem(_contextRows.at(srow).items.at(scol));
|
||||
}
|
||||
if ((_linkOver && !lnk) || (!_linkOver && lnk)) {
|
||||
setCursor(lnk ? style::cur_pointer : style::cur_default);
|
||||
}
|
||||
_linkOver = lnk;
|
||||
textlnkOver(lnk);
|
||||
if (_linkOver && row >= 0 && col >= 0) {
|
||||
t_assert(row >= 0 && row < _contextRows.size() && col >= 0 && col < _contextRows.at(row).items.size());
|
||||
_contextRows.at(row).items.at(col)->linkOver(_linkOver);
|
||||
Ui::repaintContextItem(_contextRows.at(row).items.at(col));
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3307,8 +3327,6 @@ bool EmojiPan::contextResultsFail(const RPCError &error) {
|
||||
void EmojiPan::showContextResults(UserData *bot, QString query) {
|
||||
bool force = false;
|
||||
if (bot != _contextBot) {
|
||||
if (!isHidden()) hideStart();
|
||||
|
||||
contextBotChanged();
|
||||
_contextBot = bot;
|
||||
force = true;
|
||||
|
@ -470,6 +470,7 @@ private:
|
||||
|
||||
int32 _selected, _pressedSel;
|
||||
QPoint _lastMousePos;
|
||||
TextLinkPtr _linkOver, _linkDown;
|
||||
|
||||
LinkButton _settings;
|
||||
|
||||
|
@ -982,14 +982,17 @@ bool ClipReadManager::carries(ClipReader *reader) const {
|
||||
bool ClipReadManager::handleProcessResult(ClipReaderPrivate *reader, ClipProcessResult result, uint64 ms) {
|
||||
QMutexLocker lock(&_readerPointersMutex);
|
||||
ReaderPointers::iterator it = _readerPointers.find(reader->_interface);
|
||||
if (it != _readerPointers.cend() && it.key()->_private != reader) {
|
||||
it = _readerPointers.end(); // it is a new reader which was realloced in the same address
|
||||
}
|
||||
if (result == ClipProcessError) {
|
||||
if (it != _readerPointers.cend()) {
|
||||
it.key()->error();
|
||||
emit callback(it.key(), it.key()->threadIndex(), ClipReaderReinit);
|
||||
|
||||
_readerPointers.erase(it);
|
||||
it = _readerPointers.end();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (it == _readerPointers.cend()) {
|
||||
return false;
|
||||
|
@ -1452,7 +1452,8 @@ void LayoutContextGif::linkOver(const TextLinkPtr &link) {
|
||||
_state |= StateDeleteOver;
|
||||
_a_deleteOver.start(1, st::stickersRowDuration);
|
||||
}
|
||||
} else if (link == _send) {
|
||||
}
|
||||
if (link == _delete || link == _send) {
|
||||
if (!_doc->loaded()) {
|
||||
ensureAnimation();
|
||||
if (!(_state & StateOver)) {
|
||||
@ -1471,7 +1472,8 @@ void LayoutContextGif::linkOut(const TextLinkPtr &link) {
|
||||
_state &= ~StateDeleteOver;
|
||||
_a_deleteOver.start(0, st::stickersRowDuration);
|
||||
}
|
||||
} else if (link == _send) {
|
||||
}
|
||||
if (link == _delete || link == _send) {
|
||||
if (!_doc->loaded()) {
|
||||
ensureAnimation();
|
||||
if (_state & StateOver) {
|
||||
|
Loading…
Reference in New Issue
Block a user