IGraphicsDataToken rename

This commit is contained in:
Jack Andersen 2015-12-17 17:25:23 -10:00
parent 11cc456b4e
commit aa787eb427
4 changed files with 18 additions and 18 deletions

View File

@ -58,7 +58,7 @@ public:
size_t texCount, ITexture** texs); size_t texCount, ITexture** texs);
void reset(); void reset();
IGraphicsDataToken commit(); GraphicsDataToken commit();
}; };
} }

View File

@ -148,7 +148,7 @@ struct IShaderDataBinding {};
/** Opaque object for maintaining ownership of factory-created resources */ /** Opaque object for maintaining ownership of factory-created resources */
struct IGraphicsData {}; struct IGraphicsData {};
class IGraphicsDataToken; class GraphicsDataToken;
/** Used by platform shader pipeline constructors */ /** Used by platform shader pipeline constructors */
enum class BlendFactor enum class BlendFactor
@ -218,18 +218,18 @@ struct IGraphicsDataFactory
size_t texCount, ITexture** texs)=0; size_t texCount, ITexture** texs)=0;
virtual void reset()=0; virtual void reset()=0;
virtual IGraphicsDataToken commit()=0; virtual GraphicsDataToken commit()=0;
private: private:
friend class IGraphicsDataToken; friend class GraphicsDataToken;
virtual void destroyData(IGraphicsData*)=0; virtual void destroyData(IGraphicsData*)=0;
virtual void destroyAllData()=0; virtual void destroyAllData()=0;
}; };
/** Opaque token for maintaining ownership of factory-created resources /** Ownership token for maintaining lifetime of factory-created resources
* deletion of this token triggers mass-deallocation of the factory's * deletion of this token triggers mass-deallocation of the factory's
* IGraphicsData. */ * IGraphicsData (please don't delete and draw contained resources in the same frame). */
class IGraphicsDataToken class GraphicsDataToken
{ {
friend class GLDataFactory; friend class GLDataFactory;
friend class D3D12DataFactory; friend class D3D12DataFactory;
@ -237,7 +237,7 @@ class IGraphicsDataToken
friend class MetalDataFactory; friend class MetalDataFactory;
IGraphicsDataFactory* m_factory = nullptr; IGraphicsDataFactory* m_factory = nullptr;
IGraphicsData* m_data = nullptr; IGraphicsData* m_data = nullptr;
IGraphicsDataToken(IGraphicsDataFactory* factory, IGraphicsData* data) GraphicsDataToken(IGraphicsDataFactory* factory, IGraphicsData* data)
: m_factory(factory), m_data(data) {} : m_factory(factory), m_data(data) {}
void doDestroy() void doDestroy()
{ {
@ -245,17 +245,17 @@ class IGraphicsDataToken
m_factory->destroyData(m_data); m_factory->destroyData(m_data);
} }
public: public:
IGraphicsDataToken() = default; GraphicsDataToken() = default;
IGraphicsDataToken(const IGraphicsDataToken& other) = delete; GraphicsDataToken(const GraphicsDataToken& other) = delete;
IGraphicsDataToken(IGraphicsDataToken&& other) GraphicsDataToken(GraphicsDataToken&& other)
{ {
m_factory = other.m_factory; m_factory = other.m_factory;
other.m_factory = nullptr; other.m_factory = nullptr;
m_data = other.m_data; m_data = other.m_data;
other.m_data = nullptr; other.m_data = nullptr;
} }
IGraphicsDataToken& operator=(const IGraphicsDataToken& other) = delete; GraphicsDataToken& operator=(const GraphicsDataToken& other) = delete;
IGraphicsDataToken& operator=(IGraphicsDataToken&& other) GraphicsDataToken& operator=(GraphicsDataToken&& other)
{ {
doDestroy(); doDestroy();
m_factory = other.m_factory; m_factory = other.m_factory;
@ -264,7 +264,7 @@ public:
other.m_data = nullptr; other.m_data = nullptr;
return *this; return *this;
} }
~IGraphicsDataToken() {doDestroy();} ~GraphicsDataToken() {doDestroy();}
}; };
} }

View File

@ -584,10 +584,10 @@ void GLDataFactory::reset()
m_deferredData = nullptr; m_deferredData = nullptr;
} }
IGraphicsDataToken GLDataFactory::commit() GraphicsDataToken GLDataFactory::commit()
{ {
if (!m_deferredData) if (!m_deferredData)
return IGraphicsDataToken(this, nullptr); return GraphicsDataToken(this, nullptr);
std::unique_lock<std::mutex> lk(m_committedMutex); std::unique_lock<std::mutex> lk(m_committedMutex);
GLData* retval = m_deferredData; GLData* retval = m_deferredData;
#ifndef NDEBUG #ifndef NDEBUG
@ -600,7 +600,7 @@ IGraphicsDataToken GLDataFactory::commit()
While this isn't strictly required, some drivers might behave While this isn't strictly required, some drivers might behave
differently */ differently */
glFlush(); glFlush();
return IGraphicsDataToken(this, retval); return GraphicsDataToken(this, retval);
} }
void GLDataFactory::destroyData(IGraphicsData* d) void GLDataFactory::destroyData(IGraphicsData* d)

View File

@ -377,7 +377,7 @@ struct TestApplicationCallback : IApplicationCallback
factory->newShaderDataBinding(pipeline, vfmt, vbo, nullptr, nullptr, 0, nullptr, 1, &texture); factory->newShaderDataBinding(pipeline, vfmt, vbo, nullptr, nullptr, 0, nullptr, 1, &texture);
/* Commit objects */ /* Commit objects */
IGraphicsDataToken data = factory->commit(); GraphicsDataToken data = factory->commit();
/* Return control to client */ /* Return control to client */
lk.unlock(); lk.unlock();