aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar krajcevski <krajcevski@google.com>2014-08-18 07:52:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-18 07:52:25 -0700
commit0f149e5a78842c920c0ce1e1ac45f54473c11f05 (patch)
tree80b0ebb6ff919ef015519f3892685c6b5fc50f3a /tools
parentb1aded8edd1d809cded20ff546c6e9218b43cda4 (diff)
Add scraper to find paths that fallback to software
R=robertphillips@google.com, krajcevski@gmail.com Author: krajcevski@google.com Review URL: https://codereview.chromium.org/475433004
Diffstat (limited to 'tools')
-rw-r--r--tools/lua/paths.lua124
-rw-r--r--tools/lua/paths_agg.lua41
2 files changed, 165 insertions, 0 deletions
diff --git a/tools/lua/paths.lua b/tools/lua/paths.lua
new file mode 100644
index 0000000000..0fa65288e1
--- /dev/null
+++ b/tools/lua/paths.lua
@@ -0,0 +1,124 @@
+--
+-- Copyright 2014 Google Inc.
+--
+-- Use of this source code is governed by a BSD-style license that can be
+-- found in the LICENSE file.
+--
+
+-- Path scraping script.
+-- This script is designed to count the number of times we fall back to software
+-- rendering for a path in a given SKP. However, this script does not count an exact
+-- number of uploads, since there is some overlap with clipping: e.g. two clipped paths
+-- may cause three uploads to the GPU (set clip 1, set clip 2, unset clip 2/reset clip 1),
+-- but these cases are rare.
+
+draws = 0
+drawPaths = 0
+drawPathsAnti = 0
+drawPathsConvexAnti = 0
+
+clips = 0
+clipPaths = 0
+clipPathsAnti = 0
+clipPathsConvexAnti = 0
+
+usedPath = false
+usedSWPath = false
+
+skpsTotal = 0
+skpsWithPath = 0
+skpsWithSWPath = 0
+
+function sk_scrape_startcanvas(c, fileName)
+ usedPath = false
+ usedSWPath = false
+end
+
+function sk_scrape_endcanvas(c, fileName)
+ skpsTotal = skpsTotal + 1
+ if usedPath then
+ skpsWithPath = skpsWithPath + 1
+ if usedSWPath then
+ skpsWithSWPath = skpsWithSWPath + 1
+ end
+ end
+end
+
+function string.starts(String,Start)
+ return string.sub(String,1,string.len(Start))==Start
+end
+
+function isPathValid(path)
+ if not path then
+ return false
+ end
+
+ if path:isEmpty() then
+ return false
+ end
+
+ if path:isRect() then
+ return false
+ end
+
+ return true
+end
+
+function sk_scrape_accumulate(t)
+ if (string.starts(t.verb, "draw")) then
+ draws = draws + 1
+ end
+
+ if (string.starts(t.verb, "clip")) then
+ clips = clips + 1
+ end
+
+ if t.verb == "clipPath" then
+ local path = t.path
+ if isPathValid(path) then
+ clipPaths = clipPaths + 1
+ usedPath = true
+ if t.aa then
+ clipPathsAnti = clipPathsAnti + 1
+ if path:isConvex() then
+ clipPathsConvexAnti = clipPathsConvexAnti + 1
+ else
+ usedSWPath = true
+ end
+ end
+ end
+ end
+
+ if t.verb == "drawPath" then
+ local path = t.path
+ local paint = t.paint
+ if paint and isPathValid(path) then
+ drawPaths = drawPaths + 1
+ usedPath = true
+ if paint:isAntiAlias() then
+ drawPathsAnti = drawPathsAnti + 1
+ if path:isConvex() then
+ drawPathsConvexAnti = drawPathsConvexAnti + 1
+ else
+ usedSWPath = true
+ end
+ end
+ end
+ end
+end
+
+function sk_scrape_summarize()
+ local swDrawPaths = drawPathsAnti - drawPathsConvexAnti
+ local swClipPaths = clipPathsAnti - clipPathsConvexAnti
+
+ io.write("clips = clips + ", clips, "\n");
+ io.write("draws = draws + ", draws, "\n");
+ io.write("clipPaths = clipPaths + ", clipPaths, "\n");
+ io.write("drawPaths = drawPaths + ", drawPaths, "\n");
+ io.write("swClipPaths = swClipPaths + ", swClipPaths, "\n");
+ io.write("swDrawPaths = swDrawPaths + ", swDrawPaths, "\n");
+
+ io.write("skpsTotal = skpsTotal + ", skpsTotal, "\n");
+ io.write("skpsWithPath = skpsWithPath + ", skpsWithPath, "\n");
+ io.write("skpsWithSWPath = skpsWithSWPath + ", skpsWithSWPath, "\n");
+end
diff --git a/tools/lua/paths_agg.lua b/tools/lua/paths_agg.lua
new file mode 100644
index 0000000000..deb212e7d6
--- /dev/null
+++ b/tools/lua/paths_agg.lua
@@ -0,0 +1,41 @@
+
+clips = 0
+draws = 0
+clipPaths = 0
+drawPaths = 0
+swClipPaths = 0
+swDrawPaths = 0
+
+skpsTotal = 0
+skpsWithPath = 0
+skpsWithSWPath = 0
+
+dofile("/tmp/lua-output")
+
+io.write("Number of clips: ", clips, "\n");
+io.write("Number of draws: ", draws, "\n");
+io.write("Number of clipped paths: ", clipPaths, "\n");
+io.write("Number of drawn paths: ", drawPaths, "\n");
+io.write("Number of clipped software paths: ", swClipPaths, "\n");
+io.write("Number of drawn software paths: ", swDrawPaths, "\n");
+
+io.write("\n")
+
+io.write("Number of SKPs total: ", skpsTotal, "\n")
+io.write("Number of SKPs that draw paths: ", skpsWithPath, "\n")
+io.write("Number of SKPs that draw SW paths: ", skpsWithSWPath, "\n")
+
+io.write("\n")
+io.write("\n")
+
+totalSWPaths = swDrawPaths + swClipPaths
+totalPaths = drawPaths + clipPaths
+
+io.write("Percentage of paths needing software: ", (100*(totalSWPaths / totalPaths)), "\n")
+io.write("Percentage of draws/clips needing software: ",
+ (100*(totalSWPaths / (draws + clips))), "\n")
+
+io.write("\n")
+
+io.write("Percentage of SKPs that draw paths: ", (100*(skpsWithPath / skpsTotal)), "\n")
+io.write("Percentage of SKPs that draw SW paths: ", (100*(skpsWithSWPath / skpsTotal)), "\n")