Make dithering an enum.
This commit is contained in:
committed by
Mathias Agopian
parent
07bb62490b
commit
6e4491c852
@@ -124,16 +124,16 @@ Java_com_google_android_filament_View_nGetAntiAliasing(JNIEnv*, jclass,
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDithering(JNIEnv*, jclass,
|
||||
jlong nativeView, jboolean dithering) {
|
||||
jlong nativeView, jint dithering) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setDithering((bool) dithering);
|
||||
view->setDithering((View::Dithering) dithering);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetDithering(JNIEnv*, jclass,
|
||||
jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jboolean)view->getDithering();
|
||||
return (jint)view->getDithering();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
||||
@@ -60,6 +60,11 @@ public class View {
|
||||
FXAA
|
||||
}
|
||||
|
||||
public enum Dithering {
|
||||
NONE,
|
||||
TEMPORAL
|
||||
}
|
||||
|
||||
public enum DepthPrepass {
|
||||
DEFAULT(-1),
|
||||
DISABLED(0),
|
||||
@@ -160,12 +165,13 @@ public class View {
|
||||
return AntiAliasing.values()[nGetAntiAliasing(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setDithering(boolean dithering) {
|
||||
nSetDithering(getNativeObject(), dithering);
|
||||
public void setDithering(@NonNull Dithering dithering) {
|
||||
nSetDithering(getNativeObject(), dithering.ordinal());
|
||||
}
|
||||
|
||||
public boolean getDithering() {
|
||||
return nGetDithering(getNativeObject());
|
||||
@NonNull
|
||||
public Dithering getDithering() {
|
||||
return Dithering.values()[nGetDithering(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setDynamicResolutionOptions(@NonNull DynamicResolutionOptions options) {
|
||||
@@ -265,8 +271,8 @@ public class View {
|
||||
private static native int nGetSampleCount(long nativeView);
|
||||
private static native void nSetAntiAliasing(long nativeView, int type);
|
||||
private static native int nGetAntiAliasing(long nativeView);
|
||||
private static native void nSetDithering(long nativeView, boolean dithering);
|
||||
private static native boolean nGetDithering(long nativeView);
|
||||
private static native void nSetDithering(long nativeView, int dithering);
|
||||
private static native int nGetDithering(long nativeView);
|
||||
private static native void nSetDynamicResolutionOptions(long nativeView,
|
||||
boolean enabled, boolean homogeneousScaling,
|
||||
float targetFrameTimeMilli, float headRoomRatio, float scaleRate,
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
/**
|
||||
* List of available post-processing anti-aliasing techniques.
|
||||
*/
|
||||
enum AntiAliasing : uint8_t {
|
||||
enum class AntiAliasing : uint8_t {
|
||||
NONE = 0,
|
||||
FXAA = 1
|
||||
};
|
||||
@@ -151,6 +151,14 @@ public:
|
||||
ENABLED,
|
||||
};
|
||||
|
||||
/**
|
||||
* List of available post-processing dithering techniques.
|
||||
*/
|
||||
enum class Dithering : uint8_t {
|
||||
NONE = 0, //!< No dithering
|
||||
TEMPORAL = 1 //!< Temporal dithering (default)
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets whether this view is rendered with or without a depth pre-pass.
|
||||
*
|
||||
@@ -378,16 +386,16 @@ public:
|
||||
/**
|
||||
* Enables or disables dithering in the post-processing stage. Enabled by default.
|
||||
*
|
||||
* @param dithering true to enable, false to disable
|
||||
* @param dithering dithering type
|
||||
*/
|
||||
void setDithering(bool dithering) noexcept;
|
||||
void setDithering(Dithering dithering) noexcept;
|
||||
|
||||
/**
|
||||
* Queries whether dithering is enabled during the post-processing stage.
|
||||
*
|
||||
* @return true if post-processing dithering is enabled, false otherwise.
|
||||
* @return the current dithering type for this view.
|
||||
*/
|
||||
bool getDithering() const noexcept;
|
||||
Dithering getDithering() const noexcept;
|
||||
|
||||
/**
|
||||
* Sets the dynamic resolution options for this view. Dynamic resolution options
|
||||
|
||||
@@ -165,7 +165,7 @@ void FRenderer::renderJob(ArenaScope& arena, FView& view) {
|
||||
const bool hasPostProcess = view.hasPostProcessPass();
|
||||
float2 scale = view.updateScale(mFrameInfoManager.getLastFrameTime());
|
||||
bool useFXAA = view.getAntiAliasing() == View::AntiAliasing::FXAA;
|
||||
bool dithering = view.getDithering();
|
||||
bool dithering = view.getDithering() == View::Dithering::TEMPORAL;
|
||||
if (!hasPostProcess) {
|
||||
// dynamic scaling and FXAA are part of the post-process phase and can't happen if
|
||||
// it's disabled.
|
||||
|
||||
@@ -863,11 +863,11 @@ View::AntiAliasing View::getAntiAliasing() const noexcept {
|
||||
return upcast(this)->getAntiAliasing();
|
||||
}
|
||||
|
||||
void View::setDithering(bool dithering) noexcept {
|
||||
void View::setDithering(Dithering dithering) noexcept {
|
||||
upcast(this)->setDithering(dithering);
|
||||
}
|
||||
|
||||
bool View::getDithering() const noexcept {
|
||||
View::Dithering View::getDithering() const noexcept {
|
||||
return upcast(this)->getDithering();
|
||||
}
|
||||
|
||||
|
||||
@@ -162,11 +162,11 @@ public:
|
||||
return mAntiAliasing;
|
||||
}
|
||||
|
||||
void setDithering(bool dithering) noexcept {
|
||||
void setDithering(Dithering dithering) noexcept {
|
||||
mDithering = dithering;
|
||||
}
|
||||
|
||||
bool getDithering() const noexcept {
|
||||
Dithering getDithering() const noexcept {
|
||||
return mDithering;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ private:
|
||||
uint8_t mVisibleLayers = 0x1;
|
||||
uint8_t mSampleCount = 1;
|
||||
AntiAliasing mAntiAliasing = AntiAliasing::FXAA;
|
||||
bool mDithering = true;
|
||||
Dithering mDithering = Dithering::TEMPORAL;
|
||||
bool mShadowingEnabled = true;
|
||||
bool mHasPostProcessPass = true;
|
||||
DepthPrepass mDepthPrepass = DepthPrepass::DEFAULT;
|
||||
|
||||
@@ -383,8 +383,8 @@ static void gui(filament::Engine* engine, filament::View*) {
|
||||
}
|
||||
|
||||
static void preRender(filament::Engine*, filament::View* view, filament::Scene*, filament::Renderer*) {
|
||||
view->setAntiAliasing(g_params.fxaa ? View::FXAA : View::NONE);
|
||||
view->setDithering(g_params.dithering);
|
||||
view->setAntiAliasing(g_params.fxaa ? View::AntiAliasing::FXAA : View::AntiAliasing::NONE);
|
||||
view->setDithering(g_params.dithering ? View::Dithering::TEMPORAL : View::Dithering::NONE);
|
||||
view->setSampleCount((uint8_t) (g_params.msaa ? 4 : 1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user