|
54 | 54 | #include <stdint.h>
|
55 | 55 | #include <stdlib.h>
|
56 | 56 |
|
57 |
| -// We require filament to be built with an API 26 toolchain, before that, |
58 |
| -// AHardwareBuffer support didn't exist. |
59 |
| -#if __ANDROID_API__ < 26 |
60 |
| -#error "__ANDROID_API__ must be at least 26" |
| 57 | +// We require filament to be built with an API 19 toolchain, before that, OpenGLES 3.0 didn't exist |
| 58 | +// Actually, OpenGL ES 3.0 was added to API 18, but API 19 is the better target and |
| 59 | +// the minimum for Jetpack at the time of this comment. |
| 60 | +#if __ANDROID_API__ < 21 |
| 61 | +#error "__ANDROID_API__ must be at least 21" |
61 | 62 | #endif
|
62 | 63 |
|
63 | 64 | using namespace utils;
|
@@ -235,18 +236,22 @@ PlatformEGLAndroid::ExternalImageEGLAndroid::~ExternalImageEGLAndroid() = defaul
|
235 | 236 |
|
236 | 237 | Platform::ExternalImageHandle PlatformEGLAndroid::createExternalImage(AHardwareBuffer const* buffer,
|
237 | 238 | bool sRGB) noexcept {
|
238 |
| - auto* const p = new (std::nothrow) ExternalImageEGLAndroid; |
239 |
| - auto hardwareBuffer = const_cast<AHardwareBuffer*>(buffer); |
240 |
| - p->aHardwareBuffer = hardwareBuffer; |
241 |
| - p->sRGB = sRGB; |
242 |
| - AHardwareBuffer_Desc hardwareBufferDescription = {}; |
243 |
| - AHardwareBuffer_describe(hardwareBuffer, &hardwareBufferDescription); |
244 |
| - p->height = hardwareBufferDescription.height; |
245 |
| - p->width = hardwareBufferDescription.width; |
246 |
| - auto textureFormat = mapToFilamentFormat(hardwareBufferDescription.format, sRGB); |
247 |
| - p->format = textureFormat; |
248 |
| - p->usage = mapToFilamentUsage(hardwareBufferDescription.usage, textureFormat); |
249 |
| - return ExternalImageHandle{ p }; |
| 239 | + if (__builtin_available(android 26, *)) { |
| 240 | + auto* const p = new (std::nothrow) ExternalImageEGLAndroid; |
| 241 | + auto hardwareBuffer = const_cast<AHardwareBuffer*>(buffer); |
| 242 | + p->aHardwareBuffer = hardwareBuffer; |
| 243 | + p->sRGB = sRGB; |
| 244 | + AHardwareBuffer_Desc hardwareBufferDescription = {}; |
| 245 | + AHardwareBuffer_describe(hardwareBuffer, &hardwareBufferDescription); |
| 246 | + p->height = hardwareBufferDescription.height; |
| 247 | + p->width = hardwareBufferDescription.width; |
| 248 | + auto textureFormat = mapToFilamentFormat(hardwareBufferDescription.format, sRGB); |
| 249 | + p->format = textureFormat; |
| 250 | + p->usage = mapToFilamentUsage(hardwareBufferDescription.usage, textureFormat); |
| 251 | + return ExternalImageHandle{ p }; |
| 252 | + } |
| 253 | + |
| 254 | + return Platform::ExternalImageHandle{}; |
250 | 255 | }
|
251 | 256 |
|
252 | 257 | bool PlatformEGLAndroid::setExternalImage(ExternalImageHandleRef externalImage,
|
|
0 commit comments