]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_apicallitem.h
UI: Fix unnecessary memory overhead when loading traces.
[vogl] / src / vogleditor / vogleditor_apicallitem.h
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 #ifndef VOGLEDITOR_APICALLITEM_H
27 #define VOGLEDITOR_APICALLITEM_H
28
29 #include <QList>
30
31 // external classes (could be predeclared)
32 #include "vogl_common.h"
33 #include "vogl_trace_packet.h"
34
35 #include "vogleditor_snapshotitem.h"
36
37 // predeclared classes
38 class vogleditor_frameItem;
39
40 class vogleditor_apiCallItem : public vogleditor_snapshotItem
41 {
42 public:
43    vogleditor_apiCallItem(vogleditor_frameItem* pFrame, vogl_trace_packet* pTracePacket, const vogl_trace_gl_entrypoint_packet& glPacket)
44        : m_pParentFrame(pFrame),
45         m_glPacket(glPacket),
46         m_pTracePacket(pTracePacket),
47         m_globalCallIndex(glPacket.m_call_counter),
48         m_begin_rdtsc(glPacket.m_packet_begin_rdtsc),
49         m_end_rdtsc(glPacket.m_packet_end_rdtsc),
50         m_backtrace_hash_index(glPacket.m_backtrace_hash_index)
51    {
52       if (m_end_rdtsc < m_begin_rdtsc)
53       {
54          m_end_rdtsc = m_begin_rdtsc + 1;
55       }
56    }
57
58    ~vogleditor_apiCallItem()
59    {
60        if (m_pTracePacket != NULL)
61        {
62            vogl_delete(m_pTracePacket);
63            m_pTracePacket = NULL;
64        }
65    }
66
67    inline vogleditor_frameItem* frame() const
68    {
69       return m_pParentFrame;
70    }
71
72    inline uint64_t globalCallIndex() const
73    {
74       return m_globalCallIndex;
75    }
76
77    inline uint64_t startTime() const
78    {
79       return m_begin_rdtsc;
80    }
81
82    inline uint64_t endTime() const
83    {
84       return m_end_rdtsc;
85    }
86
87    inline uint64_t duration() const
88    {
89       return endTime() - startTime();
90    }
91
92    const vogl_trace_gl_entrypoint_packet* getGLPacket() const
93    {
94       return &m_glPacket;
95    }
96
97    vogl_trace_packet* getTracePacket()
98    {
99       return m_pTracePacket;
100    }
101
102    inline uint64_t backtraceHashIndex() const
103    {
104        return m_backtrace_hash_index;
105    }
106
107 private:
108    vogleditor_frameItem* m_pParentFrame;
109    const vogl_trace_gl_entrypoint_packet m_glPacket;
110    vogl_trace_packet* m_pTracePacket;
111
112    uint64_t m_globalCallIndex;
113    uint64_t m_begin_rdtsc;
114    uint64_t m_end_rdtsc;
115    uint64_t m_backtrace_hash_index;
116 };
117
118 #endif // VOGLEDITOR_APICALLITEM_H