Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Add some comments
Luna Lovecraft36fe22bf1528
diff --git a/plugins/dockers/recorder/recorder_writer.cpp b/plugins/dockers/recorder/recorder_writer.cppindex 3ecfc383f3..2fa9881de0 100644--- a/plugins/dockers/recorder/recorder_writer.cpp+++ b/plugins/dockers/recorder/recorder_writer.cpp@@ -529,7 +529,9 @@ RecorderWriterManager::~RecorderWriterManager()void RecorderWriterManager::setCanvas(QPointer<KisCanvas2> canvas){+ //Saving previous region as a precaution, so that we don't have to externally manage its statesaveRegion();+// Restart writers if canvas changesbool restart = d->timer.isActive();if (restart) {@@ -581,11 +583,14 @@ void RecorderWriterManager::setup(const RecorderWriterSettings &settings)start(false, false);}+ //Settings change whenever a different document is about to be recorder, so instead of externally tracking old region, we can just read it from a filetryRestoreRegion();}void RecorderWriterManager::start(bool toggleEnabled, bool restoreState){+ // This function is called in a lot of places, so we need to restore state very slectively to avoid huge performance+ // losses. Even tho restoring state is a lot cheaper than saving it, it's still better to be carefulif (restoreState) {this->restoreState();}@@ -618,6 +623,8 @@ bool RecorderWriterManager::stop(bool toggleEnabled, bool saveState)if (!d->timer.isActive())return true;+ // This function is called in a lot of places, so we need to save state very slectively to avoid huge performance+ // lossesif (saveState) {this->saveState();}diff --git a/plugins/dockers/recorder/recorder_writer.h b/plugins/dockers/recorder/recorder_writer.hindex c96ce126fa..1cb0d5b76c 100644--- a/plugins/dockers/recorder/recorder_writer.h+++ b/plugins/dockers/recorder/recorder_writer.h@@ -130,6 +130,23 @@ public:///Remove the tail and restore region from a filevoid restoreState();+ // A note about tail frames:+ // They are needed for focused recording. It is possible that the recording is stopped with the last frame being+ // very zoomed in, so if a user tries to export the timelapse in this state, it won't properly dispaly the resulting+ // artwork. One option to fix that is to capture an overview frame whenever a timelapse is epxorted, but the artwork+ // may have changed while recording was off, so we can't do that+ //+ // My solution is a "tail" frame, an overivew captured whenever recording is stopped, and removed if recording is+ // resumed, to avoid adding dead air to timelapses.+ //+ // To avoid big jumps we capture multiple of them with interpolated motion with the last frame, like any other+ // frame.+ //+ // They are technically not needed if the user isn't using focused recording, but they don't hurt to have.++ // Saving the oldRegion varaible, for smooth frame motion, it is very cheap to do as it's literally just 16 bytes,+ // so we're free to do it excessively without worrying. We also use it to keep track of the region with multiple+ // files open, instead of doing that with some global statevoid saveRegion();void tryRestoreRegion();diff --git a/plugins/dockers/recorder/recorderdocker_dock.cpp b/plugins/dockers/recorder/recorderdocker_dock.cppindex a1e65f37dd..a23c74a0b2 100644--- a/plugins/dockers/recorder/recorderdocker_dock.cpp+++ b/plugins/dockers/recorder/recorderdocker_dock.cpp@@ -505,6 +505,9 @@ RecorderDockerDock::~RecorderDockerDock()delete exportSettings;}+// This signal is called when the last view of a document is closed. We can use it to properly stop recording for that+// document and create tail frame(s), knowing that it won't be called too often. Creating tail frames can be very+// expensive, depending on how zoomed in the user is, so doing that overzealously is unviable.void RecorderDockerDock::onDocumentAboutToClose(KoCanvasBase *canvas){KisCanvas2 *cptr = dynamic_cast<KisCanvas2 *>(canvas);@@ -523,7 +526,9 @@ void RecorderDockerDock::onDocumentAboutToClose(KoCanvasBase *canvas)}}-void RecorderDockerDock::setCanvas(KoCanvasBase* canvas)+// This is called whenever a tab is switched, be that when a user clicks on a tab, or another tab closing, so we only do+// basic recorder state save. We can not rely on this function to create tail frames, as it's called too often+void RecorderDockerDock::setCanvas(KoCanvasBase *canvas){setEnabled(canvas != nullptr);@@ -562,6 +567,7 @@ void RecorderDockerDock::setCanvas(KoCanvasBase* canvas)d->updateRecordStatus(enabled);}+// This function is only called when the last document/canvas is closed, in all other cases setCanvas is called instead.void RecorderDockerDock::unsetCanvas(){d->updateRecordStatus(false);