Lower limit from API 21 to API 19 (#1701)

* Lower limit from API 21 to API 19

This was requested by an internal application. API 19 is when OpenGL
ES 3.0 support was added so there is no good reason for us to not
support this API level. The only trick is to avoid referring to the
glTexStorage2DMultisample symbol directly as it only exists in 3.1.

* Compile out code we never use

* Use reflection to handle shared EGL contexts pre-API 21.

* Remove comment

* More fixes required to run on API level 19

- dlym() fails for ashmem on API 19, so we only try on API 26+ instead.
- Older emulation for OpenGL ES 3.0 returns error states for valid API calls so we need to clear the GL error bit before we create the GL driver.
- Activity lifecycle changes since API 19 would cause animations to keep running and to reference destroyed objects.
- EGLContext.getNativeHandle() is new in API 21, we need to use reflection on API 19. The new code path uses the class loading trick to avoid a bytecode verification error on API 19.

* Filament now runs properly on API level 19

This commit adds a new api_level() API to libutils which can be used to
query the platform's API level. On Android it works as expected, other
platforms currently return 0.
This commit is contained in:
Romain Guy
2019-09-28 14:13:06 +03:00
committed by GitHub
parent 21b208398b
commit a67d92c2ca
35 changed files with 373 additions and 87 deletions

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2019 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.
*/
#ifndef TNT_UTILS_API_H
#define TNT_UTILS_API_H
#include <utils/api_level.h>
#ifdef ANDROID
#include <mutex>
#include <sys/system_properties.h>
#endif
namespace utils {
#ifdef ANDROID
uint32_t sApiLevel = 0;
std::once_flag sApiLevelOnceFlag;
int api_level() {
std::call_once(sApiLevelOnceFlag, []() {
char sdkVersion[PROP_VALUE_MAX];
__system_property_get("ro.build.version.sdk", sdkVersion);
sApiLevel = atoi(sdkVersion);
});
return sApiLevel;
}
#else
int api_level() {
return 0; // API level is only supported on Android currently
}
#endif
} // namespace utils
#endif // TNT_UTILS_ARCHITECTURE_H