blob: 4ac8d9385fddc128b427c27bb27e2bb9499b0a5b [file] [log] [blame]
humper@google.com2815c192013-07-10 22:42:30 +00001function string.startsWith(String,Start)
2 return string.sub(String,1,string.len(Start))==Start
3end
4
5function string.endsWith(String,End)
6 return End=='' or string.sub(String,-string.len(End))==End
7end
8
humper@google.com2815c192013-07-10 22:42:30 +00009local canvas = nil
10local num_perspective_bitmaps = 0
11local num_affine_bitmaps = 0
12local num_scaled_bitmaps = 0
13local num_translated_bitmaps = 0
14local num_identity_bitmaps = 0
humper@google.com0f48ee02013-07-26 15:23:43 +000015local num_scaled_up = 0
16local num_scaled_down = 0
humper@google.com2815c192013-07-10 22:42:30 +000017
18function sk_scrape_startcanvas(c, fileName)
19 canvas = c
20end
21
22function sk_scrape_endcanvas(c, fileName)
23 canvas = nil
24end
25
26function sk_scrape_accumulate(t)
27 -- dump the params in t, specifically showing the verb first, which we
28 -- then nil out so it doesn't appear in tostr()
29 if (string.startsWith(t.verb,"drawBitmap")) then
30 matrix = canvas:getTotalMatrix()
31 matrixType = matrix:getType()
32 if matrixType.perspective then
33 num_perspective_bitmaps = num_perspective_bitmaps + 1
34 elseif matrixType.affine then
35 num_affine_bitmaps = num_affine_bitmaps + 1
36 elseif matrixType.scale then
37 num_scaled_bitmaps = num_scaled_bitmaps + 1
humper@google.com0f48ee02013-07-26 15:23:43 +000038 if matrix:getScaleX() > 1 or matrix:getScaleY() > 1 then
39 num_scaled_up = num_scaled_up + 1
40 else
41 num_scaled_down = num_scaled_down + 1
42 end
humper@google.com2815c192013-07-10 22:42:30 +000043 elseif matrixType.translate then
44 num_translated_bitmaps = num_translated_bitmaps + 1
45 else
46 num_identity_bitmaps = num_identity_bitmaps + 1
47 end
48 end
49end
50
51function sk_scrape_summarize()
52 io.write( "identity = ", num_identity_bitmaps,
53 ", translated = ", num_translated_bitmaps,
humper@google.com0f48ee02013-07-26 15:23:43 +000054 ", scaled = ", num_scaled_bitmaps, " (up = ", num_scaled_up, "; down = ", num_scaled_down, ")",
humper@google.com2815c192013-07-10 22:42:30 +000055 ", affine = ", num_affine_bitmaps,
humper@google.com9d5fedc2013-07-11 13:53:44 +000056 ", perspective = ", num_perspective_bitmaps,
57 "\n")
humper@google.com2815c192013-07-10 22:42:30 +000058end
59