Add hard stop count
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2141733002 Review-Url: https://codereview.chromium.org/2141733002
This commit is contained in:
parent
e7d15fe870
commit
7f2c85e66b
@ -1275,23 +1275,10 @@ static int lshader_asAGradient(lua_State* L) {
|
||||
info.fColorOffsets = pos.get();
|
||||
shader->asAGradient(&info);
|
||||
|
||||
bool containsHardStops = false;
|
||||
bool isEvenlySpaced = true;
|
||||
for (int i = 1; i < info.fColorCount; i++) {
|
||||
if (SkScalarNearlyEqual(info.fColorOffsets[i], info.fColorOffsets[i-1])) {
|
||||
containsHardStops = true;
|
||||
}
|
||||
if (!SkScalarNearlyEqual(info.fColorOffsets[i], i/(info.fColorCount - 1.0f))) {
|
||||
isEvenlySpaced = false;
|
||||
}
|
||||
}
|
||||
|
||||
lua_newtable(L);
|
||||
setfield_string(L, "type", gradtype2string(t));
|
||||
setfield_string(L, "tile", mode2string(info.fTileMode));
|
||||
setfield_number(L, "colorCount", info.fColorCount);
|
||||
setfield_boolean(L, "containsHardStops", containsHardStops);
|
||||
setfield_boolean(L, "isEvenlySpaced", isEvenlySpaced);
|
||||
setfield_string(L, "type", gradtype2string(t));
|
||||
setfield_string(L, "tile", mode2string(info.fTileMode));
|
||||
setfield_number(L, "colorCount", info.fColorCount);
|
||||
|
||||
lua_newtable(L);
|
||||
for (int i = 0; i < info.fColorCount; i++) {
|
||||
|
@ -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)
|
||||
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2015 Google Inc.
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
@ -12,12 +12,12 @@ def create_database(inpath, outpath):
|
||||
with sqlite3.connect(outpath) as conn:
|
||||
c = conn.cursor();
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS gradients (
|
||||
ColorCount INTEGER,
|
||||
GradientType TEXT,
|
||||
TileMode TEXT,
|
||||
EvenlySpaced INTEGER,
|
||||
HardStops INTEGER,
|
||||
Positions TEXT
|
||||
ColorCount INTEGER,
|
||||
GradientType TEXT,
|
||||
TileMode TEXT,
|
||||
EvenlySpaced INTEGER,
|
||||
HardStopCount INTEGER,
|
||||
Positions TEXT
|
||||
)''');
|
||||
c.execute("DELETE FROM gradients");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user