diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-17 23:09:47 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-17 23:09:47 +0000 |
commit | 1301bf3abfe355f9aadd53d5dbf04926013231ba (patch) | |
tree | 56b0011989025e1c1dfcb920ad6ed4b4960183c4 /tools | |
parent | e4ff3e6fe8c2b93cce18da9e45bab95283259a35 (diff) |
add initial scraper for dashing
BUG=skia:
R=bsalomon@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/196603027
git-svn-id: http://skia.googlecode.com/svn/trunk@13843 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lua/scrape_dashing.lua | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/tools/lua/scrape_dashing.lua b/tools/lua/scrape_dashing.lua new file mode 100644 index 0000000000..48f353854e --- /dev/null +++ b/tools/lua/scrape_dashing.lua @@ -0,0 +1,93 @@ +function tostr(t) + local str = "" + for k, v in next, t do + if #str > 0 then + str = str .. ", " + end + if type(k) == "number" then + str = str .. "[" .. k .. "] = " + else + str = str .. tostring(k) .. " = " + end + if type(v) == "table" then + str = str .. "{ " .. tostr(v) .. " }" + else + str = str .. tostring(v) + end + end + return str +end + +local total_found = {} -- accumulate() stores its data in here +local total_total = {} +local canvas -- holds the current canvas (from startcanvas()) + +--[[ + startcanvas() is called at the start of each picture file, passing the + canvas that we will be drawing into, and the name of the file. + + Following this call, there will be some number of calls to accumulate(t) + where t is a table of parameters that were passed to that draw-op. + + t.verb is a string holding the name of the draw-op (e.g. "drawRect") + + when a given picture is done, we call endcanvas(canvas, fileName) +]] +function sk_scrape_startcanvas(c, fileName) + canvas = c +end + +--[[ + Called when the current canvas is done drawing. +]] +function sk_scrape_endcanvas(c, fileName) + canvas = nil +end + +function increment(table, key) + table[key] = (table[key] or 0) + 1 +end + + +local drawPointsTable = {} +local drawPointsTable_direction = {} + +function sk_scrape_accumulate(t) + increment(total_total, t.verb) + + local p = t.paint + if p then + local pe = p:getPathEffect(); + if pe then + increment(total_found, t.verb) + end + end + + if "drawPoints" == t.verb then + local points = t.points + increment(drawPointsTable, #points) + if 2 == #points then + if points[1].y == points[2].y then + increment(drawPointsTable_direction, "hori") + elseif points[1].x == points[2].x then + increment(drawPointsTable_direction, "vert") + else + increment(drawPointsTable_direction, "other") + end + end + end +end + +--[[ + lua_pictures will call this function after all of the pictures have been + "accumulated". +]] +function sk_scrape_summarize() + for k, v in next, total_found do + io.write(k, " = ", v, "/", total_total[k], "\n") + end + print("histogram of point-counts for all drawPoints calls") + print(tostr(drawPointsTable)) + print(tostr(drawPointsTable_direction)) +end + |