Beispiel #1
0
void
Java_org_linaro_glmark2_native_init(JNIEnv* env, jclass clazz,
                                    jobject asset_manager,
                                    jstring args,
                                    jstring log_file)
{
    static_cast<void>(clazz);
    static const std::string arguments_file("/data/glmark2/args");
    int argc = 0;
    char **argv = 0;

    /* Load arguments from argument string or arguments file and parse them */
    if (args) {
        if (env->GetStringUTFLength(args) > 0) {
            const char *args_c_str = env->GetStringUTFChars(args, 0);
            if (args_c_str) {
                get_args_from_string(std::string(args_c_str), argc, argv);
                env->ReleaseStringUTFChars(args, args_c_str);
            }
        }
    }
    else {
        get_args_from_file(arguments_file, argc, argv);
    }

    Options::parse_args(argc, argv);
    release_args(argc, argv);

    /* Get the log file path and open the log file */
    const char *log_file_c_str = env->GetStringUTFChars(log_file, 0);
    if (log_file_c_str) {
        g_log_extra = new std::ofstream(log_file_c_str, std::ios::binary);
        env->ReleaseStringUTFChars(log_file, log_file_c_str);
    }

    /* Force reuse of EGL/GL context */
    Options::reuse_context = true;

    Log::init("glmark2", Options::show_debug, g_log_extra);
    Util::android_set_asset_manager(AAssetManager_fromJava(env, asset_manager));

    g_canvas = new CanvasAndroid(100, 100);
    g_canvas->init();

    Log::info("glmark2 %s\n", GLMARK_VERSION);
    g_canvas->print_info();

    std::vector<Scene*> scenes;

    /* Add and register scenes */
    create_and_add_scenes(scenes, *g_canvas);

    for (std::vector<Scene*>::const_iterator iter = scenes.begin();
            iter != scenes.end();
            iter++)
    {
        Benchmark::register_scene(**iter);
    }

    g_benchmark_collection = new BenchmarkCollection();
    g_benchmark_collection->populate_from_options();

    if (g_benchmark_collection->needs_decoration()) {
        g_loop = new MainLoopDecorationAndroid(*g_canvas,
                                               g_benchmark_collection->benchmarks());
    }
    else {
        g_loop = new MainLoopAndroid(*g_canvas,
                                     g_benchmark_collection->benchmarks());
    }
}
Beispiel #2
0
void
Java_org_linaro_glmark2_native_init(JNIEnv* env, jclass clazz,
                                    jobject asset_manager,
                                    jstring args,
                                    jstring log_file)
{
    static_cast<void>(clazz);
    static const std::string arguments_file("/data/glmark2/args");
    int argc = 0;
    char **argv = 0;
    std::stringstream frameend_ss;

    /* Load arguments from argument string or arguments file and parse them */
    if (args) {
        if (env->GetStringUTFLength(args) > 0) {
            const char *args_c_str = env->GetStringUTFChars(args, 0);
            if (args_c_str) {
                get_args_from_string(std::string(args_c_str), argc, argv);
                env->ReleaseStringUTFChars(args, args_c_str);
            }
        }
    }
    else {
        get_args_from_file(arguments_file, argc, argv);
    }

    Options::parse_args(argc, argv);
    release_args(argc, argv);

    /* Get the log file path and open the log file */
    const char *log_file_c_str = env->GetStringUTFChars(log_file, 0);
    if (log_file_c_str) {
        g_log_extra = new std::ofstream(log_file_c_str, std::ios::binary);
        env->ReleaseStringUTFChars(log_file, log_file_c_str);
    }

    Log::init("glmark2", Options::show_debug, g_log_extra);
    Util::android_set_asset_manager(AAssetManager_fromJava(env, asset_manager));

    g_canvas = new CanvasAndroid(Options::size.first, Options::size.second);

    g_canvas->interval(Options::sync);

    g_canvas->init();

    Log::info("=======================================================\n");
    Log::info("    glmark2 %s\n", GLMARK_VERSION);
    Log::info("=======================================================\n");

    switch(Options::frame_end) {
        case Options::FrameEndSwap:
            frameend_ss << "Swap";
            break;
        case Options::FrameEndFinish:
            frameend_ss << "Finish";
            break;
        case Options::FrameEndFlush:
            frameend_ss << "Flush";
            break;
        case Options::FrameEndReadPixels:
            frameend_ss << "ReadPixels";
            break;
        case Options::FrameEndNone:
            frameend_ss << "None";
            break;
        case Options::FrameEndDefault:
            if (Options::offscreen)
                frameend_ss << "Default (Finish)";
            else
                frameend_ss << "Default (Swap)";
            break;
    }

    Log::info("Options:\n"
              "\t\treuse-context: %s\n"
              "\t\tsynchronous:   %s\n"
              "\t\toffscreen:     %s\n"
              "\t\tend-frame:     %s\n"
              "\t\tsize:          %dx%d%s\n",
              Options::reuse_context?"True":"False",
              Options::sync?"True":"False",
              Options::offscreen?"True":"False",
              frameend_ss.str().c_str(),
              g_canvas->width(), g_canvas->height(),
              (g_canvas->width() == -1 && g_canvas->height() == -1)?"(fullscreen)":"");

    g_canvas->print_info();
    Log::info("=======================================================\n");

    /* Add and register scenes */
    g_scene_collection = new SceneCollection(*g_canvas);
    g_scene_collection->register_scenes();

    g_benchmark_collection = new BenchmarkCollection();
    g_benchmark_collection->populate_from_options();

    if (g_benchmark_collection->needs_decoration()) {
        g_loop = new MainLoopDecorationAndroid(*g_canvas,
                                               g_benchmark_collection->benchmarks());
    }
    else {
        g_loop = new MainLoopAndroid(*g_canvas,
                                     g_benchmark_collection->benchmarks());
    }
}