Skip to content

Commit

Permalink
Merge branch 'rc/1.9.5' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Oct 19, 2020
2 parents 6778ab0 + 8bccfc2 commit 9810701
Show file tree
Hide file tree
Showing 56 changed files with 1,226 additions and 113 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.9.4'
implementation 'com.google.android.filament:filament-android:1.9.5'
}
```

Expand Down Expand Up @@ -63,7 +63,7 @@ A much smaller alternative to `filamat-android` that can only generate OpenGL sh
iOS projects can use CocoaPods to install the latest release:

```
pod 'Filament', '~> 1.9.4'
pod 'Filament', '~> 1.9.5'
```

### Snapshots
Expand Down
15 changes: 14 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
This file contains one line summaries of commits that are worthy of mentioning in release notes.
A new header is inserted each time a *tag* is created.

## Next release (v1.9.5)
## Next release (main branch)

## v1.9.5

- Added a new Live Wallpaper Android sample
- `UiHelper` now supports managing a `SurfaceHolder`
- Fix: an internal texture resource was never destroyed
- Fix: hang on 2-CPU machines
- Fix: Vulkan crash when using shadow cascades
- Linux fixes for headless SwiftShader
- Fix null pointer dereference in `FIndirectLight`
- Fix Windows build by avoiding nested initializers
- Vulkan: support readPixels and headless swap chains
- VSM improvements

## v1.9.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ public Builder culling(boolean enabled) {

/**
* Controls if this renderable casts shadows, false by default.
*
* If the View's shadow type is set to {@link View.ShadowType#VSM}, castShadows should only
* be disabled if either is true:
* <ul>
* <li>{@link RenderableManager#setReceiveShadows} is also disabled</li>
* <li>the object is guaranteed to not cast shadows on itself or other objects (for
* example, a ground plane)</li>
* </ul>
*/
@NonNull
public Builder castShadows(boolean enabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,14 @@ public void setDynamicLightingOptions(float zLightNear, float zLightFar) {
*
* The ShadowType affects all the shadows seen within the View.
*
* <p>
* {@link ShadowType#VSM} imposes a restriction on marking renderables as only shadow receivers
* (but not casters). To ensure correct shadowing with VSM, all shadow participant renderables
* should be marked as both receivers and casters. Objects that are guaranteed to not cast
* shadows on themselves or other objects (such as flat ground planes) can be set to not cast
* shadows, which might improve shadow quality.
* </p>
*
* <strong>Warning: This API is still experimental and subject to change.</strong>
*/
public void setShadowType(ShadowType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import com.google.android.filament.SwapChain;

/**
* UiHelper is a simple class that can manage either a SurfaceView or a TextureView so it can
* be used to render into with Filament.
* UiHelper is a simple class that can manage either a SurfaceView, TextureView, or a SurfaceHolder
* so it can be used to render into with Filament.
*
* Here is a simple example with a SurfaceView. The code would be exactly the same with a
* TextureView:
Expand Down Expand Up @@ -191,6 +191,23 @@ public void detach() {
}
}

private static class SurfaceHolderHandler implements RenderSurface {
private SurfaceHolder mSurfaceHolder;

SurfaceHolderHandler(SurfaceHolder surface) {
mSurfaceHolder = surface;
}

@Override
public void resize(int width, int height) {
mSurfaceHolder.setFixedSize(width, height);
}

@Override
public void detach() {
}
}

private class TextureViewHandler implements RenderSurface {
private TextureView mTextureView;
private Surface mSurface;
Expand Down Expand Up @@ -258,8 +275,8 @@ public RendererCallback getRenderCallback() {
}

/**
* Free resources associated to the native window specified in {@link #attachTo(SurfaceView)}
* or {@link #attachTo(TextureView)}.
* Free resources associated to the native window specified in {@link #attachTo(SurfaceView)},
* {@link #attachTo(TextureView)}, or {@link #attachTo(SurfaceHolder)}.
*/
public void detach() {
destroySwapChain();
Expand Down Expand Up @@ -315,8 +332,8 @@ public boolean isOpaque() {
* Controls whether the render target (SurfaceView or TextureView) is opaque or not.
* The render target is considered opaque by default.
*
* Must be called before calling {@link #attachTo(SurfaceView)}
* or {@link #attachTo(TextureView)}.
* Must be called before calling {@link #attachTo(SurfaceView)}, {@link #attachTo(TextureView)},
* or {@link #attachTo(SurfaceHolder)}.
*
* @param opaque Indicates whether the render target should be opaque. True by default.
*/
Expand All @@ -341,6 +358,8 @@ public boolean isMediaOverlay() {
* Must be called before calling {@link #attachTo(SurfaceView)}
* or {@link #attachTo(TextureView)}.
*
* Has no effect when using {@link #attachTo(SurfaceHolder)}.
*
* @param overlay Indicates whether the render target should be rendered below the activity's
* surface when transparent.
*/
Expand Down Expand Up @@ -403,7 +422,9 @@ public void surfaceDestroyed(SurfaceHolder holder) {

SurfaceHolder holder = view.getHolder();
holder.addCallback(callback);
holder.setFixedSize(mDesiredWidth, mDesiredHeight);
if (mDesiredWidth > 0 && mDesiredHeight > 0) {
holder.setFixedSize(mDesiredWidth, mDesiredHeight);
}

// in case the SurfaceView's surface already existed
final Surface surface = holder.getSurface();
Expand Down Expand Up @@ -483,6 +504,55 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { }
}
}

/**
* Associate UiHelper with a SurfaceHolder.
*
* As soon as a Surface is created, we'll create the
* EGL resources needed, and call user callbacks if needed.
*/
public void attachTo(@NonNull SurfaceHolder holder) {
if (attach(holder)) {
int format = isOpaque() ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT;
holder.setFormat(format);

mRenderSurface = new SurfaceHolderHandler(holder);

final SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()");
createSwapChain(holder.getSurface());
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// Note: this is always called at least once after surfaceCreated()
if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")");
mRenderCallback.onResized(width, height);
}

@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()");
destroySwapChain();
}
};

holder.addCallback(callback);
if (mDesiredWidth > 0 && mDesiredHeight > 0) {
holder.setFixedSize(mDesiredWidth, mDesiredHeight);
}

// in case the SurfaceHolder's surface already existed
final Surface surface = holder.getSurface();
if (surface != null && surface.isValid()) {
callback.surfaceCreated(holder);
callback.surfaceChanged(holder, format,
holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height());
}
}
}

private boolean attach(@NonNull Object nativeWindow) {
if (mNativeWindow != null) {
// we are already attached to a native window
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.google.android.filament
VERSION_NAME=1.9.4
VERSION_NAME=1.9.5

POM_DESCRIPTION=Real-time physically based rendering engine for Android.

Expand Down
6 changes: 6 additions & 0 deletions android/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Demonstrates how to create a light and a mesh with the attributes required for l

![Lit Cube](../../docs/images/samples/sample_lit_cube.jpg)

### `live-wallpaper`

Demonstrates how to use Filament as renderer for an Android Live Wallpaper.

![Live Wallpaper](../../docs/images/samples/example_live_wallpaper.jpg)

### `image-based-lighting`

Demonstrates how to create image-based lights and load complex meshes:
Expand Down
12 changes: 12 additions & 0 deletions android/samples/sample-live-wallpaper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/caches
/.idea/gradle.xml
.DS_Store
/build
/captures
/src/main/assets
.externalNativeBuild
19 changes: 19 additions & 0 deletions android/samples/sample-live-wallpaper/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

project.ext.isSample = true

android {
compileSdkVersion versions.compileSdk
defaultConfig {
applicationId "com.google.android.filament.livewallpaper"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
}
}

dependencies {
implementation deps.kotlin
implementation project(':filament-android')
}
25 changes: 25 additions & 0 deletions android/samples/sample-live-wallpaper/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.filament.livewallpaper">

<uses-feature android:name="android.software.live_wallpaper" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/wallpaper_label"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service
android:name=".FilamentLiveWallpaper"
android:label="@string/wallpaper_label"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper" />
</service>
</application>

</manifest>
Loading

0 comments on commit 9810701

Please sign in to comment.