| 5907 | } // addIdentityNodesRecursively |
| 5908 | |
| 5909 | bool |
| 5910 | Node::shouldCacheOutput(bool isFrameVaryingOrAnimated, |
| 5911 | double time, |
| 5912 | ViewIdx view, |
| 5913 | int /*visitsCount*/) const |
| 5914 | { |
| 5915 | /* |
| 5916 | * Here is a list of reasons when caching is enabled for a node: |
| 5917 | * - It is references multiple times below in the graph |
| 5918 | * - Its single output has its settings panel opened, meaning the user is actively editing the output |
| 5919 | * - The force caching parameter in the "Node" tab is checked |
| 5920 | * - The aggressive caching preference of Natron is checked |
| 5921 | * - We are in a recursive action (such as an analysis) |
| 5922 | * - The plug-in does temporal clip access |
| 5923 | * - Preview image is enabled (and Natron is not running in background) |
| 5924 | * - The node is a direct input of a viewer, this is to overcome linear graphs where all nodes would not be cached |
| 5925 | * - The node is not frame varying, meaning it will always produce the same image at any time |
| 5926 | * - The node is a roto node and it is being edited |
| 5927 | * - The node does not support tiles |
| 5928 | */ |
| 5929 | |
| 5930 | std::list<const Node*> outputs; |
| 5931 | { |
| 5932 | std::list<const Node*> markedNodes; |
| 5933 | addIdentityNodesRecursively(this, this, time, view, &outputs, &markedNodes); |
| 5934 | } |
| 5935 | std::size_t sz = outputs.size(); |
| 5936 | |
| 5937 | if (sz > 1) { |
| 5938 | ///The node is referenced multiple times below, cache it |
| 5939 | return true; |
| 5940 | } else { |
| 5941 | if (sz == 1) { |
| 5942 | const Node* output = outputs.front(); |
| 5943 | ViewerInstance* isViewer = output->isEffectViewer(); |
| 5944 | if (isViewer) { |
| 5945 | int activeInputs[2]; |
| 5946 | isViewer->getActiveInputs(activeInputs[0], activeInputs[1]); |
| 5947 | if ( (output->getInput(activeInputs[0]).get() == this) || |
| 5948 | ( output->getInput(activeInputs[1]).get() == this) ) { |
| 5949 | ///The node is a direct input of the viewer. Cache it because it is likely the user will make |
| 5950 | |
| 5951 | ///changes to the viewer that will need this image. |
| 5952 | return true; |
| 5953 | } |
| 5954 | } |
| 5955 | |
| 5956 | RotoPaint* isRoto = dynamic_cast<RotoPaint*>(output->getEffectInstance().get()); |
| 5957 | if (isRoto) { |
| 5958 | // THe roto internally makes multiple references to the input so cache it |
| 5959 | return true; |
| 5960 | } |
| 5961 | |
| 5962 | if (!isFrameVaryingOrAnimated) { |
| 5963 | //This image never changes, cache it once. |
| 5964 | return true; |
| 5965 | } |
| 5966 | if ( output->isSettingsPanelVisible() ) { |
nothing calls this directly
no test coverage detected