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
44 44
45#include <QtNetwork/QNetworkDiskCache>45#include <QtNetwork/QNetworkDiskCache>
46 46
47#include <gl/Config.h>
48#include <QtGui/QOpenGLContext>
49
47#include <AccountManager.h>50#include <AccountManager.h>
48#include <AddressManager.h>51#include <AddressManager.h>
49#include <ApplicationVersion.h>52#include <ApplicationVersion.h>
@@ -150,8 +153,6 @@ · 100 unmodified lines
150#include "InterfaceParentFinder.h"153#include "InterfaceParentFinder.h"
151 154
152 155
153#include <gpu/GLBackend.h>
154#include <QtGui/QOpenGLContext>
155 156
156// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU157// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
157// FIXME seems to be broken.158// FIXME seems to be broken.
@@ -1091,7 +1092,6 @@ void Application::paintGL() { · 933 unmodified lines
1091 // update fps once a second1092 // update fps once a second
1092 if (now - _lastFramesPerSecondUpdate > USECS_PER_SECOND) {1093 if (now - _lastFramesPerSecondUpdate > USECS_PER_SECOND) {
1093 _fps = _framesPerSecond.getAverage();1094 _fps = _framesPerSecond.getAverage();
1094 qDebug() << QString::number(_fps, 'g', 4);
1095 _lastFramesPerSecondUpdate = now;1095 _lastFramesPerSecondUpdate = now;
1096 }1096 }
1097 1097
@@ -1344,6 +1344,7 @@ void Application::paintGL() { · 246 unmodified lines
1344 }1344 }
1345 1345
1346 // Overlay Composition, needs to occur after screen space effects have completed1346 // Overlay Composition, needs to occur after screen space effects have completed
1347 // FIXME migrate composition into the display plugins
1347 {1348 {
1348 PROFILE_RANGE(__FUNCTION__ "/compositor");1349 PROFILE_RANGE(__FUNCTION__ "/compositor");
1349 PerformanceTimer perfTimer("compositor");1350 PerformanceTimer perfTimer("compositor");
@@ -1372,7 +1373,6 @@ void Application::paintGL() { · 22 unmodified lines
1372 {1373 {
1373 PROFILE_RANGE(__FUNCTION__ "/pluginOutput");1374 PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
1374 PerformanceTimer perfTimer("pluginOutput");1375 PerformanceTimer perfTimer("pluginOutput");
1375 uint64_t displayStart = usecTimestampNow();
1376 auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();1376 auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();
1377 auto scratchFramebuffer = framebufferCache->getFramebuffer();1377 auto scratchFramebuffer = framebufferCache->getFramebuffer();
1378 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {1378 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
@@ -1386,12 +1386,18 @@ void Application::paintGL() { · 7 unmodified lines
1386 });1386 });
1387 auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0);1387 auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0);
1388 GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer);1388 GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer);
1389
1390 Q_ASSERT(0 != finalTexture);1389 Q_ASSERT(0 != finalTexture);
1390
1391 Q_ASSERT(!_lockedFramebufferMap.contains(finalTexture));1391 Q_ASSERT(!_lockedFramebufferMap.contains(finalTexture));
1392 _lockedFramebufferMap[finalTexture] = scratchFramebuffer;1392 _lockedFramebufferMap[finalTexture] = scratchFramebuffer;
1393
1394 uint64_t displayStart = usecTimestampNow();
1393 Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext());1395 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 }
1395 Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext());1401 Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext());
1396 1402
1397 uint64_t displayEnd = usecTimestampNow();1403 uint64_t displayEnd = usecTimestampNow();
@@ -4499,13 +4505,12 @@ void Application::toggleLogDialog() { · 3101 unmodified lines
4499}4505}
4500 4506
4501void Application::takeSnapshot() {4507void Application::takeSnapshot() {
4502#if 0
4503 QMediaPlayer* player = new QMediaPlayer();4508 QMediaPlayer* player = new QMediaPlayer();
4504 QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");4509 QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
4505 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));4510 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
4506 player->play();4511 player->play();
4507 4512
4508 QString fileName = Snapshot::saveSnapshot(_glWidget->grabFrameBuffer());4513 QString fileName = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot());
4509 4514
4510 AccountManager& accountManager = AccountManager::getInstance();4515 AccountManager& accountManager = AccountManager::getInstance();
4511 if (!accountManager.isLoggedIn()) {4516 if (!accountManager.isLoggedIn()) {
@@ -4516,7 +4521,6 @@ void Application::takeSnapshot() { · 4 unmodified lines
4516 _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);4521 _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
4517 }4522 }
4518 _snapshotShareDialog->show();4523 _snapshotShareDialog->show();
4519#endif
4520}4524}
4521 4525
4522float Application::getRenderResolutionScale() const {4526float Application::getRenderResolutionScale() const {
@@ -4728,6 +4732,7 @@ void Application::updateDisplayMode() { · 205 unmodified lines
4728 bool first = true;4732 bool first = true;
4729 foreach(auto displayPlugin, displayPlugins) {4733 foreach(auto displayPlugin, displayPlugins) {
4730 addDisplayPluginToMenu(displayPlugin, first);4734 addDisplayPluginToMenu(displayPlugin, first);
4735 // This must be a queued connection to avoid a deadlock
4731 QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, 4736 QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender,
4732 this, &Application::paintGL, Qt::QueuedConnection);4737 this, &Application::paintGL, Qt::QueuedConnection);
4733 4738