This change adds a 'SRGB' config flag when creating a SwapChain that
enables linear to sRGB conversion on write.
When using this flag, the linear->srgb conversion in the color grading
post processing should be disabled (or, the whole post-processing
stage should be disabled).
There is also a new query to determine if this flag is supported by
the underlaying platform.
On Metal, this happens automatically when the underlaying layer is sRGB.
This reverts commit 3799e219fc.
42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
/*
|
|
* Copyright (C) 2020 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <jni.h>
|
|
|
|
#include <filament/Engine.h>
|
|
#include <filament/SwapChain.h>
|
|
|
|
#include "common/CallbackUtils.h"
|
|
|
|
using namespace filament;
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
Java_com_google_android_filament_SwapChain_nSetFrameCompletedCallback(JNIEnv* env, jclass,
|
|
jlong nativeSwapChain, jobject handler, jobject runnable) {
|
|
SwapChain* swapChain = (SwapChain*) nativeSwapChain;
|
|
auto *callback = JniCallback::make(env, handler, runnable);
|
|
swapChain->setFrameCompletedCallback([](void* user) {
|
|
JniCallback* callback = (JniCallback*)user;
|
|
JniCallback::postToJavaAndDestroy(callback);
|
|
}, callback);
|
|
}
|
|
|
|
extern "C" JNIEXPORT jboolean JNICALL
|
|
Java_com_google_android_filament_SwapChain_nIsSRGBSwapChainSupported(JNIEnv *, jclass, jlong nativeEngine) {
|
|
Engine* engine = (Engine*) nativeEngine;
|
|
return (bool)SwapChain::isSRGBSwapChainSupported(*engine);
|
|
}
|