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

Unified Diff: src/utils/SkLua.cpp

Issue 2103973002: Changes to Lua gradient scraping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Count number of hard stops 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
« no previous file with comments | « no previous file | tools/lua/gradients.lua » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkLua.cpp
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index e6d5d4c5ffa10145e5b3be7baa39385eb65a03e2..2429d9934f39c8d20a92ea61e07c96f7616bd58f 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -1275,11 +1275,11 @@ static int lshader_asAGradient(lua_State* L) {
info.fColorOffsets = pos.get();
shader->asAGradient(&info);
- bool containsHardStops = false;
- bool isEvenlySpaced = true;
+ int numHardStops = 0;
+ bool isEvenlySpaced = true;
for (int i = 1; i < info.fColorCount; i++) {
if (SkScalarNearlyEqual(info.fColorOffsets[i], info.fColorOffsets[i-1])) {
- containsHardStops = true;
+ numHardStops++;
}
if (!SkScalarNearlyEqual(info.fColorOffsets[i], i/(info.fColorCount - 1.0f))) {
isEvenlySpaced = false;
@@ -1287,11 +1287,11 @@ static int lshader_asAGradient(lua_State* L) {
}
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);
+ setfield_number(L, "numHardStops", numHardStops);
+ setfield_boolean(L, "isEvenlySpaced", isEvenlySpaced);
lua_newtable(L);
for (int i = 0; i < info.fColorCount; i++) {
« no previous file with comments | « no previous file | tools/lua/gradients.lua » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698