humper@google.com | 2815c19 | 2013-07-10 22:42:30 +0000 | [diff] [blame] | 1 | function string.startsWith(String,Start) |
| 2 | return string.sub(String,1,string.len(Start))==Start |
| 3 | end |
| 4 | |
| 5 | function string.endsWith(String,End) |
| 6 | return End=='' or string.sub(String,-string.len(End))==End |
| 7 | end |
| 8 | |
humper@google.com | 2815c19 | 2013-07-10 22:42:30 +0000 | [diff] [blame] | 9 | local canvas = nil |
| 10 | local num_perspective_bitmaps = 0 |
| 11 | local num_affine_bitmaps = 0 |
| 12 | local num_scaled_bitmaps = 0 |
| 13 | local num_translated_bitmaps = 0 |
| 14 | local num_identity_bitmaps = 0 |
humper@google.com | 0f48ee0 | 2013-07-26 15:23:43 +0000 | [diff] [blame] | 15 | local num_scaled_up = 0 |
| 16 | local num_scaled_down = 0 |
humper@google.com | 2815c19 | 2013-07-10 22:42:30 +0000 | [diff] [blame] | 17 | |
| 18 | function sk_scrape_startcanvas(c, fileName) |
| 19 | canvas = c |
| 20 | end |
| 21 | |
| 22 | function sk_scrape_endcanvas(c, fileName) |
| 23 | canvas = nil |
| 24 | end |
| 25 | |
| 26 | function 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.com | 0f48ee0 | 2013-07-26 15:23:43 +0000 | [diff] [blame] | 38 | 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.com | 2815c19 | 2013-07-10 22:42:30 +0000 | [diff] [blame] | 43 | 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 |
| 49 | end |
| 50 | |
| 51 | function sk_scrape_summarize() |
| 52 | io.write( "identity = ", num_identity_bitmaps, |
| 53 | ", translated = ", num_translated_bitmaps, |
humper@google.com | 0f48ee0 | 2013-07-26 15:23:43 +0000 | [diff] [blame] | 54 | ", scaled = ", num_scaled_bitmaps, " (up = ", num_scaled_up, "; down = ", num_scaled_down, ")", |
humper@google.com | 2815c19 | 2013-07-10 22:42:30 +0000 | [diff] [blame] | 55 | ", affine = ", num_affine_bitmaps, |
humper@google.com | 9d5fedc | 2013-07-11 13:53:44 +0000 | [diff] [blame] | 56 | ", perspective = ", num_perspective_bitmaps, |
| 57 | "\n") |
humper@google.com | 2815c19 | 2013-07-10 22:42:30 +0000 | [diff] [blame] | 58 | end |
| 59 | |