| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "embedders/openglui/common/extension.h" | 5 #include "embedders/openglui/common/extension.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include "embedders/openglui/common/canvas_context.h" | 11 #include "embedders/openglui/common/canvas_context.h" |
| 12 #include "embedders/openglui/common/image_cache.h" |
| 12 #include "embedders/openglui/common/graphics_handler.h" | 13 #include "embedders/openglui/common/graphics_handler.h" |
| 13 #include "embedders/openglui/common/log.h" | 14 #include "embedders/openglui/common/log.h" |
| 14 #include "embedders/openglui/common/opengl.h" | 15 #include "embedders/openglui/common/opengl.h" |
| 15 #include "include/dart_api.h" | 16 #include "include/dart_api.h" |
| 16 | 17 |
| 17 Dart_Handle HandleError(Dart_Handle handle) { | 18 Dart_Handle HandleError(Dart_Handle handle) { |
| 18 if (Dart_IsError(handle)) Dart_PropagateError(handle); | 19 if (Dart_IsError(handle)) Dart_PropagateError(handle); |
| 19 return handle; | 20 return handle; |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 } else if (error == GL_OUT_OF_MEMORY) { | 36 } else if (error == GL_OUT_OF_MEMORY) { |
| 36 LOGE("%s: There is not enough memory left to execute the command.", | 37 LOGE("%s: There is not enough memory left to execute the command.", |
| 37 function); | 38 function); |
| 38 } else { | 39 } else { |
| 39 LOGE("ERROR!: %s returns %d", function, error); | 40 LOGE("ERROR!: %s returns %d", function, error); |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 const char* GetArgAsString(Dart_NativeArguments arguments, int idx) { | 45 const char* GetArgAsString(Dart_NativeArguments arguments, int idx) { |
| 45 Dart_Handle whatHandle = HandleError(Dart_GetNativeArgument(arguments, idx)); | 46 Dart_Handle handle = HandleError(Dart_GetNativeArgument(arguments, idx)); |
| 46 uint8_t* str; | 47 uint8_t* str; |
| 47 intptr_t length; | 48 intptr_t length; |
| 48 HandleError(Dart_StringLength(whatHandle, &length)); | 49 HandleError(Dart_StringLength(handle, &length)); |
| 49 HandleError(Dart_StringToUTF8(whatHandle, &str, &length)); | 50 HandleError(Dart_StringToUTF8(handle, &str, &length)); |
| 50 str[length] = 0; | 51 str[length] = 0; |
| 51 return const_cast<const char*>(reinterpret_cast<char*>(str)); | 52 return const_cast<const char*>(reinterpret_cast<char*>(str)); |
| 52 } | 53 } |
| 53 | 54 |
| 54 double GetArgAsDouble(Dart_NativeArguments arguments, int index) { | 55 double GetArgAsDouble(Dart_NativeArguments arguments, int index) { |
| 55 Dart_Handle handle = HandleError(Dart_GetNativeArgument(arguments, index)); | 56 Dart_Handle handle = HandleError(Dart_GetNativeArgument(arguments, index)); |
| 56 if (Dart_IsDouble(handle)) { | 57 if (Dart_IsDouble(handle)) { |
| 57 double v; | 58 double v; |
| 58 HandleError(Dart_DoubleValue(handle, &v)); | 59 HandleError(Dart_DoubleValue(handle, &v)); |
| 59 return v; | 60 return v; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 90 if (Dart_IsBoolean(handle)) { | 91 if (Dart_IsBoolean(handle)) { |
| 91 bool v; | 92 bool v; |
| 92 HandleError(Dart_BooleanValue(handle, &v)); | 93 HandleError(Dart_BooleanValue(handle, &v)); |
| 93 return v; | 94 return v; |
| 94 } | 95 } |
| 95 LOGI("Argument at index %d has non-Boolean type", index); | 96 LOGI("Argument at index %d has non-Boolean type", index); |
| 96 Dart_ThrowException(Dart_NewStringFromCString("Boolean argument expected.")); | 97 Dart_ThrowException(Dart_NewStringFromCString("Boolean argument expected.")); |
| 97 return false; | 98 return false; |
| 98 } | 99 } |
| 99 | 100 |
| 101 int GetListLength(Dart_NativeArguments arguments, int index, |
| 102 Dart_Handle& argHandle) { |
| 103 argHandle = HandleError(Dart_GetNativeArgument(arguments, index)); |
| 104 if (Dart_IsList(argHandle)) { |
| 105 intptr_t len; |
| 106 HandleError(Dart_ListLength(argHandle, &len)); |
| 107 return len; |
| 108 } |
| 109 LOGI("Argument at index %d has non-List type", index); |
| 110 Dart_ThrowException(Dart_NewStringFromCString("List argument expected.")); |
| 111 return -1; |
| 112 } |
| 113 |
| 100 GLint* GetArgsAsGLintList(Dart_NativeArguments arguments, int index, | 114 GLint* GetArgsAsGLintList(Dart_NativeArguments arguments, int index, |
| 101 int* len_out) { | 115 int* len_out) { |
| 102 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, index)); | 116 Dart_Handle argHandle; |
| 103 if (Dart_IsList(argHandle)) { | 117 int len = GetListLength(arguments, index, argHandle); |
| 104 intptr_t len; | 118 if (len < 0) return NULL; |
| 105 HandleError(Dart_ListLength(argHandle, &len)); | 119 GLint* list = new GLint[len]; |
| 106 GLint* list = new GLint[len]; | 120 for (int i = 0; i < len; i++) { |
| 107 for (int i = 0; i < len; i++) { | 121 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 108 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 122 int64_t v; |
| 109 int64_t v; | 123 HandleError(Dart_IntegerToInt64(vHandle, &v)); |
| 110 HandleError(Dart_IntegerToInt64(vHandle, &v)); | 124 list[i] = v; |
| 111 list[i] = v; | |
| 112 } | |
| 113 *len_out = len; | |
| 114 return list; | |
| 115 } | 125 } |
| 116 LOGI("Argument at index %d has non-List type", index); | 126 *len_out = len; |
| 117 Dart_ThrowException(Dart_NewStringFromCString("List argument expected.")); | 127 return list; |
| 118 return NULL; | |
| 119 } | 128 } |
| 120 | 129 |
| 121 GLfloat* GetArgsAsFloatList(Dart_NativeArguments arguments, int index, | 130 GLfloat* GetArgsAsFloatList(Dart_NativeArguments arguments, int index, |
| 122 int* len_out) { | 131 int* len_out) { |
| 123 Dart_Handle locationHandle = | 132 Dart_Handle argHandle; |
| 124 HandleError(Dart_GetNativeArgument(arguments, 0)); | 133 int len = GetListLength(arguments, index, argHandle); |
| 125 int64_t location; | 134 if (len < 0) return NULL; |
| 126 HandleError(Dart_IntegerToInt64(locationHandle, &location)); | 135 GLfloat* list = new GLfloat[len]; |
| 136 for (int i = 0; i < len; i++) { |
| 137 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 138 double v; |
| 139 HandleError(Dart_DoubleValue(vHandle, &v)); |
| 140 list[i] = v; |
| 141 } |
| 142 *len_out = len; |
| 143 return list; |
| 144 } |
| 127 | 145 |
| 128 Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 146 char** GetArgsAsStringList(Dart_NativeArguments arguments, int index, |
| 129 | 147 int* len_out) { |
| 130 if (Dart_IsList(argHandle)) { | 148 Dart_Handle argHandle; |
| 131 intptr_t len; | 149 int len = GetListLength(arguments, index, argHandle); |
| 132 HandleError(Dart_ListLength(argHandle, &len)); | 150 if (len < 0) return NULL; |
| 133 GLfloat* list = new GLfloat[len]; | 151 char** list = new char*[len]; |
| 134 for (int i = 0; i < len; i++) { | 152 for (int i = 0; i < len; i++) { |
| 135 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); | 153 Dart_Handle vHandle = Dart_ListGetAt(argHandle, i); |
| 136 double v; | 154 uint8_t* str; |
| 137 HandleError(Dart_DoubleValue(vHandle, &v)); | 155 intptr_t length; |
| 138 list[i] = v; | 156 HandleError(Dart_StringLength(vHandle, &length)); |
| 139 } | 157 HandleError(Dart_StringToUTF8(vHandle, &str, &length)); |
| 140 *len_out = len; | 158 str[length] = 0; |
| 141 return list; | 159 list[i] = reinterpret_cast<char*>(str); |
| 142 } | 160 } |
| 143 LOGI("Argument at index %d has non-List type", index); | 161 *len_out = len; |
| 144 Dart_ThrowException(Dart_NewStringFromCString("List argument expected.")); | 162 return list; |
| 145 return NULL; | |
| 146 } | 163 } |
| 147 | 164 |
| 148 void SetBoolReturnValue(Dart_NativeArguments arguments, bool b) { | 165 void SetBoolReturnValue(Dart_NativeArguments arguments, bool b) { |
| 149 Dart_Handle result = HandleError(Dart_NewBoolean(b)); | 166 Dart_Handle result = HandleError(Dart_NewBoolean(b)); |
| 150 Dart_SetReturnValue(arguments, result); | 167 Dart_SetReturnValue(arguments, result); |
| 151 } | 168 } |
| 152 | 169 |
| 153 void SetIntReturnValue(Dart_NativeArguments arguments, int v) { | 170 void SetIntReturnValue(Dart_NativeArguments arguments, int v) { |
| 154 Dart_Handle result = HandleError(Dart_NewInteger(v)); | 171 Dart_Handle result = HandleError(Dart_NewInteger(v)); |
| 155 Dart_SetReturnValue(arguments, result); | 172 Dart_SetReturnValue(arguments, result); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 489 |
| 473 Dart_Handle sourceHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 490 Dart_Handle sourceHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); |
| 474 intptr_t length[1]; | 491 intptr_t length[1]; |
| 475 HandleError(Dart_StringLength(sourceHandle, length)); | 492 HandleError(Dart_StringLength(sourceHandle, length)); |
| 476 LOGI("Source length is %d", static_cast<int>(length[0])); | 493 LOGI("Source length is %d", static_cast<int>(length[0])); |
| 477 uint8_t* str[1]; | 494 uint8_t* str[1]; |
| 478 HandleError(Dart_StringToUTF8(sourceHandle, &str[0], length)); | 495 HandleError(Dart_StringToUTF8(sourceHandle, &str[0], length)); |
| 479 LOGI("Converted length is %d", static_cast<int>(length[0])); | 496 LOGI("Converted length is %d", static_cast<int>(length[0])); |
| 480 str[0][*length] = 0; | 497 str[0][*length] = 0; |
| 481 | 498 |
| 482 const GLchar* source = | 499 LOGI("Source: %s", |
| 483 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str[0])); | 500 const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str[0]))); |
| 484 LOGI("Source: %s", source); | |
| 485 glShaderSource(shader, 1, | 501 glShaderSource(shader, 1, |
| 486 const_cast<const GLchar**>(reinterpret_cast<GLchar**>(str)), NULL); | 502 const_cast<const GLchar**>(reinterpret_cast<GLchar**>(str)), NULL); |
| 487 CheckGLError("glShaderSource"); | 503 CheckGLError("glShaderSource"); |
| 488 Dart_ExitScope(); | 504 Dart_ExitScope(); |
| 489 } | 505 } |
| 490 | 506 |
| 491 void GLUseProgram(Dart_NativeArguments arguments) { | 507 void GLUseProgram(Dart_NativeArguments arguments) { |
| 492 LOGI("GLUseProgram"); | 508 LOGI("GLUseProgram"); |
| 493 Dart_EnterScope(); | 509 Dart_EnterScope(); |
| 494 int64_t program = GetArgAsInt(arguments, 0); | 510 int64_t program = GetArgAsInt(arguments, 0); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 Context2D(handle)->setGlobalAlpha(alpha); | 987 Context2D(handle)->setGlobalAlpha(alpha); |
| 972 SetDoubleReturnValue(arguments, alpha); | 988 SetDoubleReturnValue(arguments, alpha); |
| 973 Dart_ExitScope(); | 989 Dart_ExitScope(); |
| 974 LOGI("Out C2DSetGlobalAlpha"); | 990 LOGI("Out C2DSetGlobalAlpha"); |
| 975 } | 991 } |
| 976 | 992 |
| 977 void C2DSetFillStyle(Dart_NativeArguments arguments) { | 993 void C2DSetFillStyle(Dart_NativeArguments arguments) { |
| 978 LOGI("In C2DSetFillStyle"); | 994 LOGI("In C2DSetFillStyle"); |
| 979 Dart_EnterScope(); | 995 Dart_EnterScope(); |
| 980 int handle = GetArgAsInt(arguments, 0); | 996 int handle = GetArgAsInt(arguments, 0); |
| 981 Dart_Handle whatHandle = HandleError(Dart_GetNativeArgument(arguments, 1)); | 997 const char* color = GetArgAsString(arguments, 1); |
| 982 if (Dart_IsString(whatHandle)) { | 998 Context2D(handle)->setFillColor(color); |
| 983 const char* color = GetArgAsString(arguments, 1); | |
| 984 Context2D(handle)->setFillColor(color); | |
| 985 } else { // Texture from gradient or image. | |
| 986 } | |
| 987 Dart_ExitScope(); | 999 Dart_ExitScope(); |
| 988 LOGI("Out C2DSetFillStyle"); | 1000 LOGI("Out C2DSetFillStyle"); |
| 989 } | 1001 } |
| 990 | 1002 |
| 991 void C2DSetFont(Dart_NativeArguments arguments) { | 1003 void C2DSetFont(Dart_NativeArguments arguments) { |
| 992 LOGI("In C2DSetFont"); | 1004 LOGI("In C2DSetFont"); |
| 993 Dart_EnterScope(); | 1005 Dart_EnterScope(); |
| 994 int handle = GetArgAsInt(arguments, 0); | 1006 int handle = GetArgAsInt(arguments, 0); |
| 995 const char* font = GetArgAsString(arguments, 1); | 1007 const char* font = GetArgAsString(arguments, 1); |
| 996 SetStringReturnValue(arguments, Context2D(handle)->setFont(font)); | 1008 SetStringReturnValue(arguments, Context2D(handle)->setFont(font)); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 double h = GetArgAsDouble(arguments, 4); | 1376 double h = GetArgAsDouble(arguments, 4); |
| 1365 Context2D(handle)->Rect(x, y, w, h); | 1377 Context2D(handle)->Rect(x, y, w, h); |
| 1366 Dart_ExitScope(); | 1378 Dart_ExitScope(); |
| 1367 LOGI("Out C2DRect"); | 1379 LOGI("Out C2DRect"); |
| 1368 } | 1380 } |
| 1369 | 1381 |
| 1370 void C2DRestore(Dart_NativeArguments arguments) { | 1382 void C2DRestore(Dart_NativeArguments arguments) { |
| 1371 LOGI("In C2DRestore"); | 1383 LOGI("In C2DRestore"); |
| 1372 Dart_EnterScope(); | 1384 Dart_EnterScope(); |
| 1373 int handle = GetArgAsInt(arguments, 0); | 1385 int handle = GetArgAsInt(arguments, 0); |
| 1374 Context2D(handle)->Restore(); | 1386 CanvasContext* context = Context2D(handle); |
| 1387 context->Restore(); |
| 1375 Dart_ExitScope(); | 1388 Dart_ExitScope(); |
| 1376 LOGI("Out C2DRestore"); | 1389 LOGI("Out C2DRestore"); |
| 1377 } | 1390 } |
| 1378 | 1391 |
| 1379 void C2DRotate(Dart_NativeArguments arguments) { | 1392 void C2DRotate(Dart_NativeArguments arguments) { |
| 1380 LOGI("In C2DRotate"); | 1393 LOGI("In C2DRotate"); |
| 1381 Dart_EnterScope(); | 1394 Dart_EnterScope(); |
| 1382 int handle = GetArgAsInt(arguments, 0); | 1395 int handle = GetArgAsInt(arguments, 0); |
| 1383 double a = GetArgAsDouble(arguments, 1); | 1396 double a = GetArgAsDouble(arguments, 1); |
| 1384 Context2D(handle)->Rotate(a); | 1397 Context2D(handle)->Rotate(a); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 LOGI("In C2DTranslate"); | 1512 LOGI("In C2DTranslate"); |
| 1500 Dart_EnterScope(); | 1513 Dart_EnterScope(); |
| 1501 int handle = GetArgAsInt(arguments, 0); | 1514 int handle = GetArgAsInt(arguments, 0); |
| 1502 double x = GetArgAsDouble(arguments, 1); | 1515 double x = GetArgAsDouble(arguments, 1); |
| 1503 double y = GetArgAsDouble(arguments, 2); | 1516 double y = GetArgAsDouble(arguments, 2); |
| 1504 Context2D(handle)->Translate(x, y); | 1517 Context2D(handle)->Translate(x, y); |
| 1505 Dart_ExitScope(); | 1518 Dart_ExitScope(); |
| 1506 LOGI("Out C2DTranslate"); | 1519 LOGI("Out C2DTranslate"); |
| 1507 } | 1520 } |
| 1508 | 1521 |
| 1522 void C2DSetFillGradient(Dart_NativeArguments arguments) { |
| 1523 LOGI("In C2DSetFillGradient"); |
| 1524 Dart_EnterScope(); |
| 1525 int handle = GetArgAsInt(arguments, 0); |
| 1526 bool is_radial = GetArgAsBool(arguments, 1); |
| 1527 double x0 = GetArgAsDouble(arguments, 2); |
| 1528 double y0 = GetArgAsDouble(arguments, 3); |
| 1529 double r0 = GetArgAsDouble(arguments, 4); |
| 1530 double x1 = GetArgAsDouble(arguments, 5); |
| 1531 double y1 = GetArgAsDouble(arguments, 6); |
| 1532 double r1 = GetArgAsDouble(arguments, 7); |
| 1533 int num_positions, num_colors; |
| 1534 float* positions = GetArgsAsFloatList(arguments, 8, &num_positions); |
| 1535 char** colors = GetArgsAsStringList(arguments, 9, &num_colors); |
| 1536 Context2D(handle)->SetFillGradient(is_radial, x0, y0, r0, x1, y1, r1, |
| 1537 num_positions, positions, colors); |
| 1538 Dart_ExitScope(); |
| 1539 LOGI("Out C2DSetFillGradient"); |
| 1540 } |
| 1541 |
| 1542 void C2DSetStrokeGradient(Dart_NativeArguments arguments) { |
| 1543 LOGI("In C2DSetStrokeGradient"); |
| 1544 Dart_EnterScope(); |
| 1545 int handle = GetArgAsInt(arguments, 0); |
| 1546 bool is_radial = GetArgAsBool(arguments, 1); |
| 1547 double x0 = GetArgAsDouble(arguments, 2); |
| 1548 double y0 = GetArgAsDouble(arguments, 3); |
| 1549 double r0 = GetArgAsDouble(arguments, 4); |
| 1550 double x1 = GetArgAsDouble(arguments, 5); |
| 1551 double y1 = GetArgAsDouble(arguments, 6); |
| 1552 double r1 = GetArgAsDouble(arguments, 7); |
| 1553 int num_positions, num_colors; |
| 1554 float* positions = GetArgsAsFloatList(arguments, 8, &num_positions); |
| 1555 char** colors = GetArgsAsStringList(arguments, 9, &num_colors); |
| 1556 Context2D(handle)->SetStrokeGradient(is_radial, x0, y0, r0, x1, y1, r1, |
| 1557 num_positions, positions, colors); |
| 1558 Dart_ExitScope(); |
| 1559 LOGI("Out C2DSetStrokeGradient"); |
| 1560 } |
| 1561 |
| 1562 void C2DGetImageWidth(Dart_NativeArguments arguments) { |
| 1563 LOGI("In C2DGetImageWidth"); |
| 1564 Dart_EnterScope(); |
| 1565 const char* src_url = GetArgAsString(arguments, 0); |
| 1566 int w = ImageCache::GetWidth(src_url); |
| 1567 SetIntReturnValue(arguments, w); |
| 1568 Dart_ExitScope(); |
| 1569 LOGI("Out C2DGetImageWidth"); |
| 1570 } |
| 1571 |
| 1572 void C2DGetImageHeight(Dart_NativeArguments arguments) { |
| 1573 LOGI("In C2DGetImageHeight"); |
| 1574 Dart_EnterScope(); |
| 1575 const char* src_url = GetArgAsString(arguments, 0); |
| 1576 int h = ImageCache::GetHeight(src_url); |
| 1577 SetIntReturnValue(arguments, h); |
| 1578 Dart_ExitScope(); |
| 1579 LOGI("Out C2DGetImageHeight"); |
| 1580 } |
| 1581 |
| 1509 struct FunctionLookup { | 1582 struct FunctionLookup { |
| 1510 const char* name; | 1583 const char* name; |
| 1511 Dart_NativeFunction function; | 1584 Dart_NativeFunction function; |
| 1512 }; | 1585 }; |
| 1513 | 1586 |
| 1514 FunctionLookup function_list[] = { | 1587 FunctionLookup function_list[] = { |
| 1515 {"Log", Log}, | 1588 {"Log", Log}, |
| 1516 {"LogError", LogError}, | 1589 {"LogError", LogError}, |
| 1517 {"SystemRand", SystemRand}, | 1590 {"SystemRand", SystemRand}, |
| 1518 {"SystemSrand", SystemSrand}, | 1591 {"SystemSrand", SystemSrand}, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 { "C2DSave", C2DSave}, | 1704 { "C2DSave", C2DSave}, |
| 1632 { "C2DScale", C2DScale}, | 1705 { "C2DScale", C2DScale}, |
| 1633 { "C2DSetLineDash", C2DSetLineDash}, | 1706 { "C2DSetLineDash", C2DSetLineDash}, |
| 1634 { "C2DSetLineDashOffset", C2DSetLineDashOffset}, | 1707 { "C2DSetLineDashOffset", C2DSetLineDashOffset}, |
| 1635 { "C2DSetTransform", C2DSetTransform}, | 1708 { "C2DSetTransform", C2DSetTransform}, |
| 1636 { "C2DStroke", C2DStroke}, | 1709 { "C2DStroke", C2DStroke}, |
| 1637 { "C2DStrokeRect", C2DStrokeRect}, | 1710 { "C2DStrokeRect", C2DStrokeRect}, |
| 1638 { "C2DStrokeText", C2DStrokeText}, | 1711 { "C2DStrokeText", C2DStrokeText}, |
| 1639 { "C2DTransform", C2DTransform}, | 1712 { "C2DTransform", C2DTransform}, |
| 1640 { "C2DTranslate", C2DTranslate}, | 1713 { "C2DTranslate", C2DTranslate}, |
| 1714 { "C2DSetFillGradient", C2DSetFillGradient}, |
| 1715 { "C2DSetStrokeGradient", C2DSetStrokeGradient}, |
| 1716 { "C2DGetImageWidth", C2DGetImageWidth}, |
| 1717 { "C2DGetImageHeight", C2DGetImageHeight}, |
| 1718 |
| 1641 {NULL, NULL}}; | 1719 {NULL, NULL}}; |
| 1642 | 1720 |
| 1643 Dart_NativeFunction ResolveName(Dart_Handle name, int argc) { | 1721 Dart_NativeFunction ResolveName(Dart_Handle name, int argc) { |
| 1644 if (!Dart_IsString(name)) return NULL; | 1722 if (!Dart_IsString(name)) return NULL; |
| 1645 Dart_NativeFunction result = NULL; | 1723 Dart_NativeFunction result = NULL; |
| 1646 Dart_EnterScope(); | 1724 Dart_EnterScope(); |
| 1647 const char* cname; | 1725 const char* cname; |
| 1648 HandleError(Dart_StringToCString(name, &cname)); | 1726 HandleError(Dart_StringToCString(name, &cname)); |
| 1649 for (int i = 0; function_list[i].name != NULL; ++i) { | 1727 for (int i = 0; function_list[i].name != NULL; ++i) { |
| 1650 if (strcmp(function_list[i].name, cname) == 0) { | 1728 if (strcmp(function_list[i].name, cname) == 0) { |
| 1651 result = function_list[i].function; | 1729 result = function_list[i].function; |
| 1652 break; | 1730 break; |
| 1653 } | 1731 } |
| 1654 } | 1732 } |
| 1655 Dart_ExitScope(); | 1733 Dart_ExitScope(); |
| 1656 return result; | 1734 return result; |
| 1657 } | 1735 } |
| OLD | NEW |