Set HomeActivity transparent to avoid texture corruption (black and white)

This commit is contained in:
Gabriel Calero 2018-05-15 15:14:17 -03:00
parent 97a493d113
commit 306b8cc68a
7 changed files with 27 additions and 49 deletions

View file

@ -42,7 +42,7 @@
android:name=".HomeActivity"
android:label="@string/home"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/Theme.AppCompat.Translucent.NoActionBar">
</activity>
<activity
android:name=".GotoActivity"

View file

@ -36,8 +36,6 @@ public class InterfaceActivity extends QtActivity {
//public static native void handleHifiURL(String hifiURLString);
private native long nativeOnCreate(InterfaceActivity instance, AssetManager assetManager);
//private native void nativeOnPause();
//private native void nativeOnResume();
private native void nativeOnDestroy();
private native void nativeGotoUrl(String url);
private native void nativeGoBackFromAndroidActivity();
@ -120,29 +118,26 @@ public class InterfaceActivity extends QtActivity {
@Override
protected void onPause() {
super.onPause();
//nativeOnPause();
nativeEnterBackground();
//gvrApi.pauseTracking();
}
@Override
protected void onStart() {
super.onStart();
if (!isLoading) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
nativeEnterForeground();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@Override
protected void onStop() {
super.onStop();
nativeEnterBackground();
}
@Override
protected void onResume() {
super.onResume();
//nativeOnResume();
nativeEnterForeground();
//gvrApi.resumeTracking();
}

View file

@ -27,10 +27,7 @@ public class SplashActivity extends Activity {
}
public void onAppLoadedComplete() {
// Give interface more time so textures don't fail(got deleted) on Adreno (joystick)
new Handler(getMainLooper()).postDelayed(() -> {
startActivity(new Intent(this, HomeActivity.class));
new Handler(getMainLooper()).postDelayed(() -> SplashActivity.this.finish(), 1000);
}, 500);
startActivity(new Intent(this, HomeActivity.class)); // + 2 sec
SplashActivity.this.finish();
}
}

View file

@ -18,7 +18,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
android:background="@color/colorPrimaryDark"
android:elevation="4dp"
/>
@ -33,6 +33,7 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="@color/colorPrimaryDark"
app:menu="@menu/menu_home"
>
<LinearLayout

View file

@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@color/colorPrimary"
tools:context="io.highfidelity.hifiinterface.HomeActivity"
tools:showIn="@layout/activity_home">

View file

@ -8192,15 +8192,11 @@ void Application::openAndroidActivity(const QString& activityName) {
void Application::enterBackground() {
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"stop", Qt::BlockingQueuedConnection);
getActiveDisplayPlugin()->deactivate();
}
void Application::enterForeground() {
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"start", Qt::BlockingQueuedConnection);
if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
qWarning() << "Could not re-activate display plugin";
}
}
#endif

View file

@ -131,44 +131,32 @@ void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() {
// render stick base
auto stickBaseTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getLeftVirtualPad()->getFirstTouch(),
_virtualPadPixelSize, _virtualPadPixelSize);
render([&](gpu::Batch& batch) {
batch.enableStereo(false);
batch.setProjectionTransform(mat4());
batch.setPipeline(_cursorPipeline);
batch.setResourceTexture(0, _virtualPadStickBaseTexture);
batch.resetViewTransform();
batch.setModelTransform(stickBaseTransform);
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
batch.draw(gpu::TRIANGLE_STRIP, 4);
});
// render stick head
auto stickTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getLeftVirtualPad()->getCurrentTouch(),
_virtualPadPixelSize, _virtualPadPixelSize);
_virtualPadPixelSize, _virtualPadPixelSize);
auto jumpTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getJumpButtonPosition(),
_virtualPadJumpBtnPixelSize, _virtualPadJumpBtnPixelSize);
render([&](gpu::Batch& batch) {
batch.enableStereo(false);
batch.setFramebuffer(_compositeFramebuffer);
batch.resetViewTransform();
batch.setProjectionTransform(mat4());
batch.setPipeline(_cursorPipeline);
batch.setResourceTexture(0, _virtualPadStickTexture);
batch.resetViewTransform();
batch.setModelTransform(stickTransform);
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
batch.setResourceTexture(0, _virtualPadStickBaseTexture);
batch.setModelTransform(stickBaseTransform);
batch.draw(gpu::TRIANGLE_STRIP, 4);
});
if (!virtualPadManager.getLeftVirtualPad()->isBeingTouched()) {
// render stick head
auto jumpTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getJumpButtonPosition(),
_virtualPadJumpBtnPixelSize, _virtualPadJumpBtnPixelSize);
render([&](gpu::Batch& batch) {
batch.enableStereo(false);
batch.setProjectionTransform(mat4());
batch.setPipeline(_cursorPipeline);
batch.setResourceTexture(0, _virtualPadStickTexture);
batch.setModelTransform(stickTransform);
batch.draw(gpu::TRIANGLE_STRIP, 4);
if (!virtualPadManager.getLeftVirtualPad()->isBeingTouched()) {
batch.setResourceTexture(0, _virtualPadJumpBtnTexture);
batch.resetViewTransform();
batch.setModelTransform(jumpTransform);
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
batch.draw(gpu::TRIANGLE_STRIP, 4);
});
}
}
});
}
#endif
Parent::compositeExtra();