OLD | NEW |
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 Loading... |
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; | 1278 int numHardStops = 0; |
1279 bool isEvenlySpaced = true; | 1279 bool isEvenlySpaced = true; |
1280 for (int i = 1; i < info.fColorCount; i++) { | 1280 for (int i = 1; i < info.fColorCount; i++) { |
1281 if (SkScalarNearlyEqual(info.fColorOffsets[i], info.fColorOffset
s[i-1])) { | 1281 if (SkScalarNearlyEqual(info.fColorOffsets[i], info.fColorOffset
s[i-1])) { |
1282 containsHardStops = true; | 1282 numHardStops++; |
1283 } | 1283 } |
1284 if (!SkScalarNearlyEqual(info.fColorOffsets[i], i/(info.fColorCo
unt - 1.0f))) { | 1284 if (!SkScalarNearlyEqual(info.fColorOffsets[i], i/(info.fColorCo
unt - 1.0f))) { |
1285 isEvenlySpaced = false; | 1285 isEvenlySpaced = false; |
1286 } | 1286 } |
1287 } | 1287 } |
1288 | 1288 |
1289 lua_newtable(L); | 1289 lua_newtable(L); |
1290 setfield_string(L, "type", gradtype2string(t)); | 1290 setfield_string(L, "type", gradtype2string(t)); |
1291 setfield_string(L, "tile", mode2string(info.fTileMode
)); | 1291 setfield_string(L, "tile", mode2string(info.fTileMode)); |
1292 setfield_number(L, "colorCount", info.fColorCount); | 1292 setfield_number(L, "colorCount", info.fColorCount); |
1293 setfield_boolean(L, "containsHardStops", containsHardStops); | 1293 setfield_number(L, "numHardStops", numHardStops); |
1294 setfield_boolean(L, "isEvenlySpaced", isEvenlySpaced); | 1294 setfield_boolean(L, "isEvenlySpaced", isEvenlySpaced); |
1295 | 1295 |
1296 lua_newtable(L); | 1296 lua_newtable(L); |
1297 for (int i = 0; i < info.fColorCount; i++) { | 1297 for (int i = 0; i < info.fColorCount; i++) { |
1298 // Lua uses 1-based indexing | 1298 // Lua uses 1-based indexing |
1299 setarray_scalar(L, i+1, pos[i]); | 1299 setarray_scalar(L, i+1, pos[i]); |
1300 } | 1300 } |
1301 lua_setfield(L, -2, "positions"); | 1301 lua_setfield(L, -2, "positions"); |
1302 | 1302 |
1303 return 1; | 1303 return 1; |
1304 } | 1304 } |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 REG_CLASS(L, SkTextBlob); | 2149 REG_CLASS(L, SkTextBlob); |
2150 REG_CLASS(L, SkTypeface); | 2150 REG_CLASS(L, SkTypeface); |
2151 REG_CLASS(L, SkXfermode); | 2151 REG_CLASS(L, SkXfermode); |
2152 } | 2152 } |
2153 | 2153 |
2154 extern "C" int luaopen_skia(lua_State* L); | 2154 extern "C" int luaopen_skia(lua_State* L); |
2155 extern "C" int luaopen_skia(lua_State* L) { | 2155 extern "C" int luaopen_skia(lua_State* L) { |
2156 SkLua::Load(L); | 2156 SkLua::Load(L); |
2157 return 0; | 2157 return 0; |
2158 } | 2158 } |
OLD | NEW |