#include <string>
using namespace IPDF;
+using namespace std;
void DebugScript::ParseAction(View * view, Screen * scr)
{
+ if (m_input == NULL || !m_input->good())
+ return;
+ istream & inp = *m_input;
+ Debug("Get action type...");
std::string actionType;
inp >> actionType;
+ Debug("Action type: %s", actionType.c_str());
// Skip comments
while (actionType[0] == '#')
{
{
currentAction.type = AT_QueryGPUBounds;
inp >> currentAction.textargs;
+ currentAction.loops = 1;
}
else if (actionType == "screenshot")
{
currentAction.type = AT_ScreenShot;
inp >> currentAction.textargs;
}
+ else
+ Fatal("Unknown action %s", actionType.c_str());
}
class DebugScript
{
public:
- DebugScript() : inp(), currentAction(), m_actions(), m_labels(), m_index(0) {}
+ DebugScript(std::istream * in) : m_input(in), currentAction(), m_actions(), m_labels(), m_index(0) {}
virtual ~DebugScript() {}
- void Load(const char *filename)
- {
- inp.open(filename);
- }
+
bool Execute(View *view, Screen *scr);
private:
enum ActionType
Action() : type(AT_WaitFrame), x(0), y(0), ix(0), iy(0), z(0), loops(0), textargs("") {}
};
- std::ifstream inp;
+ std::istream * m_input;
Action currentAction;
std::vector<Action> m_actions;
label start
setbounds 0 0 1 1
+gpubounds
loadsvg svg-tests/fox-vector.svg
-querygpubounds original.dat
-screenshot original.bmp
-loop 1950 pxzoom 0 0 -1
-loop 200 wait
-debug hi
-loop 1950 pxzoom 0 0 1
-querygpubounds transformed.dat
-screenshot transformed.bmp
+approachz 0.5 0.5 1e-37 1e-37 2
+loadsvg svg-tests/fox-vector.svg
+approachz 0 0 1 1 2
+approachz 0.5 0.5 1e-37 1e-37 2
wait
void MainLoop(Document & doc, Screen & scr, View & view, int max_frames = -1)
{
// order is important... segfaults occur when screen (which inits GL) is not constructed first -_-
- DebugScript script;
+
scr.DebugFontInit("fonts/DejaVuSansMono.ttf", 12);
//scr.DebugFontInit("fonts/DejaVuSansMono.ttf", 18);
scr.SetMouseHandler(RatCatcher);
- if (script_filename)
+ ifstream tmp;
+ istream * script_input = NULL;
+ if (script_filename != NULL)
{
- script.Load(script_filename);
+ if (strcmp(script_filename, "stdin") == 0)
+ script_input = &cin;
+ else
+ {
+ tmp.open(script_filename);
+ script_input = &tmp;
+ }
}
+ DebugScript script(script_input);
double total_cpu_time = 0;
double total_gpu_time = 0;
--- /dev/null
+#!/usr/bin/python -u
+
+import sys
+import os
+from pylab import *
+import subprocess
+import time
+
+import gpubounds_error
+
+def grid_scaling(binname, x0, y0, w0, h0, s, steps=100,testsvg="svg-tests/grid.svg"):
+ data = []
+ n = open("/dev/null", "w")
+ p = subprocess.Popen(binname + " -s stdin", bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=n, shell=True)
+ p.stdin.write("setbounds %s %s %s %s\n" % (str(x0),str(y0),str(w0),str(h0)))
+ p.stdin.write("loadsvg %s\n" % testsvg)
+ p.stdin.write("querygpubounds original.dat\n")
+ p.stdin.write("screenshot original.bmp\n")
+ for i in xrange(steps):
+ p.stdin.write("clear\n")
+ p.stdin.write("loop 1 zoom 0.5 0.5 %s\n" % str(s))
+ p.stdin.write("loadsvg %s\n" % testsvg)
+ p.stdin.write("querygpubounds step%d.dat\n" % i)
+ while not os.path.isfile("step%d.dat" % i):
+ pass
+ p.stdin.write("clearperf\n")
+ p.stdin.write("loop 10 wait\n")
+ p.stdin.write("recordperf\n")
+ p.stdin.write("printperf\n")
+ perf = p.stdout.readline()
+ time.sleep(0.5)
+ data += [gpubounds_error.ComputeError("original.dat", "step%d.dat" % i)]
+ #data += [gpubounds_error.UniqueBounds("step%d.dat" % i)]
+
+
+ print "Quit"
+ p.stdin.write("screenshot final.bmp\n")
+ p.stdin.write("quit\n")
+ p.stdin.close()
+
+ data = asarray(data)
+ plot(data)
+ show(block=True)
+
+
+if __name__ == "__main__":
+ binname = "../src/ipdf"
+ if len(sys.argv) > 1:
+ binname = sys.argv[1]
+ grid_scaling(binname, 0.5, 0.5, 1, 1, 0.5)