From patchwork Wed Aug 1 09:59:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 10439 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B5D9324027 for ; Wed, 1 Aug 2012 09:59:15 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4C002A18480 for ; Wed, 1 Aug 2012 09:59:15 +0000 (UTC) Received: by ghbz12 with SMTP id z12so6922094ghb.11 for ; Wed, 01 Aug 2012 02:59:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=84i9gHZkBN8cbhDDj+mbdQsyyqzD/P0T6J65LpmsbU4=; b=pnDt+ugqXLllWJrPwuxyUjptbBTF4bUc3FUdDp6OrywLlwaA4kstvXKD0mcWOdl+38 OoxarIREaVTi0gICK6L3FuNde1fsGYpgwTZ4y2Xkbryhd78S07LXEOqEbvZy5ArsOHjp XjPrAj0/1IVSIDxs/O2L2YvM4Tki50DYBc2LbpRJlP6OWpnf8iZLgD5s8K32o/ACa3fS Az9m/pFqLnq9F0DbPA1cQdA+3n227e60TGUCGOvbNqFM2hWQs7glCsgrhtdwP59RwTgW 8XnU2w3xWvTCJaGIdAhPrq55OSmQJ7ruzEIEfdx7ZciWm2T7/9PJX9dGVGo7Dp4YH01G +rzg== Received: by 10.50.149.134 with SMTP id ua6mr3398834igb.11.1343815154305; Wed, 01 Aug 2012 02:59:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.87.40 with SMTP id u8csp188995igz; Wed, 1 Aug 2012 02:59:13 -0700 (PDT) Received: by 10.180.86.133 with SMTP id p5mr15129613wiz.17.1343815152501; Wed, 01 Aug 2012 02:59:12 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id q3si28711282wiz.28.2012.08.01.02.59.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Aug 2012 02:59:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1SwVhv-0002ND-KI for ; Wed, 01 Aug 2012 09:59:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 85C0AE03EE for ; Wed, 1 Aug 2012 09:59:11 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 242 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 242: Android: Display the benchmark results log in the GUI. Message-Id: <20120801095911.15805.96869.launchpad@ackee.canonical.com> Date: Wed, 01 Aug 2012 09:59:11 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15719"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 60231265d2cf285fac1df543e2f0bde3e2b125e4 X-Gm-Message-State: ALoCoQk0ITo9ykMbnXdsNSKmOvp/Chlh7UptbgIV7PJndHH7bs0J4kvLlSjyogYX2s7pltEN27jc Merge authors: Alexandros Frantzis (afrantzis) Related merge proposals: https://code.launchpad.net/~linaro-graphics-wg/glmark2/android-gui-log/+merge/117448 proposed by: Alexandros Frantzis (afrantzis) review: Approve - Jesse Barker (jesse-barker) ------------------------------------------------------------ revno: 242 [merge] committer: Alexandros Frantzis branch nick: trunk timestamp: Wed 2012-08-01 12:57:46 +0300 message: Android: Display the benchmark results log in the GUI. added: android/res/drawable/menu_results.png android/res/layout/activity_results.xml android/src/org/linaro/glmark2/ResultsActivity.java modified: android/AndroidManifest.xml android/res/menu/main_options_menu.xml android/res/values/strings.xml android/res/xml/preferences.xml android/src/org/linaro/glmark2/Glmark2Native.java android/src/org/linaro/glmark2/Glmark2SurfaceView.java android/src/org/linaro/glmark2/MainActivity.java src/android.cpp src/libmatrix/log.cc src/libmatrix/log.h wscript --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'android/AndroidManifest.xml' --- android/AndroidManifest.xml 2012-07-26 11:29:49 +0000 +++ android/AndroidManifest.xml 2012-07-31 10:28:13 +0000 @@ -19,7 +19,6 @@ @@ -40,6 +39,12 @@ + + + + + === added file 'android/res/drawable/menu_results.png' Binary files android/res/drawable/menu_results.png 1970-01-01 00:00:00 +0000 and android/res/drawable/menu_results.png 2012-07-30 13:14:25 +0000 differ === added file 'android/res/layout/activity_results.xml' --- android/res/layout/activity_results.xml 1970-01-01 00:00:00 +0000 +++ android/res/layout/activity_results.xml 2012-07-30 13:14:25 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + === modified file 'android/res/menu/main_options_menu.xml' --- android/res/menu/main_options_menu.xml 2012-07-26 09:18:27 +0000 +++ android/res/menu/main_options_menu.xml 2012-07-30 13:14:25 +0000 @@ -16,6 +16,10 @@ android:title="@string/settingsMainOptionsText" android:icon="@drawable/menu_settings" /> + + === modified file 'android/res/values/strings.xml' --- android/res/values/strings.xml 2012-07-26 11:29:49 +0000 +++ android/res/values/strings.xml 2012-07-31 10:35:18 +0000 @@ -5,6 +5,7 @@ GLMark2 Benchmark Editor GLMark2 Settings About GLMark2 + GLMark2 Results GLMark2 Run Save @@ -13,12 +14,17 @@ Load list Delete list Settings + Last results About Save to external storage Run forever Run indefinitely, looping from the last benchmark back to the first + Log debug messages + Display debug messages in the log + Show benchmark results + Show results after running benchmarks GLMark2 %1$s OpenGL (ES) 2.0 benchmark suite === modified file 'android/res/xml/preferences.xml' --- android/res/xml/preferences.xml 2012-07-26 09:18:27 +0000 +++ android/res/xml/preferences.xml 2012-07-31 10:35:18 +0000 @@ -4,4 +4,12 @@ android:title="@string/runForeverPreferenceTitle" android:summary="@string/runForeverPreferenceSummary" android:defaultValue="false" /> + + === modified file 'android/src/org/linaro/glmark2/Glmark2Native.java' --- android/src/org/linaro/glmark2/Glmark2Native.java 2012-07-04 14:38:56 +0000 +++ android/src/org/linaro/glmark2/Glmark2Native.java 2012-07-30 12:28:16 +0000 @@ -24,7 +24,8 @@ import android.content.res.AssetManager; class Glmark2Native { - public static native void init(AssetManager assetManager, String args); + public static native void init(AssetManager assetManager, String args, + String logFilePath); public static native void resize(int w, int h); public static native boolean render(); public static native void done(); === modified file 'android/src/org/linaro/glmark2/Glmark2SurfaceView.java' --- android/src/org/linaro/glmark2/Glmark2SurfaceView.java 2012-07-04 14:27:42 +0000 +++ android/src/org/linaro/glmark2/Glmark2SurfaceView.java 2012-07-30 12:28:16 +0000 @@ -1,5 +1,7 @@ package org.linaro.glmark2; +import java.io.File; + import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; import android.app.Activity; @@ -203,7 +205,8 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) { String args = mView.getActivity().getIntent().getStringExtra("args"); - Glmark2Native.init(mView.getActivity().getAssets(), args); + File f = new File(mView.getActivity().getFilesDir(), "last_run.log"); + Glmark2Native.init(mView.getActivity().getAssets(), args, f.getAbsolutePath()); } private Glmark2SurfaceView mView; === modified file 'android/src/org/linaro/glmark2/MainActivity.java' --- android/src/org/linaro/glmark2/MainActivity.java 2012-07-26 12:13:44 +0000 +++ android/src/org/linaro/glmark2/MainActivity.java 2012-07-31 10:35:18 +0000 @@ -62,6 +62,9 @@ public static final int DIALOG_LOAD_LIST_ID = 3; public static final int DIALOG_DELETE_LIST_ID = 4; + public static final int ACTIVITY_GLMARK2_REQUEST_CODE = 1; + public static final int ACTIVITY_EDITOR_REQUEST_CODE = 2; + /** * The supported benchmark item actions. */ @@ -266,6 +269,10 @@ startActivity(new Intent(MainActivity.this, MainPreferencesActivity.class)); ret = true; break; + case R.id.results: + startActivity(new Intent(MainActivity.this, ResultsActivity.class)); + ret = true; + break; case R.id.about: startActivity(new Intent(MainActivity.this, AboutActivity.class)); ret = true; @@ -280,7 +287,14 @@ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (resultCode == RESULT_OK) { + if (requestCode == ACTIVITY_GLMARK2_REQUEST_CODE) + { + startActivity(new Intent(this, ResultsActivity.class)); + return; + } + else if (requestCode == ACTIVITY_EDITOR_REQUEST_CODE && + resultCode == RESULT_OK) + { String benchmarkText = data.getStringExtra("benchmark-text"); int benchmarkPos = data.getIntExtra("benchmark-pos", 0); doBenchmarkItemAction(benchmarkPos, BenchmarkItemAction.EDIT, benchmarkText); @@ -312,9 +326,15 @@ args += "-b " + benchmarks.get(i) + " "; if (prefs.getBoolean("run_forever", false)) args += "--run-forever "; + if (prefs.getBoolean("log_debug", false)) + args += "--debug "; if (!args.isEmpty()) intent.putExtra("args", args); - startActivity(intent); + + if (prefs.getBoolean("show_results", true)) + startActivityForResult(intent, ACTIVITY_GLMARK2_REQUEST_CODE); + else + startActivity(intent); } }); @@ -332,7 +352,7 @@ intent.putExtra("benchmark-text", t); intent.putExtra("benchmark-pos", position); intent.putExtra("scene-info", sceneInfoList); - startActivityForResult(intent, 1); + startActivityForResult(intent, ACTIVITY_EDITOR_REQUEST_CODE); } }); === added file 'android/src/org/linaro/glmark2/ResultsActivity.java' --- android/src/org/linaro/glmark2/ResultsActivity.java 1970-01-01 00:00:00 +0000 +++ android/src/org/linaro/glmark2/ResultsActivity.java 2012-07-30 13:14:25 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright © 2012 Linaro Limited + * + * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. + * + * glmark2 is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * glmark2. If not, see . + * + * Authors: + * Alexandros Frantzis + */ +package org.linaro.glmark2; + +import java.io.*; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +public class ResultsActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_results); + TextView tv = (TextView) findViewById(R.id.results); + + File f = new File(getFilesDir(), "last_run.log"); + + try { + /* Read log from file */ + BufferedReader reader = new BufferedReader(new FileReader(f)); + String line = null; + StringBuffer sb = new StringBuffer(); + + while ((line = reader.readLine()) != null) { + sb.append(line); + sb.append('\n'); + } + + reader.close(); + tv.setText(sb.toString()); + } + catch (Exception ex) { + } + } +} + === modified file 'src/android.cpp' --- src/android.cpp 2012-07-18 09:45:59 +0000 +++ src/android.cpp 2012-07-30 12:28:16 +0000 @@ -37,6 +37,7 @@ static Canvas *g_canvas; static MainLoop *g_loop; static BenchmarkCollection *g_benchmark_collection; +static std::ostream *g_log_extra; class MainLoopAndroid : public MainLoop { @@ -258,7 +259,8 @@ void Java_org_linaro_glmark2_native_init(JNIEnv* env, jclass clazz, jobject asset_manager, - jstring args) + jstring args, + jstring log_file) { static_cast(clazz); static const std::string arguments_file("/data/glmark2/args"); @@ -282,10 +284,17 @@ 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); + 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); @@ -340,6 +349,7 @@ delete g_loop; delete g_benchmark_collection; delete g_canvas; + delete g_log_extra; } jboolean @@ -409,7 +419,7 @@ static JNINativeMethod glmark2_native_methods[] = { { "init", - "(Landroid/content/res/AssetManager;Ljava/lang/String;)V", + "(Landroid/content/res/AssetManager;Ljava/lang/String;Ljava/lang/String;)V", reinterpret_cast(Java_org_linaro_glmark2_native_init) }, { === modified file 'src/libmatrix/log.cc' --- src/libmatrix/log.cc 2012-01-27 22:01:59 +0000 +++ src/libmatrix/log.cc 2012-07-30 09:27:14 +0000 @@ -10,6 +10,7 @@ // Alexandros Frantzis // Jesse Barker // +#include #include #include #include @@ -26,8 +27,7 @@ const string Log::continuation_prefix("\x10"); string Log::appname_; bool Log::do_debug_(false); - -#ifndef ANDROID +std::ostream* Log::extra_out_(0); static const string terminal_color_normal("\033[0m"); static const string terminal_color_red("\033[1;31m"); @@ -96,17 +96,26 @@ delete[] buf; } + void Log::info(const char *fmt, ...) { static const string infoprefix("Info"); + const string& prefix(do_debug_ ? infoprefix : empty); + va_list ap; + va_start(ap, fmt); + +#ifndef ANDROID static const string& infocolor(isatty(fileno(stdout)) ? terminal_color_cyan : empty); - va_list ap; - va_start(ap, fmt); - if (do_debug_) - print_prefixed_message(std::cout, infocolor, infoprefix, fmt, ap); - else - print_prefixed_message(std::cout, empty, empty, fmt, ap); + const string& color(do_debug_ ? infocolor : empty); + print_prefixed_message(std::cout, color, prefix, fmt, ap); +#else + __android_log_vprint(ANDROID_LOG_INFO, appname_.c_str(), fmt, ap); +#endif + + if (extra_out_) + print_prefixed_message(*extra_out_, empty, prefix, fmt, ap); + va_end(ap); } @@ -114,12 +123,21 @@ Log::debug(const char *fmt, ...) { static const string dbgprefix("Debug"); + if (!do_debug_) + return; + va_list ap; + va_start(ap, fmt); + +#ifndef ANDROID static const string& dbgcolor(isatty(fileno(stdout)) ? terminal_color_yellow : empty); - if (!do_debug_) - return; - va_list ap; - va_start(ap, fmt); print_prefixed_message(std::cout, dbgcolor, dbgprefix, fmt, ap); +#else + __android_log_vprint(ANDROID_LOG_DEBUG, appname_.c_str(), fmt, ap); +#endif + + if (extra_out_) + print_prefixed_message(*extra_out_, empty, dbgprefix, fmt, ap); + va_end(ap); } @@ -127,52 +145,29 @@ Log::error(const char *fmt, ...) { static const string errprefix("Error"); + va_list ap; + va_start(ap, fmt); + +#ifndef ANDROID static const string& errcolor(isatty(fileno(stderr)) ? terminal_color_red : empty); - va_list ap; - va_start(ap, fmt); print_prefixed_message(std::cerr, errcolor, errprefix, fmt, ap); +#else + __android_log_vprint(ANDROID_LOG_ERROR, appname_.c_str(), fmt, ap); +#endif + + if (extra_out_) + print_prefixed_message(*extra_out_, empty, errprefix, fmt, ap); + va_end(ap); } void Log::flush() { +#ifndef ANDROID std::cout.flush(); std::cerr.flush(); -} -#else -void -Log::info(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __android_log_vprint(ANDROID_LOG_INFO, appname_.c_str(), fmt, ap); - va_end(ap); -} - -void -Log::debug(const char *fmt, ...) -{ - if (!do_debug_) - return; - va_list ap; - va_start(ap, fmt); - __android_log_vprint(ANDROID_LOG_DEBUG, appname_.c_str(), fmt, ap); - va_end(ap); -} - -void -Log::error(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - __android_log_vprint(ANDROID_LOG_ERROR, appname_.c_str(), fmt, ap); - va_end(ap); -} - -void -Log::flush() -{ -} - #endif + if (extra_out_) + extra_out_->flush(); +} === modified file 'src/libmatrix/log.h' --- src/libmatrix/log.h 2012-01-27 22:01:59 +0000 +++ src/libmatrix/log.h 2012-07-30 09:27:14 +0000 @@ -14,14 +14,17 @@ #define LOG_H_ #include +#include class Log { public: - static void init(const std::string& appname, bool do_debug = false) + static void init(const std::string& appname, bool do_debug = false, + std::ostream *extra_out = 0) { appname_ = appname; do_debug_ = do_debug; + extra_out_ = extra_out; } // Emit an informational message static void info(const char *fmt, ...); @@ -41,6 +44,8 @@ static std::string appname_; // Indicates whether debug level messages should generate any output static bool do_debug_; + // Extra stream to output log messages to + static std::ostream *extra_out_; }; #endif /* LOG_H_ */ === modified file 'wscript' --- wscript 2012-07-27 09:11:50 +0000 +++ wscript 2012-07-30 09:27:14 +0000 @@ -36,7 +36,7 @@ ctx.check_tool('compiler_cxx') # Check required headers - req_headers = ['stdlib.h', 'string.h', 'stdint.h', 'stdio.h', 'jpeglib.h'] + req_headers = ['stdlib.h', 'string.h', 'unistd.h', 'stdint.h', 'stdio.h', 'jpeglib.h'] for header in req_headers: ctx.check_cxx(header_name = header, auto_add_header_name = True, mandatory = True)