]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor.h
ad007e2ba8b65c0f3382350f010cf88b473486e4
[vogl] / src / vogleditor / vogleditor.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_H
27 #define VOGLEDITOR_H
28
29 #include <QMainWindow>
30 #include <QString>
31 #include <QLabel>
32 #include <QModelIndexList>
33
34 #include "vogl_dynamic_string.h"
35 #include "vogl_hash_map.h"
36 #include "vogl_json.h"
37 #include "vogleditor_qframebufferexplorer.h"
38 #include "vogleditor_qprogramexplorer.h"
39 #include "vogleditor_qshaderexplorer.h"
40 #include "vogleditor_qtextureexplorer.h"
41 #include "vogleditor_qtimelineview.h"
42 #include "vogleditor_tracereplayer.h"
43
44 namespace Ui {
45 class VoglEditor;
46 }
47
48 typedef uint64_t GLuint64;
49
50 class vogleditor_QTextureExplorer;
51
52 class QItemSelection;
53 class QModelIndex;
54 class QSortFilterProxyModel;
55 class QToolButton;
56 class vogl_context_snapshot;
57 class vogl_framebuffer_state;
58 class vogl_program_state;
59 class vogl_replay_window;
60 class vogl_shader_state;
61 class vogl_texture_state;
62 class vogl_trace_file_reader;
63 class vogl_trace_file_writer;
64 class vogl_trace_packet;
65 class vogl_gl_state_snapshot;
66 class vogleditor_apiCallTimelineModel;
67 class vogleditor_apiCallTreeItem;
68 class vogleditor_gl_state_snapshot;
69 class vogleditor_QApiCallTreeModel;
70
71 class VoglEditor : public QMainWindow
72 {
73    Q_OBJECT
74
75 public:
76    explicit VoglEditor(QWidget* parent = 0);
77    ~VoglEditor();
78
79    bool open_trace_file(vogl::dynamic_string filename);
80    void close_trace_file();
81
82 private slots:
83    void on_action_Open_triggered();
84    void on_action_Close_triggered();
85    void on_actionE_xit_triggered();
86    void on_actionExport_API_Calls_triggered();
87
88    void on_treeView_currentChanged(const QModelIndex & current, const QModelIndex & previous);
89
90    void on_treeView_clicked(const QModelIndex& index);
91
92    void playCurrentTraceFile();
93    void pauseCurrentTraceFile();
94    void trimCurrentTraceFile();
95    void stopCurrentTraceFile();
96
97    void on_stateTreeView_clicked(const QModelIndex &index);
98
99    void on_searchTextBox_textChanged(const QString &searchText);
100    void on_searchNextButton_clicked();
101    void on_searchPrevButton_clicked();
102    void on_prevSnapshotButton_clicked();
103    void on_nextSnapshotButton_clicked();
104    void on_prevDrawcallButton_clicked();
105    void on_nextDrawcallButton_clicked();
106
107    void on_program_edited(vogl_program_state* pNewProgramState);   
108
109    void on_actionSave_Session_triggered();
110
111    void on_actionOpen_Session_triggered();
112
113 private:
114    Ui::VoglEditor* ui;
115
116    void onApiCallSelected(const QModelIndex &index, bool bAllowStateSnapshot);
117    bool displayTexture(GLuint64 textureHandle, bool bBringTabToFront);
118    void displayFramebuffer(GLuint64 framebufferHandle, bool bBringTabToFront);
119    bool displayShader(GLuint64 shaderHandle, bool bBringTabToFront);
120    void displayProgram(GLuint64 programHandle, bool bBringTabToFront);
121
122    // temp?
123    vogl_gl_state_snapshot *read_state_snapshot_from_trace(vogl_trace_file_reader* pTrace_reader);
124
125    void reset_tracefile_ui();
126    void reset_snapshot_ui();
127
128    void update_ui_for_snapshot(vogleditor_gl_state_snapshot *pStateSnapshot);
129    void displayMachineInfoHelper(QString prefix, const QString& sectionKeyStr, const vogl::json_value& value, QString& rMachineInfoStr);
130    void displayMachineInfo();
131    void recursive_update_snapshot_flags(vogleditor_apiCallTreeItem* pItem, bool& bFoundEditedSnapshot);
132
133    vogleditor_gl_state_snapshot* findMostRecentSnapshot_helper(vogleditor_apiCallTreeItem* pItem, vogleditor_gl_state_snapshot*& pMostRecentSnapshot, const vogleditor_gl_state_snapshot* pCurSnapshot);
134    vogleditor_gl_state_snapshot* findMostRecentSnapshot(vogleditor_apiCallTreeItem* pItem, const vogleditor_gl_state_snapshot* pCurSnapshot);
135
136    void selectApicallModelIndex(QModelIndex index, bool scrollTo, bool select);
137
138    void write_child_api_calls(vogleditor_apiCallTreeItem* pItem, FILE* pFile);
139
140    bool load_session_from_disk(QString sessionFile);
141    bool save_session_to_disk(QString sessionFile);
142    bool save_snapshot_to_disk(vogl_gl_state_snapshot* pSnapshot, dynamic_string filename, vogl_blob_manager *pBlob_manager);
143
144    QString m_openFilename;
145    QLabel* m_statusLabel;
146    vogleditor_QFramebufferExplorer* m_framebufferExplorer;
147    vogleditor_QTextureExplorer* m_textureExplorer;
148    vogleditor_QTextureExplorer* m_renderbufferExplorer;
149    vogleditor_QProgramExplorer* m_programExplorer;
150    vogleditor_QShaderExplorer* m_shaderExplorer;
151    vogleditor_QTimelineView* m_timeline;
152
153    vogleditor_gl_state_snapshot* m_currentSnapshot;
154    vogleditor_apiCallTreeItem* m_pCurrentCallTreeItem;
155
156    QToolButton* m_pPlayButton;
157    QToolButton* m_pPauseButton;
158    QToolButton* m_pTrimButton;
159    QToolButton* m_pStopButton;
160
161    vogleditor_traceReplayer m_traceReplayer;
162    vogl_trace_file_reader* m_pTraceReader;
163    vogl::json_document m_backtraceDoc;
164    vogl::hash_map<vogl::uint32, vogl::json_node*> m_backtraceToJsonMap;
165
166    vogleditor_apiCallTimelineModel* m_pTimelineModel;
167
168    vogleditor_QApiCallTreeModel* m_pApicallTreeModel;
169
170    QModelIndexList m_searchApicallResults;
171 };
172
173 #endif // VOGLEDITOR_H