Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Set up native EGL render loop for Oculus, Google and SVR flavors
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Feb 13, 2018
1 parent 9cdee48 commit 1b53c2a
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 178 deletions.
12 changes: 12 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,23 @@ android {
]
}

googlevr {
java.srcDirs = [
'src/common/nativeactivity'
]
}

oculusvr {
java.srcDirs = [
'src/common/nativeactivity'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/ovr_mobile/VrApi/Libs"]
}

svr {
java.srcDirs = [
'src/common/nativeactivity'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/svr/libs"]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.vrbrowser;

import android.app.NativeActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.graphics.SurfaceTexture;
import android.view.Surface;
import android.view.SurfaceView;

import org.mozilla.gecko.GeckoSession;

public class VRBrowserActivity extends NativeActivity {
static String LOGTAG = "VRBrowser";
static final String DEFAULT_URL = "https://mozvr.com";
// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("native-lib");
}

private SurfaceView mSurfaceView;
private static GeckoSession mSession;
private static Surface mBrowserSurface;

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.e(LOGTAG,"in onCreate");
super.onCreate(savedInstanceState);
if (mSession == null) {
mSession = new GeckoSession();
}
getWindow().takeSurface(null);
SurfaceView surfaceView = new SurfaceView(this);
surfaceView.getHolder().addCallback(this);

setContentView(surfaceView);
loadFromIntent(getIntent());
}

@Override
protected void onNewIntent(final Intent intent) {
Log.e(LOGTAG,"In onNewIntent");
super.onNewIntent(intent);
setIntent(intent);
final String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
if (intent.getData() != null) {
loadFromIntent(intent);
}
}
}

private void loadFromIntent(final Intent intent) {
final Uri uri = intent.getData();
Log.e(LOGTAG, "Load URI from intent: " + (uri != null ? uri.toString() : DEFAULT_URL));
String uriValue = (uri != null ? uri.toString() : DEFAULT_URL);
mSession.loadUri(uriValue);
}

@Override
protected void onPause() {
Log.e(LOGTAG, "In onPause");
super.onPause();
}

@Override
protected void onResume() {
Log.e(LOGTAG, "in onResume");
super.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
}

private void setSurfaceTexture(String aName, final SurfaceTexture aTexture, final int aWidth, final int aHeight) {
runOnUiThread(new Runnable() {
public void run() {
createBrowser(aTexture, aWidth, aHeight);
}
});
}

private void createBrowser(SurfaceTexture aTexture, int aWidth, int aHeight) {
if (aTexture != null) {
Log.e(LOGTAG,"In createBrowser");
aTexture.setDefaultBufferSize(aWidth, aHeight);
mBrowserSurface = new Surface(aTexture);
mSession.acquireDisplay().surfaceChanged(mBrowserSurface, aWidth, aHeight);
mSession.openWindow(this);
}
}
}
1 change: 1 addition & 0 deletions app/src/googlevr/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:screenOrientation="landscape"
android:enableVrMode="@string/gvr_vr_mode_component"
android:resizeableActivity="false">
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
<!-- Intent filter that enables this app to be launched from the
Daydream Home menu. -->
<intent-filter>
Expand Down
178 changes: 0 additions & 178 deletions app/src/main/java/org/mozilla/vrbrowser/VRBrowserActivity.java

This file was deleted.

1 change: 1 addition & 0 deletions app/src/oculusvr/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<application>
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<activity android:name=".VRBrowserActivity" android:screenOrientation="landscape">
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
</activity>
</application>
</manifest>
1 change: 1 addition & 0 deletions app/src/svr/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<application>
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<activity android:name=".VRBrowserActivity" android:screenOrientation="reverseLandscape">
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
<!-- Intent filter that enables this app to be launched from the
Snapdragon Launcher menu. -->
<intent-filter>
Expand Down

0 comments on commit 1b53c2a

Please sign in to comment.