[Android] GPU trace viewer and launcher activities

This commit is contained in:
Triang3l 2022-07-17 16:58:19 +03:00
parent 421c9a80c5
commit 8948b2b557
6 changed files with 114 additions and 3 deletions

View File

@ -30,14 +30,27 @@
android:theme="@android:style/Theme.Material.Light">
<activity
android:name="jp.xenia.emulator.WindowDemoActivity"
android:label="@string/activity_label_window_demo">
android:name="jp.xenia.emulator.LauncherActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="jp.xenia.emulator.GpuTraceViewerActivity"
android:exported="true"
android:label="@string/activity_label_gpu_trace_viewer"
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.Material.Light.NoActionBar" />
<activity
android:name="jp.xenia.emulator.WindowDemoActivity"
android:exported="true"
android:label="@string/activity_label_window_demo"
android:theme="@android:style/Theme.Material.Light.NoActionBar" />
</application>
</manifest>

View File

@ -0,0 +1,18 @@
package jp.xenia.emulator;
import android.os.Bundle;
public class GpuTraceViewerActivity extends WindowedAppActivity {
@Override
protected String getWindowedAppIdentifier() {
return "xenia_gpu_vulkan_trace_viewer";
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gpu_trace_viewer);
setWindowSurfaceView(findViewById(R.id.gpu_trace_viewer_surface_view));
}
}

View File

@ -0,0 +1,45 @@
package jp.xenia.emulator;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class LauncherActivity extends Activity {
private static final int REQUEST_OPEN_GPU_TRACE_VIEWER = 0;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
}
@Override
protected void onActivityResult(
final int requestCode, final int resultCode, final Intent data) {
if (requestCode == REQUEST_OPEN_GPU_TRACE_VIEWER && resultCode == RESULT_OK) {
final Uri uri = data.getData();
if (uri != null) {
final Intent gpuTraceViewerIntent = new Intent(this, GpuTraceViewerActivity.class);
final Bundle gpuTraceViewerLaunchArguments = new Bundle();
gpuTraceViewerLaunchArguments.putString("target_trace_file", uri.toString());
gpuTraceViewerIntent.putExtra(
WindowedAppActivity.EXTRA_CVARS, gpuTraceViewerLaunchArguments);
startActivity(gpuTraceViewerIntent);
}
}
}
public void onLaunchGpuTraceViewerClick(final View view) {
final Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/octet-stream");
startActivityForResult(intent, REQUEST_OPEN_GPU_TRACE_VIEWER);
}
public void onLaunchWindowDemoClick(final View view) {
startActivity(new Intent(this, WindowDemoActivity.class));
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<jp.xenia.emulator.WindowSurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gpu_trace_viewer_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jp.xenia.emulator.GpuTraceViewerActivity" />

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jp.xenia.emulator.LauncherActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onLaunchGpuTraceViewerClick"
android:text="@string/activity_label_gpu_trace_viewer" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onLaunchWindowDemoClick"
android:text="@string/activity_label_window_demo" />
</LinearLayout>
</ScrollView>

View File

@ -1,4 +1,5 @@
<resources>
<string name="app_name">Xenia</string>
<string name="activity_label_window_demo">Xenia Window Demo</string>
<string name="activity_label_gpu_trace_viewer">GPU Trace Viewer</string>
<string name="activity_label_window_demo">Window Demo</string>
</resources>