optimized gifs scroll in saved gifs section

This commit is contained in:
John Preston 2015-12-30 01:33:56 +08:00
parent 38ea16fea4
commit d72a3c4189
5 changed files with 28 additions and 11 deletions

View File

@ -141,7 +141,7 @@ Open **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu >
PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"
./configure --toolchain=msvc --disable-programs --disable-doc --disable-everything --disable-mmx --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=flac --enable-decoder=gif --enable-decoder=h264 --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=mpeg4 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-hwaccel=h264_d3d11va --enable-hwaccel=h264_dxva2 --enable-parser=aac --enable-parser=aac_latm --enable-parser=flac --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=gif --enable-demuxer=h264 --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-muxer=ogg --enable-muxer=opus --extra-ldflags="-libpath:/d/TBuild/Libraries/opus/win32/VS2010/Win32/Release celt.lib silk_common.lib silk_float.lib"
./configure --toolchain=msvc --disable-programs --disable-doc --disable-everything --disable-w32threads --disable-mmx --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=flac --enable-decoder=gif --enable-decoder=h264 --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=mpeg4 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-hwaccel=h264_d3d11va --enable-hwaccel=h264_dxva2 --enable-parser=aac --enable-parser=aac_latm --enable-parser=flac --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=gif --enable-demuxer=h264 --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-muxer=ogg --enable-muxer=opus --extra-ldflags="-libpath:/d/TBuild/Libraries/opus/win32/VS2010/Win32/Release celt.lib silk_common.lib silk_float.lib"
make
make install

View File

@ -1214,6 +1214,7 @@ StickerPanInner::StickerPanInner() : TWidget()
, _a_selected(animation(this, &StickerPanInner::step_selected))
, _top(0)
, _showingGifs(cShowingSavedGifs())
, _lastScrolled(0)
, _selected(-1)
, _pressedSel(-1)
, _settings(this, lang(lng_stickers_you_have))
@ -1229,6 +1230,9 @@ StickerPanInner::StickerPanInner() : TWidget()
_previewTimer.setSingleShot(true);
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreview()));
_updateGifs.setSingleShot(true);
connect(&_updateGifs, SIGNAL(timeout()), this, SLOT(onUpdateGifs()));
}
void StickerPanInner::setMaxHeight(int32 h) {
@ -1240,6 +1244,7 @@ void StickerPanInner::setMaxHeight(int32 h) {
void StickerPanInner::setScrollTop(int top) {
if (top == _top) return;
_lastScrolled = getms();
_top = top;
updateSelected();
}
@ -1734,15 +1739,12 @@ uint64 StickerPanInner::currentSet(int yOffset) const {
void StickerPanInner::ui_repaintSavedGif(const LayoutSavedGif *layout) {
if (!_showingGifs) return;
int32 position = layout->position();
int32 row = position / MatrixRowShift, col = position % MatrixRowShift;
t_assert((row < _gifRows.size()) && (col < _gifRows.at(row).size()));
const GifRow &gifRow(_gifRows.at(row));
int32 left = st::savedGifsLeft, top = st::emojiPanHeader + row * (st::savedGifHeight + st::savedGifsSkip);
for (int32 i = 0; i < col; ++i) left += gifRow.at(i)->width() + st::savedGifsSkip;
rtlupdate(left, top, gifRow.at(col)->width(), st::savedGifHeight);
uint64 ms = getms();
if (_lastScrolled + 100 <= ms) {
update();
} else {
_updateGifs.start(_lastScrolled + 100 - ms);
}
}
bool StickerPanInner::ui_isSavedGifVisible(const LayoutSavedGif *layout) {
@ -2062,6 +2064,17 @@ void StickerPanInner::onPreview() {
}
}
void StickerPanInner::onUpdateGifs() {
if (!_showingGifs) return;
uint64 ms = getms();
if (_lastScrolled + 100 <= ms) {
update();
} else {
_updateGifs.start(_lastScrolled + 100 - ms);
}
}
void StickerPanInner::step_selected(uint64 ms, bool timer) {
QRegion toUpdate;
for (Animations::iterator i = _animations.begin(); i != _animations.end();) {

View File

@ -366,6 +366,7 @@ public slots:
void updateSelected();
void onSettings();
void onPreview();
void onUpdateGifs();
signals:
@ -415,6 +416,8 @@ private:
QList<bool> _custom;
bool _showingGifs;
uint64 _lastScrolled;
QTimer _updateGifs;
typedef QList<LayoutSavedGif*> GifRow;
typedef QList<GifRow> GifRows;

View File

@ -449,6 +449,7 @@ QPixmap imagePix(QImage img, int32 w, int32 h, bool smooth, bool blurred, bool r
}
}
if (rounded) imageRound(img);
img.setDevicePixelRatio(cRetinaFactor());
return QPixmap::fromImage(img, Qt::ColorOnly);
}

View File

@ -1368,7 +1368,7 @@ void LayoutSavedGif::paint(Painter &p, bool paused, uint64 ms) const {
if (!_data->thumb->isNull()) {
if (_data->thumb->loaded()) {
if (_thumb.width() != _width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
const_cast<LayoutSavedGif*>(this)->_thumb = _data->thumb->pixNoCache(frame.width(), frame.height(), true, false, false, _width, height);
const_cast<LayoutSavedGif*>(this)->_thumb = _data->thumb->pixNoCache(frame.width() * cIntRetinaFactor(), frame.height() * cIntRetinaFactor(), true, false, false, _width, height);
}
} else {
_data->thumb->load();