API BREAKAGE: this change aims to fix multi-view support (#2376)

* API BREAKAGE: this change aims to fix multi-view support


What has changed:
- View doesn't have a notion of clear color anymore
- View doesn't have a notion of discard flags anymore
- The clear color and color-buffer discard/clear flags are moved to Renderer
- Skybox can now be set to a constant color
- View have a blend-mode

What does is all mean:
"Clearing" (i.e.) setting its background is now handled by Skybox, by
setting a constant color to the Skybox. This should take care of
drawing views side by side.

When a view needs to be drawn on top of another, it's BlendMode needs to
be set to TRANSLUCENT and of course and, generally, it wither won't have
a skybox, or will have one that sets some translucent pixels.

As an optimization, a View with BlendMode::OPAQUE will have its
background cleared with the color specified in Renderer.

If the SwapChain already has some content, it's now possible to set
the Renderer to not discard the content, together with TRANSLUCENT views,
it's possible to draw on top of that content.


It is NOT possible to share depth/stencil buffers between views.

Fixes: #2369, #2372, #2364

* Address reviewers comments.

Note: WebGL is still broken with this PR
This commit is contained in:
Mathias Agopian
2020-04-10 15:54:14 -07:00
committed by GitHub
parent 95c8dd0185
commit 1b36f82c1e
47 changed files with 495 additions and 333 deletions

View File

@@ -18,6 +18,8 @@
#include <filament/Skybox.h>
#include <math/vec4.h>
using namespace filament;
extern "C" JNIEXPORT jlong JNICALL
@@ -54,6 +56,13 @@ Java_com_google_android_filament_Skybox_nBuilderIntensity(JNIEnv *env, jclass cl
builder->intensity(intensity);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Skybox_nBuilderColor(JNIEnv *, jclass,
jlong nativeSkyBoxBuilder, jfloat r, jfloat g, jfloat b, jfloat a) {
Skybox::Builder *builder = (Skybox::Builder *) nativeSkyBoxBuilder;
builder->color({r, g, b, a});
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Skybox_nBuilderBuild(JNIEnv *env, jclass type,
jlong nativeSkyBoxBuilder, jlong nativeEngine) {
@@ -82,3 +91,10 @@ Java_com_google_android_filament_Skybox_nGetIntensity(JNIEnv *env, jclass clazz,
Skybox *skybox = (Skybox *) nativeSkybox;
return static_cast<jint>(skybox->getIntensity());
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Skybox_nSetColor(JNIEnv *, jclass,
jlong nativeSkybox, jfloat r, jfloat g, jfloat b, jfloat a) {
Skybox *skybox = (Skybox *) nativeSkybox;
skybox->setColor({r, g, b, a});
}