mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 05:00:06 -05:00
Replace all instances of auto_ptr with unique_ptr.
Make EmberRender and EmberAnimate place their output renders in the same folder of the input parameter file. Previously it was just placing them in the same folder as the executable, which is wrong.
This commit is contained in:
parent
2df1f7a52b
commit
69b8aaea5b
@ -815,6 +815,24 @@ static string Trim(const string& str, char ch = ' ')
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a copy of a file path string with the path portion removed.
|
||||
/// </summary>
|
||||
/// <param name="filename">The string to retrieve the path from</param>
|
||||
/// <returns>The path portion of the string</returns>
|
||||
static string GetPath(const string& filename)
|
||||
{
|
||||
string s;
|
||||
const size_t lastSlash = filename.find_last_of("\\/");
|
||||
|
||||
if (std::string::npos != lastSlash)
|
||||
s = filename.substr(0, lastSlash + 1);
|
||||
else
|
||||
s = "";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Placeholder for a templated function to query the value of a specified system environment variable
|
||||
/// of a specific type. This function does nothing as the functions for specific types implement the behavior
|
||||
|
@ -34,7 +34,7 @@ bool EmberAnimate(EmberOptions& opt)
|
||||
bool appendXml = false;
|
||||
unsigned char* finalImagep;
|
||||
unsigned int i, channels, ftime;
|
||||
string s, flameName, filename;
|
||||
string s, flameName, filename, inputPath = GetPath(opt.Input());
|
||||
ostringstream os;
|
||||
vector<unsigned char> finalImage, vecRgb;
|
||||
vector<Ember<T>> embers;
|
||||
@ -44,8 +44,8 @@ bool EmberAnimate(EmberOptions& opt)
|
||||
Ember<T> centerEmber;
|
||||
XmlToEmber<T> parser;
|
||||
EmberToXml<T> emberToXml;
|
||||
auto_ptr<RenderProgress<T>> progress(new RenderProgress<T>());
|
||||
auto_ptr<Renderer<T, bucketT>> renderer(CreateRenderer<T, bucketT>(opt.EmberCL() ? OPENCL_RENDERER : CPU_RENDERER, opt.Platform(), opt.Device(), false, 0, emberReport));
|
||||
unique_ptr<RenderProgress<T>> progress(new RenderProgress<T>());
|
||||
unique_ptr<Renderer<T, bucketT>> renderer(CreateRenderer<T, bucketT>(opt.EmberCL() ? OPENCL_RENDERER : CPU_RENDERER, opt.Platform(), opt.Device(), false, 0, emberReport));
|
||||
vector<string> errorReport = emberReport.ErrorReport();
|
||||
|
||||
if (!errorReport.empty())
|
||||
@ -277,7 +277,7 @@ bool EmberAnimate(EmberOptions& opt)
|
||||
if (opt.Out().empty())
|
||||
{
|
||||
os.str("");
|
||||
os << opt.Prefix() << setfill('0') << setw(5) << ftime << opt.Suffix() << "." << opt.Format();
|
||||
os << inputPath << opt.Prefix() << setfill('0') << setw(5) << ftime << opt.Suffix() << "." << opt.Format();
|
||||
filename = os.str();
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ static bool WriteBmp(const char* filename, unsigned char* image, size_t width, s
|
||||
{
|
||||
bool b = false;
|
||||
size_t newSize;
|
||||
auto_ptr<BYTE> bgrBuf(ConvertRGBToBMPBuffer(image, width, height, newSize));
|
||||
unique_ptr<BYTE> bgrBuf(ConvertRGBToBMPBuffer(image, width, height, newSize));
|
||||
|
||||
if (bgrBuf.get())
|
||||
b = SaveBmp(filename, bgrBuf.get(), width, height, newSize);
|
||||
|
@ -77,8 +77,8 @@ bool EmberGenome(EmberOptions& opt)
|
||||
EmberToXml<T> emberToXml;
|
||||
VariationList<T> varList;
|
||||
EmberReport emberReport, emberReport2;
|
||||
auto_ptr<RenderProgress<T>> progress(new RenderProgress<T>());
|
||||
auto_ptr<Renderer<T, bucketT>> renderer(CreateRenderer<T, bucketT>(opt.EmberCL() ? OPENCL_RENDERER : CPU_RENDERER, opt.Platform(), opt.Device(), false, 0, emberReport));
|
||||
unique_ptr<RenderProgress<T>> progress(new RenderProgress<T>());
|
||||
unique_ptr<Renderer<T, bucketT>> renderer(CreateRenderer<T, bucketT>(opt.EmberCL() ? OPENCL_RENDERER : CPU_RENDERER, opt.Platform(), opt.Device(), false, 0, emberReport));
|
||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand(ISAAC_INT(t.Tic()), ISAAC_INT(t.Tic() * 2), ISAAC_INT(t.Tic() * 3));
|
||||
vector<string> errorReport = emberReport.ErrorReport();
|
||||
|
||||
|
@ -32,6 +32,7 @@ bool EmberRender(EmberOptions& opt)
|
||||
size_t strips;
|
||||
size_t iterCount;
|
||||
string filename;
|
||||
string inputPath = GetPath(opt.Input());
|
||||
ostringstream os;
|
||||
vector<Ember<T>> embers;
|
||||
vector<unsigned char> finalImage, vecRgb;
|
||||
@ -41,8 +42,8 @@ bool EmberRender(EmberOptions& opt)
|
||||
XmlToEmber<T> parser;
|
||||
EmberToXml<T> emberToXml;
|
||||
vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>> randVec;
|
||||
auto_ptr<RenderProgress<T>> progress(new RenderProgress<T>());
|
||||
auto_ptr<Renderer<T, bucketT>> renderer(CreateRenderer<T, bucketT>(opt.EmberCL() ? OPENCL_RENDERER : CPU_RENDERER, opt.Platform(), opt.Device(), false, 0, emberReport));
|
||||
unique_ptr<RenderProgress<T>> progress(new RenderProgress<T>());
|
||||
unique_ptr<Renderer<T, bucketT>> renderer(CreateRenderer<T, bucketT>(opt.EmberCL() ? OPENCL_RENDERER : CPU_RENDERER, opt.Platform(), opt.Device(), false, 0, emberReport));
|
||||
vector<string> errorReport = emberReport.ErrorReport();
|
||||
|
||||
if (!errorReport.empty())
|
||||
@ -250,13 +251,13 @@ bool EmberRender(EmberOptions& opt)
|
||||
}
|
||||
else if (opt.NameEnable() && !finalEmber.m_Name.empty())
|
||||
{
|
||||
filename = opt.Prefix() + finalEmber.m_Name + opt.Suffix() + "." + opt.Format();
|
||||
filename = inputPath + opt.Prefix() + finalEmber.m_Name + opt.Suffix() + "." + opt.Format();
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream ssLocal;
|
||||
|
||||
ssLocal << opt.Prefix() << setfill('0') << setw(5) << i << opt.Suffix() << "." << opt.Format();
|
||||
ssLocal << inputPath << opt.Prefix() << setfill('0') << setw(5) << i << opt.Suffix() << "." << opt.Format();
|
||||
filename = ssLocal.str();
|
||||
}
|
||||
|
||||
|
@ -139,9 +139,9 @@ void MakeTestAllVarsRegPrePostComboFile(const string& filename)
|
||||
while (index < varList.RegSize())
|
||||
{
|
||||
Ember<float> ember1;
|
||||
auto_ptr<Variation<float>> regVar (varList.GetVariationCopy(index, VARTYPE_REG));
|
||||
auto_ptr<Variation<float>> preVar (varList.GetVariationCopy("pre_" + regVar->Name()));
|
||||
auto_ptr<Variation<float>> postVar(varList.GetVariationCopy("post_" + regVar->Name()));
|
||||
unique_ptr<Variation<float>> regVar(varList.GetVariationCopy(index, VARTYPE_REG));
|
||||
unique_ptr<Variation<float>> preVar(varList.GetVariationCopy("pre_" + regVar->Name()));
|
||||
unique_ptr<Variation<float>> postVar(varList.GetVariationCopy("post_" + regVar->Name()));
|
||||
|
||||
ember1.m_FinalRasW = 640;
|
||||
ember1.m_FinalRasH = 480;
|
||||
@ -666,7 +666,7 @@ bool TestVarCopy()
|
||||
{
|
||||
Variation<sT>* var = vlf.GetVariation(i);
|
||||
Variation<dT>* destVar = NULL;
|
||||
auto_ptr<Variation<sT>> copyVar(var->Copy());//Test Copy().
|
||||
unique_ptr<Variation<sT>> copyVar(var->Copy());//Test Copy().
|
||||
|
||||
if (!TestVarEqual<sT, sT>(var, copyVar.get()))
|
||||
{
|
||||
@ -675,7 +675,7 @@ bool TestVarCopy()
|
||||
}
|
||||
|
||||
var->Copy(destVar);//Test Copy(var*);
|
||||
auto_ptr<Variation<dT>> destPtr(destVar);//Just for deletion.
|
||||
unique_ptr<Variation<dT>> destPtr(destVar);//Just for deletion.
|
||||
|
||||
if (!TestVarEqual<sT, dT>(var, destPtr.get()))
|
||||
{
|
||||
@ -1142,13 +1142,13 @@ void TestXformsInOutPoints()
|
||||
while (index < varList.RegSize())
|
||||
{
|
||||
vector<Xform<float>> xforms;
|
||||
auto_ptr<Variation<float>> regVar (varList.GetVariationCopy(index, VARTYPE_REG));
|
||||
unique_ptr<Variation<float>> regVar(varList.GetVariationCopy(index, VARTYPE_REG));
|
||||
string s = regVar->OpenCLString() + regVar->OpenCLFuncsString();
|
||||
|
||||
if (s.find("MwcNext") == string::npos)
|
||||
{
|
||||
auto_ptr<Variation<float>> preVar (varList.GetVariationCopy("pre_" + regVar->Name()));
|
||||
auto_ptr<Variation<float>> postVar(varList.GetVariationCopy("post_" + regVar->Name()));
|
||||
unique_ptr<Variation<float>> preVar(varList.GetVariationCopy("pre_" + regVar->Name()));
|
||||
unique_ptr<Variation<float>> postVar(varList.GetVariationCopy("post_" + regVar->Name()));
|
||||
|
||||
Xform<float> xform0(0.25f, rand.Frand01<float>(), rand.Frand11<float>(), 1, rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>());
|
||||
Xform<float> xform1(0.25f, rand.Frand01<float>(), rand.Frand11<float>(), 1, rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>(), rand.Frand11<float>());
|
||||
@ -1772,9 +1772,9 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
//cout << "sizeof(RendererCL<float>): " << sizeof(RendererCL<float>) << endl;
|
||||
//cout << "sizeof(RendererCL<double>): " << sizeof(RendererCL<double>) << endl;
|
||||
|
||||
/*auto_ptr<LinearVariation<float>> linV(new LinearVariation<float>());
|
||||
auto_ptr<PreLinearVariation<float>> preLinV(new PreLinearVariation<float>());
|
||||
auto_ptr<PostLinearVariation<float>> postLinV(new PostLinearVariation<float>());
|
||||
/*unique_ptr<LinearVariation<float>> linV(new LinearVariation<float>());
|
||||
unique_ptr<PreLinearVariation<float>> preLinV(new PreLinearVariation<float>());
|
||||
unique_ptr<PostLinearVariation<float>> postLinV(new PostLinearVariation<float>());
|
||||
|
||||
cout << linV->BaseName() << endl;
|
||||
cout << preLinV->BaseName() << endl;
|
||||
@ -1789,7 +1789,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
//TestGpuVectorRead<double>();
|
||||
//TestGpuVectorRead<float>();
|
||||
//return 0;
|
||||
//auto_ptr<PreFarblurVariation<float>> preFarblurV(new PreFarblurVariation<float>());
|
||||
//unique_ptr<PreFarblurVariation<float>> preFarblurV(new PreFarblurVariation<float>());
|
||||
//size_t vsize = 1024 * 1024;
|
||||
//
|
||||
//t.Tic();
|
||||
|
@ -670,10 +670,10 @@ bool FractoriumFinalRenderDialog::CreateControllerFromGUI(bool createRenderer)
|
||||
//Create a float or double controller based on the GUI.
|
||||
#ifdef DO_DOUBLE
|
||||
if (Double())
|
||||
m_Controller = auto_ptr<FinalRenderEmberControllerBase>(new FinalRenderEmberController<double>(this));
|
||||
m_Controller = unique_ptr<FinalRenderEmberControllerBase>(new FinalRenderEmberController<double>(this));
|
||||
else
|
||||
#endif
|
||||
m_Controller = auto_ptr<FinalRenderEmberControllerBase>(new FinalRenderEmberController<float>(this));
|
||||
m_Controller = unique_ptr<FinalRenderEmberControllerBase>(new FinalRenderEmberController<float>(this));
|
||||
|
||||
//Restore the ember and ember file.
|
||||
if (m_Controller.get())
|
||||
|
@ -125,6 +125,6 @@ private:
|
||||
QLineEdit* m_SuffixEdit;
|
||||
FractoriumSettings* m_Settings;
|
||||
Fractorium* m_Fractorium;
|
||||
auto_ptr<FinalRenderEmberControllerBase> m_Controller;
|
||||
unique_ptr<FinalRenderEmberControllerBase> m_Controller;
|
||||
Ui::FinalRenderDialog ui;
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ template<typename T>
|
||||
FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderDialog* finalRender)
|
||||
: FinalRenderEmberControllerBase(finalRender)
|
||||
{
|
||||
m_FinalPreviewRenderer = auto_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
||||
m_FinalPreviewRenderer = unique_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
||||
m_FinalPreviewRenderer->Callback(NULL);
|
||||
m_FinalPreviewRenderer->NumChannels(4);
|
||||
|
||||
@ -418,7 +418,7 @@ bool FinalRenderEmberController<T>::CreateRenderer(eRendererType renderType, uns
|
||||
m_OutputTexID = 0;//Don't care about tex ID when doing final render.
|
||||
m_Shared = shared;
|
||||
|
||||
m_Renderer = auto_ptr<EmberNs::RendererBase>(::CreateRenderer<T, T>(renderType, platform, device, shared, m_OutputTexID, emberReport));
|
||||
m_Renderer = unique_ptr<EmberNs::RendererBase>(::CreateRenderer<T, T>(renderType, platform, device, shared, m_OutputTexID, emberReport));
|
||||
errorReport = emberReport.ErrorReport();
|
||||
|
||||
if (!errorReport.empty())
|
||||
|
@ -135,7 +135,7 @@ protected:
|
||||
Ember<T> m_PreviewEmber;
|
||||
EmberFile<T> m_EmberFile;
|
||||
EmberToXml<T> m_XmlWriter;
|
||||
auto_ptr<EmberNs::Renderer<T, T>> m_FinalPreviewRenderer;
|
||||
unique_ptr<EmberNs::Renderer<T, T>> m_FinalPreviewRenderer;
|
||||
};
|
||||
|
||||
template class FinalRenderEmberController<float>;
|
||||
|
@ -84,10 +84,10 @@ Fractorium::Fractorium(QWidget* parent)
|
||||
//of their respective objects.
|
||||
#ifdef DO_DOUBLE
|
||||
if (m_Settings->Double())
|
||||
m_Controller = auto_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<double>(this));
|
||||
m_Controller = unique_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<double>(this));
|
||||
else
|
||||
#endif
|
||||
m_Controller = auto_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<float>(this));
|
||||
m_Controller = unique_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<float>(this));
|
||||
|
||||
if (m_Wrapper.CheckOpenCL() && m_Settings->OpenCL() && m_QualitySpin->value() < 30)
|
||||
m_QualitySpin->setValue(30);
|
||||
|
@ -398,7 +398,7 @@ private:
|
||||
int m_VarSortMode;
|
||||
int m_PreviousPaletteRow;
|
||||
OpenCLWrapper m_Wrapper;
|
||||
auto_ptr<FractoriumEmberControllerBase> m_Controller;
|
||||
unique_ptr<FractoriumEmberControllerBase> m_Controller;
|
||||
Ui::FractoriumClass ui;
|
||||
};
|
||||
|
||||
|
@ -69,9 +69,9 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
|
||||
{
|
||||
m_PreviewRun = false;
|
||||
m_PreviewRunning = false;
|
||||
m_SheepTools = auto_ptr<SheepTools<T, T>>(new SheepTools<T, T>("flam3-palettes.xml", new EmberNs::Renderer<T, T>()));
|
||||
m_GLController = auto_ptr<GLEmberController<T>>(new GLEmberController<T>(fractorium, fractorium->ui.GLDisplay, this));
|
||||
m_PreviewRenderer = auto_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
||||
m_SheepTools = unique_ptr<SheepTools<T, T>>(new SheepTools<T, T>("flam3-palettes.xml", new EmberNs::Renderer<T, T>()));
|
||||
m_GLController = unique_ptr<GLEmberController<T>>(new GLEmberController<T>(fractorium, fractorium->ui.GLDisplay, this));
|
||||
m_PreviewRenderer = unique_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
||||
SetupVariationTree();
|
||||
InitPaletteTable("flam3-palettes.xml");
|
||||
BackgroundChanged(QColor(0, 0, 0));//Default to black.
|
||||
|
@ -231,7 +231,7 @@ protected:
|
||||
vector<unsigned char> m_FinalImage;
|
||||
vector<unsigned char> m_PreviewFinalImage;
|
||||
vector<eProcessAction> m_ProcessActions;
|
||||
auto_ptr<EmberNs::RendererBase> m_Renderer;
|
||||
unique_ptr<EmberNs::RendererBase> m_Renderer;
|
||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> m_Rand;
|
||||
Fractorium* m_Fractorium;
|
||||
QTimer* m_RenderTimer;
|
||||
@ -447,9 +447,9 @@ private:
|
||||
Palette<T> m_TempPalette;
|
||||
PaletteList<T> m_PaletteList;
|
||||
VariationList<T> m_VariationList;
|
||||
auto_ptr<SheepTools<T, T>> m_SheepTools;
|
||||
auto_ptr<GLEmberController<T>> m_GLController;
|
||||
auto_ptr<EmberNs::Renderer<T, T>> m_PreviewRenderer;
|
||||
unique_ptr<SheepTools<T, T>> m_SheepTools;
|
||||
unique_ptr<GLEmberController<T>> m_GLController;
|
||||
unique_ptr<EmberNs::Renderer<T, T>> m_PreviewRenderer;
|
||||
QFuture<void> m_PreviewResult;
|
||||
std::function<void (unsigned int, unsigned int)> m_PreviewRenderFunc;
|
||||
};
|
||||
|
@ -493,7 +493,7 @@ bool FractoriumEmberController<T>::CreateRenderer(eRendererType renderType, unsi
|
||||
DeleteRenderer();//Delete the renderer and refresh the textures.
|
||||
//Before starting, must take care of allocations.
|
||||
gl->Allocate(true);//Forcing a realloc of the texture is necessary on AMD, but not on nVidia.
|
||||
m_Renderer = auto_ptr<EmberNs::RendererBase>(::CreateRenderer<T, T>(renderType, platform, device, shared, gl->OutputTexID(), emberReport));
|
||||
m_Renderer = unique_ptr<EmberNs::RendererBase>(::CreateRenderer<T, T>(renderType, platform, device, shared, gl->OutputTexID(), emberReport));
|
||||
errorReport = emberReport.ErrorReport();
|
||||
|
||||
if (errorReport.empty())
|
||||
@ -625,10 +625,10 @@ bool Fractorium::CreateControllerFromOptions()
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
if (m_Settings->Double())
|
||||
m_Controller = auto_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<double>(this));
|
||||
m_Controller = unique_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<double>(this));
|
||||
else
|
||||
#endif
|
||||
m_Controller = auto_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<float>(this));
|
||||
m_Controller = unique_ptr<FractoriumEmberControllerBase>(new FractoriumEmberController<float>(this));
|
||||
|
||||
//Restore the ember and ember file.
|
||||
if (m_Controller.get())
|
||||
|
Loading…
Reference in New Issue
Block a user