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

Side by Side Diff: src/utils/SkLua.cpp

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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/lua/gradients.lua » ('j') | tools/lua/gradients.lua » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLua.h" 8 #include "SkLua.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 SkShader::GradientInfo info; 1268 SkShader::GradientInfo info;
1269 sk_bzero(&info, sizeof(info)); 1269 sk_bzero(&info, sizeof(info));
1270 1270
1271 SkShader::GradientType t = shader->asAGradient(&info); 1271 SkShader::GradientType t = shader->asAGradient(&info);
1272 1272
1273 if (SkShader::kNone_GradientType != t) { 1273 if (SkShader::kNone_GradientType != t) {
1274 SkAutoTArray<SkScalar> pos(info.fColorCount); 1274 SkAutoTArray<SkScalar> pos(info.fColorCount);
1275 info.fColorOffsets = pos.get(); 1275 info.fColorOffsets = pos.get();
1276 shader->asAGradient(&info); 1276 shader->asAGradient(&info);
1277 1277
1278 bool containsHardStops = false;
1279 bool isEvenlySpaced = true;
1280 for (int i = 1; i < info.fColorCount; i++) {
1281 if (SkScalarNearlyEqual(info.fColorOffsets[i], info.fColorOffset s[i-1])) {
1282 containsHardStops = true;
1283 }
1284 if (!SkScalarNearlyEqual(info.fColorOffsets[i], i/(info.fColorCo unt - 1.0f))) {
1285 isEvenlySpaced = false;
1286 }
1287 }
1288
1289 lua_newtable(L); 1278 lua_newtable(L);
1290 setfield_string(L, "type", gradtype2string(t)); 1279 setfield_string(L, "type", gradtype2string(t));
1291 setfield_string(L, "tile", mode2string(info.fTileMode )); 1280 setfield_string(L, "tile", mode2string(info.fTileMode));
1292 setfield_number(L, "colorCount", info.fColorCount); 1281 setfield_number(L, "colorCount", info.fColorCount);
1293 setfield_boolean(L, "containsHardStops", containsHardStops);
1294 setfield_boolean(L, "isEvenlySpaced", isEvenlySpaced);
1295 1282
1296 lua_newtable(L); 1283 lua_newtable(L);
1297 for (int i = 0; i < info.fColorCount; i++) { 1284 for (int i = 0; i < info.fColorCount; i++) {
1298 // Lua uses 1-based indexing 1285 // Lua uses 1-based indexing
1299 setarray_scalar(L, i+1, pos[i]); 1286 setarray_scalar(L, i+1, pos[i]);
1300 } 1287 }
1301 lua_setfield(L, -2, "positions"); 1288 lua_setfield(L, -2, "positions");
1302 1289
1303 return 1; 1290 return 1;
1304 } 1291 }
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 REG_CLASS(L, SkTextBlob); 2136 REG_CLASS(L, SkTextBlob);
2150 REG_CLASS(L, SkTypeface); 2137 REG_CLASS(L, SkTypeface);
2151 REG_CLASS(L, SkXfermode); 2138 REG_CLASS(L, SkXfermode);
2152 } 2139 }
2153 2140
2154 extern "C" int luaopen_skia(lua_State* L); 2141 extern "C" int luaopen_skia(lua_State* L);
2155 extern "C" int luaopen_skia(lua_State* L) { 2142 extern "C" int luaopen_skia(lua_State* L) {
2156 SkLua::Load(L); 2143 SkLua::Load(L);
2157 return 0; 2144 return 0;
2158 } 2145 }
OLDNEW
« no previous file with comments | « no previous file | tools/lua/gradients.lua » ('j') | tools/lua/gradients.lua » ('J')

Powered by Google App Engine
This is Rietveld 408576698