1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 22:09:35 +00:00

Code refactor: CombinerProgram()::getKey() returns reference instead of object

to avoid copy of the key to temp object when combiner added to combiners map.
This commit is contained in:
Sergey Lipskiy 2017-12-14 15:45:41 +07:00
parent 6a72b09b1f
commit 5604bb94fa
6 changed files with 14 additions and 5 deletions

View File

@ -64,6 +64,13 @@ bool CombinerKey::isRectKey() const
return ((m_key.muxs0 >> 24) & 1) != 0;
}
void CombinerKey::read(std::istream & _is) {
void CombinerKey::read(std::istream & _is)
{
_is.read((char*)&m_key.mux, sizeof(m_key.mux));
}
const CombinerKey & CombinerKey::getEmpty()
{
static CombinerKey emptyKey;
return emptyKey;
}

View File

@ -26,6 +26,8 @@ public:
void read(std::istream & _is);
static const CombinerKey & getEmpty();
private:
gDPCombine m_key;
};

View File

@ -12,7 +12,7 @@ namespace graphics {
virtual void activate() = 0;
virtual void update(bool _force) = 0;
virtual CombinerKey getKey() const = 0;
virtual const CombinerKey & getKey() const = 0;
virtual bool usesTexture() const = 0;
virtual bool usesTile(u32 _t) const = 0;

View File

@ -44,7 +44,7 @@ void CombinerProgramImpl::update(bool _force)
(*it)->update(_force);
}
CombinerKey CombinerProgramImpl::getKey() const
const CombinerKey & CombinerProgramImpl::getKey() const
{
return m_key;
}

View File

@ -31,7 +31,7 @@ namespace glsl {
void activate() override;
void update(bool _force) override;
CombinerKey getKey() const override;
const CombinerKey & getKey() const override;
bool usesTexture() const override;
bool usesTile(u32 _t) const override;

View File

@ -10,7 +10,7 @@ namespace graphics {
virtual ~ShaderProgram() {}
void update(bool _force) override {}
CombinerKey getKey() const override {return CombinerKey();}
const CombinerKey & getKey() const override { return CombinerKey::getEmpty(); }
bool usesTexture() const override {return true;}
virtual bool usesTile(u32 _t) const override {return _t == 0 ? true : false;}
virtual bool usesShade() const override {return false;}