Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb4e3b05 authored by Pablo Ceballos's avatar Pablo Ceballos Committed by android-build-merger
Browse files

Merge "Implement the stub for glCreateShaderProgramv" into nyc-dev am: 2c6d71bb

am: 67a364a7

* commit '67a364a7':
  Implement the stub for glCreateShaderProgramv
parents 7ee9a841 67a364a7
Loading
Loading
Loading
Loading
+62 −2
Original line number Diff line number Diff line
@@ -2,7 +2,67 @@
static jint
android_glCreateShaderProgramv
  (JNIEnv *_env, jobject _this, jint type, jobjectArray strings) {
    jint _exception = 0;
    const char * _exceptionType = NULL;
    const char * _exceptionMessage = NULL;
    GLsizei _count;
    const GLchar** _strings = NULL;
    jstring* _jstrings = NULL;
    GLuint _returnValue = 0;

    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
    return 0;
    if (!strings) {
        _exception = 1;
        _exceptionType = "java/lang/IllegalArgumentException";
        _exceptionMessage = "strings == null";
        goto exit;
    }

    _count = _env->GetArrayLength(strings);

    _strings = (const GLchar**) calloc(_count, sizeof(const GLchar*));
    if (!_strings) {
        _exception = 1;
        _exceptionType = "java/lang/OutOfMemoryError";
        _exceptionMessage = "out of memory";
        goto exit;
    }

    _jstrings = (jstring*) calloc(_count, sizeof(jstring));
    if (!_jstrings) {
        _exception = 1;
        _exceptionType = "java/lang/OutOfMemoryError";
        _exceptionMessage = "out of memory";
        goto exit;
    }

    for(int i = 0; i < _count; i++) {
        _jstrings[i] = (jstring) _env->GetObjectArrayElement(strings, i);
        if (!_jstrings[i]) {
            _exception = 1;
            _exceptionType = "java/lang/IllegalArgumentException";
            _exceptionMessage = "strings == null";
            goto exit;
        }
        _strings[i] = _env->GetStringUTFChars(_jstrings[i], 0);
    }

    _returnValue = glCreateShaderProgramv((GLenum)type, _count, _strings);
exit:
    if (_strings && _jstrings) {
        for(int i = 0; i < _count; i++) {
            if (_strings[i] && _jstrings[i]) {
                _env->ReleaseStringUTFChars(_jstrings[i], _strings[i]);
            }
        }
    }
    if (_strings) {
        free(_strings);
    }
    if (_jstrings) {
        free(_jstrings);
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
    }
    return (jint)_returnValue;
}