Skip to content

Commit 89190b2

Browse files
committed
Revert android to android 21
1 parent f4f45c6 commit 89190b2

6 files changed

+27
-22
lines changed

android/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ buildscript {
9494

9595
ext.versions = [
9696
'jdk': 17,
97-
'minSdk': 26,
97+
'minSdk': 21,
9898
'targetSdk': 34,
9999
'compileSdk': 34,
100100
'kotlin': '2.0.21',
@@ -125,7 +125,7 @@ buildscript {
125125
ext.cmakeArgs = [
126126
"--no-warn-unused-cli",
127127
"-DANDROID_PIE=ON",
128-
"-DANDROID_PLATFORM=26",
128+
"-DANDROID_PLATFORM=21",
129129
"-DANDROID_STL=c++_static",
130130
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
131131
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString(),

build/toolchain-aarch64-linux-android.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(CMAKE_SYSTEM_NAME Linux)
2121
set(CMAKE_SYSTEM_VERSION 1)
2222

2323
# android
24-
set(API_LEVEL 26)
24+
set(API_LEVEL 21)
2525

2626
# architecture
2727
set(ARCH aarch64-linux-android)

build/toolchain-arm7-linux-android.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(CMAKE_SYSTEM_NAME Linux)
2121
set(CMAKE_SYSTEM_VERSION 1)
2222

2323
# android
24-
set(API_LEVEL 26)
24+
set(API_LEVEL 21)
2525

2626
# architecture
2727
set(ARCH armv7a-linux-androideabi)

build/toolchain-x86-linux-android.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(CMAKE_SYSTEM_NAME Linux)
2121
set(CMAKE_SYSTEM_VERSION 1)
2222

2323
# android
24-
set(API_LEVEL 26)
24+
set(API_LEVEL 21)
2525

2626
# architecture
2727
set(ARCH i686-linux-android)

build/toolchain-x86_64-linux-android.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(CMAKE_SYSTEM_NAME Linux)
2121
set(CMAKE_SYSTEM_VERSION 1)
2222

2323
# android
24-
set(API_LEVEL 26)
24+
set(API_LEVEL 21)
2525

2626
# architecture
2727
set(ARCH x86_64-linux-android)

filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp

+21-16
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@
5454
#include <stdint.h>
5555
#include <stdlib.h>
5656

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"
6162
#endif
6263

6364
using namespace utils;
@@ -235,18 +236,22 @@ PlatformEGLAndroid::ExternalImageEGLAndroid::~ExternalImageEGLAndroid() = defaul
235236

236237
Platform::ExternalImageHandle PlatformEGLAndroid::createExternalImage(AHardwareBuffer const* buffer,
237238
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{};
250255
}
251256

252257
bool PlatformEGLAndroid::setExternalImage(ExternalImageHandleRef externalImage,

0 commit comments

Comments
 (0)