1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Rewrite FrameBufferList::_findBuffer

This commit is contained in:
Sergey Lipskiy 2017-03-05 21:35:20 +07:00
parent 811dea1d77
commit a28ca93ada
2 changed files with 9 additions and 15 deletions

View File

@ -509,26 +509,20 @@ FrameBuffer * FrameBufferList::findBuffer(u32 _startAddress)
return nullptr; return nullptr;
} }
FrameBuffer * FrameBufferList::_findBuffer(u32 _startAddress, u32 _endAddress, u32 _width) void FrameBufferList::removeIntersections()
{ {
if (m_list.empty()) assert(!m_list.empty());
return nullptr;
FrameBuffers::iterator iter = m_list.end(); FrameBuffers::iterator iter = m_list.end();
do { do {
--iter; --iter;
if ((iter->m_startAddress <= _startAddress && iter->m_endAddress >= _startAddress) || // [ { ] if (&(*iter) == m_pCurrent)
(_startAddress <= iter->m_startAddress && _endAddress >= iter->m_startAddress)) { // { [ } continue;
if ((iter->m_startAddress <= m_pCurrent->m_startAddress && iter->m_endAddress >= m_pCurrent->m_startAddress) || // [ { ]
if (_startAddress != iter->m_startAddress || _width != iter->m_width) { (m_pCurrent->m_startAddress <= iter->m_startAddress && m_pCurrent->m_endAddress >= iter->m_startAddress)) { // { [ }
m_list.erase(iter); iter = m_list.erase(iter);
return _findBuffer(_startAddress, _endAddress, _width);
}
return &(*iter);
} }
} while (iter != m_list.begin()); } while (iter != m_list.begin());
return nullptr;
} }
FrameBuffer * FrameBufferList::findTmpBuffer(u32 _address) FrameBuffer * FrameBufferList::findTmpBuffer(u32 _address)
@ -584,7 +578,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
m_pCurrent->copyRdram(); m_pCurrent->copyRdram();
} }
m_pCurrent = _findBuffer(m_pCurrent->m_startAddress, m_pCurrent->m_endAddress, m_pCurrent->m_width); removeIntersections();
} }
if (m_pCurrent == nullptr || m_pCurrent->m_startAddress != _address || m_pCurrent->m_width != _width) if (m_pCurrent == nullptr || m_pCurrent->m_startAddress != _address || m_pCurrent->m_width != _width)

View File

@ -106,7 +106,7 @@ private:
FrameBufferList() : m_pCurrent(nullptr), m_pCopy(nullptr) {} FrameBufferList() : m_pCurrent(nullptr), m_pCopy(nullptr) {}
FrameBufferList(const FrameBufferList &); FrameBufferList(const FrameBufferList &);
FrameBuffer * _findBuffer(u32 _startAddress, u32 _endAddress, u32 _width); void removeIntersections();
void _createScreenSizeBuffer(); void _createScreenSizeBuffer();
void _renderScreenSizeBuffer(); void _renderScreenSizeBuffer();