History

It crashes, but it's the start of a new architecture

Zach Fox committed 10 years ago

Commit b6dd7951 parent ed1d0873 files · +27 −34Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+25−31
@@ -5430,9 +5430,7 @@ void Application::toggleLogDialog() { · 5429 unmodified lines
54305430 }
54315431 }
54325432
5433−uint8_t _currentAnimatedSnapshotFrame;
5434−GifWriter _animatedSnapshotGifWriter;
5435−#define SNAPSNOT_ANIMATED_WIDTH (640)
5433+#define SNAPSNOT_ANIMATED_WIDTH (900)
54365434 #define SNAPSNOT_ANIMATED_FRAMERATE_FPS (20)
54375435 #define SNAPSNOT_ANIMATED_FRAME_DELAY (100/SNAPSNOT_ANIMATED_FRAMERATE_FPS)
54385436 #define SNAPSNOT_ANIMATED_DURATION_SECS (3)
@@ -5446,6 +5444,8 @@ void Application::takeSnapshot(bool notify, const QString& format, float aspectR · 7 unmodified lines
54465444 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
54475445 player->play();
54485446
5447+ GifWriter _animatedSnapshotGifWriter;
5448+ uint8_t _currentAnimatedSnapshotFrame;
54495449 QString path;
54505450
54515451 // If this is a still snapshot...
@@ -5460,7 +5460,6 @@ void Application::takeSnapshot(bool notify, const QString& format, float aspectR · 8 unmodified lines
54605460 else if (!format.compare("animated"))
54615461 {
54625462 char* cstr;
5463− connect(&animatedSnapshotTimer, &QTimer::timeout, this, &Application::animatedSnapshotTimerCb);
54645463 _currentAnimatedSnapshotFrame = 0;
54655464 // File path stuff
54665465 path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
@@ -5469,38 +5468,33 @@ void Application::takeSnapshot(bool notify, const QString& format, float aspectR · 2 unmodified lines
54695468 string fname = path.toStdString();
54705469 cstr = new char[fname.size() + 1];
54715470 strcpy(cstr, fname.c_str());
5472− // Start the GIF
5473− QImage frame = (getActiveDisplayPlugin()->getScreenshot(1.91)).scaledToWidth(SNAPSNOT_ANIMATED_WIDTH).convertToFormat(QImage::Format_RGBA8888);
5474− GifBegin(&_animatedSnapshotGifWriter, cstr, frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY);
5475− Application::animatedSnapshotTimerCb();
5476− animatedSnapshotTimer.start(50);
5477− }
5478− });
5479−}
54805471
5481−void Application::animatedSnapshotTimerCb()
5482−{
5483− if (_currentAnimatedSnapshotFrame == SNAPSNOT_ANIMATED_NUM_FRAMES)
5484− {
5485− animatedSnapshotTimer.stop();
5486− GifEnd(&_animatedSnapshotGifWriter);
5487− QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
5488− path.append(QDir::separator());
5489− path.append("test.gif");
5490− emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path, false);
5491− return;
5492− }
5472+ connect(&animatedSnapshotTimer, &QTimer::timeout, this, [&] {
5473+ if (_currentAnimatedSnapshotFrame == SNAPSNOT_ANIMATED_NUM_FRAMES)
5474+ {
5475+ animatedSnapshotTimer.stop();
5476+ GifEnd(&_animatedSnapshotGifWriter);
5477+ emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path, false);
5478+ return;
5479+ }
54935480
5494− QImage frame = (getActiveDisplayPlugin()->getScreenshot(1.91)).scaledToWidth(SNAPSNOT_ANIMATED_WIDTH).convertToFormat(QImage::Format_RGBA8888);
5495− uint32_t frameNumBytes = frame.width() * frame.height() * 4;
5496− uint8_t* pixelArray = new uint8_t[frameNumBytes];
5481+ QImage frame = (getActiveDisplayPlugin()->getScreenshot(aspectRatio)).scaledToWidth(SNAPSNOT_ANIMATED_WIDTH).convertToFormat(QImage::Format_RGBA8888);
5482+ if (_currentAnimatedSnapshotFrame == 0)
5483+ {
5484+ GifBegin(&_animatedSnapshotGifWriter, cstr, frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY);
5485+ }
5486+ uint32_t frameNumBytes = frame.width() * frame.height() * 4;
5487+ uint8_t* pixelArray = new uint8_t[frameNumBytes];
54975488
5498− GifWriteFrame(&_animatedSnapshotGifWriter, (uint8_t*)frame.bits(), frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY);
5499− _currentAnimatedSnapshotFrame++;
5489+ GifWriteFrame(&_animatedSnapshotGifWriter, (uint8_t*)frame.bits(), frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY);
5490+ _currentAnimatedSnapshotFrame++;
55005491
5501− delete[frameNumBytes] pixelArray;
5492+ delete[frameNumBytes] pixelArray;
5493+ });
5494+ animatedSnapshotTimer.start(SNAPSNOT_ANIMATED_FRAME_DELAY * 10);
5495+ }
5496+ });
55025497 }
5503−
55045498 void Application::shareSnapshot(const QString& path) {
55055499 postLambdaEvent([path] {
55065500 // not much to do here, everything is done in snapshot code...