#pragma once #include "FractoriumSettings.h" #include "FractoriumEmberController.h" /// /// FinalRenderEmberControllerBase and FinalRenderEmberController classes. /// /// /// FractoriumEmberController and Fractorium need each other, but each can't include the other. /// So Fractorium includes this file, and Fractorium is declared as a forward declaration here. /// class Fractorium; class FractoriumFinalRenderDialog; /// /// Used to hold the options specified in the current state of the Gui for performing the final render. /// struct FinalRenderGuiState { bool m_EarlyClip; bool m_AlphaChannel; bool m_Transparency; bool m_OpenCL; bool m_Double; bool m_SaveXml; bool m_DoAll; bool m_DoSequence; bool m_KeepAspect; eScaleType m_Scale; QString m_Path; QString m_DoAllExt; QString m_Prefix; QString m_Suffix; unsigned int m_PlatformIndex; unsigned int m_DeviceIndex; unsigned int m_ThreadCount; unsigned int m_Width; unsigned int m_Height; double m_Quality; unsigned int m_TemporalSamples; unsigned int m_Supersample; }; /// /// FinalRenderEmberControllerBase serves as a non-templated base class with virtual /// functions which will be overridden in a derived class that takes a template parameter. /// Although not meant to be used as an interactive renderer, it derives from FractoriumEmberControllerBase /// to access a few of its members to avoid having to redefine them here. /// class FinalRenderEmberControllerBase : public FractoriumEmberControllerBase { friend FractoriumFinalRenderDialog; public: FinalRenderEmberControllerBase(FractoriumFinalRenderDialog* finalRender); virtual ~FinalRenderEmberControllerBase() { } virtual unsigned __int64 SyncAndComputeMemory() { return 0; } virtual QString Name() const { return ""; } virtual void ResetProgress(bool total = true) { } #ifdef DO_DOUBLE virtual void SetOriginalEmber(Ember& ember) { } #else virtual void SetOriginalEmber(Ember& ember) { } #endif virtual double OriginalAspect() { return 1; } void CancelRender(); bool CreateRendererFromGUI(); protected: bool m_Run; bool m_PreviewRun; unsigned int m_ImageCount; unsigned int m_FinishedImageCount; QFuture m_Result; QFuture m_PreviewResult; std::function m_RenderFunc; std::function m_PreviewRenderFunc; vector m_PreviewFinalImage; FractoriumSettings* m_Settings; FractoriumFinalRenderDialog* m_FinalRender; FinalRenderGuiState m_GuiState; OpenCLWrapper m_Wrapper; CriticalSection m_PreviewCs; Timing m_RenderTimer; Timing m_TotalTimer; }; /// /// Templated derived class which implements all interaction functionality between the embers /// of a specific template type and the final render dialog; /// template class FinalRenderEmberController : public FinalRenderEmberControllerBase { public: FinalRenderEmberController(FractoriumFinalRenderDialog* finalRender); virtual ~FinalRenderEmberController() { } virtual void SetEmber(const Ember& ember, bool verbatim = false); virtual void CopyEmber(Ember& ember); virtual void SetEmberFile(const EmberFile& emberFile); virtual void CopyEmberFile(EmberFile& emberFile); #ifdef DO_DOUBLE virtual void SetEmber(const Ember& ember, bool verbatim = false); virtual void CopyEmber(Ember& ember); virtual void SetEmberFile(const EmberFile& emberFile); virtual void CopyEmberFile(EmberFile& emberFile); virtual void SetOriginalEmber(Ember& ember); #else virtual void SetOriginalEmber(Ember& ember); #endif virtual double OriginalAspect(); virtual int ProgressFunc(Ember& ember, void* foo, double fraction, int stage, double etaMs); virtual bool Render(); virtual bool CreateRenderer(eRendererType renderType, unsigned int platform, unsigned int device, bool shared = true); virtual unsigned int SizeOfT() { return sizeof(T); } virtual unsigned __int64 SyncAndComputeMemory(); virtual QString Name() const { return QString::fromStdString(m_Ember.m_Name); } virtual void ResetProgress(bool total = true); void CancelPreviewRender(); protected: void Sync(Ember& ember); Ember m_Ember; Ember m_OriginalEmber; Ember m_PreviewEmber; EmberFile m_EmberFile; EmberToXml m_XmlWriter; auto_ptr> m_PreviewRenderer; }; template class FinalRenderEmberController; #ifdef DO_DOUBLE template class FinalRenderEmberController; #endif