MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / setupMinimalUpdateViewerParams

Method setupMinimalUpdateViewerParams

Engine/ViewerInstance.cpp:825–955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823}
824
825void
826ViewerInstance::setupMinimalUpdateViewerParams(const SequenceTime time,
827 const ViewIdx view,
828 const int textureIndex,
829 const AbortableRenderInfoPtr& abortInfo,
830 const bool isSequential,
831 ViewerArgs* outArgs)
832{
833 assert(_imp->uiContext);
834
835 {
836 QMutexLocker l(&_imp->viewerParamsMutex);
837 outArgs->mipmapLevelWithoutDraft = (unsigned int)_imp->viewerMipMapLevel;
838 }
839
840 assert(_imp->uiContext);
841
842 // This is the current zoom factor (1. == 100%) currently set by the user in the viewport
843 double zoomFactor = _imp->uiContext->getZoomFactor();
844
845 // We render the image that is the nearest mipmap level higher in quality.
846 // For instance, if we were to render at 48% zoom factor, we would render at 50% which is mipmapLevel=1
847 // If on the other hand the zoom factor would be at 51%, then we would render at 100% which is mipmapLevel=0
848
849 // Adjust the mipmap level (without taking draft into account yet) as the max of the closest mipmap level of the viewer zoom
850 // and the requested user proxy mipmap level
851 if (isFullFrameProcessingEnabled()) {
852 outArgs->mipmapLevelWithoutDraft = 0;
853 } else {
854 int zoomMipMapLevel;
855 {
856 double closestPowerOf2 = zoomFactor >= 1 ? 1 : ipow( 2, (int)-std::ceil(std::log(zoomFactor) / M_LN2) );
857 zoomMipMapLevel = std::log(closestPowerOf2) / M_LN2;
858 }
859 outArgs->mipmapLevelWithoutDraft = (unsigned int)std::max( (int)outArgs->mipmapLevelWithoutDraft, (int)zoomMipMapLevel );
860 }
861 outArgs->mipMapLevelWithDraft = outArgs->mipmapLevelWithoutDraft;
862
863 outArgs->draftModeEnabled = getApp()->isDraftRenderEnabled();
864
865 // If draft mode is enabled, compute the mipmap level according to the auto-proxy setting in the preferences
866 if ( outArgs->draftModeEnabled && appPTR->getCurrentSettings()->isAutoProxyEnabled() ) {
867 unsigned int autoProxyLevel = appPTR->getCurrentSettings()->getAutoProxyMipMapLevel();
868 if (zoomFactor > 1) {
869 //Decrease draft mode at each inverse mipmaplevel level taken
870 unsigned int invLevel = Image::getLevelFromScale(1. / zoomFactor);
871 if (invLevel < autoProxyLevel) {
872 autoProxyLevel -= invLevel;
873 } else {
874 autoProxyLevel = 0;
875 }
876 }
877 outArgs->mipMapLevelWithDraft = (unsigned int)std::max( (int)outArgs->mipmapLevelWithoutDraft, (int)autoProxyLevel );
878 }
879
880
881 // The hash of the node to render, we store it and make sure we never call getHash() again for the render of this frame
882 outArgs->activeInputHash = outArgs->activeInputToRender->getHash();

Callers

nothing calls this directly

Calls 15

ipowFunction · 0.85
maxFunction · 0.85
getAppFunction · 0.85
getZoomFactorMethod · 0.80
isAutoProxyEnabledMethod · 0.80
getCurrentSettingsMethod · 0.80
emptyMethod · 0.80
getNodeFunction · 0.70
ceilFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected