Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: tools/lua/scrape.lua

Issue 15511006: add startcanvas/endcanvas entry-points for the script. rename all "official" entry-points to use "s… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/lua/lua_pictures.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 -- just a helper function to dump the parameters, for debugging 1 -- just a helper function to dump the parameters, for debugging
2 function tostr(t) 2 function tostr(t)
3 local str = "" 3 local str = ""
4 for k, v in next, t do 4 for k, v in next, t do
5 if #str > 0 then 5 if #str > 0 then
6 str = str .. ", " 6 str = str .. ", "
7 end 7 end
8 if type(k) == "number" then 8 if type(k) == "number" then
9 str = str .. "[" .. k .. "] = " 9 str = str .. "[" .. k .. "] = "
10 else 10 else
11 str = str .. tostring(k) .. " = " 11 str = str .. tostring(k) .. " = "
12 end 12 end
13 if type(v) == "table" then 13 if type(v) == "table" then
14 str = str .. "{ " .. tostr(v) .. " }" 14 str = str .. "{ " .. tostr(v) .. " }"
15 else 15 else
16 str = str .. tostring(v) 16 str = str .. tostring(v)
17 end 17 end
18 end 18 end
19 return str 19 return str
20 end 20 end
21 21
22 total = {} 22 local total = {} -- accumulate() stores its data in here
23 local canvas -- holds the current canvas (from startcanvas())
23 24
24 function setcanvas(c) 25 --[[
26 startcanvas() is called at the start of each picture file, passing the
27 canvas that we will be drawing into, and the name of the file.
28
29 Following this call, there will be some number of calls to accumulate(t)
30 where t is a table of parameters that were passed to that draw-op.
31
32 t.verb is a string holding the name of the draw-op (e.g. "drawRect")
33
34 when a given picture is done, we call endcanvas(canvas, fileName)
35 ]]
36 function sk_scrape_startcanvas(c, fileName)
25 canvas = c 37 canvas = c
26 end 38 end
27 39
28 -- called with the parameters to each canvas.draw call 40 --[[
29 function accumulate(t) 41 Called when the current canvas is done drawing.
42 ]]
43 function sk_scrape_endcanvas(c, fileName)
44 canvas = nil
45 end
46
47 --[[
48 Called with the parameters to each canvas.draw call, where canvas is the
49 current canvas as set by startcanvas()
50 ]]
51 function sk_scrape_accumulate(t)
30 local n = total[t.verb] or 0 52 local n = total[t.verb] or 0
31 total[t.verb] = n + 1 53 total[t.verb] = n + 1
32 54
33 if false and t.verb == "drawRect" then 55 if false and t.verb == "drawRect" then
34 local m = canvas:getTotalMatrix() 56 local m = canvas:getTotalMatrix()
35 print("... ", tostr(m), "\n") 57 print("... ", tostr(m), "\n")
36 end 58 end
37 59
38 -- enable to dump all of the parameters we were sent 60 -- enable to dump all of the parameters we were sent
39 if false then 61 if false then
40 -- dump the params in t, specifically showing the verb first, which we 62 -- dump the params in t, specifically showing the verb first, which we
41 -- then nil out so it doesn't appear in tostr() 63 -- then nil out so it doesn't appear in tostr()
42 io.write(t.verb, " ") 64 io.write(t.verb, " ")
43 t.verb = nil 65 t.verb = nil
44 io.write(tostr(t), "\n") 66 io.write(tostr(t), "\n")
45 end 67 end
46 end 68 end
47 69
48 -- lua_pictures will call this function after all of the files have been 70 --[[
49 -- "accumulated" 71 lua_pictures will call this function after all of the pictures have been
50 function summarize() 72 "accumulated".
51 io.write("\n", tostr(total), "\n") 73 ]]
74 function sk_scrape_summarize()
75 io.write("\n{ ", tostr(total), " }\n")
52 end 76 end
53 77
OLDNEW
« no previous file with comments | « tools/lua/lua_pictures.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698