optimize rendering iteration
This commit is contained in:
@@ -772,6 +772,21 @@ bool NoteData::GetPrevTapNoteRowForTrack( int track, int &rowInOut ) const
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return an iterator range. This can be used to iterate trackwise over a range of
|
||||
* notes. It's like FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE, except it only requires
|
||||
* two map searches (iterating is O(1)), but the iterators will become invalid if
|
||||
* the notes they represent disappear, so you need to pay attention to how you modify
|
||||
* the data. */
|
||||
void NoteData::GetTapNoteRange( int iTrack, int iStartRow, int iEndRow, TrackMap::const_iterator &begin, TrackMap::const_iterator &end ) const
|
||||
{
|
||||
ASSERT_M( iTrack < GetNumTracks(), ssprintf("%i,%i", iTrack, GetNumTracks()) );
|
||||
ASSERT_M( iStartRow <= iEndRow, ssprintf("%i > %i", iStartRow, iEndRow) );
|
||||
|
||||
const TrackMap &mapTrack = m_TapNotes[iTrack];
|
||||
begin = mapTrack.lower_bound( iStartRow );
|
||||
end = mapTrack.upper_bound( iEndRow );
|
||||
}
|
||||
|
||||
bool NoteData::GetNextTapNoteRowForAllTracks( int &rowInOut ) const
|
||||
{
|
||||
int iClosestNextRow = 999999;
|
||||
|
||||
@@ -21,9 +21,12 @@
|
||||
|
||||
class NoteData
|
||||
{
|
||||
public:
|
||||
typedef map<int,TapNote> TrackMap;
|
||||
|
||||
private:
|
||||
// There's no point in inserting empty notes into the map.
|
||||
// Any blank space in the map is defined to be empty.
|
||||
typedef map<int,TapNote> TrackMap;
|
||||
vector<TrackMap> m_TapNotes;
|
||||
|
||||
vector<HoldNote> m_HoldNotes;
|
||||
@@ -60,6 +63,8 @@ public:
|
||||
bool GetNextTapNoteRowForAllTracks( int &rowInOut ) const;
|
||||
bool GetPrevTapNoteRowForTrack( int track, int &rowInOut ) const;
|
||||
|
||||
void GetTapNoteRange( int iTrack, int iStartRow, int iEndRow, TrackMap::const_iterator &begin, TrackMap::const_iterator &end ) const;
|
||||
|
||||
void MoveTapNoteTrack( int dest, int src );
|
||||
void SetTapNote( int track, int row, const TapNote& tn );
|
||||
|
||||
|
||||
@@ -605,9 +605,13 @@ void NoteField::DrawPrimitives()
|
||||
NextDisplay = CurDisplay; ++NextDisplay;
|
||||
|
||||
// draw notes from furthest to closest
|
||||
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE_REVERSE( *m_pNoteData, c, i, iFirstIndexToDraw, iLastIndexToDraw )
|
||||
|
||||
NoteData::TrackMap::const_iterator begin, end;
|
||||
m_pNoteData->GetTapNoteRange( c, iFirstIndexToDraw, iLastIndexToDraw, begin, end );
|
||||
for( ; begin != end; ++begin )
|
||||
{
|
||||
const TapNote &tn = m_pNoteData->GetTapNote(c, i);
|
||||
int i = begin->first;
|
||||
const TapNote &tn = begin->second; //m_pNoteData->GetTapNote(c, i);
|
||||
if( tn.type == TapNote::empty ) // no note here
|
||||
continue; // skip
|
||||
|
||||
|
||||
Reference in New Issue
Block a user