X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=src%2Fvogleditor%2Fvogleditor_qapicalltreemodel.cpp;h=a3f8ca3a03ab13d1e9e3c2c68a9ddcd744352554;hb=63b963ced8b174c86342a12f64fba3d595a39631;hp=c89e1589c24d425f37a88ef11c249ee2a3e44149;hpb=efdbc27f2074c559c8bbd4c118c45fda53e7aa7a;p=vogl diff --git a/src/vogleditor/vogleditor_qapicalltreemodel.cpp b/src/vogleditor/vogleditor_qapicalltreemodel.cpp index c89e158..a3f8ca3 100644 --- a/src/vogleditor/vogleditor_qapicalltreemodel.cpp +++ b/src/vogleditor/vogleditor_qapicalltreemodel.cpp @@ -34,7 +34,7 @@ vogleditor_QApiCallTreeModel::vogleditor_QApiCallTreeModel(vogl_trace_file_reader* reader, QObject *parent) : QAbstractItemModel(parent) { - m_rootItem = new vogleditor_apiCallTreeItem(this); + m_rootItem = vogl_new(vogleditor_apiCallTreeItem, this); setupModelData(reader, m_rootItem); } @@ -42,7 +42,7 @@ vogleditor_QApiCallTreeModel::~vogleditor_QApiCallTreeModel() { if (m_rootItem != NULL) { - delete m_rootItem; + vogl_delete(m_rootItem); m_rootItem = NULL; } @@ -72,8 +72,6 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace m_trace_ctypes.init(pTrace_reader->get_sof_packet().m_pointer_sizes); - vogl_trace_packet trace_packet(&m_trace_ctypes); - for ( ; ; ) { vogl_trace_file_reader::trace_file_reader_status_t read_status = pTrace_reader->read_next_packet(); @@ -97,7 +95,9 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace if (pTrace_reader->get_packet_type() == cTSPTGLEntrypoint) { - if (!trace_packet.deserialize(pTrace_reader->get_packet_buf().get_ptr(), pTrace_reader->get_packet_buf().size(), false)) + vogl_trace_packet* pTrace_packet = vogl_new(vogl_trace_packet, &m_trace_ctypes); + + if (!pTrace_packet->deserialize(pTrace_reader->get_packet_buf().get_ptr(), pTrace_reader->get_packet_buf().size(), false)) { console::error("%s: Failed parsing GL entrypoint packet\n", VOGL_FUNCTION_NAME); break; @@ -111,12 +111,12 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace // Check if this is a state snapshot. // This is entirely optional since the client is designed to dynamically get new snapshots // if they don't exist. - GLuint cmd = trace_packet.get_param_value(0); - GLuint size = trace_packet.get_param_value(1); VOGL_NOTE_UNUSED(size); + GLuint cmd = pTrace_packet->get_param_value(0); + GLuint size = pTrace_packet->get_param_value(1); VOGL_NOTE_UNUSED(size); if (cmd == cITCRKeyValueMap) { - key_value_map &kvm = trace_packet.get_key_value_map(); + key_value_map &kvm = pTrace_packet->get_key_value_map(); dynamic_string cmd_type(kvm.get_string("command_type")); if (cmd_type == "state_snapshot") @@ -172,23 +172,23 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace // format parameters funcCall.append("( "); dynamic_string paramStr; - for (uint param_index = 0; param_index < trace_packet.total_params(); param_index++) + for (uint param_index = 0; param_index < pTrace_packet->total_params(); param_index++) { if (param_index != 0) funcCall.append(", "); paramStr.clear(); - trace_packet.pretty_print_param(paramStr, param_index, false); + pTrace_packet->pretty_print_param(paramStr, param_index, false); funcCall.append(paramStr.c_str()); } funcCall.append(" )"); - if (trace_packet.has_return_value()) + if (pTrace_packet->has_return_value()) { funcCall.append(" = "); paramStr.clear(); - trace_packet.pretty_print_return_value(paramStr, false); + pTrace_packet->pretty_print_return_value(paramStr, false); funcCall.append(paramStr.c_str()); } @@ -196,8 +196,8 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace // and append it to the parent if (pCurFrame == NULL) { - pCurFrame = new vogleditor_frameItem(total_swaps); - vogleditor_apiCallTreeItem* pNewFrameNode = new vogleditor_apiCallTreeItem(pCurFrame, pCurParent); + pCurFrame = vogl_new(vogleditor_frameItem, total_swaps); + vogleditor_apiCallTreeItem* pNewFrameNode = vogl_new(vogleditor_apiCallTreeItem, pCurFrame, pCurParent); pCurParent->appendChild(pNewFrameNode); m_itemList.append(pNewFrameNode); @@ -212,7 +212,7 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace } // make item and node for the api call - vogleditor_apiCallItem* pCallItem = new vogleditor_apiCallItem(pCurFrame, trace_packet, *pGL_packet); + vogleditor_apiCallItem* pCallItem = vogl_new(vogleditor_apiCallItem, pCurFrame, pTrace_packet, *pGL_packet); pCurFrame->appendCall(pCallItem); if (pPendingSnapshot != NULL) @@ -221,7 +221,7 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace pPendingSnapshot = NULL; } - vogleditor_apiCallTreeItem* item = new vogleditor_apiCallTreeItem(funcCall, pCallItem, pCurParent); + vogleditor_apiCallTreeItem* item = vogl_new(vogleditor_apiCallTreeItem, funcCall, pCallItem, pCurParent); pCurParent->appendChild(item); m_itemList.append(item); @@ -235,6 +235,16 @@ void vogleditor_QApiCallTreeModel::setupModelData(vogl_trace_file_reader* pTrace // reset the CurFrame so that a new frame node will be created on the next api call pCurFrame = NULL; } + else if (entrypoint_id == VOGL_ENTRYPOINT_glBegin) + { + // items in the glBegin/glEnd block will be nested, including the glEnd + pCurParent = item; + } + else if (entrypoint_id == VOGL_ENTRYPOINT_glEnd) + { + // move the parent back one level of the hierarchy, to its own parent + pCurParent = pCurParent->parent(); + } } if (pTrace_reader->get_packet_type() == cTSPTEOF) @@ -312,9 +322,23 @@ QVariant vogleditor_QApiCallTreeModel::data(const QModelIndex &index, int role) if (!index.isValid()) return QVariant(); - vogleditor_apiCallTreeItem *item = static_cast(index.internalPointer()); + vogleditor_apiCallTreeItem* pItem = static_cast(index.internalPointer()); + + // highlight the API call cell if it has a substring which matches the searchString + if (role == Qt::BackgroundRole && index.column() == VOGL_ACTC_APICALL) + { + if (!m_searchString.isEmpty()) + { + QVariant data = pItem->columnData(VOGL_ACTC_APICALL, Qt::DisplayRole); + QString string = data.toString(); + if (string.contains(m_searchString, Qt::CaseInsensitive)) + { + return QColor(Qt::yellow); + } + } + } - return item->columnData(index.column(), role); + return pItem->columnData(index.column(), role); } Qt::ItemFlags vogleditor_QApiCallTreeModel::flags(const QModelIndex &index) const @@ -334,44 +358,35 @@ QVariant vogleditor_QApiCallTreeModel::headerData(int section, Qt::Orientation o return QVariant(); } -QModelIndexList vogleditor_QApiCallTreeModel::find_search_matches(const QString searchText) +void vogleditor_QApiCallTreeModel::set_highlight_search_string(const QString searchString) +{ + m_searchString = searchString; +} + +QModelIndex vogleditor_QApiCallTreeModel::find_prev_search_result(vogleditor_apiCallTreeItem* start, const QString searchText) { QLinkedListIterator iter(m_itemList); - QModelIndexList matches; - // iterate through all items and find matching text - while (iter.hasNext()) + if (start != NULL) { - vogleditor_apiCallTreeItem* pItem = iter.peekNext(); - QVariant data = pItem->columnData(VOGL_ACTC_APICALL, Qt::DisplayRole); - QString string = data.toString(); - if (string.contains(searchText, Qt::CaseInsensitive)) + if (iter.findNext(start) == false) { - matches.push_back(indexOf(pItem)); + // the object wasn't found in the list, so return a default (invalid) item + return QModelIndex(); } - iter.next(); + // need to back up past the current item + iter.previous(); } - - return matches; -} - -QModelIndex vogleditor_QApiCallTreeModel::find_prev_search_result(vogleditor_apiCallTreeItem* start, const QString searchText) -{ - QLinkedListIterator iter(m_itemList); - - if (iter.findNext(start) == false) + else { - // the object wasn't found in the list, so just return the same item - return indexOf(start); + // set the iterator to the back so that searching starts from the end of the list + iter.toBack(); } - // need to back up past the current item - iter.previous(); - // now the iterator is pointing to the desired start object in the list, // continually check the prev item and find one with a snapshot - vogleditor_apiCallTreeItem* pFound = start; + vogleditor_apiCallTreeItem* pFound = NULL; while (iter.hasPrevious()) { vogleditor_apiCallTreeItem* pItem = iter.peekPrevious(); @@ -391,18 +406,20 @@ QModelIndex vogleditor_QApiCallTreeModel::find_prev_search_result(vogleditor_api QModelIndex vogleditor_QApiCallTreeModel::find_next_search_result(vogleditor_apiCallTreeItem* start, const QString searchText) { - QLinkedListIterator iter(m_itemList); - if (iter.findNext(start) == false) + if (start != NULL) { - // the object wasn't found in the list, so just return the same item - return indexOf(start); + if (iter.findNext(start) == false) + { + // the object wasn't found in the list, so return a default (invalid) item + return QModelIndex(); + } } // now the iterator is pointing to the desired start object in the list, // continually check the next item and find one with a snapshot - vogleditor_apiCallTreeItem* pFound = start; + vogleditor_apiCallTreeItem* pFound = NULL; while (iter.hasNext()) { vogleditor_apiCallTreeItem* pItem = iter.peekNext(); @@ -424,18 +441,26 @@ vogleditor_apiCallTreeItem* vogleditor_QApiCallTreeModel::find_prev_snapshot(vog { QLinkedListIterator iter(m_itemList); - if (iter.findNext(start) == false) + if (start != NULL) { - // the object wasn't found in the list, so just return the same item - return start; - } + if (iter.findNext(start) == false) + { + // the object wasn't found in the list + return NULL; + } - // need to back up past the current item - iter.previous(); + // need to back up past the current item + iter.previous(); + } + else + { + // set the iterator to the back so that searching starts from the end of the list + iter.toBack(); + } // now the iterator is pointing to the desired start object in the list, // continually check the prev item and find one with a snapshot - vogleditor_apiCallTreeItem* pFound = start; + vogleditor_apiCallTreeItem* pFound = NULL; while (iter.hasPrevious()) { if (iter.peekPrevious()->has_snapshot()) @@ -454,15 +479,19 @@ vogleditor_apiCallTreeItem* vogleditor_QApiCallTreeModel::find_next_snapshot(vog { QLinkedListIterator iter(m_itemList); - if (iter.findNext(start) == false) + // if start is NULL, then search will begin from top, otherwise it will begin from the start item and search onwards + if (start != NULL) { - // the object wasn't found in the list, so just return the same item - return start; + if (iter.findNext(start) == false) + { + // the object wasn't found in the list + return NULL; + } } // now the iterator is pointing to the desired start object in the list, // continually check the next item and find one with a snapshot - vogleditor_apiCallTreeItem* pFound = start; + vogleditor_apiCallTreeItem* pFound = NULL; while (iter.hasNext()) { if (iter.peekNext()->has_snapshot()) @@ -482,18 +511,26 @@ vogleditor_apiCallTreeItem *vogleditor_QApiCallTreeModel::find_prev_drawcall(vog { QLinkedListIterator iter(m_itemList); - if (iter.findNext(start) == false) + if (start != NULL) { - // the object wasn't found in the list, so just return the same item - return start; - } + if (iter.findNext(start) == false) + { + // the object wasn't found in the list + return NULL; + } - // need to back up past the current item - iter.previous(); + // need to back up past the current item + iter.previous(); + } + else + { + // set the iterator to the back so that searching starts from the end of the list + iter.toBack(); + } // now the iterator is pointing to the desired start object in the list, // continually check the prev item and find one with a snapshot - vogleditor_apiCallTreeItem* pFound = start; + vogleditor_apiCallTreeItem* pFound = NULL; while (iter.hasPrevious()) { vogleditor_apiCallTreeItem* pItem = iter.peekPrevious(); @@ -501,7 +538,9 @@ vogleditor_apiCallTreeItem *vogleditor_QApiCallTreeModel::find_prev_drawcall(vog { gl_entrypoint_id_t entrypointId = static_cast(pItem->apiCallItem()->getGLPacket()->m_entrypoint_id); if (vogl_is_draw_entrypoint(entrypointId) || - vogl_is_clear_entrypoint(entrypointId)) + vogl_is_clear_entrypoint(entrypointId) || + (entrypointId == VOGL_ENTRYPOINT_glBitmap) || + (entrypointId == VOGL_ENTRYPOINT_glEnd)) { pFound = iter.peekPrevious(); break; @@ -520,13 +559,13 @@ vogleditor_apiCallTreeItem *vogleditor_QApiCallTreeModel::find_next_drawcall(vog if (iter.findNext(start) == false) { - // the object wasn't found in the list, so just return the same item - return start; + // the object wasn't found in the list + return NULL; } // now the iterator is pointing to the desired start object in the list, // continually check the next item and find one with a snapshot - vogleditor_apiCallTreeItem* pFound = start; + vogleditor_apiCallTreeItem* pFound = NULL; while (iter.hasNext()) { vogleditor_apiCallTreeItem* pItem = iter.peekNext(); @@ -534,7 +573,55 @@ vogleditor_apiCallTreeItem *vogleditor_QApiCallTreeModel::find_next_drawcall(vog { gl_entrypoint_id_t entrypointId = static_cast(pItem->apiCallItem()->getGLPacket()->m_entrypoint_id); if (vogl_is_draw_entrypoint(entrypointId) || - vogl_is_clear_entrypoint(entrypointId)) + vogl_is_clear_entrypoint(entrypointId) || + (entrypointId == VOGL_ENTRYPOINT_glBitmap) || + (entrypointId == VOGL_ENTRYPOINT_glEnd)) + { + pFound = iter.peekNext(); + break; + } + } + + iter.next(); + } + + return pFound; +} + +vogleditor_apiCallTreeItem* vogleditor_QApiCallTreeModel::find_call_number(uint64_t callNumber) +{ + QLinkedListIterator iter(m_itemList); + + vogleditor_apiCallTreeItem* pFound = NULL; + while (iter.hasNext()) + { + vogleditor_apiCallTreeItem* pItem = iter.peekNext(); + if (pItem->apiCallItem() != NULL) + { + if (pItem->apiCallItem()->globalCallIndex() == callNumber) + { + pFound = iter.peekNext(); + break; + } + } + + iter.next(); + } + + return pFound; +} + +vogleditor_apiCallTreeItem* vogleditor_QApiCallTreeModel::find_frame_number(uint64_t frameNumber) +{ + QLinkedListIterator iter(m_itemList); + + vogleditor_apiCallTreeItem* pFound = NULL; + while (iter.hasNext()) + { + vogleditor_apiCallTreeItem* pItem = iter.peekNext(); + if (pItem->frameItem() != NULL) + { + if (pItem->frameItem()->frameNumber() == frameNumber) { pFound = iter.peekNext(); break;