MCPcopy Create free account
hub / github.com/baldurk/renderdoc / GetIndexForEID

Method GetIndexForEID

qrenderdoc/Windows/EventBrowser.cpp:511–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509 }
510
511 QModelIndex GetIndexForEID(uint32_t eid)
512 {
513 if(eid == 0)
514 return createIndex(0, 0, TagCaptureStart);
515
516 if(eid >= m_Actions.size())
517 return QModelIndex();
518
519 const ActionDescription *action = m_Actions[eid];
520 if(action)
521 {
522 // this function is not called regularly (anywhere to do with painting) but only occasionally
523 // to find an index by EID, so we do an 'expensive' search for the row in the parent. The
524 // cache is LRU and holds a few entries in case the user is jumping back and forth between a
525 // few.
526 for(size_t i = 0; i < m_RowInParentCache.size(); i++)
527 {
528 if(m_RowInParentCache[i].first == eid)
529 return createIndex(m_RowInParentCache[i].second, 0, eid);
530 }
531
532 const int MaxCacheSize = 10;
533
534 // oldest entry is on the back, pop it
535 if(m_RowInParentCache.size() == MaxCacheSize)
536 m_RowInParentCache.pop_back();
537
538 // account for the Capture Start row we'll add at the top level
539 int rowInParent = action->parent ? 0 : 1;
540
541 const rdcarray<ActionDescription> &actions =
542 action->parent ? action->parent->children : m_Ctx.CurRootActions();
543
544 for(const ActionDescription &a : actions)
545 {
546 // the first action with an EID greater than the one we're searching for should contain it.
547 if(a.eventId >= eid)
548 {
549 // except if the action is a fake marker. In this case its own event ID is invalid, so we
550 // check the range of its children (knowing it only has one layer of children)
551 if(a.IsFakeMarker())
552 {
553 if(a.eventId == eid)
554 break;
555
556 if(a.children[0].eventId < eid)
557 {
558 rowInParent++;
559 continue;
560 }
561 }
562
563 // keep counting until we get to the row within this action
564 for(size_t i = 0; i < a.events.size(); i++)
565 {
566 if(a.events[i].eventId < eid)
567 {
568 rowInParent++;

Callers 5

FindNextMethod · 0.80
filter_applyMethod · 0.80
SelectEventMethod · 0.80
location_keyPressMethod · 0.80
IsAPIEventVisibleMethod · 0.80

Calls 6

createIndexFunction · 0.85
QModelIndexClass · 0.50
sizeMethod · 0.45
pop_backMethod · 0.45
countMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected