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

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

Issue 2150663002: Add verb field in scraping scripts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | tools/lua/gradients.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function sk_scrape_startcanvas(c, fileName) end 1 function sk_scrape_startcanvas(c, fileName) end
2 function sk_scrape_endcanvas(c, fileName) end 2 function sk_scrape_endcanvas(c, fileName) end
3 3
4 LuaDoubleNearlyZero = 1.0 / bit32.lshift(1.0, 12) 4 LuaDoubleNearlyZero = 1.0 / bit32.lshift(1.0, 12)
5 5
6 function LuaDoubleNearlyEqual(a, b) 6 function LuaDoubleNearlyEqual(a, b)
7 return math.abs(a-b) <= LuaDoubleNearlyZero 7 return math.abs(a-b) <= LuaDoubleNearlyZero
8 end 8 end
9 9
10 verbs = {}
10 gradients = {} 11 gradients = {}
11 12
12 i = 1 13 i = 1
13 14
14 function sk_scrape_accumulate(t) 15 function sk_scrape_accumulate(t)
15 local p = t.paint 16 local p = t.paint
16 if p then 17 if p then
17 local s = p:getShader() 18 local s = p:getShader()
18 if s then 19 if s then
19 local g = s:asAGradient() 20 local g = s:asAGradient()
20 if g then 21 if g then
22 if verbs[t.verb] then
23 verbs[t.verb] = verbs[t.verb] + 1
24 else
25 verbs[t.verb] = 1
26 end
27
21 gradients[i] = {} 28 gradients[i] = {}
22 29
23 gradients[i].colorCount = g.colorCount 30 gradients[i].colorCount = g.colorCount
24 gradients[i].type = g.type 31 gradients[i].type = g.type
25 gradients[i].tile = g.tile 32 gradients[i].tile = g.tile
26 33
27 isEvenlySpaced = true 34 isEvenlySpaced = true
28 for j = 1, g.colorCount, 1 do 35 for j = 1, g.colorCount, 1 do
29 if not LuaDoubleNearlyEqual(g.positions[j], (j-1)/(g.colorCo unt-1)) then 36 if not LuaDoubleNearlyEqual(g.positions[j], (j-1)/(g.colorCo unt-1)) then
30 isEvenlySpaced = false 37 isEvenlySpaced = false
31 end 38 end
32 end 39 end
33 gradients[i].isEvenlySpaced = isEvenlySpaced 40 gradients[i].isEvenlySpaced = isEvenlySpaced
34 41
35 numHardStops = 0 42 numHardStops = 0
36 for j = 2, g.colorCount, 1 do 43 for j = 2, g.colorCount, 1 do
37 if LuaDoubleNearlyEqual(g.positions[j], g.positions[j-1]) th en 44 if LuaDoubleNearlyEqual(g.positions[j], g.positions[j-1]) th en
38 numHardStops = numHardStops + 1 45 numHardStops = numHardStops + 1
39 end 46 end
40 end 47 end
41 gradients[i].numHardStops = numHardStops; 48 gradients[i].numHardStops = numHardStops
42 49
50 gradients[i].verb = t.verb
51
43 gradients[i].positions = {} 52 gradients[i].positions = {}
44 for j = 1, g.colorCount, 1 do 53 for j = 1, g.colorCount, 1 do
45 gradients[i].positions[j] = g.positions[j] 54 gradients[i].positions[j] = g.positions[j]
46 end 55 end
47 56
48 i = i + 1 57 i = i + 1
49 end 58 end
50 end 59 end
51 end 60 end
52 end 61 end
53 62
54 function sk_scrape_summarize() 63 function sk_scrape_summarize()
55 for k, v in pairs(gradients) do 64 for k, v in pairs(gradients) do
56 local pos = "" 65 local pos = ""
57 for j = 1, v.colorCount , 1 do 66 for j = 1, v.colorCount , 1 do
58 pos = pos .. v.positions[j] 67 pos = pos .. v.positions[j]
59 if j ~= v.colorCount then 68 if j ~= v.colorCount then
60 pos = pos .. "," 69 pos = pos .. ","
61 end 70 end
62 end 71 end
63 72
64 io.write(string.format("%d %s %s %d %d %s\n", 73 io.write(string.format("%d %s %s %d %d %s %s\n",
65 v.colorCount, 74 v.colorCount,
66 v.type, 75 v.type,
67 v.tile, 76 v.tile,
68 tonumber(v.isEvenlySpaced and 1 or 0), 77 tonumber(v.isEvenlySpaced and 1 or 0),
69 v.numHardStops, 78 v.numHardStops,
79 v.verb,
70 pos)) 80 pos))
71 end 81 end
72 end 82 end
73 83
OLDNEW
« no previous file with comments | « no previous file | tools/lua/gradients.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698