Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(765)

Side by Side Diff: tools/lua/count_dashes.lua

Issue 2199823002: Add code to lua paths to get the fill path and get lists of verbs and (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Various minor fixes from Mike's comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/utils/SkLua.cpp ('K') | « src/utils/SkLua.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 --
2 -- Copyright 2016 Google Inc.
3 --
4 -- Use of this source code is governed by a BSD-style license that can be
5 -- found in the LICENSE file.
6 --
7
8 -- Dashed path scraping script.
9 -- This script is designed to count the total number of dashes in a dashed path
10 -- by computing the fill path and then counting how many individual segments are
11 -- inside the resulting fill path.
12
13 dashes = 0
14
15 pathPieces = {}
16
17 function sk_scrape_startcanvas(c, fileName)
18 end
19
20 function sk_scrape_endcanvas(c, fileName)
21 end
22
23 function sk_scrape_accumulate(t)
24 local paint = t.paint
25 if paint then
26 local pe = paint:getPathEffect()
27 if pe then
28 local dash = pe:asADash()
29 if dash and t.verb == "drawPath" then
reed1 2016/08/01 21:17:21 we're still creating the dash object even when the
Harry Stern 2016/08/01 22:07:33 Oh, I see. I thought you were just saying that I h
30 dashes = dashes + 1
31 pathPieces[dashes] = 0
32
33 local path = t.path
34 local fillpath = paint:getFillPath(path)
35 local verbs = fillpath:getVerbs()
36 for _, verb in ipairs(verbs) do
37 if verb == "move" then
38 pathPieces[dashes] = pathPieces[dashes] + 1
39 end
40 end
41 end
42 end
43 end
44 end
45
46 -- We mulitply by two because for each segment of the dash, we do two measuremen ts:
47 -- One for the beginning and one for the end of each dash.
48 function sk_scrape_summarize()
49 local pieces5 = 0;
50 local pieces10 = 0;
51 for _, p in ipairs(pathPieces) do
52 local pieces = 2*p
53 if pieces < 5 then
54 pieces5 = pieces5 + 1
55 end
56 if pieces > 5 and pieces < 10 then
57 pieces10 = pieces10 + 1
58 end
59 end
60 io.write(string.format("%d %d %d\n", 2*dashes, pieces5, pieces10))
61 end
OLDNEW
« src/utils/SkLua.cpp ('K') | « src/utils/SkLua.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698