9e85b51d9098758f72ce3e686c150f44c79b0f5c
[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() : inp(), currentAction(), m_actions(), m_labels(), m_index(0) {}
17         virtual ~DebugScript() {}
18         void Load(const char *filename)
19         {
20                 inp.open(filename);
21         }
22         bool Execute(View *view, Screen *scr);
23 private:
24         enum ActionType
25         {
26                 AT_WaitFrame,
27                 AT_Translate,
28                 AT_Zoom,
29                 AT_TranslatePx,
30                 AT_ZoomPx,
31                 AT_SetCPURendering,
32                 AT_SetGPURendering,
33                 AT_EnableLazyRendering,
34                 AT_DisableLazyRendering,
35                 AT_LoadSVG,
36                 AT_Label,
37                 AT_Goto,
38                 AT_Debug,
39                 AT_ClearDocument,
40                 AT_ClearPerformance,
41                 AT_PrintPerformance,
42                 AT_RecordPerformance,
43                 AT_DebugFont,
44                 AT_ApproachBoundsZeno,
45                 AT_ApproachBoundsLinear,
46                 AT_SetBounds,
47                 AT_QueryGPUBounds, // query bounds of Beziers when transformed to GPU
48                 AT_ScreenShot, // take screenshot
49                 AT_Quit
50         };
51
52         struct Action
53         {
54                 ActionType type;
55                 Real x, y;
56                 int ix, iy;
57                 Real z;
58                 int iz;
59                 int loops;
60                 Real w, h;
61                 std::string textargs;
62                 Action() : type(AT_WaitFrame), x(0), y(0), ix(0), iy(0), z(0), loops(0), textargs("") {}
63         };
64
65         std::ifstream inp;
66
67         Action currentAction;
68         std::vector<Action> m_actions;
69         std::map<std::string, int> m_labels;
70         unsigned m_index;
71         
72         struct PerformanceData
73         {
74                 clock_t clock;
75                 unsigned object_count;
76                 VRect view_bounds;
77         };
78         
79         PerformanceData m_perf_start;
80         PerformanceData m_perf_last;
81         
82         void PrintPerformance(View * view, Screen * scr);
83         void ClearPerformance(View * view, Screen * scr);
84         
85         void ParseAction(View * view, Screen * scr);
86 };
87
88 }
89
90 #endif

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