diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2012-06-06 13:52:43 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-15 15:12:42 +0100 |
commit | 3d78bc19c5b63541fd45dad7580ade55ba512764 (patch) | |
tree | f2d95055e6adfeb1a6b432aa83c28a5fc11f766f /scripts/pybootchartgui/pybootchartgui/batch.py | |
parent | bc19f8bc9c7c52365d3e7cc26f43a08a62a8492b (diff) | |
download | poky-3d78bc19c5b63541fd45dad7580ade55ba512764.tar.gz |
pybootchartgui: add the original code
This is from:
http://pybootchartgui.googlecode.com/files/pybootchartgui-r124.tar.gz
Will modify it to make the build profiling in pictures.
Remove the examples since they would not work any more, and they cost
much disk space.
[YOCTO #2403]
(From OE-Core rev: 1f0791109e1aed715f02945834d6d7fdb9a411b4)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/pybootchartgui/pybootchartgui/batch.py')
-rw-r--r-- | scripts/pybootchartgui/pybootchartgui/batch.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/batch.py b/scripts/pybootchartgui/pybootchartgui/batch.py new file mode 100644 index 0000000000..bd67c9350e --- /dev/null +++ b/scripts/pybootchartgui/pybootchartgui/batch.py | |||
@@ -0,0 +1,23 @@ | |||
1 | import cairo | ||
2 | |||
3 | import draw | ||
4 | |||
5 | def render(res, format, filename): | ||
6 | handlers = { | ||
7 | "png": (lambda w,h: cairo.ImageSurface(cairo.FORMAT_ARGB32,w,h), lambda sfc: sfc.write_to_png(filename)), | ||
8 | "pdf": (lambda w,h: cairo.PDFSurface(filename, w, h), lambda sfc: 0), | ||
9 | "svg": (lambda w,h: cairo.SVGSurface(filename, w, h), lambda sfc: 0) | ||
10 | } | ||
11 | |||
12 | if not(handlers.has_key(format)): | ||
13 | print "Unknown format '%s'." % format | ||
14 | return 10 | ||
15 | |||
16 | make_surface, write_surface = handlers[format] | ||
17 | w,h = draw.extents(*res) | ||
18 | w = max(w, draw.MIN_IMG_W) | ||
19 | surface = make_surface(w,h) | ||
20 | ctx = cairo.Context(surface) | ||
21 | draw.render(ctx, *res) | ||
22 | write_surface(surface) | ||
23 | |||