combine snapshotOperator lists per sam's suggestions

This commit is contained in:
SamGondelman 2019-04-22 16:22:18 -07:00
parent 06fbc8440e
commit 4fc97effda
7 changed files with 18 additions and 38 deletions

View file

@ -8441,23 +8441,15 @@ void Application::loadAvatarBrowser() const {
void Application::addSnapshotOperator(const SnapshotOperator& snapshotOperator) {
std::lock_guard<std::mutex> lock(_snapshotMutex);
_snapshotOperators.push(snapshotOperator);
_hasPrimarySnapshot |= std::get<2>(snapshotOperator);
}
bool Application::takeSnapshotOperators(std::queue<SnapshotOperator>& snapshotOperators) {
std::lock_guard<std::mutex> lock(_snapshotMutex);
bool hasPrimarySnapshot = _hasPrimarySnapshot;
_hasPrimarySnapshot = false;
_snapshotOperators.swap(snapshotOperators);
return !snapshotOperators.empty();
}
void Application::addSecondarySnapshotOperator(const SecondarySnapshotOperator& snapshotOperator) {
std::lock_guard<std::mutex> lock(_snapshotMutex);
_secondarySnapshotOperators.push(snapshotOperator);
}
bool Application::takeSecondarySnapshotOperators(std::queue<SecondarySnapshotOperator>& snapshotOperators) {
std::lock_guard<std::mutex> lock(_snapshotMutex);
_secondarySnapshotOperators.swap(snapshotOperators);
return !snapshotOperators.empty();
return hasPrimarySnapshot;
}
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
@ -8476,15 +8468,15 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
SnapshotAnimated::saveSnapshotAnimated(path, aspectRatio, DependencyManager::get<WindowScriptingInterface>());
});
}
}, aspectRatio });
}, aspectRatio, true });
}
void Application::takeSecondaryCameraSnapshot(const bool& notify, const QString& filename) {
addSecondarySnapshotOperator([notify, filename](const QImage& snapshot) {
addSnapshotOperator({ [notify, filename](const QImage& snapshot) {
QString snapshotPath = DependencyManager::get<Snapshot>()->saveSnapshot(snapshot, filename, TestScriptingInterface::getInstance()->getTestResultsLocation());
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, notify);
});
}, 0, false });
}
void Application::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const bool& notify, const QString& filename) {

View file

@ -345,12 +345,9 @@ public:
void toggleAwayMode();
#endif
using SnapshotOperator = std::pair<std::function<void(const QImage&)>, float>;
using SecondarySnapshotOperator = std::function<void(const QImage&)>;
using SnapshotOperator = std::tuple<std::function<void(const QImage&)>, float, bool>;
void addSnapshotOperator(const SnapshotOperator& snapshotOperator);
bool takeSnapshotOperators(std::queue<SnapshotOperator>& snapshotOperators);
void addSecondarySnapshotOperator(const SecondarySnapshotOperator& snapshotOperator);
bool takeSecondarySnapshotOperators(std::queue<SecondarySnapshotOperator>& snapshotOperators);
signals:
void svoImportRequested(const QString& url);
@ -798,7 +795,7 @@ private:
SharedSoundPointer _sampleSound;
std::mutex _snapshotMutex;
std::queue<SnapshotOperator> _snapshotOperators;
std::queue<SecondarySnapshotOperator> _secondarySnapshotOperators;
bool _hasPrimarySnapshot { false };
DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin;
QString _autoSwitchDisplayModeSupportedHMDPluginName;

View file

@ -245,7 +245,6 @@ void GraphicsEngine::render_performFrame() {
}
std::queue<Application::SnapshotOperator> snapshotOperators;
std::queue<Application::SecondarySnapshotOperator> secondarySnapshotOperators;
if (!_programsCompiled.load()) {
gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) {
batch.setFramebuffer(finalFramebuffer);
@ -274,7 +273,6 @@ void GraphicsEngine::render_performFrame() {
renderArgs._hudOperator = displayPlugin->getHUDOperator();
renderArgs._hudTexture = qApp->getApplicationOverlay().getOverlayTexture();
renderArgs._takingSnapshot = qApp->takeSnapshotOperators(snapshotOperators);
qApp->takeSecondarySnapshotOperators(secondarySnapshotOperators);
renderArgs._blitFramebuffer = finalFramebuffer;
render_runRenderFrame(&renderArgs);
}
@ -290,7 +288,6 @@ void GraphicsEngine::render_performFrame() {
}
};
frame->snapshotOperators = snapshotOperators;
frame->secondarySnapshotOperators = secondarySnapshotOperators;
// deliver final scene rendering commands to the display plugin
{
PROFILE_RANGE(render, "/pluginOutput");

View file

@ -168,7 +168,7 @@ void Snapshot::takeNextSnapshot() {
if (_taking360Snapshot) {
if (!_waitingOnSnapshot) {
_waitingOnSnapshot = true;
qApp->addSecondarySnapshotOperator([this](const QImage& snapshot) {
qApp->addSnapshotOperator({ [this](const QImage& snapshot) {
// Order is:
// 0. Down
// 1. Front
@ -202,7 +202,7 @@ void Snapshot::takeNextSnapshot() {
_waitingOnSnapshot = false;
_snapshotIndex++;
});
}, 0, false });
}
} else {
_snapshotTimer.stop();

View file

@ -86,7 +86,7 @@ void SnapshotAnimated::captureFrames() {
SnapshotAnimated::snapshotAnimatedTimerRunning = false;
}
}
}, SnapshotAnimated::aspectRatio });
}, SnapshotAnimated::aspectRatio, true });
} else {
// Notify the user that we're processing the snapshot
// This also pops up the "Share" dialog. The unprocessed GIF will be visualized as a loading icon until processingGifCompleted() is called.

View file

@ -725,20 +725,15 @@ void OpenGLDisplayPlugin::present() {
PROFILE_RANGE_EX(render, "snapshotOperators", 0xffff00ff, frameId)
while (!_currentFrame->snapshotOperators.empty()) {
auto& snapshotOperator = _currentFrame->snapshotOperators.front();
snapshotOperator.first(getScreenshot(snapshotOperator.second));
if (std::get<2>(snapshotOperator)) {
std::get<0>(snapshotOperator)(getScreenshot(std::get<1>(snapshotOperator)));
} else {
std::get<0>(snapshotOperator)(getSecondaryCameraScreenshot());
}
_currentFrame->snapshotOperators.pop();
}
}
{ // If we have any secondary camera snapshots this frame, handle them
PROFILE_RANGE_EX(render, "secondarySnapshotOperators", 0x00ff00ff, frameId)
while (!_currentFrame->secondarySnapshotOperators.empty()) {
auto& snapshotOperator = _currentFrame->secondarySnapshotOperators.front();
snapshotOperator(getSecondaryCameraScreenshot());
_currentFrame->secondarySnapshotOperators.pop();
}
}
// Take the composite framebuffer and send it to the output device
{
PROFILE_RANGE_EX(render, "internalPresent", 0xff00ffff, frameId)

View file

@ -42,8 +42,7 @@ namespace gpu {
/// How to process the framebuffer when the frame dies. MUST BE THREAD SAFE
FramebufferRecycler framebufferRecycler;
std::queue<std::pair<std::function<void(const QImage&)>, float>> snapshotOperators;
std::queue<std::function<void(const QImage&)>> secondarySnapshotOperators;
std::queue<std::tuple<std::function<void(const QImage&)>, float, bool>> snapshotOperators;
protected:
friend class Deserializer;