Index: tools/lua/scrape_dashing.lua |
diff --git a/tools/lua/scrape.lua b/tools/lua/scrape_dashing.lua |
similarity index 55% |
copy from tools/lua/scrape.lua |
copy to tools/lua/scrape_dashing.lua |
index 627018800acb2839f2b6be47dc63c4a1e2391bc7..48f353854ecb499ee2da9baf24f8bdf58077b5c3 100644 |
--- a/tools/lua/scrape.lua |
+++ b/tools/lua/scrape_dashing.lua |
@@ -18,7 +18,8 @@ function tostr(t) |
return str |
end |
-local total = {} -- accumulate() stores its data in here |
+local total_found = {} -- accumulate() stores its data in here |
+local total_total = {} |
local canvas -- holds the current canvas (from startcanvas()) |
--[[ |
@@ -43,29 +44,36 @@ function sk_scrape_endcanvas(c, fileName) |
canvas = nil |
end |
---[[ |
- Called with the parameters to each canvas.draw call, where canvas is the |
- current canvas as set by startcanvas() |
-]] |
+function increment(table, key) |
+ table[key] = (table[key] or 0) + 1 |
+end |
+ |
+ |
+local drawPointsTable = {} |
+local drawPointsTable_direction = {} |
+ |
function sk_scrape_accumulate(t) |
- local n = total[t.verb] or 0 |
- total[t.verb] = n + 1 |
+ increment(total_total, t.verb) |
- if false and t.verb == "drawRect" and t.paint:isAntiAlias() then |
- local r = t.rect; |
- local p = t.paint; |
- local c = p:getColor(); |
- print("drawRect ", tostr(r), tostr(c), "\n") |
+ local p = t.paint |
+ if p then |
+ local pe = p:getPathEffect(); |
+ if pe then |
+ increment(total_found, t.verb) |
+ end |
end |
- if false and t.verb == "drawPath" then |
- local pred, r1, r2, d1, d2 = t.path:isNestedRects() |
- |
- if pred then |
- print("drawRect_Nested", tostr(r1), tostr(r2), d1, d2) |
- else |
- print("drawPath", "isEmpty", tostring(t.path:isEmpty()), |
- "isRect", tostring(t.path:isRect()), tostr(t.path:getBounds())) |
+ 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 |
@@ -75,6 +83,11 @@ end |
"accumulated". |
]] |
function sk_scrape_summarize() |
- io.write("\n{ ", tostr(total), " }\n") |
+ 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 |