| Index: runtime/embedders/android/android_extension.cc
|
| ===================================================================
|
| --- runtime/embedders/android/android_extension.cc (revision 16869)
|
| +++ runtime/embedders/android/android_extension.cc (working copy)
|
| @@ -24,11 +24,26 @@
|
| void CheckGLError(const char *function) {
|
| int error = glGetError();
|
| if (error != GL_NO_ERROR) {
|
| - LOGE("ERROR!: %s returns %d", function, error);
|
| + if (error == GL_INVALID_ENUM) {
|
| + LOGE("%s: An unacceptable value is given for an enumerated argument.",
|
| + function);
|
| + } else if (error == GL_INVALID_VALUE) {
|
| + LOGE("%s: A numeric argument is out of range.", function);
|
| + } else if (error == GL_INVALID_OPERATION) {
|
| + LOGE("%s: The specified operation is not allowed in the current state.",
|
| + function);
|
| + } else if (error == GL_INVALID_FRAMEBUFFER_OPERATION) {
|
| + LOGE("%s: The framebuffer object is not complete.", function);
|
| + } else if (error == GL_OUT_OF_MEMORY) {
|
| + LOGE("%s: There is not enough memory left to execute the command.",
|
| + function);
|
| + } else {
|
| + LOGE("ERROR!: %s returns %d", function, error);
|
| + }
|
| }
|
| }
|
|
|
| -const char* GetStringArg(Dart_NativeArguments arguments, int idx) {
|
| +const char* GetArgAsString(Dart_NativeArguments arguments, int idx) {
|
| Dart_Handle whatHandle = HandleError(Dart_GetNativeArgument(arguments, idx));
|
| uint8_t* str;
|
| intptr_t length;
|
| @@ -38,16 +53,130 @@
|
| return const_cast<const char*>(reinterpret_cast<char*>(str));
|
| }
|
|
|
| +double GetArgAsDouble(Dart_NativeArguments arguments, int index) {
|
| + Dart_Handle handle = HandleError(Dart_GetNativeArgument(arguments, index));
|
| + if (Dart_IsDouble(handle)) {
|
| + double v;
|
| + HandleError(Dart_DoubleValue(handle, &v));
|
| + return v;
|
| + }
|
| + if (Dart_IsInteger(handle)) {
|
| + int64_t v;
|
| + HandleError(Dart_IntegerToInt64(handle, &v));
|
| + return static_cast<double>(v);
|
| + }
|
| + LOGE("Argument at index %d has non-numeric type", index);
|
| + Dart_ThrowException(Dart_NewStringFromCString("Numeric argument expected."));
|
| + return 0;
|
| +}
|
| +
|
| +int64_t GetArgAsInt(Dart_NativeArguments arguments, int index) {
|
| + Dart_Handle handle = HandleError(Dart_GetNativeArgument(arguments, index));
|
| + if (Dart_IsDouble(handle)) {
|
| + double v;
|
| + HandleError(Dart_DoubleValue(handle, &v));
|
| + return static_cast<int64_t>(v);
|
| + }
|
| + if (Dart_IsInteger(handle)) {
|
| + int64_t v;
|
| + HandleError(Dart_IntegerToInt64(handle, &v));
|
| + return v;
|
| + }
|
| + LOGE("Argument at index %d has non-numeric type", index);
|
| + Dart_ThrowException(Dart_NewStringFromCString("Numeric argument expected."));
|
| + return 0;
|
| +}
|
| +
|
| +bool GetArgAsBool(Dart_NativeArguments arguments, int index) {
|
| + Dart_Handle handle = HandleError(Dart_GetNativeArgument(arguments, index));
|
| + if (Dart_IsBoolean(handle)) {
|
| + bool v;
|
| + HandleError(Dart_BooleanValue(handle, &v));
|
| + return v;
|
| + }
|
| + LOGI("Argument at index %d has non-Boolean type", index);
|
| + Dart_ThrowException(Dart_NewStringFromCString("Boolean argument expected."));
|
| + return false;
|
| +}
|
| +
|
| +GLint* GetArgsAsGLintList(Dart_NativeArguments arguments, int index,
|
| + int* len_out) {
|
| + Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, index));
|
| + if (Dart_IsList(argHandle)) {
|
| + int len;
|
| + HandleError(Dart_ListLength(argHandle, &len));
|
| + GLint* list = new GLint[len];
|
| + for (int i = 0; i < len; i++) {
|
| + Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| + int64_t v;
|
| + HandleError(Dart_IntegerToInt64(vHandle, &v));
|
| + list[i] = v;
|
| + }
|
| + *len_out = len;
|
| + return list;
|
| + }
|
| + LOGI("Argument at index %d has non-List type", index);
|
| + Dart_ThrowException(Dart_NewStringFromCString("List argument expected."));
|
| + return NULL;
|
| +}
|
| +
|
| +GLfloat* GetArgsAsFloatList(Dart_NativeArguments arguments, int index,
|
| + int* len_out) {
|
| + Dart_Handle locationHandle =
|
| + HandleError(Dart_GetNativeArgument(arguments, 0));
|
| + int64_t location;
|
| + HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| +
|
| + Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| +
|
| + if (Dart_IsList(argHandle)) {
|
| + int len;
|
| + HandleError(Dart_ListLength(argHandle, &len));
|
| + GLfloat* list = new GLfloat[len];
|
| + for (int i = 0; i < len; i++) {
|
| + Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| + double v;
|
| + HandleError(Dart_DoubleValue(vHandle, &v));
|
| + list[i] = v;
|
| + }
|
| + *len_out = len;
|
| + return list;
|
| + }
|
| + LOGI("Argument at index %d has non-List type", index);
|
| + Dart_ThrowException(Dart_NewStringFromCString("List argument expected."));
|
| + return NULL;
|
| +}
|
| +
|
| +void SetBoolReturnValue(Dart_NativeArguments arguments, bool b) {
|
| + Dart_Handle result = HandleError(Dart_NewBoolean(b));
|
| + Dart_SetReturnValue(arguments, result);
|
| +}
|
| +
|
| +void SetIntReturnValue(Dart_NativeArguments arguments, int v) {
|
| + Dart_Handle result = HandleError(Dart_NewInteger(v));
|
| + Dart_SetReturnValue(arguments, result);
|
| +}
|
| +
|
| +void SetStringReturnValue(Dart_NativeArguments arguments, const char* s) {
|
| + Dart_Handle result = HandleError(Dart_NewStringFromCString(s));
|
| + Dart_SetReturnValue(arguments, result);
|
| +}
|
| +
|
| void Log(Dart_NativeArguments arguments) {
|
| Dart_EnterScope();
|
| - LOGI(GetStringArg(arguments, 0));
|
| + LOGI(GetArgAsString(arguments, 0));
|
| Dart_ExitScope();
|
| }
|
|
|
| +void LogError(Dart_NativeArguments arguments) {
|
| + Dart_EnterScope();
|
| + LOGE(GetArgAsString(arguments, 0));
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| void SystemRand(Dart_NativeArguments arguments) {
|
| Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(rand()));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, rand());
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -65,7 +194,7 @@
|
| success = true;
|
| }
|
| }
|
| - Dart_SetReturnValue(arguments, HandleError(Dart_NewBoolean(success)));
|
| + SetBoolReturnValue(arguments, success);
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -85,14 +214,9 @@
|
| LOGI("GLAttachShader");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
| + int64_t shader = GetArgAsInt(arguments, 1);
|
|
|
| - Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t shader;
|
| - HandleError(Dart_IntegerToInt64(shaderHandle, &shader));
|
| -
|
| glAttachShader(program, shader);
|
| CheckGLError("glAttachShader");
|
| Dart_ExitScope();
|
| @@ -102,14 +226,9 @@
|
| LOGI("GLBindBuffer");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle targetHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t target;
|
| - HandleError(Dart_IntegerToInt64(targetHandle, &target));
|
| + int64_t target = GetArgAsInt(arguments, 0);
|
| + int64_t buffer = GetArgAsInt(arguments, 1);
|
|
|
| - Dart_Handle bufferHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t buffer;
|
| - HandleError(Dart_IntegerToInt64(bufferHandle, &buffer));
|
| -
|
| glBindBuffer(target, buffer);
|
| CheckGLError("glBindBuffer");
|
| Dart_ExitScope();
|
| @@ -119,9 +238,7 @@
|
| LOGI("GLBufferData");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle targetHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t target;
|
| - HandleError(Dart_IntegerToInt64(targetHandle, &target));
|
| + int64_t target = GetArgAsInt(arguments, 0);
|
|
|
| Dart_Handle dataHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| intptr_t size;
|
| @@ -130,7 +247,7 @@
|
| LOGI("Size: %d", size);
|
|
|
| // TODO(vsm): No guarantee that this is a float!
|
| - float* data = reinterpret_cast<float*>(malloc(size * sizeof(float)));
|
| + float* data = new float[size];
|
| for (int i = 0; i < size; i++) {
|
| Dart_Handle elemHandle = HandleError(Dart_ListGetAt(dataHandle, i));
|
| double value;
|
| @@ -143,20 +260,16 @@
|
| int64_t usage;
|
| HandleError(Dart_IntegerToInt64(usageHandle, &usage));
|
|
|
| - glBufferData(target, size * sizeof(float), data, usage);
|
| + glBufferData(target, size * sizeof(data[0]), data, usage);
|
| CheckGLError("glBufferData");
|
| - free(data);
|
| + delete[] data;
|
| Dart_ExitScope();
|
| }
|
|
|
| void GLCompileShader(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| -
|
| - Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t shader;
|
| - HandleError(Dart_IntegerToInt64(shaderHandle, &shader));
|
| -
|
| LOGI("GLCompileShader");
|
| + Dart_EnterScope();
|
| + int64_t shader = GetArgAsInt(arguments, 0);
|
| glCompileShader(shader);
|
| CheckGLError("glCompileShader");
|
| Dart_ExitScope();
|
| @@ -166,37 +279,28 @@
|
| LOGI("GLCreateBuffer");
|
| Dart_EnterScope();
|
| GLuint buffer;
|
| -
|
| glGenBuffers(1, &buffer);
|
| CheckGLError("glGenBuffers");
|
| - Dart_Handle result = HandleError(Dart_NewInteger(buffer));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, buffer);
|
| Dart_ExitScope();
|
| }
|
|
|
| void GLCreateProgram(Dart_NativeArguments arguments) {
|
| LOGI("GLCreateProgram");
|
| Dart_EnterScope();
|
| -
|
| int64_t program = glCreateProgram();
|
| CheckGLError("glCreateProgram");
|
| - Dart_Handle result = HandleError(Dart_NewInteger(program));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, program);
|
| Dart_ExitScope();
|
| }
|
|
|
| void GLCreateShader(Dart_NativeArguments arguments) {
|
| + LOGI("GLCreateShader");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle typeHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t type;
|
| - HandleError(Dart_IntegerToInt64(typeHandle, &type));
|
| -
|
| + int64_t type = GetArgAsInt(arguments, 0);
|
| int64_t shader = glCreateShader((GLenum)type);
|
| - LOGI("GLCreateShader");
|
| CheckGLError("glCreateShader");
|
| - Dart_Handle result = HandleError(Dart_NewInteger(shader));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, shader);
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -204,18 +308,10 @@
|
| LOGI("GLDrawArrays");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle modeHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t mode;
|
| - HandleError(Dart_IntegerToInt64(modeHandle, &mode));
|
| + int64_t mode = GetArgAsInt(arguments, 0);
|
| + int64_t first = GetArgAsInt(arguments, 1);
|
| + int64_t count = GetArgAsInt(arguments, 2);
|
|
|
| - Dart_Handle firstHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t first;
|
| - HandleError(Dart_IntegerToInt64(firstHandle, &first));
|
| -
|
| - Dart_Handle countHandle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - int64_t count;
|
| - HandleError(Dart_IntegerToInt64(countHandle, &count));
|
| -
|
| glDrawArrays(mode, first, count);
|
| CheckGLError("glDrawArrays");
|
| Dart_ExitScope();
|
| @@ -225,10 +321,7 @@
|
| LOGI("GLEnableVertexAttribArray");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
|
|
| glEnableVertexAttribArray(location);
|
| CheckGLError("glEnableVertexAttribArray");
|
| @@ -239,9 +332,7 @@
|
| LOGI("GLGetAttribLocation");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
|
|
| Dart_Handle nameHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| intptr_t length;
|
| @@ -253,18 +344,14 @@
|
| int64_t location = glGetAttribLocation(program,
|
| const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str)));
|
| CheckGLError("glGetAttribLocation");
|
| - Dart_Handle result = HandleError(Dart_NewInteger(location));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, location);
|
| Dart_ExitScope();
|
| }
|
|
|
| void GLGetError(Dart_NativeArguments arguments) {
|
| LOGI("GLGetError");
|
| Dart_EnterScope();
|
| -
|
| - int64_t error = glGetError();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(error));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, glGetError());
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -272,20 +359,14 @@
|
| LOGI("GLGetProgramParameter");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
| + int64_t param = GetArgAsInt(arguments, 1);
|
|
|
| - Dart_Handle paramHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t param;
|
| - HandleError(Dart_IntegerToInt64(paramHandle, ¶m));
|
| -
|
| GLint value = -1;
|
| glGetProgramiv(program, param, &value);
|
| CheckGLError("glGetProgramiv");
|
|
|
| - Dart_Handle result = HandleError(Dart_NewInteger(value));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, value);
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -293,20 +374,14 @@
|
| LOGI("GLGetShaderParameter");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t shader;
|
| - HandleError(Dart_IntegerToInt64(shaderHandle, &shader));
|
| + int64_t shader = GetArgAsInt(arguments, 0);
|
| + int64_t param = GetArgAsInt(arguments, 1);
|
|
|
| - Dart_Handle paramHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t param;
|
| - HandleError(Dart_IntegerToInt64(paramHandle, ¶m));
|
| -
|
| GLint value = -1;
|
| glGetShaderiv((GLuint)shader, (GLenum)param, &value);
|
| CheckGLError("glGetShaderiv");
|
|
|
| - Dart_Handle result = HandleError(Dart_NewInteger(value));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, value);
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -314,9 +389,7 @@
|
| LOGI("GLGetShaderInfoLog");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t shader;
|
| - HandleError(Dart_IntegerToInt64(shaderHandle, &shader));
|
| + int64_t shader = GetArgAsInt(arguments, 0);
|
|
|
| GLint infoLogLength = 0;
|
| glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
| @@ -325,8 +398,7 @@
|
| glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);
|
| strInfoLog[infoLogLength] = 0;
|
|
|
| - Dart_Handle result = HandleError(Dart_NewStringFromCString(strInfoLog));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetStringReturnValue(arguments, strInfoLog);
|
| Dart_ExitScope();
|
| delete[] strInfoLog;
|
| }
|
| @@ -335,9 +407,7 @@
|
| LOGI("GLGetProgramInfoLog");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
|
|
| GLint infoLogLength;
|
| glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
| @@ -346,8 +416,7 @@
|
| glGetProgramInfoLog(program, infoLogLength, NULL, strInfoLog);
|
| strInfoLog[infoLogLength] = 0;
|
|
|
| - Dart_Handle result = HandleError(Dart_NewStringFromCString(strInfoLog));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetStringReturnValue(arguments, strInfoLog);
|
| Dart_ExitScope();
|
| delete[] strInfoLog;
|
| }
|
| @@ -356,10 +425,9 @@
|
| LOGI("GLGetUniformLocation");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
|
|
| +
|
| Dart_Handle nameHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| intptr_t length;
|
| HandleError(Dart_StringLength(nameHandle, &length));
|
| @@ -370,19 +438,14 @@
|
| int64_t location = glGetUniformLocation(program,
|
| const_cast<const GLchar*>(reinterpret_cast<GLchar*>(str)));
|
| CheckGLError("glGetUniformLocation");
|
| - Dart_Handle result = HandleError(Dart_NewInteger(location));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, location);
|
| Dart_ExitScope();
|
| }
|
|
|
| void GLLinkProgram(Dart_NativeArguments arguments) {
|
| LOGI("GLLinkProgram");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| -
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
| glLinkProgram(program);
|
| CheckGLError("glLinkProgram");
|
| Dart_ExitScope();
|
| @@ -392,9 +455,7 @@
|
| LOGI("GLShaderSource");
|
| Dart_EnterScope();
|
|
|
| - Dart_Handle shaderHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t shader;
|
| - HandleError(Dart_IntegerToInt64(shaderHandle, &shader));
|
| + int64_t shader = GetArgAsInt(arguments, 0);
|
|
|
| Dart_Handle sourceHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| intptr_t length[1];
|
| @@ -417,11 +478,7 @@
|
| void GLUseProgram(Dart_NativeArguments arguments) {
|
| LOGI("GLUseProgram");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle programHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t program;
|
| - HandleError(Dart_IntegerToInt64(programHandle, &program));
|
| -
|
| + int64_t program = GetArgAsInt(arguments, 0);
|
| glUseProgram(program);
|
| CheckGLError("glUseProgram");
|
| Dart_ExitScope();
|
| @@ -430,16 +487,8 @@
|
| void GLUniform1i(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform1i");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t v0;
|
| - HandleError(Dart_IntegerToInt64(v0Handle, &v0));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int64_t v0 = GetArgAsInt(arguments, 1);
|
| glUniform1i(location, v0);
|
| CheckGLError("glUniform1i");
|
| Dart_ExitScope();
|
| @@ -448,20 +497,9 @@
|
| void GLUniform2i(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform2i");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t v0;
|
| - HandleError(Dart_IntegerToInt64(v0Handle, &v0));
|
| -
|
| - Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - int64_t v1;
|
| - HandleError(Dart_IntegerToInt64(v1Handle, &v1));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int64_t v0 = GetArgAsInt(arguments, 1);
|
| + int64_t v1 = GetArgAsInt(arguments, 2);
|
| glUniform2i(location, v0, v1);
|
| CheckGLError("glUniform2i");
|
| Dart_ExitScope();
|
| @@ -470,24 +508,10 @@
|
| void GLUniform3i(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform3i");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t v0;
|
| - HandleError(Dart_IntegerToInt64(v0Handle, &v0));
|
| -
|
| - Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - int64_t v1;
|
| - HandleError(Dart_IntegerToInt64(v1Handle, &v1));
|
| -
|
| - Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - int64_t v2;
|
| - HandleError(Dart_IntegerToInt64(v2Handle, &v2));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int64_t v0 = GetArgAsInt(arguments, 1);
|
| + int64_t v1 = GetArgAsInt(arguments, 2);
|
| + int64_t v2 = GetArgAsInt(arguments, 3);
|
| glUniform3i(location, v0, v1, v2);
|
| CheckGLError("glUniform3i");
|
| Dart_ExitScope();
|
| @@ -496,28 +520,11 @@
|
| void GLUniform4i(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform4i");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t v0;
|
| - HandleError(Dart_IntegerToInt64(v0Handle, &v0));
|
| -
|
| - Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - int64_t v1;
|
| - HandleError(Dart_IntegerToInt64(v1Handle, &v1));
|
| -
|
| - Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - int64_t v2;
|
| - HandleError(Dart_IntegerToInt64(v2Handle, &v2));
|
| -
|
| - Dart_Handle v3Handle = HandleError(Dart_GetNativeArgument(arguments, 4));
|
| - int64_t v3;
|
| - HandleError(Dart_IntegerToInt64(v3Handle, &v3));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int64_t v0 = GetArgAsInt(arguments, 1);
|
| + int64_t v1 = GetArgAsInt(arguments, 2);
|
| + int64_t v2 = GetArgAsInt(arguments, 3);
|
| + int64_t v3 = GetArgAsInt(arguments, 4);
|
| glUniform4i(location, v0, v1, v2, v3);
|
| CheckGLError("glUniform4i");
|
| Dart_ExitScope();
|
| @@ -526,16 +533,8 @@
|
| void GLUniform1f(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform1f");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - double v0;
|
| - HandleError(Dart_DoubleValue(v0Handle, &v0));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + double v0 = GetArgAsDouble(arguments, 1);
|
| glUniform1f(location, v0);
|
| CheckGLError("glUniform1f");
|
| Dart_ExitScope();
|
| @@ -544,20 +543,9 @@
|
| void GLUniform2f(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform2f");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - double v0;
|
| - HandleError(Dart_DoubleValue(v0Handle, &v0));
|
| -
|
| - Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - double v1;
|
| - HandleError(Dart_DoubleValue(v1Handle, &v1));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + double v0 = GetArgAsDouble(arguments, 1);
|
| + double v1 = GetArgAsDouble(arguments, 2);
|
| glUniform2f(location, v0, v1);
|
| CheckGLError("glUniform2f");
|
| Dart_ExitScope();
|
| @@ -566,24 +554,10 @@
|
| void GLUniform3f(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform3f");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - double v0;
|
| - HandleError(Dart_DoubleValue(v0Handle, &v0));
|
| -
|
| - Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - double v1;
|
| - HandleError(Dart_DoubleValue(v1Handle, &v1));
|
| -
|
| - Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - double v2;
|
| - HandleError(Dart_DoubleValue(v2Handle, &v2));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + double v0 = GetArgAsDouble(arguments, 1);
|
| + double v1 = GetArgAsDouble(arguments, 2);
|
| + double v2 = GetArgAsDouble(arguments, 3);
|
| glUniform3f(location, v0, v1, v2);
|
| CheckGLError("glUniform3f");
|
| Dart_ExitScope();
|
| @@ -592,28 +566,11 @@
|
| void GLUniform4f(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform4f");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle v0Handle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - double v0;
|
| - HandleError(Dart_DoubleValue(v0Handle, &v0));
|
| -
|
| - Dart_Handle v1Handle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - double v1;
|
| - HandleError(Dart_DoubleValue(v1Handle, &v1));
|
| -
|
| - Dart_Handle v2Handle = HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - double v2;
|
| - HandleError(Dart_DoubleValue(v2Handle, &v2));
|
| -
|
| - Dart_Handle v3Handle = HandleError(Dart_GetNativeArgument(arguments, 4));
|
| - double v3;
|
| - HandleError(Dart_DoubleValue(v3Handle, &v3));
|
| -
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + double v0 = GetArgAsDouble(arguments, 1);
|
| + double v1 = GetArgAsDouble(arguments, 2);
|
| + double v2 = GetArgAsDouble(arguments, 3);
|
| + double v3 = GetArgAsDouble(arguments, 4);
|
| glUniform4f(location, v0, v1, v2, v3);
|
| CheckGLError("glUniform4f");
|
| Dart_ExitScope();
|
| @@ -622,24 +579,10 @@
|
| void GLUniform1iv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform1iv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLint* list = new GLint[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - int64_t v;
|
| - HandleError(Dart_IntegerToInt64(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLint* list = GetArgsAsGLintList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform1iv(location, len, list);
|
| delete [] list;
|
| CheckGLError("glUniform1iv");
|
| @@ -650,24 +593,10 @@
|
| void GLUniform2iv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform2iv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLint* list = new GLint[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - int64_t v;
|
| - HandleError(Dart_IntegerToInt64(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLint* list = GetArgsAsGLintList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform2iv(location, len / 2, list);
|
| delete [] list;
|
| CheckGLError("glUniform2iv");
|
| @@ -678,24 +607,10 @@
|
| void GLUniform3iv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform3iv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLint* list = new GLint[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - int64_t v;
|
| - HandleError(Dart_IntegerToInt64(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLint* list = GetArgsAsGLintList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform3iv(location, len / 3, list);
|
| delete [] list;
|
| CheckGLError("glUniform3iv");
|
| @@ -706,24 +621,10 @@
|
| void GLUniform4iv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform4iv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLint* list = new GLint[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - int64_t v;
|
| - HandleError(Dart_IntegerToInt64(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLint* list = GetArgsAsGLintList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform1iv(location, len / 4, list);
|
| delete [] list;
|
| CheckGLError("glUniform4iv");
|
| @@ -734,24 +635,10 @@
|
| void GLUniform1fv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform1fv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLfloat* list = new GLfloat[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - double v;
|
| - HandleError(Dart_DoubleValue(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLfloat* list = GetArgsAsFloatList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform1fv(location, len, list);
|
| delete [] list;
|
| CheckGLError("glUniform1fv");
|
| @@ -762,24 +649,10 @@
|
| void GLUniform2fv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform2fv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLfloat* list = new GLfloat[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - double v;
|
| - HandleError(Dart_DoubleValue(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLfloat* list = GetArgsAsFloatList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform2fv(location, len / 2, list);
|
| delete [] list;
|
| CheckGLError("glUniform2fv");
|
| @@ -790,24 +663,10 @@
|
| void GLUniform3fv(Dart_NativeArguments arguments) {
|
| LOGI("GLUniform3fv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLfloat* list = new GLfloat[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - double v;
|
| - HandleError(Dart_DoubleValue(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLfloat* list = GetArgsAsFloatList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform3fv(location, len / 3, list);
|
| delete [] list;
|
| CheckGLError("glUniform3fv");
|
| @@ -818,24 +677,10 @@
|
| void GLUniform4fv(Dart_NativeArguments arguments) {
|
| LOGI("In GLUniform4fv");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle locationHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t location;
|
| - HandleError(Dart_IntegerToInt64(locationHandle, &location));
|
| -
|
| - Dart_Handle argHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| -
|
| - if (Dart_IsList(argHandle)) {
|
| - int len;
|
| - HandleError(Dart_ListLength(argHandle, &len));
|
| - GLfloat* list = new GLfloat[len];
|
| - for (int i = 0; i < len; i++) {
|
| - Dart_Handle vHandle = Dart_ListGetAt(argHandle, i);
|
| - double v;
|
| - HandleError(Dart_DoubleValue(vHandle, &v));
|
| - list[i] = v;
|
| - }
|
| + int64_t location = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + GLfloat* list = GetArgsAsFloatList(arguments, 1, &len);
|
| + if (list != NULL) {
|
| glUniform4fv(location, len / 4, list);
|
| delete [] list;
|
| CheckGLError("glUniform4fv");
|
| @@ -846,29 +691,10 @@
|
| void GLViewport(Dart_NativeArguments arguments) {
|
| LOGI("GLViewport");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle xHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t x;
|
| - HandleError(Dart_IntegerToInt64(xHandle, &x));
|
| -
|
| - Dart_Handle yHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t y;
|
| - HandleError(Dart_IntegerToInt64(yHandle, &y));
|
| -
|
| - Dart_Handle widthHandle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - int64_t width;
|
| - HandleError(Dart_IntegerToInt64(widthHandle, &width));
|
| -
|
| - Dart_Handle heightHandle = HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - int64_t height;
|
| - HandleError(Dart_IntegerToInt64(heightHandle, &height));
|
| -
|
| - LOGI("Dimensions: [%d, %d, %d, %d]",
|
| - static_cast<int>(x),
|
| - static_cast<int>(y),
|
| - static_cast<int>(width),
|
| - static_cast<int>(height));
|
| -
|
| + int64_t x = GetArgAsInt(arguments, 0);
|
| + int64_t y = GetArgAsInt(arguments, 1);
|
| + int64_t width = GetArgAsInt(arguments, 2);
|
| + int64_t height = GetArgAsInt(arguments, 3);
|
| glViewport(x, y, width, height);
|
| CheckGLError("glViewPort");
|
| Dart_ExitScope();
|
| @@ -877,28 +703,12 @@
|
| void GLVertexAttribPointer(Dart_NativeArguments arguments) {
|
| LOGI("GLVertexAttribPointer");
|
| Dart_EnterScope();
|
| + int64_t index = GetArgAsInt(arguments, 0);
|
| + int64_t size = GetArgAsInt(arguments, 1);
|
| + int64_t type = GetArgAsInt(arguments, 2);
|
| + bool normalized = GetArgAsBool(arguments, 3);
|
| + int64_t stride = GetArgAsInt(arguments, 4);
|
|
|
| - Dart_Handle indexHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - int64_t index;
|
| - HandleError(Dart_IntegerToInt64(indexHandle, &index));
|
| -
|
| - Dart_Handle sizeHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - int64_t size;
|
| - HandleError(Dart_IntegerToInt64(sizeHandle, &size));
|
| -
|
| - Dart_Handle typeHandle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - int64_t type;
|
| - HandleError(Dart_IntegerToInt64(typeHandle, &type));
|
| -
|
| - Dart_Handle normalizedHandle =
|
| - HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - bool normalized;
|
| - HandleError(Dart_BooleanValue(normalizedHandle, &normalized));
|
| -
|
| - Dart_Handle strideHandle = HandleError(Dart_GetNativeArgument(arguments, 4));
|
| - int64_t stride;
|
| - HandleError(Dart_IntegerToInt64(strideHandle, &stride));
|
| -
|
| Dart_Handle pointerHandle = HandleError(Dart_GetNativeArgument(arguments, 5));
|
| int64_t pointerValue;
|
| HandleError(Dart_IntegerToInt64(pointerHandle, &pointerValue));
|
| @@ -913,23 +723,10 @@
|
| void GLClearColor(Dart_NativeArguments arguments) {
|
| LOGI("GLClearColor");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle redHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - double red;
|
| - HandleError(Dart_DoubleValue(redHandle, &red));
|
| -
|
| - Dart_Handle greenHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| - double green;
|
| - HandleError(Dart_DoubleValue(greenHandle, &green));
|
| -
|
| - Dart_Handle blueHandle = HandleError(Dart_GetNativeArgument(arguments, 2));
|
| - double blue;
|
| - HandleError(Dart_DoubleValue(blueHandle, &blue));
|
| -
|
| - Dart_Handle alphaHandle = HandleError(Dart_GetNativeArgument(arguments, 3));
|
| - double alpha;
|
| - HandleError(Dart_DoubleValue(alphaHandle, &alpha));
|
| -
|
| + double red = GetArgAsDouble(arguments, 0);
|
| + double green = GetArgAsDouble(arguments, 1);
|
| + double blue = GetArgAsDouble(arguments, 2);
|
| + double alpha = GetArgAsDouble(arguments, 3);
|
| glClearColor(red, green, blue, alpha);
|
| CheckGLError("glClearColor");
|
| Dart_ExitScope();
|
| @@ -938,11 +735,7 @@
|
| void GLClearDepth(Dart_NativeArguments arguments) {
|
| LOGI("GLClearDepth");
|
| Dart_EnterScope();
|
| -
|
| - Dart_Handle depthHandle = HandleError(Dart_GetNativeArgument(arguments, 0));
|
| - double depth;
|
| - HandleError(Dart_DoubleValue(depthHandle, &depth));
|
| -
|
| + double depth = GetArgAsDouble(arguments, 0);
|
| glClearDepthf(depth);
|
| CheckGLError("glClearDepthf");
|
| Dart_ExitScope();
|
| @@ -959,92 +752,58 @@
|
| Dart_ExitScope();
|
| }
|
|
|
| -void GLArrayBuffer(Dart_NativeArguments arguments) {
|
| - LOGI("GLArrayBuffer");
|
| +void ReturnGLIntConstant(Dart_NativeArguments arguments, int c) {
|
| Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_ARRAY_BUFFER));
|
| - Dart_SetReturnValue(arguments, result);
|
| + SetIntReturnValue(arguments, c);
|
| Dart_ExitScope();
|
| }
|
|
|
| +void GLArrayBuffer(Dart_NativeArguments arguments) {
|
| + ReturnGLIntConstant(arguments, GL_ARRAY_BUFFER);
|
| +}
|
| +
|
| void GLColorBufferBit(Dart_NativeArguments arguments) {
|
| - LOGI("GLColorBuffer");
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_COLOR_BUFFER_BIT));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_COLOR_BUFFER_BIT);
|
| }
|
|
|
| void GLCompileStatus(Dart_NativeArguments arguments) {
|
| - LOGI("GLCompileStatus");
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_COMPILE_STATUS));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_COMPILE_STATUS);
|
| }
|
|
|
| void GLDepthBufferBit(Dart_NativeArguments arguments) {
|
| - LOGI("GLDepthBufferBit");
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_DEPTH_BUFFER_BIT));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_DEPTH_BUFFER_BIT);
|
| }
|
|
|
| void GLFloat(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_FLOAT));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_FLOAT);
|
| }
|
|
|
| void GLFragmentShader(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_FRAGMENT_SHADER));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_FRAGMENT_SHADER);
|
| }
|
|
|
| void GLLinkStatus(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_LINK_STATUS));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_LINK_STATUS);
|
| }
|
|
|
| void GLStaticDraw(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_STATIC_DRAW));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_STATIC_DRAW);
|
| }
|
|
|
| void GLTriangleStrip(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_TRIANGLE_STRIP));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_TRIANGLE_STRIP);
|
| }
|
|
|
| void GLTriangles(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_TRIANGLES));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_TRIANGLES);
|
| }
|
|
|
| void GLTrue(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_TRUE));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_TRUE);
|
| }
|
|
|
| void GLVertexShader(Dart_NativeArguments arguments) {
|
| - Dart_EnterScope();
|
| - Dart_Handle result = HandleError(Dart_NewInteger(GL_VERTEX_SHADER));
|
| - Dart_SetReturnValue(arguments, result);
|
| - Dart_ExitScope();
|
| + ReturnGLIntConstant(arguments, GL_VERTEX_SHADER);
|
| }
|
|
|
| uint8_t* RandomArray(int seed, int length) {
|
| @@ -1106,18 +865,37 @@
|
| void PlayBackground(Dart_NativeArguments arguments) {
|
| LOGI("PlayBackground");
|
| Dart_EnterScope();
|
| - const char* what = GetStringArg(arguments, 0);
|
| - PlayBackground(what);
|
| + const char* what = GetArgAsString(arguments, 0);
|
| + int rtn = PlayBackgroundSound(what);
|
| + SetIntReturnValue(arguments, rtn);
|
| Dart_ExitScope();
|
| }
|
|
|
| void StopBackground(Dart_NativeArguments arguments) {
|
| LOGI("StopBackground");
|
| Dart_EnterScope();
|
| - StopBackground();
|
| + StopBackgroundSound();
|
| Dart_ExitScope();
|
| }
|
|
|
| +void LoadSample(Dart_NativeArguments arguments) {
|
| + LOGI("LoadSample");
|
| + Dart_EnterScope();
|
| + const char* what = GetArgAsString(arguments, 0);
|
| + int rtn = LoadSoundSample(what);
|
| + SetIntReturnValue(arguments, rtn);
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| +void PlaySample(Dart_NativeArguments arguments) {
|
| + LOGI("PlaySample");
|
| + Dart_EnterScope();
|
| + const char* what = GetArgAsString(arguments, 0);
|
| + int rtn = PlaySoundSample(what);
|
| + SetIntReturnValue(arguments, rtn);
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| struct FunctionLookup {
|
| const char* name;
|
| Dart_NativeFunction function;
|
| @@ -1125,6 +903,7 @@
|
|
|
| FunctionLookup function_list[] = {
|
| {"Log", Log},
|
| + {"LogError", LogError},
|
| {"SystemRand", SystemRand},
|
| {"SystemSrand", SystemSrand},
|
| {"EGLSwapBuffers", EGLSwapBuffers},
|
| @@ -1185,6 +964,8 @@
|
| // Audio support.
|
| {"PlayBackground", PlayBackground},
|
| {"StopBackground", StopBackground},
|
| + {"LoadSample", LoadSample},
|
| + {"PlaySample", PlaySample},
|
|
|
| {NULL, NULL}};
|
|
|
|
|