Merge "Merge "ImageWriter: configure surface to use user specified format" into qt-qpr1-dev am: f5fa3cf7cf" into qt-qpr1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
bdb2f1c3be
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <gui/IProducerListener.h>
|
#include <gui/IProducerListener.h>
|
||||||
#include <gui/Surface.h>
|
#include <gui/Surface.h>
|
||||||
|
#include <ui/PublicFormat.h>
|
||||||
#include <android_runtime/AndroidRuntime.h>
|
#include <android_runtime/AndroidRuntime.h>
|
||||||
#include <android_runtime/android_view_Surface.h>
|
#include <android_runtime/android_view_Surface.h>
|
||||||
#include <android_runtime/android_hardware_HardwareBuffer.h>
|
#include <android_runtime/android_hardware_HardwareBuffer.h>
|
||||||
@@ -401,8 +402,28 @@ static jlong ImageWriter_init(JNIEnv* env, jobject thiz, jobject weakThiz, jobje
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Set consumer buffer format to user specified format
|
||||||
|
PublicFormat publicFormat = static_cast<PublicFormat>(userFormat);
|
||||||
|
int nativeFormat = mapPublicFormatToHalFormat(publicFormat);
|
||||||
|
android_dataspace nativeDataspace = mapPublicFormatToHalDataspace(publicFormat);
|
||||||
|
res = native_window_set_buffers_format(anw.get(), nativeFormat);
|
||||||
|
if (res != OK) {
|
||||||
|
ALOGE("%s: Unable to configure consumer native buffer format to %#x",
|
||||||
|
__FUNCTION__, nativeFormat);
|
||||||
|
jniThrowRuntimeException(env, "Failed to set Surface format");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = native_window_set_buffers_data_space(anw.get(), nativeDataspace);
|
||||||
|
if (res != OK) {
|
||||||
|
ALOGE("%s: Unable to configure consumer dataspace %#x",
|
||||||
|
__FUNCTION__, nativeDataspace);
|
||||||
|
jniThrowRuntimeException(env, "Failed to set Surface dataspace");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
surfaceFormat = userFormat;
|
surfaceFormat = userFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->setBufferFormat(surfaceFormat);
|
ctx->setBufferFormat(surfaceFormat);
|
||||||
env->SetIntField(thiz,
|
env->SetIntField(thiz,
|
||||||
gImageWriterClassInfo.mWriterFormat, reinterpret_cast<jint>(surfaceFormat));
|
gImageWriterClassInfo.mWriterFormat, reinterpret_cast<jint>(surfaceFormat));
|
||||||
|
|||||||
Reference in New Issue
Block a user