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
5430 }5430 }
5431}5431}
5432 5432
5433uint8_t _currentAnimatedSnapshotFrame;5433#define SNAPSNOT_ANIMATED_WIDTH (900)
5434GifWriter _animatedSnapshotGifWriter;
5435#define SNAPSNOT_ANIMATED_WIDTH (640)
5436#define SNAPSNOT_ANIMATED_FRAMERATE_FPS (20)5434#define SNAPSNOT_ANIMATED_FRAMERATE_FPS (20)
5437#define SNAPSNOT_ANIMATED_FRAME_DELAY (100/SNAPSNOT_ANIMATED_FRAMERATE_FPS)5435#define SNAPSNOT_ANIMATED_FRAME_DELAY (100/SNAPSNOT_ANIMATED_FRAMERATE_FPS)
5438#define SNAPSNOT_ANIMATED_DURATION_SECS (3)5436#define SNAPSNOT_ANIMATED_DURATION_SECS (3)
@@ -5446,6 +5444,8 @@ void Application::takeSnapshot(bool notify, const QString& format, float aspectR · 7 unmodified lines
5446 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));5444 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
5447 player->play();5445 player->play();
5448 5446
5447 GifWriter _animatedSnapshotGifWriter;
5448 uint8_t _currentAnimatedSnapshotFrame;
5449 QString path;5449 QString path;
5450 5450
5451 // If this is a still snapshot...5451 // If this is a still snapshot...
@@ -5460,7 +5460,6 @@ void Application::takeSnapshot(bool notify, const QString& format, float aspectR · 8 unmodified lines
5460 else if (!format.compare("animated"))5460 else if (!format.compare("animated"))
5461 {5461 {
5462 char* cstr;5462 char* cstr;
5463 connect(&animatedSnapshotTimer, &QTimer::timeout, this, &Application::animatedSnapshotTimerCb);
5464 _currentAnimatedSnapshotFrame = 0;5463 _currentAnimatedSnapshotFrame = 0;
5465 // File path stuff5464 // File path stuff
5466 path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);5465 path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
@@ -5469,38 +5468,33 @@ void Application::takeSnapshot(bool notify, const QString& format, float aspectR · 2 unmodified lines
5469 string fname = path.toStdString();5468 string fname = path.toStdString();
5470 cstr = new char[fname.size() + 1];5469 cstr = new char[fname.size() + 1];
5471 strcpy(cstr, fname.c_str());5470 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}
5480 5471
5481void Application::animatedSnapshotTimerCb()5472 connect(&animatedSnapshotTimer, &QTimer::timeout, this, [&] {
5482{5473 if (_currentAnimatedSnapshotFrame == SNAPSNOT_ANIMATED_NUM_FRAMES)
5483 if (_currentAnimatedSnapshotFrame == SNAPSNOT_ANIMATED_NUM_FRAMES)5474 {
5484 {5475 animatedSnapshotTimer.stop();
5485 animatedSnapshotTimer.stop();5476 GifEnd(&_animatedSnapshotGifWriter);
5486 GifEnd(&_animatedSnapshotGifWriter);5477 emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path, false);
5487 QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);5478 return;
5488 path.append(QDir::separator());5479 }
5489 path.append("test.gif");
5490 emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path, false);
5491 return;
5492 }
5493 5480
5494 QImage frame = (getActiveDisplayPlugin()->getScreenshot(1.91)).scaledToWidth(SNAPSNOT_ANIMATED_WIDTH).convertToFormat(QImage::Format_RGBA8888);5481 QImage frame = (getActiveDisplayPlugin()->getScreenshot(aspectRatio)).scaledToWidth(SNAPSNOT_ANIMATED_WIDTH).convertToFormat(QImage::Format_RGBA8888);
5495 uint32_t frameNumBytes = frame.width() * frame.height() * 4;5482 if (_currentAnimatedSnapshotFrame == 0)
5496 uint8_t* pixelArray = new uint8_t[frameNumBytes];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];
5497 5488
5498 GifWriteFrame(&_animatedSnapshotGifWriter, (uint8_t*)frame.bits(), frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY);5489 GifWriteFrame(&_animatedSnapshotGifWriter, (uint8_t*)frame.bits(), frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY);
5499 _currentAnimatedSnapshotFrame++;5490 _currentAnimatedSnapshotFrame++;
5500 5491
5501 delete[frameNumBytes] pixelArray;5492 delete[frameNumBytes] pixelArray;
5493 });
5494 animatedSnapshotTimer.start(SNAPSNOT_ANIMATED_FRAME_DELAY * 10);
5495 }
5496 });
5502}5497}
5503
5504void Application::shareSnapshot(const QString& path) {5498void Application::shareSnapshot(const QString& path) {
5505 postLambdaEvent([path] {5499 postLambdaEvent([path] {
5506 // not much to do here, everything is done in snapshot code...5500 // not much to do here, everything is done in snapshot code...