1function 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 9local 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 15local num_scaled_up = 0 16local num_scaled_down = 0 17 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 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 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 49end 50 51function sk_scrape_summarize() 52 io.write( "identity = ", num_identity_bitmaps, 53 ", translated = ", num_translated_bitmaps, 54 ", scaled = ", num_scaled_bitmaps, " (up = ", num_scaled_up, "; down = ", num_scaled_down, ")", 55 ", affine = ", num_affine_bitmaps, 56 ", perspective = ", num_perspective_bitmaps, 57 "\n") 58end 59 60