Really hacky python performance scripts!
[ipdf/code.git] / src / debugscript.h
1 #ifndef _DEBUGSCRIPT_H
2 #define _DEBUGSCRIPT_H
3
4 #include "real.h"
5 #include "view.h"
6 #include "screen.h"
7 #include <iostream>
8 #include <fstream>
9
10 namespace IPDF
11 {
12
13 class DebugScript
14 {
15 public:
16         DebugScript(std::istream * in) : m_input(in), currentAction(), m_actions(), m_labels(), m_index(0) {}
17         virtual ~DebugScript() {}
18
19         bool Execute(View *view, Screen *scr);
20 private:
21         enum ActionType
22         {
23                 AT_WaitFrame,
24                 AT_Translate,
25                 AT_Zoom,
26                 AT_TranslatePx,
27                 AT_ZoomPx,
28                 AT_SetCPURendering,
29                 AT_SetGPURendering,
30                 AT_EnableLazyRendering,
31                 AT_DisableLazyRendering,
32                 AT_LoadSVG,
33                 AT_Label,
34                 AT_Goto,
35                 AT_Debug,
36                 AT_ClearDocument,
37                 AT_ClearPerformance,
38                 AT_PrintPerformance,
39                 AT_RecordPerformance,
40                 AT_DebugFont,
41                 AT_ApproachBoundsZeno,
42                 AT_ApproachBoundsLinear,
43                 AT_SetBounds,
44                 AT_QueryGPUBounds, // query bounds of Beziers when transformed to GPU
45                 AT_ScreenShot, // take screenshot
46                 AT_Quit
47         };
48
49         struct Action
50         {
51                 ActionType type;
52                 Real x, y;
53                 int ix, iy;
54                 Real z;
55                 int iz;
56                 int loops;
57                 Real w, h;
58                 std::string textargs;
59                 Action() : type(AT_WaitFrame), x(0), y(0), ix(0), iy(0), z(0), loops(0), textargs("") {}
60         };
61
62         std::istream * m_input;
63
64         Action currentAction;
65         std::vector<Action> m_actions;
66         std::map<std::string, int> m_labels;
67         unsigned m_index;
68         
69         struct PerformanceData
70         {
71                 clock_t clock;
72                 unsigned object_count;
73                 VRect view_bounds;
74         };
75         
76         PerformanceData m_perf_start;
77         PerformanceData m_perf_last;
78         
79         void PrintPerformance(View * view, Screen * scr);
80         void ClearPerformance(View * view, Screen * scr);
81         
82         void ParseAction(View * view, Screen * scr);
83 };
84
85 }
86
87 #endif

UCC git Repository :: git.ucc.asn.au