History

Fixing screenshot functionality

Brad Davis committed 10 years ago

Commit d8bb9f81 parent b9ace946 files · +105 −17Browse files

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

Unified · Split

interface/src/Application.cpp+14−9
@@ -44,6 +44,9 @@ · 43 unmodified lines
4444
4545 #include <QtNetwork/QNetworkDiskCache>
4646
47+#include <gl/Config.h>
48+#include <QtGui/QOpenGLContext>
49+
4750 #include <AccountManager.h>
4851 #include <AddressManager.h>
4952 #include <ApplicationVersion.h>
@@ -150,8 +153,6 @@ · 100 unmodified lines
150153 #include "InterfaceParentFinder.h"
151154
152155
153−#include <gpu/GLBackend.h>
154−#include <QtGui/QOpenGLContext>
155156
156157 // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
157158 // FIXME seems to be broken.
@@ -1091,7 +1092,6 @@ void Application::paintGL() { · 933 unmodified lines
10911092 // update fps once a second
10921093 if (now - _lastFramesPerSecondUpdate > USECS_PER_SECOND) {
10931094 _fps = _framesPerSecond.getAverage();
1094− qDebug() << QString::number(_fps, 'g', 4);
10951095 _lastFramesPerSecondUpdate = now;
10961096 }
10971097
@@ -1344,6 +1344,7 @@ void Application::paintGL() { · 246 unmodified lines
13441344 }
13451345
13461346 // Overlay Composition, needs to occur after screen space effects have completed
1347+ // FIXME migrate composition into the display plugins
13471348 {
13481349 PROFILE_RANGE(__FUNCTION__ "/compositor");
13491350 PerformanceTimer perfTimer("compositor");
@@ -1372,7 +1373,6 @@ void Application::paintGL() { · 22 unmodified lines
13721373 {
13731374 PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
13741375 PerformanceTimer perfTimer("pluginOutput");
1375− uint64_t displayStart = usecTimestampNow();
13761376 auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();
13771377 auto scratchFramebuffer = framebufferCache->getFramebuffer();
13781378 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
@@ -1386,12 +1386,18 @@ void Application::paintGL() { · 7 unmodified lines
13861386 });
13871387 auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0);
13881388 GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer);
1389−
13901389 Q_ASSERT(0 != finalTexture);
1390+
13911391 Q_ASSERT(!_lockedFramebufferMap.contains(finalTexture));
13921392 _lockedFramebufferMap[finalTexture] = scratchFramebuffer;
1393+
1394+ uint64_t displayStart = usecTimestampNow();
13931395 Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext());
1394− displayPlugin->submitSceneTexture(_frameCount, finalTexture, toGlm(size));
1396+ {
1397+ PROFILE_RANGE(__FUNCTION__ "/pluginSubmitScene");
1398+ PerformanceTimer perfTimer("pluginSubmitScene");
1399+ displayPlugin->submitSceneTexture(_frameCount, finalTexture, toGlm(size));
1400+ }
13951401 Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext());
13961402
13971403 uint64_t displayEnd = usecTimestampNow();
@@ -4499,13 +4505,12 @@ void Application::toggleLogDialog() { · 3101 unmodified lines
44994505 }
45004506
45014507 void Application::takeSnapshot() {
4502−#if 0
45034508 QMediaPlayer* player = new QMediaPlayer();
45044509 QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
45054510 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
45064511 player->play();
45074512
4508− QString fileName = Snapshot::saveSnapshot(_glWidget->grabFrameBuffer());
4513+ QString fileName = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot());
45094514
45104515 AccountManager& accountManager = AccountManager::getInstance();
45114516 if (!accountManager.isLoggedIn()) {
@@ -4516,7 +4521,6 @@ void Application::takeSnapshot() { · 4 unmodified lines
45164521 _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
45174522 }
45184523 _snapshotShareDialog->show();
4519−#endif
45204524 }
45214525
45224526 float Application::getRenderResolutionScale() const {
@@ -4728,6 +4732,7 @@ void Application::updateDisplayMode() { · 205 unmodified lines
47284732 bool first = true;
47294733 foreach(auto displayPlugin, displayPlugins) {
47304734 addDisplayPluginToMenu(displayPlugin, first);
4735+ // This must be a queued connection to avoid a deadlock
47314736 QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender,
47324737 this, &Application::paintGL, Qt::QueuedConnection);
47334738