2 -- Copyright 2014 Google Inc.
4 -- Use of this source code is governed by a BSD-style license that can be
5 -- found in the LICENSE file.
8 -- Path scraping script.
9 -- This script is designed to count the number of times we fall back to software
10 -- rendering for a path in a given SKP. However, this script does not count an exact
11 -- number of uploads, since there is some overlap with clipping: e.g. two clipped paths
12 -- may cause three uploads to the GPU (set clip 1, set clip 2, unset clip 2/reset clip 1),
13 -- but these cases are rare.
18 drawPathsConvexAnti = 0
23 clipPathsConvexAnti = 0
32 function sk_scrape_startcanvas(c, fileName)
37 function sk_scrape_endcanvas(c, fileName)
38 skpsTotal = skpsTotal + 1
40 skpsWithPath = skpsWithPath + 1
42 skpsWithSWPath = skpsWithSWPath + 1
47 function string.starts(String,Start)
48 return string.sub(String,1,string.len(Start))==Start
51 function isPathValid(path)
56 if path:isEmpty() then
67 function sk_scrape_accumulate(t)
68 if (string.starts(t.verb, "draw")) then
72 if (string.starts(t.verb, "clip")) then
76 if t.verb == "clipPath" then
78 if isPathValid(path) then
79 clipPaths = clipPaths + 1
82 clipPathsAnti = clipPathsAnti + 1
83 if path:isConvex() then
84 clipPathsConvexAnti = clipPathsConvexAnti + 1
92 if t.verb == "drawPath" then
95 if paint and isPathValid(path) then
96 drawPaths = drawPaths + 1
98 if paint:isAntiAlias() then
99 drawPathsAnti = drawPathsAnti + 1
100 if path:isConvex() then
101 drawPathsConvexAnti = drawPathsConvexAnti + 1
110 function sk_scrape_summarize()
111 local swDrawPaths = drawPathsAnti - drawPathsConvexAnti
112 local swClipPaths = clipPathsAnti - clipPathsConvexAnti
114 io.write("clips = clips + ", clips, "\n");
115 io.write("draws = draws + ", draws, "\n");
116 io.write("clipPaths = clipPaths + ", clipPaths, "\n");
117 io.write("drawPaths = drawPaths + ", drawPaths, "\n");
118 io.write("swClipPaths = swClipPaths + ", swClipPaths, "\n");
119 io.write("swDrawPaths = swDrawPaths + ", swDrawPaths, "\n");
121 io.write("skpsTotal = skpsTotal + ", skpsTotal, "\n");
122 io.write("skpsWithPath = skpsWithPath + ", skpsWithPath, "\n");
123 io.write("skpsWithSWPath = skpsWithSWPath + ", skpsWithSWPath, "\n");