-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathglheapdiagram.h
101 lines (78 loc) · 2.86 KB
/
glheapdiagram.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef GLHEAPDIAGRAM_H
#define GLHEAPDIAGRAM_H
#include <memory>
#include <QOpenGLWidget>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions>
#include <QPoint>
#include "activeregionsdiagramlayer.h"
#include "addressdiagramlayer.h"
#include "eventdiagramlayer.h"
#include "glheapdiagramlayer.h"
#include "heapblockdiagramlayer.h"
#include "heaphistory.h"
#include "transform3d.h"
class OpenGLShaderProgram;
class GLHeapDiagram : public QOpenGLWidget, protected QOpenGLFunctions {
public:
explicit GLHeapDiagram(QWidget *parent = nullptr);
~GLHeapDiagram() override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
signals:
void frameSwapped();
void blockClicked(bool, HeapBlock);
void showMessage(std::string);
public slots:
void setFileToDisplay(const QString& filename);
void setSizeToHighlight(uint32_t size);
protected slots:
void update();
protected:
void initializeGL() override;
void paintGL() override;
void resizeGL(int width, int height) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
private:
Q_OBJECT
// This should be a power-of-2.
static constexpr uint32_t number_of_grid_lines_ = 16;
// Initialization of the GL members below.
void setupHeapblockGLStructures();
void setupGridGLStructures();
void updateHeapToScreenMap();
void updateUnitSquareToHeapMap();
void getScaleFromHeapToScreen(double* scale_x, double* scale_y);
void getScaleFromScreenToHeap(double* scale_x, double* scale_y);
bool screenToHeap(double, double, uint32_t* tick, uint64_t* address);
//void heapToScreen(uint32_t tick, uint64_t address, double*, double*);
void loadFileInternal();
void setHeapBaseUniforms();
void setTickBaseUniforms();
std::string file_to_load_;
// Blocks of this size will be highlighted.
uint32_t size_to_highlight_ = 0;
bool refresh_all_vertices_ = false;
// Gets set to true after the initializeGL() method runs.
bool is_GL_initialized_;
// Due to limited precision of floats, a straight mapping void setTickBaseUniforms();
// heap to the screen space can have a degenerate matrix with a zero
// entry. In order to prevent this, the scaling down is implemented
// with two matrices that are applied iteratively.
QMatrix2x2 heap_to_screen_matrix_;
std::unique_ptr<HeapBlockDiagramLayer> block_layer_;
std::unique_ptr<EventDiagramLayer> event_layer_;
std::unique_ptr<AddressDiagramLayer> address_layer_;
std::unique_ptr<ActiveRegionsDiagramLayer> pages_layer_;
// The heap history.
HeapHistory heap_history_;
// Last mouse position for dragging and selecting.
QPoint last_mouse_position_;
void setupUniformsForShaders();
void debugDumpVerticesAndMappings();
};
#endif // GLHEAPDIAGRAM_H