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

Unified Diff: tools/lua/gradients.lua

Issue 2141733002: Add hard stop count (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unnecessary code in SkLua.cpp 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 side-by-side diff with in-line comments
Download patch
Index: tools/lua/gradients.lua
diff --git a/tools/lua/gradients.lua b/tools/lua/gradients.lua
index 628632817f9c2dc0c236ebe243058b0261b8af61..fb43017b1d8c6cb20d72d467d56c7b74fa7ad26e 100644
--- a/tools/lua/gradients.lua
+++ b/tools/lua/gradients.lua
@@ -1,6 +1,12 @@
function sk_scrape_startcanvas(c, fileName) end
function sk_scrape_endcanvas(c, fileName) end
+SkScalarNearlyZero = 1.0 / bit32.lshift(1.0, 12)
reed1 2016/07/12 15:44:46 since lua just has doubles, I don't think it helps
+
+function SkScalarNearlyEqual(a, b)
+ return math.abs(a,b) <= SkScalarNearlyZero
+end
+
gradients = {}
i = 1
@@ -13,11 +19,25 @@ function sk_scrape_accumulate(t)
local g = s:asAGradient()
if g then
gradients[i] = {}
- gradients[i].colorCount = g.colorCount
- gradients[i].type = g.type
- gradients[i].tile = g.tile
- gradients[i].isEvenlySpaced = g.isEvenlySpaced
- gradients[i].containsHardStops = g.containsHardStops
+
+ gradients[i].colorCount = g.colorCount
+ gradients[i].type = g.type
+ gradients[i].tile = g.tile
+
+ numHardStops = 0
+ isEvenlySpaced = true
+ for j = 2, g.colorCount, 1 do
+ if not SkScalarNearlyEqual(g.positions[j], j/(g.colorCount-1)) then
+ isEvenlySpaced = false
+ end
+
+ if SkScalarNearlyEqual(g.positions[j], g.positions[j-1]) then
+ numHardStops = numHardStops + 1
+ end
+ end
+
+ gradients[i].isEvenlySpaced = isEvenlySpaced
+ gradients[i].numHardStops = numHardStops;
gradients[i].positions = {}
for j = 1, g.colorCount, 1 do
@@ -45,7 +65,7 @@ function sk_scrape_summarize()
v.type,
v.tile,
tonumber(v.isEvenlySpaced and 1 or 0),
- tonumber(v.containsHardStops and 1 or 0),
+ v.numHardStops,
pos))
end
end
« no previous file with comments | « src/utils/SkLua.cpp ('k') | tools/lua/gradients.py » ('j') | tools/lua/gradients.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698