Merge branch 'master' of git.ucc.asn.au:ipdf/code
[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_PrintFPS, // Print FPS statistics about the frames
47                 AT_PrintBounds, // Print bounds
48                 AT_Quit
49         };
50
51         struct Action
52         {
53                 ActionType type;
54                 Real x, y;
55                 int ix, iy;
56                 Real z;
57                 int iz;
58                 int loops;
59                 Real w, h;
60                 std::string textargs;
61                 Action() : type(AT_WaitFrame), x(0), y(0), ix(0), iy(0), z(0), loops(0), textargs("") {}
62         };
63
64         std::istream * m_input;
65
66         Action currentAction;
67         std::vector<Action> m_actions;
68         std::map<std::string, int> m_labels;
69         unsigned m_index;
70         
71         double m_fps_cpu_mean;
72         double m_fps_gpu_mean;
73         double m_fps_cpu_stddev;
74         double m_fps_gpu_stddev;
75         
76         struct PerformanceData
77         {
78                 clock_t clock;
79                 unsigned object_count;
80                 VRect view_bounds;
81         };
82         
83         PerformanceData m_perf_start;
84         PerformanceData m_perf_last;
85         
86         void PrintPerformance(View * view, Screen * scr);
87         void ClearPerformance(View * view, Screen * scr);
88         
89         void ParseAction(View * view, Screen * scr);
90 };
91
92 }
93
94 #endif

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