EGL: refactor and enforce clang-format
Test: build, flash and boot
Change-Id: Idbc4426ef485f7fc18a6a499f5933437af14fac8
diff --git a/opengl/libs/EGL/BlobCache.cpp b/opengl/libs/EGL/BlobCache.cpp
index a27c09f..beca7f1 100644
--- a/opengl/libs/EGL/BlobCache.cpp
+++ b/opengl/libs/EGL/BlobCache.cpp
@@ -18,11 +18,11 @@
#include "BlobCache.h"
+#include <android-base/properties.h>
#include <errno.h>
#include <inttypes.h>
-
-#include <android-base/properties.h>
#include <log/log.h>
+
#include <chrono>
namespace android {
@@ -36,8 +36,8 @@
// BlobCache::Header::mDeviceVersion value
static const uint32_t blobCacheDeviceVersion = 1;
-BlobCache::BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize):
- mMaxTotalSize(maxTotalSize),
+BlobCache::BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize)
+ : mMaxTotalSize(maxTotalSize),
mMaxKeySize(maxKeySize),
mMaxValueSize(maxValueSize),
mTotalSize(0) {
@@ -52,21 +52,21 @@
ALOGV("initializing random seed using %lld", (unsigned long long)now);
}
-void BlobCache::set(const void* key, size_t keySize, const void* value,
- size_t valueSize) {
+void BlobCache::set(const void* key, size_t keySize, const void* value, size_t valueSize) {
if (mMaxKeySize < keySize) {
- ALOGV("set: not caching because the key is too large: %zu (limit: %zu)",
- keySize, mMaxKeySize);
+ ALOGV("set: not caching because the key is too large: %zu (limit: %zu)", keySize,
+ mMaxKeySize);
return;
}
if (mMaxValueSize < valueSize) {
- ALOGV("set: not caching because the value is too large: %zu (limit: %zu)",
- valueSize, mMaxValueSize);
+ ALOGV("set: not caching because the value is too large: %zu (limit: %zu)", valueSize,
+ mMaxValueSize);
return;
}
if (mMaxTotalSize < keySize + valueSize) {
ALOGV("set: not caching because the combined key/value size is too "
- "large: %zu (limit: %zu)", keySize + valueSize, mMaxTotalSize);
+ "large: %zu (limit: %zu)",
+ keySize + valueSize, mMaxTotalSize);
return;
}
if (keySize == 0) {
@@ -95,16 +95,16 @@
continue;
} else {
ALOGV("set: not caching new key/value pair because the "
- "total cache size limit would be exceeded: %zu "
- "(limit: %zu)",
- keySize + valueSize, mMaxTotalSize);
+ "total cache size limit would be exceeded: %zu "
+ "(limit: %zu)",
+ keySize + valueSize, mMaxTotalSize);
break;
}
}
mCacheEntries.insert(index, CacheEntry(keyBlob, valueBlob));
mTotalSize = newTotalSize;
- ALOGV("set: created new cache entry with %zu byte key and %zu byte value",
- keySize, valueSize);
+ ALOGV("set: created new cache entry with %zu byte key and %zu byte value", keySize,
+ valueSize);
} else {
// Update the existing cache entry.
std::shared_ptr<Blob> valueBlob(new Blob(value, valueSize, true));
@@ -117,25 +117,25 @@
continue;
} else {
ALOGV("set: not caching new value because the total cache "
- "size limit would be exceeded: %zu (limit: %zu)",
- keySize + valueSize, mMaxTotalSize);
+ "size limit would be exceeded: %zu (limit: %zu)",
+ keySize + valueSize, mMaxTotalSize);
break;
}
}
index->setValue(valueBlob);
mTotalSize = newTotalSize;
ALOGV("set: updated existing cache entry with %zu byte key and %zu byte "
- "value", keySize, valueSize);
+ "value",
+ keySize, valueSize);
}
break;
}
}
-size_t BlobCache::get(const void* key, size_t keySize, void* value,
- size_t valueSize) {
+size_t BlobCache::get(const void* key, size_t keySize, void* value, size_t valueSize) {
if (mMaxKeySize < keySize) {
- ALOGV("get: not searching because the key is too large: %zu (limit %zu)",
- keySize, mMaxKeySize);
+ ALOGV("get: not searching because the key is too large: %zu (limit %zu)", keySize,
+ mMaxKeySize);
return 0;
}
std::shared_ptr<Blob> cacheKey(new Blob(key, keySize, false));
@@ -154,8 +154,8 @@
ALOGV("get: copying %zu bytes to caller's buffer", valueBlobSize);
memcpy(value, valueBlob->getData(), valueBlobSize);
} else {
- ALOGV("get: caller's buffer is too small for value: %zu (needs %zu)",
- valueSize, valueBlobSize);
+ ALOGV("get: caller's buffer is too small for value: %zu (needs %zu)", valueSize,
+ valueBlobSize);
}
return valueBlobSize;
}
@@ -167,7 +167,7 @@
size_t BlobCache::getFlattenedSize() const {
auto buildId = base::GetProperty("ro.build.id", "");
size_t size = align4(sizeof(Header) + buildId.size());
- for (const CacheEntry& e : mCacheEntries) {
+ for (const CacheEntry& e : mCacheEntries) {
std::shared_ptr<Blob> const& keyBlob = e.getKey();
std::shared_ptr<Blob> const& valueBlob = e.getValue();
size += align4(sizeof(EntryHeader) + keyBlob->getSize() + valueBlob->getSize());
@@ -193,7 +193,7 @@
// Write cache entries
uint8_t* byteBuffer = reinterpret_cast<uint8_t*>(buffer);
off_t byteOffset = align4(sizeof(Header) + header->mBuildIdLength);
- for (const CacheEntry& e : mCacheEntries) {
+ for (const CacheEntry& e : mCacheEntries) {
std::shared_ptr<Blob> const& keyBlob = e.getKey();
std::shared_ptr<Blob> const& valueBlob = e.getValue();
size_t keySize = keyBlob->getSize();
@@ -259,8 +259,7 @@
return -EINVAL;
}
- const EntryHeader* eheader = reinterpret_cast<const EntryHeader*>(
- &byteBuffer[byteOffset]);
+ const EntryHeader* eheader = reinterpret_cast<const EntryHeader*>(&byteBuffer[byteOffset]);
size_t keySize = eheader->mKeySize;
size_t valueSize = eheader->mValueSize;
size_t entrySize = sizeof(EntryHeader) + keySize + valueSize;
@@ -304,10 +303,8 @@
return mTotalSize > mMaxTotalSize / 2;
}
-BlobCache::Blob::Blob(const void* data, size_t size, bool copyData) :
- mData(copyData ? malloc(size) : data),
- mSize(size),
- mOwnsData(copyData) {
+BlobCache::Blob::Blob(const void* data, size_t size, bool copyData)
+ : mData(copyData ? malloc(size) : data), mSize(size), mOwnsData(copyData) {
if (data != nullptr && copyData) {
memcpy(const_cast<void*>(mData), data, size);
}
@@ -335,19 +332,13 @@
return mSize;
}
-BlobCache::CacheEntry::CacheEntry() {
-}
+BlobCache::CacheEntry::CacheEntry() {}
-BlobCache::CacheEntry::CacheEntry(
- const std::shared_ptr<Blob>& key, const std::shared_ptr<Blob>& value):
- mKey(key),
- mValue(value) {
-}
+BlobCache::CacheEntry::CacheEntry(const std::shared_ptr<Blob>& key,
+ const std::shared_ptr<Blob>& value)
+ : mKey(key), mValue(value) {}
-BlobCache::CacheEntry::CacheEntry(const CacheEntry& ce):
- mKey(ce.mKey),
- mValue(ce.mValue) {
-}
+BlobCache::CacheEntry::CacheEntry(const CacheEntry& ce) : mKey(ce.mKey), mValue(ce.mValue) {}
bool BlobCache::CacheEntry::operator<(const CacheEntry& rhs) const {
return *mKey < *rhs.mKey;
diff --git a/opengl/libs/EGL/BlobCache.h b/opengl/libs/EGL/BlobCache.h
index e5c5e5b..50b4e4c 100644
--- a/opengl/libs/EGL/BlobCache.h
+++ b/opengl/libs/EGL/BlobCache.h
@@ -54,8 +54,7 @@
// 0 < keySize
// value != NULL
// 0 < valueSize
- void set(const void* key, size_t keySize, const void* value,
- size_t valueSize);
+ void set(const void* key, size_t keySize, const void* value, size_t valueSize);
// get retrieves from the cache the binary value associated with a given
// binary key. If the key is present in the cache then the length of the
@@ -75,7 +74,6 @@
// 0 <= valueSize
size_t get(const void* key, size_t keySize, void* value, size_t valueSize);
-
// getFlattenedSize returns the number of bytes needed to store the entire
// serialized cache.
size_t getFlattenedSize() const;
@@ -168,7 +166,6 @@
void setValue(const std::shared_ptr<Blob>& value);
private:
-
// mKey is the key that identifies the cache entry.
std::shared_ptr<Blob> mKey;
@@ -245,6 +242,6 @@
std::vector<CacheEntry> mCacheEntries;
};
-}
+} // namespace android
#endif // ANDROID_BLOB_CACHE_H
diff --git a/opengl/libs/EGL/BlobCache_test.cpp b/opengl/libs/EGL/BlobCache_test.cpp
index cf67cf4..d31373b 100644
--- a/opengl/libs/EGL/BlobCache_test.cpp
+++ b/opengl/libs/EGL/BlobCache_test.cpp
@@ -14,25 +14,24 @@
** limitations under the License.
*/
+#include "BlobCache.h"
+
#include <fcntl.h>
+#include <gtest/gtest.h>
#include <stdio.h>
#include <memory>
-#include <gtest/gtest.h>
-
-#include "BlobCache.h"
-
namespace android {
-template<typename T> using sp = std::shared_ptr<T>;
+template <typename T>
+using sp = std::shared_ptr<T>;
class BlobCacheTest : public ::testing::Test {
protected:
-
enum {
OK = 0,
- BAD_VALUE = -EINVAL
+ BAD_VALUE = -EINVAL,
};
enum {
@@ -41,19 +40,15 @@
MAX_TOTAL_SIZE = 13,
};
- virtual void SetUp() {
- mBC.reset(new BlobCache(MAX_KEY_SIZE, MAX_VALUE_SIZE, MAX_TOTAL_SIZE));
- }
+ virtual void SetUp() { mBC.reset(new BlobCache(MAX_KEY_SIZE, MAX_VALUE_SIZE, MAX_TOTAL_SIZE)); }
- virtual void TearDown() {
- mBC.reset();
- }
+ virtual void TearDown() { mBC.reset(); }
std::unique_ptr<BlobCache> mBC;
};
TEST_F(BlobCacheTest, CacheSingleValueSucceeds) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
ASSERT_EQ('e', buf[0]);
@@ -63,7 +58,7 @@
}
TEST_F(BlobCacheTest, CacheTwoValuesSucceeds) {
- unsigned char buf[2] = { 0xee, 0xee };
+ unsigned char buf[2] = {0xee, 0xee};
mBC->set("ab", 2, "cd", 2);
mBC->set("ef", 2, "gh", 2);
ASSERT_EQ(size_t(2), mBC->get("ab", 2, buf, 2));
@@ -75,9 +70,9 @@
}
TEST_F(BlobCacheTest, GetOnlyWritesInsideBounds) {
- unsigned char buf[6] = { 0xee, 0xee, 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[6] = {0xee, 0xee, 0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
- ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf+1, 4));
+ ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf + 1, 4));
ASSERT_EQ(0xee, buf[0]);
ASSERT_EQ('e', buf[1]);
ASSERT_EQ('f', buf[2]);
@@ -87,7 +82,7 @@
}
TEST_F(BlobCacheTest, GetOnlyWritesIfBufferIsLargeEnough) {
- unsigned char buf[3] = { 0xee, 0xee, 0xee };
+ unsigned char buf[3] = {0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 3));
ASSERT_EQ(0xee, buf[0]);
@@ -101,7 +96,7 @@
}
TEST_F(BlobCacheTest, MultipleSetsCacheLatestValue) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
mBC->set("abcd", 4, "ijkl", 4);
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
@@ -112,9 +107,9 @@
}
TEST_F(BlobCacheTest, SecondSetKeepsFirstValueIfTooLarge) {
- unsigned char buf[MAX_VALUE_SIZE+1] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[MAX_VALUE_SIZE + 1] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
- mBC->set("abcd", 4, buf, MAX_VALUE_SIZE+1);
+ mBC->set("abcd", 4, buf, MAX_VALUE_SIZE + 1);
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
ASSERT_EQ('e', buf[0]);
ASSERT_EQ('f', buf[1]);
@@ -123,13 +118,13 @@
}
TEST_F(BlobCacheTest, DoesntCacheIfKeyIsTooBig) {
- char key[MAX_KEY_SIZE+1];
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
- for (int i = 0; i < MAX_KEY_SIZE+1; i++) {
+ char key[MAX_KEY_SIZE + 1];
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
+ for (int i = 0; i < MAX_KEY_SIZE + 1; i++) {
key[i] = 'a';
}
- mBC->set(key, MAX_KEY_SIZE+1, "bbbb", 4);
- ASSERT_EQ(size_t(0), mBC->get(key, MAX_KEY_SIZE+1, buf, 4));
+ mBC->set(key, MAX_KEY_SIZE + 1, "bbbb", 4);
+ ASSERT_EQ(size_t(0), mBC->get(key, MAX_KEY_SIZE + 1, buf, 4));
ASSERT_EQ(0xee, buf[0]);
ASSERT_EQ(0xee, buf[1]);
ASSERT_EQ(0xee, buf[2]);
@@ -137,16 +132,16 @@
}
TEST_F(BlobCacheTest, DoesntCacheIfValueIsTooBig) {
- char buf[MAX_VALUE_SIZE+1];
- for (int i = 0; i < MAX_VALUE_SIZE+1; i++) {
+ char buf[MAX_VALUE_SIZE + 1];
+ for (int i = 0; i < MAX_VALUE_SIZE + 1; i++) {
buf[i] = 'b';
}
- mBC->set("abcd", 4, buf, MAX_VALUE_SIZE+1);
- for (int i = 0; i < MAX_VALUE_SIZE+1; i++) {
+ mBC->set("abcd", 4, buf, MAX_VALUE_SIZE + 1);
+ for (int i = 0; i < MAX_VALUE_SIZE + 1; i++) {
buf[i] = 0xee;
}
- ASSERT_EQ(size_t(0), mBC->get("abcd", 4, buf, MAX_VALUE_SIZE+1));
- for (int i = 0; i < MAX_VALUE_SIZE+1; i++) {
+ ASSERT_EQ(size_t(0), mBC->get("abcd", 4, buf, MAX_VALUE_SIZE + 1));
+ for (int i = 0; i < MAX_VALUE_SIZE + 1; i++) {
SCOPED_TRACE(i);
ASSERT_EQ(0xee, buf[i]);
}
@@ -174,7 +169,7 @@
TEST_F(BlobCacheTest, CacheMaxKeySizeSucceeds) {
char key[MAX_KEY_SIZE];
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
for (int i = 0; i < MAX_KEY_SIZE; i++) {
key[i] = 'a';
}
@@ -195,8 +190,7 @@
for (int i = 0; i < MAX_VALUE_SIZE; i++) {
buf[i] = 0xee;
}
- ASSERT_EQ(size_t(MAX_VALUE_SIZE), mBC->get("abcd", 4, buf,
- MAX_VALUE_SIZE));
+ ASSERT_EQ(size_t(MAX_VALUE_SIZE), mBC->get("abcd", 4, buf, MAX_VALUE_SIZE));
for (int i = 0; i < MAX_VALUE_SIZE; i++) {
SCOPED_TRACE(i);
ASSERT_EQ('b', buf[i]);
@@ -223,7 +217,7 @@
}
TEST_F(BlobCacheTest, CacheMinKeyAndValueSizeSucceeds) {
- unsigned char buf[1] = { 0xee };
+ unsigned char buf[1] = {0xee};
mBC->set("x", 1, "y", 1);
ASSERT_EQ(size_t(1), mBC->get("x", 1, buf, 1));
ASSERT_EQ('y', buf[0]);
@@ -258,13 +252,13 @@
}
// Count the number of entries in the cache.
int numCached = 0;
- for (int i = 0; i < maxEntries+1; i++) {
+ for (int i = 0; i < maxEntries + 1; i++) {
uint8_t k = i;
if (mBC->get(&k, 1, nullptr, 0) == 1) {
numCached++;
}
}
- ASSERT_EQ(maxEntries/2 + 1, numCached);
+ ASSERT_EQ(maxEntries / 2 + 1, numCached);
}
class BlobCacheFlattenTest : public BlobCacheTest {
@@ -291,7 +285,7 @@
};
TEST_F(BlobCacheFlattenTest, FlattenOneValue) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
roundTrip();
ASSERT_EQ(size_t(4), mBC2->get("abcd", 4, buf, 4));
@@ -359,7 +353,7 @@
}
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadMagic) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
size_t size = mBC->getFlattenedSize();
@@ -376,7 +370,7 @@
}
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheVersion) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
size_t size = mBC->getFlattenedSize();
@@ -395,7 +389,7 @@
}
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheDeviceVersion) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
size_t size = mBC->getFlattenedSize();
@@ -414,7 +408,7 @@
}
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBufferTooSmall) {
- unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+ unsigned char buf[4] = {0xee, 0xee, 0xee, 0xee};
mBC->set("abcd", 4, "efgh", 4);
size_t size = mBC->getFlattenedSize();
diff --git a/opengl/libs/EGL/CallStack.h b/opengl/libs/EGL/CallStack.h
index 0e2a9b3..b7fdf97 100644
--- a/opengl/libs/EGL/CallStack.h
+++ b/opengl/libs/EGL/CallStack.h
@@ -16,8 +16,9 @@
#pragma once
-#include <log/log.h>
#include <backtrace/Backtrace.h>
+#include <log/log.h>
+
#include <memory>
class CallStack {
@@ -30,9 +31,8 @@
if (backtrace->Unwind(2)) {
for (size_t i = 0, c = backtrace->NumFrames(); i < c; i++) {
__android_log_print(ANDROID_LOG_DEBUG, logtag, "%s",
- backtrace->FormatFrameData(i).c_str());
+ backtrace->FormatFrameData(i).c_str());
}
}
}
};
-
diff --git a/opengl/libs/EGL/Loader.h b/opengl/libs/EGL/Loader.h
index 7b2d7c9..81742ab 100644
--- a/opengl/libs/EGL/Loader.h
+++ b/opengl/libs/EGL/Loader.h
@@ -1,29 +1,26 @@
-/*
+/*
** Copyright 2009, 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
+ ** 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
+ ** 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
+ ** 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 ANDROID_EGL_LOADER_H
#define ANDROID_EGL_LOADER_H
+#include <EGL/egl.h>
#include <stdint.h>
-#include <EGL/egl.h>
-
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
struct egl_connection_t;
@@ -62,16 +59,12 @@
void initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask);
void init_angle_backend(void* dso, egl_connection_t* cnx);
- static __attribute__((noinline))
- void init_api(void* dso,
- char const * const * api,
- char const * const * ref_api,
- __eglMustCastToProperFunctionPointerType* curr,
- getProcAddressType getProcAddress);
+ static __attribute__((noinline)) void init_api(void* dso, const char* const* api,
+ const char* const* ref_api,
+ __eglMustCastToProperFunctionPointerType* curr,
+ getProcAddressType getProcAddress);
};
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
#endif /* ANDROID_EGL_LOADER_H */
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index a3e3859..e5b9e14 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -14,45 +14,35 @@
** limitations under the License.
*/
+#include <EGL/egl.h>
+#include <android-base/properties.h>
+#include <log/log.h>
#include <stdlib.h>
-#include <EGL/egl.h>
-
-#include <android-base/properties.h>
-
-#include <log/log.h>
-
#include "../egl_impl.h"
-
-#include "egldefs.h"
-#include "egl_tls.h"
-#include "egl_display.h"
-#include "egl_object.h"
-#include "egl_layers.h"
#include "CallStack.h"
#include "Loader.h"
+#include "egl_display.h"
+#include "egl_layers.h"
+#include "egl_object.h"
+#include "egl_tls.h"
+#include "egldefs.h"
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
egl_connection_t gEGLImpl;
gl_hooks_t gHooks[2];
gl_hooks_t gHooksNoContext;
pthread_key_t gGLWrapperKey = -1;
-// ----------------------------------------------------------------------------
-
-void setGLHooksThreadSpecific(gl_hooks_t const *value) {
+void setGLHooksThreadSpecific(gl_hooks_t const* value) {
setGlThreadSpecific(value);
}
-/*****************************************************************************/
-
static int gl_no_context() {
if (egl_tls_t::logNoContextCall()) {
- char const* const error = "call to OpenGL ES API with "
- "no current context (logged once per thread)";
+ const char* const error = "call to OpenGL ES API with "
+ "no current context (logged once per thread)";
if (LOG_NDEBUG) {
ALOGE(error);
} else {
@@ -65,10 +55,9 @@
return 0;
}
-static void early_egl_init(void)
-{
+static void early_egl_init(void) {
int numHooks = sizeof(gHooksNoContext) / sizeof(EGLFuncPointer);
- EGLFuncPointer *iter = reinterpret_cast<EGLFuncPointer*>(&gHooksNoContext);
+ EGLFuncPointer* iter = reinterpret_cast<EGLFuncPointer*>(&gHooksNoContext);
for (int hook = 0; hook < numHooks; ++hook) {
*(iter++) = reinterpret_cast<EGLFuncPointer>(gl_no_context);
}
@@ -76,72 +65,40 @@
setGLHooksThreadSpecific(&gHooksNoContext);
}
-static pthread_once_t once_control = PTHREAD_ONCE_INIT;
-static int sEarlyInitState = pthread_once(&once_control, &early_egl_init);
-
-// ----------------------------------------------------------------------------
-
-egl_display_t* validate_display(EGLDisplay dpy) {
- egl_display_t* const dp = get_display(dpy);
- if (!dp) return setError(EGL_BAD_DISPLAY, (egl_display_t*)nullptr);
- if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, (egl_display_t*)nullptr);
-
- return dp;
-}
-
-egl_display_t* validate_display_connection(EGLDisplay dpy, egl_connection_t** outCnx) {
- *outCnx = nullptr;
- egl_display_t* dp = validate_display(dpy);
- if (!dp)
- return dp;
- *outCnx = &gEGLImpl;
- if ((*outCnx)->dso == nullptr) {
- return setError(EGL_BAD_CONFIG, (egl_display_t*)nullptr);
- }
- return dp;
-}
-
-// ----------------------------------------------------------------------------
-
-const GLubyte * egl_get_string_for_current_context(GLenum name) {
+const GLubyte* egl_get_string_for_current_context(GLenum name) {
// NOTE: returning NULL here will fall-back to the default
// implementation.
EGLContext context = egl_tls_t::getContext();
- if (context == EGL_NO_CONTEXT)
- return nullptr;
+ if (context == EGL_NO_CONTEXT) return nullptr;
- egl_context_t const * const c = get_context(context);
+ const egl_context_t* const c = get_context(context);
if (c == nullptr) // this should never happen, by construction
return nullptr;
- if (name != GL_EXTENSIONS)
- return nullptr;
+ if (name != GL_EXTENSIONS) return nullptr;
- return (const GLubyte *)c->gl_extensions.c_str();
+ return (const GLubyte*)c->gl_extensions.c_str();
}
-const GLubyte * egl_get_string_for_current_context(GLenum name, GLuint index) {
+const GLubyte* egl_get_string_for_current_context(GLenum name, GLuint index) {
// NOTE: returning NULL here will fall-back to the default
// implementation.
EGLContext context = egl_tls_t::getContext();
- if (context == EGL_NO_CONTEXT)
- return nullptr;
+ if (context == EGL_NO_CONTEXT) return nullptr;
- egl_context_t const * const c = get_context(context);
+ const egl_context_t* const c = get_context(context);
if (c == nullptr) // this should never happen, by construction
return nullptr;
- if (name != GL_EXTENSIONS)
- return nullptr;
+ if (name != GL_EXTENSIONS) return nullptr;
// if index is out of bounds, assume it will be in the default
// implementation too, so we don't have to generate a GL error here
- if (index >= c->tokenized_gl_extensions.size())
- return nullptr;
+ if (index >= c->tokenized_gl_extensions.size()) return nullptr;
- return (const GLubyte *)c->tokenized_gl_extensions[index].c_str();
+ return (const GLubyte*)c->tokenized_gl_extensions[index].c_str();
}
GLint egl_get_num_extensions_for_current_context() {
@@ -149,10 +106,9 @@
// implementation.
EGLContext context = egl_tls_t::getContext();
- if (context == EGL_NO_CONTEXT)
- return -1;
+ if (context == EGL_NO_CONTEXT) return -1;
- egl_context_t const * const c = get_context(context);
+ const egl_context_t* const c = get_context(context);
if (c == nullptr) // this should never happen, by construction
return -1;
@@ -163,7 +119,8 @@
return &gEGLImpl;
}
-// ----------------------------------------------------------------------------
+static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+static int sEarlyInitState = pthread_once(&once_control, &early_egl_init);
static EGLBoolean egl_init_drivers_locked() {
if (sEarlyInitState) {
@@ -191,7 +148,6 @@
return cnx->dso ? EGL_TRUE : EGL_FALSE;
}
-
// this mutex protects driver load logic as a critical section since it accesses to global variable
// like gEGLImpl
static pthread_mutex_t sInitDriverMutex = PTHREAD_MUTEX_INITIALIZER;
@@ -225,13 +181,10 @@
}
}
-void gl_noop() {
-}
+void gl_noop() {}
-// ----------------------------------------------------------------------------
-
-void setGlThreadSpecific(gl_hooks_t const *value) {
- gl_hooks_t const * volatile * tls_hooks = get_tls_hooks();
+void setGlThreadSpecific(gl_hooks_t const* value) {
+ gl_hooks_t const* volatile* tls_hooks = get_tls_hooks();
tls_hooks[TLS_SLOT_OPENGL_API] = value;
}
@@ -267,8 +220,4 @@
#undef GL_ENTRY
#undef EGL_ENTRY
-
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
-
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index c51a129..502c14f 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -20,7 +20,6 @@
#include <EGL/eglext.h>
#include "../egl_impl.h"
-
#include "egl_layers.h"
#include "egl_platform_entries.h"
#include "egl_tls.h"
diff --git a/opengl/libs/EGL/egl_angle_platform.cpp b/opengl/libs/EGL/egl_angle_platform.cpp
index 97dc0f1..4250daa 100644
--- a/opengl/libs/EGL/egl_angle_platform.cpp
+++ b/opengl/libs/EGL/egl_angle_platform.cpp
@@ -16,19 +16,19 @@
#if defined(__ANDROID__)
-#include "Loader.h"
#include "egl_angle_platform.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <EGL/Platform.h>
#pragma GCC diagnostic pop
-
#include <android/dlext.h>
#include <dlfcn.h>
#include <graphicsenv/GraphicsEnv.h>
-#include <time.h>
#include <log/log.h>
+#include <time.h>
+
+#include "Loader.h"
namespace angle {
@@ -114,14 +114,12 @@
return false;
}
- angleResetDisplayPlatform =
- reinterpret_cast<ResetDisplayPlatformFunc>(
- eglGetProcAddress("ANGLEResetDisplayPlatform"));
+ angleResetDisplayPlatform = reinterpret_cast<ResetDisplayPlatformFunc>(
+ eglGetProcAddress("ANGLEResetDisplayPlatform"));
PlatformMethods* platformMethods = nullptr;
- if (!((angleGetDisplayPlatform)(dpy, g_PlatformMethodNames,
- g_NumPlatformMethods, nullptr,
- &platformMethods))) {
+ if (!((angleGetDisplayPlatform)(dpy, g_PlatformMethodNames, g_NumPlatformMethods, nullptr,
+ &platformMethods))) {
ALOGE("ANGLEGetDisplayPlatform call failed!");
return false;
}
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index bcf4961..efa67db 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -16,17 +16,14 @@
#include "egl_cache.h"
-#include "../egl_impl.h"
-
-#include "egl_display.h"
-
+#include <log/log.h>
#include <private/EGL/cache.h>
-
#include <unistd.h>
#include <thread>
-#include <log/log.h>
+#include "../egl_impl.h"
+#include "egl_display.h"
// Cache size limits.
static const size_t maxKeySize = 12 * 1024;
@@ -36,9 +33,7 @@
// The time in seconds to wait before saving newly inserted cache entries.
static const unsigned int deferredSaveDelay = 4;
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
#define BC_EXT_STR "EGL_ANDROID_blob_cache"
@@ -50,25 +45,22 @@
//
// Callback functions passed to EGL.
//
-static void setBlob(const void* key, EGLsizeiANDROID keySize,
- const void* value, EGLsizeiANDROID valueSize) {
+static void setBlob(const void* key, EGLsizeiANDROID keySize, const void* value,
+ EGLsizeiANDROID valueSize) {
egl_cache_t::get()->setBlob(key, keySize, value, valueSize);
}
-static EGLsizeiANDROID getBlob(const void* key, EGLsizeiANDROID keySize,
- void* value, EGLsizeiANDROID valueSize) {
+static EGLsizeiANDROID getBlob(const void* key, EGLsizeiANDROID keySize, void* value,
+ EGLsizeiANDROID valueSize) {
return egl_cache_t::get()->getBlob(key, keySize, value, valueSize);
}
//
// egl_cache_t definition
//
-egl_cache_t::egl_cache_t() :
- mInitialized(false) {
-}
+egl_cache_t::egl_cache_t() : mInitialized(false) {}
-egl_cache_t::~egl_cache_t() {
-}
+egl_cache_t::~egl_cache_t() {}
egl_cache_t egl_cache_t::sCache;
@@ -76,7 +68,7 @@
return &sCache;
}
-void egl_cache_t::initialize(egl_display_t *display) {
+void egl_cache_t::initialize(egl_display_t* display) {
std::lock_guard<std::mutex> lock(mMutex);
egl_connection_t* const cnx = &gEGLImpl;
@@ -85,28 +77,26 @@
size_t bcExtLen = strlen(BC_EXT_STR);
size_t extsLen = strlen(exts);
bool equal = !strcmp(BC_EXT_STR, exts);
- bool atStart = !strncmp(BC_EXT_STR " ", exts, bcExtLen+1);
- bool atEnd = (bcExtLen+1) < extsLen &&
- !strcmp(" " BC_EXT_STR, exts + extsLen - (bcExtLen+1));
+ bool atStart = !strncmp(BC_EXT_STR " ", exts, bcExtLen + 1);
+ bool atEnd = (bcExtLen + 1) < extsLen &&
+ !strcmp(" " BC_EXT_STR, exts + extsLen - (bcExtLen + 1));
bool inMiddle = strstr(exts, " " BC_EXT_STR " ") != nullptr;
if (equal || atStart || atEnd || inMiddle) {
PFNEGLSETBLOBCACHEFUNCSANDROIDPROC eglSetBlobCacheFuncsANDROID;
- eglSetBlobCacheFuncsANDROID =
- reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSANDROIDPROC>(
- cnx->egl.eglGetProcAddress(
- "eglSetBlobCacheFuncsANDROID"));
+ eglSetBlobCacheFuncsANDROID = reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSANDROIDPROC>(
+ cnx->egl.eglGetProcAddress("eglSetBlobCacheFuncsANDROID"));
if (eglSetBlobCacheFuncsANDROID == nullptr) {
ALOGE("EGL_ANDROID_blob_cache advertised, "
- "but unable to get eglSetBlobCacheFuncsANDROID");
+ "but unable to get eglSetBlobCacheFuncsANDROID");
return;
}
- eglSetBlobCacheFuncsANDROID(display->disp.dpy,
- android::setBlob, android::getBlob);
+ eglSetBlobCacheFuncsANDROID(display->disp.dpy, android::setBlob, android::getBlob);
EGLint err = cnx->egl.eglGetError();
if (err != EGL_SUCCESS) {
ALOGE("eglSetBlobCacheFuncsANDROID resulted in an error: "
- "%#x", err);
+ "%#x",
+ err);
}
}
}
@@ -122,8 +112,8 @@
mBlobCache = nullptr;
}
-void egl_cache_t::setBlob(const void* key, EGLsizeiANDROID keySize,
- const void* value, EGLsizeiANDROID valueSize) {
+void egl_cache_t::setBlob(const void* key, EGLsizeiANDROID keySize, const void* value,
+ EGLsizeiANDROID valueSize) {
std::lock_guard<std::mutex> lock(mMutex);
if (keySize < 0 || valueSize < 0) {
@@ -150,8 +140,8 @@
}
}
-EGLsizeiANDROID egl_cache_t::getBlob(const void* key, EGLsizeiANDROID keySize,
- void* value, EGLsizeiANDROID valueSize) {
+EGLsizeiANDROID egl_cache_t::getBlob(const void* key, EGLsizeiANDROID keySize, void* value,
+ EGLsizeiANDROID valueSize) {
std::lock_guard<std::mutex> lock(mMutex);
if (keySize < 0 || valueSize < 0) {
@@ -178,6 +168,4 @@
return mBlobCache.get();
}
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_cache.h b/opengl/libs/EGL/egl_cache.h
index 7382b91..d10a615 100644
--- a/opengl/libs/EGL/egl_cache.h
+++ b/opengl/libs/EGL/egl_cache.h
@@ -20,21 +20,18 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include "FileBlobCache.h"
-
#include <memory>
#include <mutex>
#include <string>
-// ----------------------------------------------------------------------------
+#include "FileBlobCache.h"
+
namespace android {
-// ----------------------------------------------------------------------------
class egl_display_t;
class EGLAPI egl_cache_t {
public:
-
// get returns a pointer to the singleton egl_cache_t object. This
// singleton object will never be destroyed.
static egl_cache_t* get();
@@ -117,8 +114,6 @@
static egl_cache_t sCache;
};
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
#endif // ANDROID_EGL_CACHE_H
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index a6e4a5c..07ec327 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -38,21 +38,17 @@
using namespace android::hardware::configstore;
using namespace android::hardware::configstore::V1_0;
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
-static char const * const sVendorString = "Android";
-static char const* const sVersionString14 = "1.4 Android META-EGL";
-static char const* const sVersionString15 = "1.5 Android META-EGL";
-static char const * const sClientApiString = "OpenGL_ES";
+static const char* const sVendorString = "Android";
+static const char* const sVersionString14 = "1.4 Android META-EGL";
+static const char* const sVersionString15 = "1.5 Android META-EGL";
+static const char* const sClientApiString = "OpenGL_ES";
-extern char const * const gBuiltinExtensionString;
-extern char const * const gExtensionString;
+extern const char* const gBuiltinExtensionString;
+extern const char* const gExtensionString;
-extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
-
-// ----------------------------------------------------------------------------
+extern void setGLHooksThreadSpecific(gl_hooks_t const* value);
bool findExtension(const char* exts, const char* name, size_t nameLen) {
if (exts) {
@@ -80,9 +76,12 @@
egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS];
-egl_display_t::egl_display_t() :
- magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0), eglIsInitialized(false) {
-}
+egl_display_t::egl_display_t()
+ : magic('_dpy'),
+ finishOnSwap(false),
+ traceGpuCompletion(false),
+ refs(0),
+ eglIsInitialized(false) {}
egl_display_t::~egl_display_t() {
magic = 0;
@@ -94,7 +93,7 @@
return nullptr;
}
- uintptr_t index = uintptr_t(dpy)-1U;
+ uintptr_t index = uintptr_t(dpy) - 1U;
if (index >= NUM_DISPLAYS || !sDisplay[index].isValid()) {
return nullptr;
}
@@ -124,8 +123,7 @@
EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp,
const EGLAttrib* attrib_list) {
- if (uintptr_t(disp) >= NUM_DISPLAYS)
- return nullptr;
+ if (uintptr_t(disp) >= NUM_DISPLAYS) return nullptr;
return sDisplay[uintptr_t(disp)].getPlatformDisplay(disp, attrib_list);
}
@@ -200,7 +198,7 @@
// It is possible that eglGetPlatformDisplay does not have a
// working implementation for Android platform; in that case,
// one last fallback to eglGetDisplay
- if(dpy == EGL_NO_DISPLAY) {
+ if (dpy == EGL_NO_DISPLAY) {
if (attrib_list) {
ALOGW("getPlatformDisplay: unexpected attribute list, attributes ignored");
}
@@ -217,8 +215,7 @@
return EGLDisplay(uintptr_t(display) + 1U);
}
-EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
-
+EGLBoolean egl_display_t::initialize(EGLint* major, EGLint* minor) {
{ // scope for refLock
std::unique_lock<std::mutex> _l(refLock);
refs++;
@@ -226,7 +223,7 @@
// We don't know what to report until we know what the
// driver supports. Make sure we are initialized before
// returning the version info.
- while(!eglIsInitialized) {
+ while (!eglIsInitialized) {
refCond.wait(_l);
}
egl_connection_t* const cnx = &gEGLImpl;
@@ -239,7 +236,7 @@
if (minor != nullptr) *minor = cnx->minor;
return EGL_TRUE;
}
- while(eglIsInitialized) {
+ while (eglIsInitialized) {
refCond.wait(_l);
}
}
@@ -259,40 +256,31 @@
if (cnx->dso) {
EGLDisplay idpy = disp.dpy;
if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
- //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
+ // ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
// idpy, cnx->major, cnx->minor, cnx);
// display is now initialized
disp.state = egl_display_t::INITIALIZED;
// get the query-strings for this display for each implementation
- disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
- EGL_VENDOR);
- disp.queryString.version = cnx->egl.eglQueryString(idpy,
- EGL_VERSION);
- disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
- EGL_EXTENSIONS);
- disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
- EGL_CLIENT_APIS);
+ disp.queryString.vendor = cnx->egl.eglQueryString(idpy, EGL_VENDOR);
+ disp.queryString.version = cnx->egl.eglQueryString(idpy, EGL_VERSION);
+ disp.queryString.extensions = cnx->egl.eglQueryString(idpy, EGL_EXTENSIONS);
+ disp.queryString.clientApi = cnx->egl.eglQueryString(idpy, EGL_CLIENT_APIS);
} else {
ALOGW("eglInitialize(%p) failed (%s)", idpy,
- egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
+ egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
}
}
if (cnx->minor == 5) {
// full list in egl_entries.in
- if (!cnx->egl.eglCreateImage ||
- !cnx->egl.eglDestroyImage ||
- !cnx->egl.eglGetPlatformDisplay ||
- !cnx->egl.eglCreatePlatformWindowSurface ||
- !cnx->egl.eglCreatePlatformPixmapSurface ||
- !cnx->egl.eglCreateSync ||
- !cnx->egl.eglDestroySync ||
- !cnx->egl.eglClientWaitSync ||
- !cnx->egl.eglGetSyncAttrib ||
- !cnx->egl.eglWaitSync) {
+ if (!cnx->egl.eglCreateImage || !cnx->egl.eglDestroyImage ||
+ !cnx->egl.eglGetPlatformDisplay || !cnx->egl.eglCreatePlatformWindowSurface ||
+ !cnx->egl.eglCreatePlatformPixmapSurface || !cnx->egl.eglCreateSync ||
+ !cnx->egl.eglDestroySync || !cnx->egl.eglClientWaitSync ||
+ !cnx->egl.eglGetSyncAttrib || !cnx->egl.eglWaitSync) {
ALOGE("Driver indicates EGL 1.5 support, but does not have "
"a critical API");
cnx->minor = 4;
@@ -387,7 +375,6 @@
}
EGLBoolean egl_display_t::terminate() {
-
{ // scope for refLock
std::unique_lock<std::mutex> _rl(refLock);
if (refs == 0) {
@@ -420,7 +407,7 @@
}
if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) {
ALOGW("eglTerminate(%p) failed (%s)", disp.dpy,
- egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
+ egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
}
// REVISIT: it's unclear what to do if eglTerminate() fails
disp.state = egl_display_t::TERMINATED;
@@ -453,8 +440,7 @@
return res;
}
-void egl_display_t::loseCurrent(egl_context_t * cur_c)
-{
+void egl_display_t::loseCurrent(egl_context_t* cur_c) {
if (cur_c) {
egl_display_t* display = cur_c->getDisplay();
if (display) {
@@ -463,8 +449,7 @@
}
}
-void egl_display_t::loseCurrentImpl(egl_context_t * cur_c)
-{
+void egl_display_t::loseCurrentImpl(egl_context_t* cur_c) {
// by construction, these are either 0 or valid (possibly terminated)
// it should be impossible for these to be invalid
ContextRef _cur_c(cur_c);
@@ -474,7 +459,6 @@
{ // scope for the lock
std::lock_guard<std::mutex> _l(lock);
cur_c->onLooseCurrent();
-
}
// This cannot be called with the lock held because it might end-up
@@ -485,10 +469,9 @@
_cur_d.release();
}
-EGLBoolean egl_display_t::makeCurrent(egl_context_t* c, egl_context_t* cur_c,
- EGLSurface draw, EGLSurface read, EGLContext /*ctx*/,
- EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx)
-{
+EGLBoolean egl_display_t::makeCurrent(egl_context_t* c, egl_context_t* cur_c, EGLSurface draw,
+ EGLSurface read, EGLContext /*ctx*/, EGLSurface impl_draw,
+ EGLSurface impl_read, EGLContext impl_ctx) {
EGLBoolean result;
// by construction, these are either 0 or valid (possibly terminated)
@@ -500,14 +483,12 @@
{ // scope for the lock
std::lock_guard<std::mutex> _l(lock);
if (c) {
- result = c->cnx->egl.eglMakeCurrent(
- disp.dpy, impl_draw, impl_read, impl_ctx);
+ result = c->cnx->egl.eglMakeCurrent(disp.dpy, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
c->onMakeCurrent(draw, read);
}
} else {
- result = cur_c->cnx->egl.eglMakeCurrent(
- disp.dpy, impl_draw, impl_read, impl_ctx);
+ result = cur_c->cnx->egl.eglMakeCurrent(disp.dpy, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
cur_c->onLooseCurrent();
}
@@ -533,6 +514,23 @@
return findExtension(mExtensionString.c_str(), name, nameLen);
}
-// ----------------------------------------------------------------------------
+egl_display_t* validate_display(EGLDisplay dpy) {
+ egl_display_t* const dp = get_display(dpy);
+ if (!dp) return setError(EGL_BAD_DISPLAY, (egl_display_t*)nullptr);
+ if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, (egl_display_t*)nullptr);
+
+ return dp;
+}
+
+egl_display_t* validate_display_connection(EGLDisplay dpy, egl_connection_t** outCnx) {
+ *outCnx = nullptr;
+ egl_display_t* dp = validate_display(dpy);
+ if (!dp) return dp;
+ *outCnx = &gEGLImpl;
+ if ((*outCnx)->dso == nullptr) {
+ return setError(EGL_BAD_CONFIG, (egl_display_t*)nullptr);
+ }
+ return dp;
+}
+
}; // namespace android
-// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h
index 4a437af..0155133 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -17,24 +17,20 @@
#ifndef ANDROID_EGL_DISPLAY_H
#define ANDROID_EGL_DISPLAY_H
-
-#include <stdint.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
#include <stddef.h>
+#include <stdint.h>
#include <condition_variable>
#include <mutex>
#include <string>
#include <unordered_set>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#include "egldefs.h"
#include "../hooks.h"
+#include "egldefs.h"
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
class egl_object_t;
class egl_context_t;
@@ -43,25 +39,23 @@
bool findExtension(const char* exts, const char* name, size_t nameLen = 0);
bool needsAndroidPEglMitigation();
-// ----------------------------------------------------------------------------
-
class EGLAPI egl_display_t { // marked as EGLAPI for testing purposes
static egl_display_t sDisplay[NUM_DISPLAYS];
EGLDisplay getDisplay(EGLNativeDisplayType display);
EGLDisplay getPlatformDisplay(EGLNativeDisplayType display, const EGLAttrib* attrib_list);
- void loseCurrentImpl(egl_context_t * cur_c);
+ void loseCurrentImpl(egl_context_t* cur_c);
public:
enum {
NOT_INITIALIZED = 0,
- INITIALIZED = 1,
- TERMINATED = 2
+ INITIALIZED = 1,
+ TERMINATED = 2,
};
egl_display_t();
~egl_display_t();
- EGLBoolean initialize(EGLint *major, EGLint *minor);
+ EGLBoolean initialize(EGLint* major, EGLint* minor);
EGLBoolean terminate();
// add object to this display's list
@@ -74,75 +68,69 @@
static egl_display_t* get(EGLDisplay dpy);
static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp, const EGLAttrib* attrib_list);
- EGLBoolean makeCurrent(egl_context_t* c, egl_context_t* cur_c,
- EGLSurface draw, EGLSurface read, EGLContext ctx,
- EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx);
- static void loseCurrent(egl_context_t * cur_c);
+ EGLBoolean makeCurrent(egl_context_t* c, egl_context_t* cur_c, EGLSurface draw, EGLSurface read,
+ EGLContext ctx, EGLSurface impl_draw, EGLSurface impl_read,
+ EGLContext impl_ctx);
+ static void loseCurrent(egl_context_t* cur_c);
inline bool isReady() const { return (refs > 0); }
inline bool isValid() const { return magic == '_dpy'; }
inline bool isAlive() const { return isValid(); }
- char const * getVendorString() const { return mVendorString.c_str(); }
- char const * getVersionString() const { return mVersionString.c_str(); }
- char const * getClientApiString() const { return mClientApiString.c_str(); }
- char const * getExtensionString() const { return mExtensionString.c_str(); }
+ char const* getVendorString() const { return mVendorString.c_str(); }
+ char const* getVersionString() const { return mVersionString.c_str(); }
+ char const* getClientApiString() const { return mClientApiString.c_str(); }
+ char const* getExtensionString() const { return mExtensionString.c_str(); }
bool haveExtension(const char* name, size_t nameLen = 0) const;
inline uint32_t getRefsCount() const { return refs; }
struct strings_t {
- char const * vendor;
- char const * version;
- char const * clientApi;
- char const * extensions;
+ char const* vendor;
+ char const* version;
+ char const* clientApi;
+ char const* extensions;
};
struct DisplayImpl {
- DisplayImpl() : dpy(EGL_NO_DISPLAY), state(NOT_INITIALIZED) { }
- EGLDisplay dpy;
- EGLint state;
- strings_t queryString;
+ DisplayImpl() : dpy(EGL_NO_DISPLAY), state(NOT_INITIALIZED) {}
+ EGLDisplay dpy;
+ EGLint state;
+ strings_t queryString;
};
private:
- uint32_t magic;
+ uint32_t magic;
public:
- DisplayImpl disp;
- bool finishOnSwap; // property: debug.egl.finish
- bool traceGpuCompletion; // property: debug.egl.traceGpuCompletion
- bool hasColorSpaceSupport;
+ DisplayImpl disp;
+ bool finishOnSwap; // property: debug.egl.finish
+ bool traceGpuCompletion; // property: debug.egl.traceGpuCompletion
+ bool hasColorSpaceSupport;
private:
- uint32_t refs;
- bool eglIsInitialized;
- mutable std::mutex lock;
- mutable std::mutex refLock;
- mutable std::condition_variable refCond;
- std::unordered_set<egl_object_t*> objects;
- std::string mVendorString;
- std::string mVersionString;
- std::string mClientApiString;
- std::string mExtensionString;
+ uint32_t refs;
+ bool eglIsInitialized;
+ mutable std::mutex lock;
+ mutable std::mutex refLock;
+ mutable std::condition_variable refCond;
+ std::unordered_set<egl_object_t*> objects;
+ std::string mVendorString;
+ std::string mVersionString;
+ std::string mClientApiString;
+ std::string mExtensionString;
};
-// ----------------------------------------------------------------------------
-
inline egl_display_t* get_display(EGLDisplay dpy) {
return egl_display_t::get(dpy);
}
-// ----------------------------------------------------------------------------
-
egl_display_t* validate_display(EGLDisplay dpy);
egl_display_t* validate_display_connection(EGLDisplay dpy, egl_connection_t** outCnx);
EGLBoolean validate_display_context(EGLDisplay dpy, EGLContext ctx);
EGLBoolean validate_display_surface(EGLDisplay dpy, EGLSurface surface);
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
#endif // ANDROID_EGL_DISPLAY_H
diff --git a/opengl/libs/EGL/egl_layers.cpp b/opengl/libs/EGL/egl_layers.cpp
index ea86c9a..9752e38 100644
--- a/opengl/libs/EGL/egl_layers.cpp
+++ b/opengl/libs/EGL/egl_layers.cpp
@@ -85,17 +85,21 @@
// Look up which GPA we should use
int gpaIndex = func_indices["eglGetProcAddress"];
- ALOGV("getNextLayerProcAddress - name(%s) gpaIndex(%i) <- using GPA from this index", name, gpaIndex);
+ ALOGV("getNextLayerProcAddress - name(%s) gpaIndex(%i) <- using GPA from this index", name,
+ gpaIndex);
EGLFuncPointer gpaNext = (*next_layer_funcs)[gpaIndex];
- ALOGV("getNextLayerProcAddress - name(%s) gpaIndex(%i) gpaNext(%llu) <- using GPA at this address", name, gpaIndex, (unsigned long long)gpaNext);
-
+ ALOGV("getNextLayerProcAddress - name(%s) gpaIndex(%i) gpaNext(%llu) <- using GPA at this "
+ "address",
+ name, gpaIndex, (unsigned long long)gpaNext);
// Call it for the requested function
typedef void* (*PFNEGLGETPROCADDRESSPROC)(const char*);
PFNEGLGETPROCADDRESSPROC next = reinterpret_cast<PFNEGLGETPROCADDRESSPROC>(gpaNext);
val = reinterpret_cast<EGLFuncPointer>(next(name));
- ALOGV("getNextLayerProcAddress - name(%s) gpaIndex(%i) gpaNext(%llu) Got back (%llu) from GPA", name, gpaIndex, (unsigned long long)gpaNext, (unsigned long long)val);
+ ALOGV("getNextLayerProcAddress - name(%s) gpaIndex(%i) gpaNext(%llu) Got back (%llu) from "
+ "GPA",
+ name, gpaIndex, (unsigned long long)gpaNext, (unsigned long long)val);
// We should store it now, but to do that, we need to move func_idx to the class so we can
// increment it separately
@@ -105,7 +109,9 @@
int index = func_indices[name];
val = (*next_layer_funcs)[index];
- ALOGV("getNextLayerProcAddress - name(%s) index(%i) entry(%llu) - Got a hit, returning known entry", name, index, (unsigned long long)val);
+ ALOGV("getNextLayerProcAddress - name(%s) index(%i) entry(%llu) - Got a hit, returning known "
+ "entry",
+ name, index, (unsigned long long)val);
return reinterpret_cast<void*>(val);
}
@@ -117,20 +123,26 @@
// Some names overlap, only fill with initial entry
// This does mean that some indices will not be used
if (func_indices.find(name) == func_indices.end()) {
- ALOGV("SetupFuncMaps - name(%s), func_idx(%i), No entry for func_indices, assigning now", name, func_idx);
+ ALOGV("SetupFuncMaps - name(%s), func_idx(%i), No entry for func_indices, assigning "
+ "now",
+ name, func_idx);
func_names[func_idx] = name;
func_indices[name] = func_idx;
} else {
- ALOGV("SetupFuncMaps - name(%s), func_idx(%i), Found entry for func_indices", name, func_idx);
+ ALOGV("SetupFuncMaps - name(%s), func_idx(%i), Found entry for func_indices", name,
+ func_idx);
}
// Populate layer_functions once with initial value
// These values will arrive in priority order, starting with platform entries
if (functions[func_idx] == nullptr) {
- ALOGV("SetupFuncMaps - name(%s), func_idx(%i), No entry for functions, assigning (%llu)", name, func_idx, (unsigned long long) *curr);
+ ALOGV("SetupFuncMaps - name(%s), func_idx(%i), No entry for functions, assigning "
+ "(%llu)",
+ name, func_idx, (unsigned long long)*curr);
functions[func_idx] = *curr;
} else {
- ALOGV("SetupFuncMaps - name(%s), func_idx(%i), Found entry for functions (%llu)", name, func_idx, (unsigned long long) functions[func_idx]);
+ ALOGV("SetupFuncMaps - name(%s), func_idx(%i), Found entry for functions (%llu)", name,
+ func_idx, (unsigned long long)functions[func_idx]);
}
entries++;
@@ -380,8 +392,8 @@
auto app_namespace = android::GraphicsEnv::getInstance().getAppNamespace();
if (app_namespace && !android::base::StartsWith(layer, kSystemLayerLibraryDir)) {
char* error_message = nullptr;
- dlhandle_ = OpenNativeLibraryInNamespace(
- app_namespace, layer.c_str(), &native_bridge_, &error_message);
+ dlhandle_ = OpenNativeLibraryInNamespace(app_namespace, layer.c_str(),
+ &native_bridge_, &error_message);
if (!dlhandle_) {
ALOGE("Failed to load layer %s with error: %s", layer.c_str(),
error_message);
diff --git a/opengl/libs/EGL/egl_layers.h b/opengl/libs/EGL/egl_layers.h
index 1e2783f..705525d 100644
--- a/opengl/libs/EGL/egl_layers.h
+++ b/opengl/libs/EGL/egl_layers.h
@@ -17,19 +17,18 @@
#ifndef ANDROID_EGL_LAYERS_H
#define ANDROID_EGL_LAYERS_H
+#include <EGL/egldefs.h>
+#include <android/dlext.h>
+#include <dlfcn.h>
+#include <nativebridge/native_bridge.h>
+#include <nativeloader/native_loader.h>
+
#include <string>
#include <unordered_map>
#include <vector>
-#include <android/dlext.h>
-#include <dlfcn.h>
-
-#include <EGL/egldefs.h>
#include "egl_platform_entries.h"
-#include <nativebridge/native_bridge.h>
-#include <nativeloader/native_loader.h>
-
typedef __eglMustCastToProperFunctionPointerType EGLFuncPointer;
namespace android {
@@ -46,8 +45,8 @@
void LoadLayers();
void InitLayers(egl_connection_t*);
- void LayerPlatformEntries(layer_setup_func layer_setup, EGLFuncPointer*, char const* const*);
- void LayerDriverEntries(layer_setup_func layer_setup, EGLFuncPointer*, char const* const*);
+ void LayerPlatformEntries(layer_setup_func layer_setup, EGLFuncPointer*, const char* const*);
+ void LayerDriverEntries(layer_setup_func layer_setup, EGLFuncPointer*, const char* const*);
bool Initialized();
std::string GetDebugLayers();
@@ -59,18 +58,23 @@
std::vector<layer_setup_func> layer_setup_;
private:
- LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0), dlhandle_(nullptr), native_bridge_(false){};
+ LayerLoader()
+ : layers_loaded_(false),
+ initialized_(false),
+ current_layer_(0),
+ dlhandle_(nullptr),
+ native_bridge_(false){};
bool layers_loaded_;
bool initialized_;
unsigned current_layer_;
void* dlhandle_;
bool native_bridge_;
- template<typename Func = void*>
+ template <typename Func = void*>
Func GetTrampoline(const char* name) const {
if (native_bridge_) {
- return reinterpret_cast<Func>(android::NativeBridgeGetTrampoline(
- dlhandle_, name, nullptr, 0));
+ return reinterpret_cast<Func>(
+ android::NativeBridgeGetTrampoline(dlhandle_, name, nullptr, 0));
}
return reinterpret_cast<Func>(dlsym(dlhandle_, name));
}
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index b14444b..847b351 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -18,19 +18,14 @@
#include <sstream>
-
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
-egl_object_t::egl_object_t(egl_display_t* disp) :
- display(disp), count(1) {
+egl_object_t::egl_object_t(egl_display_t* disp) : display(disp), count(1) {
// NOTE: this does an implicit incRef
display->addObject(this);
}
-egl_object_t::~egl_object_t() {
-}
+egl_object_t::~egl_object_t() {}
void egl_object_t::terminate() {
// this marks the object as "terminated"
@@ -53,8 +48,6 @@
return display->getObject(object);
}
-// ----------------------------------------------------------------------------
-
egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, EGLNativeWindowType win,
EGLSurface surface, EGLint colorSpace, egl_connection_t const* cnx)
: egl_object_t(dpy),
@@ -66,10 +59,10 @@
colorSpace(colorSpace),
egl_smpte2086_dirty(false),
egl_cta861_3_dirty(false) {
- egl_smpte2086_metadata.displayPrimaryRed = { EGL_DONT_CARE, EGL_DONT_CARE };
- egl_smpte2086_metadata.displayPrimaryGreen = { EGL_DONT_CARE, EGL_DONT_CARE };
- egl_smpte2086_metadata.displayPrimaryBlue = { EGL_DONT_CARE, EGL_DONT_CARE };
- egl_smpte2086_metadata.whitePoint = { EGL_DONT_CARE, EGL_DONT_CARE };
+ egl_smpte2086_metadata.displayPrimaryRed = {EGL_DONT_CARE, EGL_DONT_CARE};
+ egl_smpte2086_metadata.displayPrimaryGreen = {EGL_DONT_CARE, EGL_DONT_CARE};
+ egl_smpte2086_metadata.displayPrimaryBlue = {EGL_DONT_CARE, EGL_DONT_CARE};
+ egl_smpte2086_metadata.whitePoint = {EGL_DONT_CARE, EGL_DONT_CARE};
egl_smpte2086_metadata.maxLuminance = EGL_DONT_CARE;
egl_smpte2086_metadata.minLuminance = EGL_DONT_CARE;
egl_cta861_3_metadata.maxFrameAverageLightLevel = EGL_DONT_CARE;
@@ -173,16 +166,30 @@
return EGL_FALSE;
}
- metadata.displayPrimaryRed.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.x) / EGL_METADATA_SCALING_EXT;
- metadata.displayPrimaryRed.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.y) / EGL_METADATA_SCALING_EXT;
- metadata.displayPrimaryGreen.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.x) / EGL_METADATA_SCALING_EXT;
- metadata.displayPrimaryGreen.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.y) / EGL_METADATA_SCALING_EXT;
- metadata.displayPrimaryBlue.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.x) / EGL_METADATA_SCALING_EXT;
- metadata.displayPrimaryBlue.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.y) / EGL_METADATA_SCALING_EXT;
- metadata.whitePoint.x = static_cast<float>(egl_smpte2086_metadata.whitePoint.x) / EGL_METADATA_SCALING_EXT;
- metadata.whitePoint.y = static_cast<float>(egl_smpte2086_metadata.whitePoint.y) / EGL_METADATA_SCALING_EXT;
- metadata.maxLuminance = static_cast<float>(egl_smpte2086_metadata.maxLuminance) / EGL_METADATA_SCALING_EXT;
- metadata.minLuminance = static_cast<float>(egl_smpte2086_metadata.minLuminance) / EGL_METADATA_SCALING_EXT;
+ metadata.displayPrimaryRed.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.x) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.displayPrimaryRed.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.y) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.displayPrimaryGreen.x =
+ static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.x) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.displayPrimaryGreen.y =
+ static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.y) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.displayPrimaryBlue.x =
+ static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.x) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.displayPrimaryBlue.y =
+ static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.y) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.whitePoint.x =
+ static_cast<float>(egl_smpte2086_metadata.whitePoint.x) / EGL_METADATA_SCALING_EXT;
+ metadata.whitePoint.y =
+ static_cast<float>(egl_smpte2086_metadata.whitePoint.y) / EGL_METADATA_SCALING_EXT;
+ metadata.maxLuminance =
+ static_cast<float>(egl_smpte2086_metadata.maxLuminance) / EGL_METADATA_SCALING_EXT;
+ metadata.minLuminance =
+ static_cast<float>(egl_smpte2086_metadata.minLuminance) / EGL_METADATA_SCALING_EXT;
return EGL_TRUE;
}
@@ -196,13 +203,15 @@
return EGL_FALSE;
}
- metadata.maxContentLightLevel = static_cast<float>(egl_cta861_3_metadata.maxContentLightLevel) / EGL_METADATA_SCALING_EXT;
- metadata.maxFrameAverageLightLevel = static_cast<float>(egl_cta861_3_metadata.maxFrameAverageLightLevel) / EGL_METADATA_SCALING_EXT;
+ metadata.maxContentLightLevel = static_cast<float>(egl_cta861_3_metadata.maxContentLightLevel) /
+ EGL_METADATA_SCALING_EXT;
+ metadata.maxFrameAverageLightLevel =
+ static_cast<float>(egl_cta861_3_metadata.maxFrameAverageLightLevel) /
+ EGL_METADATA_SCALING_EXT;
return EGL_TRUE;
}
-
EGLBoolean egl_surface_t::getColorSpaceAttribute(EGLint attribute, EGLint* value) const {
if (attribute == EGL_GL_COLORSPACE_KHR) {
*value = colorSpace;
@@ -211,7 +220,7 @@
return EGL_FALSE;
}
-EGLBoolean egl_surface_t::getSmpte2086Attribute(EGLint attribute, EGLint *value) const {
+EGLBoolean egl_surface_t::getSmpte2086Attribute(EGLint attribute, EGLint* value) const {
switch (attribute) {
case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT:
*value = egl_smpte2086_metadata.displayPrimaryRed.x;
@@ -257,7 +266,7 @@
return EGL_FALSE;
}
-EGLBoolean egl_surface_t::getCta8613Attribute(EGLint attribute, EGLint *value) const {
+EGLBoolean egl_surface_t::getCta8613Attribute(EGLint attribute, EGLint* value) const {
switch (attribute) {
case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT:
*value = egl_cta861_3_metadata.maxContentLightLevel;
@@ -276,8 +285,6 @@
egl_object_t::terminate();
}
-// ----------------------------------------------------------------------------
-
egl_context_t::egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
egl_connection_t const* cnx, int version)
: egl_object_t(get_display(dpy)),
@@ -302,43 +309,39 @@
* Here we cache the GL_EXTENSIONS string for this context and we
* add the extensions always handled by the wrapper
*/
+ if (!gl_extensions.empty()) return;
- if (gl_extensions.empty()) {
- // call the implementation's glGetString(GL_EXTENSIONS)
- const char* exts = (const char *)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS);
+ // call the implementation's glGetString(GL_EXTENSIONS)
+ const char* exts = (const char*)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS);
+ if (!exts) return;
- // If this context is sharing with another context, and the other context was reset
- // e.g. due to robustness failure, this context might also be reset and glGetString can
- // return NULL.
- if (exts) {
- gl_extensions = exts;
- if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) {
- gl_extensions.insert(0, "GL_EXT_debug_marker ");
- // eglGetProcAddress could return function pointers to these
- // functions while they actually don't work. Fix them now.
- __eglMustCastToProperFunctionPointerType* f;
- f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version]
- ->gl.glInsertEventMarkerEXT;
- if (*f != gl_noop) *f = gl_noop;
- f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version]
- ->gl.glPushGroupMarkerEXT;
- if (*f != gl_noop) *f = gl_noop;
- f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version]
- ->gl.glPopGroupMarkerEXT;
- if (*f != gl_noop) *f = gl_noop;
- }
+ // If this context is sharing with another context, and the other context was reset
+ // e.g. due to robustness failure, this context might also be reset and glGetString can
+ // return NULL.
+ gl_extensions = exts;
+ if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) {
+ gl_extensions.insert(0, "GL_EXT_debug_marker ");
+ // eglGetProcAddress could return function pointers to these
+ // functions while they actually don't work. Fix them now.
+ __eglMustCastToProperFunctionPointerType* f;
+ f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version]
+ ->gl.glInsertEventMarkerEXT;
+ if (*f != gl_noop) *f = gl_noop;
+ f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version]
+ ->gl.glPushGroupMarkerEXT;
+ if (*f != gl_noop) *f = gl_noop;
+ f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version]
+ ->gl.glPopGroupMarkerEXT;
+ if (*f != gl_noop) *f = gl_noop;
+ }
- // tokenize the supported extensions for the glGetStringi() wrapper
- std::stringstream ss;
- std::string str;
- ss << gl_extensions;
- while (ss >> str) {
- tokenized_gl_extensions.push_back(str);
- }
- }
+ // tokenize the supported extensions for the glGetStringi() wrapper
+ std::stringstream ss;
+ std::string str;
+ ss << gl_extensions;
+ while (ss >> str) {
+ tokenized_gl_extensions.push_back(str);
}
}
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index fb2bdf4..e593b1c 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -17,30 +17,25 @@
#ifndef ANDROID_EGL_OBJECT_H
#define ANDROID_EGL_OBJECT_H
-#include <atomic>
-#include <stdint.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <log/log.h>
#include <stddef.h>
+#include <stdint.h>
+#include <system/window.h>
+#include <atomic>
#include <string>
#include <vector>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#include <system/window.h>
-
-#include <log/log.h>
-
#include "egl_display.h"
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
class egl_display_t;
class egl_object_t {
- egl_display_t *display;
+ egl_display_t* display;
mutable std::atomic_size_t count;
protected:
@@ -64,6 +59,7 @@
egl_object_t* ref;
LocalRef() = delete;
LocalRef(const LocalRef* rhs) = delete;
+
public:
~LocalRef();
explicit LocalRef(egl_object_t* rhs);
@@ -73,9 +69,7 @@
ref = native;
}
}
- inline N* get() {
- return static_cast<N*>(ref);
- }
+ inline N* get() { return static_cast<N*>(ref); }
void acquire() const;
void release() const;
void terminate();
@@ -84,7 +78,7 @@
friend class LocalRef;
};
-template<typename N, typename T>
+template <typename N, typename T>
egl_object_t::LocalRef<N, T>::LocalRef(egl_object_t* rhs) : ref(rhs) {
if (ref) {
ref->incRef();
@@ -92,21 +86,21 @@
}
template <typename N, typename T>
-egl_object_t::LocalRef<N,T>::~LocalRef() {
+egl_object_t::LocalRef<N, T>::~LocalRef() {
if (ref) {
ref->destroy();
}
}
template <typename N, typename T>
-void egl_object_t::LocalRef<N,T>::acquire() const {
+void egl_object_t::LocalRef<N, T>::acquire() const {
if (ref) {
ref->incRef();
}
}
template <typename N, typename T>
-void egl_object_t::LocalRef<N,T>::release() const {
+void egl_object_t::LocalRef<N, T>::release() const {
if (ref) {
if (ref->decRef() == 1) {
// shouldn't happen because this is called from LocalRef
@@ -116,7 +110,7 @@
}
template <typename N, typename T>
-void egl_object_t::LocalRef<N,T>::terminate() {
+void egl_object_t::LocalRef<N, T>::terminate() {
if (ref) {
ref->terminate();
}
@@ -128,6 +122,7 @@
protected:
~egl_surface_t();
void terminate() override;
+
public:
typedef egl_object_t::LocalRef<egl_surface_t, EGLSurface> Ref;
@@ -151,10 +146,13 @@
// it's not hard to imagine native games accessing them.
EGLSurface surface;
EGLConfig config;
+
private:
ANativeWindow* win;
+
public:
egl_connection_t const* cnx;
+
private:
bool connected;
void disconnect();
@@ -186,14 +184,15 @@
egl_cta861_3_metadata egl_cta861_3_metadata;
};
-class egl_context_t: public egl_object_t {
+class egl_context_t : public egl_object_t {
protected:
~egl_context_t() {}
+
public:
typedef egl_object_t::LocalRef<egl_context_t, EGLContext> Ref;
- egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
- egl_connection_t const* cnx, int version);
+ egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config, egl_connection_t const* cnx,
+ int version);
void onLooseCurrent();
void onMakeCurrent(EGLSurface draw, EGLSurface read);
@@ -209,30 +208,22 @@
std::vector<std::string> tokenized_gl_extensions;
};
-// ----------------------------------------------------------------------------
+typedef egl_surface_t::Ref SurfaceRef;
+typedef egl_context_t::Ref ContextRef;
-typedef egl_surface_t::Ref SurfaceRef;
-typedef egl_context_t::Ref ContextRef;
-
-// ----------------------------------------------------------------------------
-
-template<typename NATIVE, typename EGL>
+template <typename NATIVE, typename EGL>
static inline NATIVE* egl_to_native_cast(EGL arg) {
return reinterpret_cast<NATIVE*>(arg);
}
-static inline
-egl_surface_t* get_surface(EGLSurface surface) {
+static inline egl_surface_t* get_surface(EGLSurface surface) {
return egl_to_native_cast<egl_surface_t>(surface);
}
-static inline
-egl_context_t* get_context(EGLContext context) {
+static inline egl_context_t* get_context(EGLContext context) {
return egl_to_native_cast<egl_context_t>(context);
}
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
#endif // ANDROID_EGL_OBJECT_H
diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp
index 92308ed..398efc0 100644
--- a/opengl/libs/EGL/egl_platform_entries.cpp
+++ b/opengl/libs/EGL/egl_platform_entries.cpp
@@ -76,12 +76,12 @@
* NOTE: Both strings MUST have a single space as the last character.
*/
-extern char const * const gBuiltinExtensionString;
-extern char const * const gExtensionString;
+extern const char* const gBuiltinExtensionString;
+extern const char* const gExtensionString;
// clang-format off
// Extensions implemented by the EGL wrapper.
-char const * const gBuiltinExtensionString =
+const char* const gBuiltinExtensionString =
"EGL_ANDROID_front_buffer_auto_refresh "
"EGL_ANDROID_get_frame_timestamps "
"EGL_ANDROID_get_native_client_buffer "
@@ -93,7 +93,7 @@
;
// Allowed list of extensions exposed to applications if implemented in the vendor driver.
-char const * const gExtensionString =
+const char* const gExtensionString =
"EGL_ANDROID_image_native_buffer " // mandatory
"EGL_ANDROID_native_fence_sync " // strongly recommended
"EGL_ANDROID_recordable " // mandatory
@@ -131,13 +131,12 @@
"EGL_NV_system_time "
;
-char const * const gClientExtensionString =
+const char* const gClientExtensionString =
"EGL_ANDROID_GLES_layers "
"EGL_ANGLE_platform_angle "
"EGL_EXT_client_extensions "
"EGL_KHR_platform_android "
;
-// clang-format on
// extensions not exposed to applications but used by the ANDROID system
// "EGL_ANDROID_blob_cache " // strongly recommended
@@ -150,96 +149,63 @@
*/
static const extension_map_t sExtensionMap[] = {
// EGL_KHR_lock_surface
- { "eglLockSurfaceKHR",
- (__eglMustCastToProperFunctionPointerType)&eglLockSurfaceKHR },
- { "eglUnlockSurfaceKHR",
- (__eglMustCastToProperFunctionPointerType)&eglUnlockSurfaceKHR },
+ { "eglLockSurfaceKHR", (__eglMustCastToProperFunctionPointerType)&eglLockSurfaceKHR },
+ { "eglUnlockSurfaceKHR", (__eglMustCastToProperFunctionPointerType)&eglUnlockSurfaceKHR },
// EGL_KHR_image, EGL_KHR_image_base
- { "eglCreateImageKHR",
- (__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR },
- { "eglDestroyImageKHR",
- (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR },
+ { "eglCreateImageKHR", (__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR },
+ { "eglDestroyImageKHR", (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR },
// EGL_KHR_reusable_sync, EGL_KHR_fence_sync
- { "eglCreateSyncKHR",
- (__eglMustCastToProperFunctionPointerType)&eglCreateSyncKHR },
- { "eglDestroySyncKHR",
- (__eglMustCastToProperFunctionPointerType)&eglDestroySyncKHR },
- { "eglClientWaitSyncKHR",
- (__eglMustCastToProperFunctionPointerType)&eglClientWaitSyncKHR },
- { "eglSignalSyncKHR",
- (__eglMustCastToProperFunctionPointerType)&eglSignalSyncKHR },
- { "eglGetSyncAttribKHR",
- (__eglMustCastToProperFunctionPointerType)&eglGetSyncAttribKHR },
+ { "eglCreateSyncKHR", (__eglMustCastToProperFunctionPointerType)&eglCreateSyncKHR },
+ { "eglDestroySyncKHR", (__eglMustCastToProperFunctionPointerType)&eglDestroySyncKHR },
+ { "eglClientWaitSyncKHR", (__eglMustCastToProperFunctionPointerType)&eglClientWaitSyncKHR },
+ { "eglSignalSyncKHR", (__eglMustCastToProperFunctionPointerType)&eglSignalSyncKHR },
+ { "eglGetSyncAttribKHR", (__eglMustCastToProperFunctionPointerType)&eglGetSyncAttribKHR },
// EGL_NV_system_time
- { "eglGetSystemTimeFrequencyNV",
- (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeFrequencyNV },
- { "eglGetSystemTimeNV",
- (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeNV },
+ { "eglGetSystemTimeFrequencyNV", (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeFrequencyNV },
+ { "eglGetSystemTimeNV", (__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeNV },
// EGL_KHR_wait_sync
- { "eglWaitSyncKHR",
- (__eglMustCastToProperFunctionPointerType)&eglWaitSyncKHR },
+ { "eglWaitSyncKHR", (__eglMustCastToProperFunctionPointerType)&eglWaitSyncKHR },
// EGL_ANDROID_presentation_time
- { "eglPresentationTimeANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID },
+ { "eglPresentationTimeANDROID", (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID },
// EGL_KHR_swap_buffers_with_damage
- { "eglSwapBuffersWithDamageKHR",
- (__eglMustCastToProperFunctionPointerType)&eglSwapBuffersWithDamageKHR },
+ { "eglSwapBuffersWithDamageKHR", (__eglMustCastToProperFunctionPointerType)&eglSwapBuffersWithDamageKHR },
// EGL_ANDROID_get_native_client_buffer
- { "eglGetNativeClientBufferANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglGetNativeClientBufferANDROID },
+ { "eglGetNativeClientBufferANDROID", (__eglMustCastToProperFunctionPointerType)&eglGetNativeClientBufferANDROID },
// EGL_KHR_partial_update
- { "eglSetDamageRegionKHR",
- (__eglMustCastToProperFunctionPointerType)&eglSetDamageRegionKHR },
+ { "eglSetDamageRegionKHR", (__eglMustCastToProperFunctionPointerType)&eglSetDamageRegionKHR },
- { "eglCreateStreamKHR",
- (__eglMustCastToProperFunctionPointerType)&eglCreateStreamKHR },
- { "eglDestroyStreamKHR",
- (__eglMustCastToProperFunctionPointerType)&eglDestroyStreamKHR },
- { "eglStreamAttribKHR",
- (__eglMustCastToProperFunctionPointerType)&eglStreamAttribKHR },
- { "eglQueryStreamKHR",
- (__eglMustCastToProperFunctionPointerType)&eglQueryStreamKHR },
- { "eglQueryStreamu64KHR",
- (__eglMustCastToProperFunctionPointerType)&eglQueryStreamu64KHR },
- { "eglQueryStreamTimeKHR",
- (__eglMustCastToProperFunctionPointerType)&eglQueryStreamTimeKHR },
- { "eglCreateStreamProducerSurfaceKHR",
- (__eglMustCastToProperFunctionPointerType)&eglCreateStreamProducerSurfaceKHR },
- { "eglStreamConsumerGLTextureExternalKHR",
- (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerGLTextureExternalKHR },
- { "eglStreamConsumerAcquireKHR",
- (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerAcquireKHR },
- { "eglStreamConsumerReleaseKHR",
- (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerReleaseKHR },
- { "eglGetStreamFileDescriptorKHR",
- (__eglMustCastToProperFunctionPointerType)&eglGetStreamFileDescriptorKHR },
- { "eglCreateStreamFromFileDescriptorKHR",
- (__eglMustCastToProperFunctionPointerType)&eglCreateStreamFromFileDescriptorKHR },
+ { "eglCreateStreamKHR", (__eglMustCastToProperFunctionPointerType)&eglCreateStreamKHR },
+ { "eglDestroyStreamKHR", (__eglMustCastToProperFunctionPointerType)&eglDestroyStreamKHR },
+ { "eglStreamAttribKHR", (__eglMustCastToProperFunctionPointerType)&eglStreamAttribKHR },
+ { "eglQueryStreamKHR", (__eglMustCastToProperFunctionPointerType)&eglQueryStreamKHR },
+ { "eglQueryStreamu64KHR", (__eglMustCastToProperFunctionPointerType)&eglQueryStreamu64KHR },
+ { "eglQueryStreamTimeKHR", (__eglMustCastToProperFunctionPointerType)&eglQueryStreamTimeKHR },
+ { "eglCreateStreamProducerSurfaceKHR", (__eglMustCastToProperFunctionPointerType)&eglCreateStreamProducerSurfaceKHR },
+ { "eglStreamConsumerGLTextureExternalKHR", (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerGLTextureExternalKHR },
+ { "eglStreamConsumerAcquireKHR", (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerAcquireKHR },
+ { "eglStreamConsumerReleaseKHR", (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerReleaseKHR },
+ { "eglGetStreamFileDescriptorKHR", (__eglMustCastToProperFunctionPointerType)&eglGetStreamFileDescriptorKHR },
+ { "eglCreateStreamFromFileDescriptorKHR", (__eglMustCastToProperFunctionPointerType)&eglCreateStreamFromFileDescriptorKHR },
// EGL_ANDROID_get_frame_timestamps
- { "eglGetNextFrameIdANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglGetNextFrameIdANDROID },
- { "eglGetCompositorTimingANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglGetCompositorTimingANDROID },
- { "eglGetCompositorTimingSupportedANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglGetCompositorTimingSupportedANDROID },
- { "eglGetFrameTimestampsANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampsANDROID },
- { "eglGetFrameTimestampSupportedANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampSupportedANDROID },
+ { "eglGetNextFrameIdANDROID", (__eglMustCastToProperFunctionPointerType)&eglGetNextFrameIdANDROID },
+ { "eglGetCompositorTimingANDROID", (__eglMustCastToProperFunctionPointerType)&eglGetCompositorTimingANDROID },
+ { "eglGetCompositorTimingSupportedANDROID", (__eglMustCastToProperFunctionPointerType)&eglGetCompositorTimingSupportedANDROID },
+ { "eglGetFrameTimestampsANDROID", (__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampsANDROID },
+ { "eglGetFrameTimestampSupportedANDROID", (__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampSupportedANDROID },
// EGL_ANDROID_native_fence_sync
- { "eglDupNativeFenceFDANDROID",
- (__eglMustCastToProperFunctionPointerType)&eglDupNativeFenceFDANDROID },
+ { "eglDupNativeFenceFDANDROID", (__eglMustCastToProperFunctionPointerType)&eglDupNativeFenceFDANDROID },
};
+// clang-format on
/*
* These extensions entry-points should not be exposed to applications.
@@ -254,9 +220,8 @@
static int sGLExtensionSlot = 0;
static pthread_mutex_t sExtensionMapMutex = PTHREAD_MUTEX_INITIALIZER;
-static void(*findProcAddress(const char* name,
- const extension_map_t* map, size_t n))() {
- for (uint32_t i=0 ; i<n ; i++) {
+static void (*findProcAddress(const char* name, const extension_map_t* map, size_t n))() {
+ for (uint32_t i = 0; i < n; i++) {
if (!strcmp(name, map[i].name)) {
return map[i].address;
}
@@ -266,14 +231,17 @@
// ----------------------------------------------------------------------------
-extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
+extern void setGLHooksThreadSpecific(gl_hooks_t const* value);
extern EGLBoolean egl_init_drivers();
-extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS];
+extern const __eglMustCastToProperFunctionPointerType
+ gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS];
extern gl_hooks_t gHooksTrace;
// ----------------------------------------------------------------------------
-static inline EGLContext getContext() { return egl_tls_t::getContext(); }
+static inline EGLContext getContext() {
+ return egl_tls_t::getContext();
+}
// ----------------------------------------------------------------------------
@@ -306,8 +274,7 @@
// Initialization
// ----------------------------------------------------------------------------
-EGLBoolean eglInitializeImpl(EGLDisplay dpy, EGLint *major, EGLint *minor)
-{
+EGLBoolean eglInitializeImpl(EGLDisplay dpy, EGLint* major, EGLint* minor) {
egl_display_t* dp = get_display(dpy);
if (!dp) return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
@@ -316,8 +283,7 @@
return res;
}
-EGLBoolean eglTerminateImpl(EGLDisplay dpy)
-{
+EGLBoolean eglTerminateImpl(EGLDisplay dpy) {
// NOTE: don't unload the drivers b/c some APIs can be called
// after eglTerminate() has been called. eglTerminate() only
// terminates an EGLDisplay, not a EGL itself.
@@ -334,14 +300,12 @@
// configuration
// ----------------------------------------------------------------------------
-EGLBoolean eglGetConfigsImpl(EGLDisplay dpy,
- EGLConfig *configs,
- EGLint config_size, EGLint *num_config)
-{
+EGLBoolean eglGetConfigsImpl(EGLDisplay dpy, EGLConfig* configs, EGLint config_size,
+ EGLint* num_config) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
- if (num_config==nullptr) {
+ if (num_config == nullptr) {
return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE);
}
@@ -350,96 +314,88 @@
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso) {
- res = cnx->egl.eglGetConfigs(
- dp->disp.dpy, configs, config_size, num_config);
+ res = cnx->egl.eglGetConfigs(dp->disp.dpy, configs, config_size, num_config);
}
return res;
}
-EGLBoolean eglChooseConfigImpl( EGLDisplay dpy, const EGLint *attrib_list,
- EGLConfig *configs, EGLint config_size,
- EGLint *num_config)
-{
+EGLBoolean eglChooseConfigImpl(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
+ EGLint config_size, EGLint* num_config) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
- if (num_config==nullptr) {
+ if (num_config == nullptr) {
return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE);
}
- EGLBoolean res = EGL_FALSE;
*num_config = 0;
egl_connection_t* const cnx = &gEGLImpl;
- if (cnx->dso) {
- if (attrib_list) {
- if (base::GetBoolProperty("debug.egl.force_msaa", false)) {
- size_t attribCount = 0;
- EGLint attrib = attrib_list[0];
+ if (!cnx->dso) return EGL_FALSE;
- // Only enable MSAA if the context is OpenGL ES 2.0 and
- // if no caveat is requested
- const EGLint *attribRendererable = nullptr;
- const EGLint *attribCaveat = nullptr;
+ if (!attrib_list || !base::GetBoolProperty("debug.egl.force_msaa", false))
+ return cnx->egl.eglChooseConfig(dp->disp.dpy, attrib_list, configs, config_size,
+ num_config);
- // Count the number of attributes and look for
- // EGL_RENDERABLE_TYPE and EGL_CONFIG_CAVEAT
- while (attrib != EGL_NONE) {
- attrib = attrib_list[attribCount];
- switch (attrib) {
- case EGL_RENDERABLE_TYPE:
- attribRendererable = &attrib_list[attribCount];
- break;
- case EGL_CONFIG_CAVEAT:
- attribCaveat = &attrib_list[attribCount];
- break;
- default:
- break;
- }
- attribCount++;
- }
+ // Force 4x MSAA
+ size_t attribCount = 0;
+ EGLint attrib = attrib_list[0];
- if (attribRendererable && attribRendererable[1] == EGL_OPENGL_ES2_BIT &&
- (!attribCaveat || attribCaveat[1] != EGL_NONE)) {
+ // Only enable MSAA if the context is OpenGL ES 2.0 and
+ // if no caveat is requested
+ const EGLint* attribRendererable = nullptr;
+ const EGLint* attribCaveat = nullptr;
- // Insert 2 extra attributes to force-enable MSAA 4x
- EGLint aaAttribs[attribCount + 4];
- aaAttribs[0] = EGL_SAMPLE_BUFFERS;
- aaAttribs[1] = 1;
- aaAttribs[2] = EGL_SAMPLES;
- aaAttribs[3] = 4;
-
- memcpy(&aaAttribs[4], attrib_list, attribCount * sizeof(EGLint));
-
- EGLint numConfigAA;
- EGLBoolean resAA = cnx->egl.eglChooseConfig(
- dp->disp.dpy, aaAttribs, configs, config_size, &numConfigAA);
-
- if (resAA == EGL_TRUE && numConfigAA > 0) {
- ALOGD("Enabling MSAA 4x");
- *num_config = numConfigAA;
- return resAA;
- }
- }
- }
+ // Count the number of attributes and look for
+ // EGL_RENDERABLE_TYPE and EGL_CONFIG_CAVEAT
+ while (attrib != EGL_NONE) {
+ attrib = attrib_list[attribCount];
+ switch (attrib) {
+ case EGL_RENDERABLE_TYPE:
+ attribRendererable = &attrib_list[attribCount];
+ break;
+ case EGL_CONFIG_CAVEAT:
+ attribCaveat = &attrib_list[attribCount];
+ break;
+ default:
+ break;
}
-
- res = cnx->egl.eglChooseConfig(
- dp->disp.dpy, attrib_list, configs, config_size, num_config);
+ attribCount++;
}
- return res;
+
+ if (attribRendererable && attribRendererable[1] == EGL_OPENGL_ES2_BIT &&
+ (!attribCaveat || attribCaveat[1] != EGL_NONE)) {
+ // Insert 2 extra attributes to force-enable MSAA 4x
+ EGLint aaAttribs[attribCount + 4];
+ aaAttribs[0] = EGL_SAMPLE_BUFFERS;
+ aaAttribs[1] = 1;
+ aaAttribs[2] = EGL_SAMPLES;
+ aaAttribs[3] = 4;
+
+ memcpy(&aaAttribs[4], attrib_list, attribCount * sizeof(EGLint));
+
+ EGLint numConfigAA;
+ EGLBoolean resAA = cnx->egl.eglChooseConfig(dp->disp.dpy, aaAttribs, configs, config_size,
+ &numConfigAA);
+
+ if (resAA == EGL_TRUE && numConfigAA > 0) {
+ ALOGD("Enabling MSAA 4x");
+ *num_config = numConfigAA;
+ return resAA;
+ }
+ }
+
+ return cnx->egl.eglChooseConfig(dp->disp.dpy, attrib_list, configs, config_size, num_config);
}
-EGLBoolean eglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config,
- EGLint attribute, EGLint *value)
-{
+EGLBoolean eglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config, EGLint attribute,
+ EGLint* value) {
egl_connection_t* cnx = nullptr;
const egl_display_t* dp = validate_display_connection(dpy, &cnx);
if (!dp) return EGL_FALSE;
- return cnx->egl.eglGetConfigAttrib(
- dp->disp.dpy, config, attribute, value);
+ return cnx->egl.eglGetConfigAttrib(dp->disp.dpy, config, attribute, value);
}
// ----------------------------------------------------------------------------
@@ -502,7 +458,8 @@
if (findExtension(dp->disp.queryString.extensions, "EGL_EXT_gl_colorspace_display_p3_linear")) {
colorSpaces.push_back(EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT);
}
- if (findExtension(dp->disp.queryString.extensions, "EGL_EXT_gl_colorspace_display_p3_passthrough")) {
+ if (findExtension(dp->disp.queryString.extensions,
+ "EGL_EXT_gl_colorspace_display_p3_passthrough")) {
colorSpaces.push_back(EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT);
}
return colorSpaces;
@@ -857,28 +814,25 @@
const EGLint* attrib_list) {
egl_connection_t* cnx = nullptr;
egl_display_t* dp = validate_display_connection(dpy, &cnx);
- if (dp) {
- EGLDisplay iDpy = dp->disp.dpy;
- android_pixel_format format;
- getNativePixelFormat(iDpy, cnx, config, &format);
+ if (!dp) return EGL_NO_SURFACE;
- // Select correct colorspace based on user's attribute list
- EGLint colorSpace = EGL_UNKNOWN;
- std::vector<EGLint> strippedAttribList;
- if (!processAttributes(dp, nullptr, attrib_list, &colorSpace, &strippedAttribList)) {
- ALOGE("error invalid colorspace: %d", colorSpace);
- return EGL_NO_SURFACE;
- }
- attrib_list = strippedAttribList.data();
+ EGLDisplay iDpy = dp->disp.dpy;
+ android_pixel_format format;
+ getNativePixelFormat(iDpy, cnx, config, &format);
- EGLSurface surface = cnx->egl.eglCreatePbufferSurface(dp->disp.dpy, config, attrib_list);
- if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dp, config, nullptr, surface,
- getReportedColorSpace(colorSpace), cnx);
- return s;
- }
+ // Select correct colorspace based on user's attribute list
+ EGLint colorSpace = EGL_UNKNOWN;
+ std::vector<EGLint> strippedAttribList;
+ if (!processAttributes(dp, nullptr, attrib_list, &colorSpace, &strippedAttribList)) {
+ ALOGE("error invalid colorspace: %d", colorSpace);
+ return EGL_NO_SURFACE;
}
- return EGL_NO_SURFACE;
+ attrib_list = strippedAttribList.data();
+
+ EGLSurface surface = cnx->egl.eglCreatePbufferSurface(iDpy, config, attrib_list);
+ if (surface == EGL_NO_SURFACE) return surface;
+
+ return new egl_surface_t(dp, config, nullptr, surface, getReportedColorSpace(colorSpace), cnx);
}
EGLBoolean eglDestroySurfaceImpl(EGLDisplay dpy, EGLSurface surface) {
@@ -931,9 +885,8 @@
// Contexts
// ----------------------------------------------------------------------------
-EGLContext eglCreateContextImpl(EGLDisplay dpy, EGLConfig config,
- EGLContext share_list, const EGLint *attrib_list)
-{
+EGLContext eglCreateContextImpl(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
+ const EGLint* attrib_list) {
egl_connection_t* cnx = nullptr;
const egl_display_t* dp = validate_display_connection(dpy, &cnx);
if (dp) {
@@ -960,8 +913,8 @@
}
};
}
- EGLContext context = cnx->egl.eglCreateContext(
- dp->disp.dpy, config, share_list, attrib_list);
+ EGLContext context =
+ cnx->egl.eglCreateContext(dp->disp.dpy, config, share_list, attrib_list);
if (context != EGL_NO_CONTEXT) {
// figure out if it's a GLESv1 or GLESv2
int version = egl_connection_t::GLESv1_INDEX;
@@ -985,17 +938,14 @@
return EGL_NO_CONTEXT;
}
-EGLBoolean eglDestroyContextImpl(EGLDisplay dpy, EGLContext ctx)
-{
+EGLBoolean eglDestroyContextImpl(EGLDisplay dpy, EGLContext ctx) {
const egl_display_t* dp = validate_display(dpy);
- if (!dp)
- return EGL_FALSE;
+ if (!dp) return EGL_FALSE;
ContextRef _c(dp, ctx);
- if (!_c.get())
- return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
+ if (!_c.get()) return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
- egl_context_t * const c = get_context(ctx);
+ egl_context_t* const c = get_context(ctx);
EGLBoolean result = c->cnx->egl.eglDestroyContext(dp->disp.dpy, c->context);
if (result == EGL_TRUE) {
_c.terminate();
@@ -1003,17 +953,14 @@
return result;
}
-EGLBoolean eglMakeCurrentImpl( EGLDisplay dpy, EGLSurface draw,
- EGLSurface read, EGLContext ctx)
-{
+EGLBoolean eglMakeCurrentImpl(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
egl_display_t* dp = validate_display(dpy);
if (!dp) return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
// If ctx is not EGL_NO_CONTEXT, read is not EGL_NO_SURFACE, or draw is not
// EGL_NO_SURFACE, then an EGL_NOT_INITIALIZED error is generated if dpy is
// a valid but uninitialized display.
- if ( (ctx != EGL_NO_CONTEXT) || (read != EGL_NO_SURFACE) ||
- (draw != EGL_NO_SURFACE) ) {
+ if ((ctx != EGL_NO_CONTEXT) || (read != EGL_NO_SURFACE) || (draw != EGL_NO_SURFACE)) {
if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE);
}
@@ -1029,17 +976,17 @@
}
// these are the underlying implementation's object
- EGLContext impl_ctx = EGL_NO_CONTEXT;
+ EGLContext impl_ctx = EGL_NO_CONTEXT;
EGLSurface impl_draw = EGL_NO_SURFACE;
EGLSurface impl_read = EGL_NO_SURFACE;
// these are our objects structs passed in
- egl_context_t * c = nullptr;
- egl_surface_t const * d = nullptr;
- egl_surface_t const * r = nullptr;
+ egl_context_t* c = nullptr;
+ egl_surface_t const* d = nullptr;
+ egl_surface_t const* r = nullptr;
// these are the current objects structs
- egl_context_t * cur_c = get_context(getContext());
+ egl_context_t* cur_c = get_context(getContext());
if (ctx != EGL_NO_CONTEXT) {
c = get_context(ctx);
@@ -1071,10 +1018,7 @@
impl_read = r->surface;
}
-
- EGLBoolean result = dp->makeCurrent(c, cur_c,
- draw, read, ctx,
- impl_draw, impl_read, impl_ctx);
+ EGLBoolean result = dp->makeCurrent(c, cur_c, draw, read, ctx, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
if (c) {
@@ -1095,81 +1039,72 @@
return result;
}
-EGLBoolean eglQueryContextImpl( EGLDisplay dpy, EGLContext ctx,
- EGLint attribute, EGLint *value)
-{
+EGLBoolean eglQueryContextImpl(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
ContextRef _c(dp, ctx);
if (!_c.get()) return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
- egl_context_t * const c = get_context(ctx);
- return c->cnx->egl.eglQueryContext(
- dp->disp.dpy, c->context, attribute, value);
-
+ egl_context_t* const c = get_context(ctx);
+ return c->cnx->egl.eglQueryContext(dp->disp.dpy, c->context, attribute, value);
}
-EGLContext eglGetCurrentContextImpl(void)
-{
+EGLContext eglGetCurrentContextImpl(void) {
// could be called before eglInitialize(), but we wouldn't have a context
// then, and this function would correctly return EGL_NO_CONTEXT.
EGLContext ctx = getContext();
return ctx;
}
-EGLSurface eglGetCurrentSurfaceImpl(EGLint readdraw)
-{
+EGLSurface eglGetCurrentSurfaceImpl(EGLint readdraw) {
// could be called before eglInitialize(), but we wouldn't have a context
// then, and this function would correctly return EGL_NO_SURFACE.
EGLContext ctx = getContext();
if (ctx) {
- egl_context_t const * const c = get_context(ctx);
+ egl_context_t const* const c = get_context(ctx);
if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE);
switch (readdraw) {
- case EGL_READ: return c->read;
- case EGL_DRAW: return c->draw;
- default: return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+ case EGL_READ:
+ return c->read;
+ case EGL_DRAW:
+ return c->draw;
+ default:
+ return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
}
}
return EGL_NO_SURFACE;
}
-EGLDisplay eglGetCurrentDisplayImpl(void)
-{
+EGLDisplay eglGetCurrentDisplayImpl(void) {
// could be called before eglInitialize(), but we wouldn't have a context
// then, and this function would correctly return EGL_NO_DISPLAY.
EGLContext ctx = getContext();
if (ctx) {
- egl_context_t const * const c = get_context(ctx);
+ egl_context_t const* const c = get_context(ctx);
if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE);
return c->dpy;
}
return EGL_NO_DISPLAY;
}
-EGLBoolean eglWaitGLImpl(void)
-{
+EGLBoolean eglWaitGLImpl(void) {
egl_connection_t* const cnx = &gEGLImpl;
- if (!cnx->dso)
- return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
+ if (!cnx->dso) return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
return cnx->egl.eglWaitGL();
}
-EGLBoolean eglWaitNativeImpl(EGLint engine)
-{
+EGLBoolean eglWaitNativeImpl(EGLint engine) {
egl_connection_t* const cnx = &gEGLImpl;
- if (!cnx->dso)
- return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
+ if (!cnx->dso) return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
return cnx->egl.eglWaitNative(engine);
}
-EGLint eglGetErrorImpl(void)
-{
+EGLint eglGetErrorImpl(void) {
EGLint err = EGL_SUCCESS;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso) {
@@ -1181,8 +1116,7 @@
return err;
}
-static __eglMustCastToProperFunctionPointerType findBuiltinWrapper(
- const char* procname) {
+static __eglMustCastToProperFunctionPointerType findBuiltinWrapper(const char* procname) {
const egl_connection_t* cnx = &gEGLImpl;
void* proc = nullptr;
@@ -1198,8 +1132,7 @@
return nullptr;
}
-__eglMustCastToProperFunctionPointerType eglGetProcAddressImpl(const char *procname)
-{
+__eglMustCastToProperFunctionPointerType eglGetProcAddressImpl(const char* procname) {
if (FILTER_EXTENSIONS(procname)) {
return nullptr;
}
@@ -1246,13 +1179,10 @@
// Ensure we have room to track it
const int slot = sGLExtensionSlot;
if (slot < MAX_NUMBER_OF_GL_EXTENSIONS) {
-
if (cnx->dso && cnx->egl.eglGetProcAddress) {
-
// Extensions are independent of the bound context
addr = cnx->egl.eglGetProcAddress(procname);
if (addr) {
-
// purposefully track the bottom of the stack in extensionMap
extensionMap[name] = addr;
@@ -1261,7 +1191,7 @@
// Track the top most entry point return the extension forwarder
cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] =
- cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = addr;
+ cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = addr;
addr = gExtensionForwarders[slot];
// Remember the slot for this extension
@@ -1293,7 +1223,7 @@
// Track the top most entry point and return the extension forwarder
cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[ext_slot] =
- cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[ext_slot] = addr;
+ cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[ext_slot] = addr;
addr = gExtensionForwarders[ext_slot];
}
@@ -1303,7 +1233,6 @@
class FrameCompletionThread {
public:
-
static void queueSync(EGLSyncKHR sync) {
static FrameCompletionThread thread;
@@ -1320,7 +1249,6 @@
}
private:
-
FrameCompletionThread() : mFramesQueued(0), mFramesCompleted(0) {
std::thread thread(&FrameCompletionThread::loop, this);
thread.detach();
@@ -1375,15 +1303,13 @@
std::mutex mMutex;
};
-EGLBoolean eglSwapBuffersWithDamageKHRImpl(EGLDisplay dpy, EGLSurface draw,
- EGLint *rects, EGLint n_rects)
-{
+EGLBoolean eglSwapBuffersWithDamageKHRImpl(EGLDisplay dpy, EGLSurface draw, EGLint* rects,
+ EGLint n_rects) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, draw);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
if (n_rects < 0 || (n_rects > 0 && rects == NULL))
return setError(EGL_BAD_PARAMETER, (EGLBoolean)EGL_FALSE);
@@ -1399,11 +1325,11 @@
if (CC_UNLIKELY(dp->finishOnSwap)) {
uint32_t pixel;
- egl_context_t * const c = get_context( egl_tls_t::getContext() );
+ egl_context_t* const c = get_context(egl_tls_t::getContext());
if (c) {
// glReadPixels() ensures that the frame is complete
- s->cnx->hooks[c->version]->gl.glReadPixels(0,0,1,1,
- GL_RGBA,GL_UNSIGNED_BYTE,&pixel);
+ s->cnx->hooks[c->version]->gl.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
+ &pixel);
}
}
@@ -1438,41 +1364,35 @@
}
if (s->cnx->egl.eglSwapBuffersWithDamageKHR) {
- return s->cnx->egl.eglSwapBuffersWithDamageKHR(dp->disp.dpy, s->surface,
- rects, n_rects);
- } else {
- return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
+ return s->cnx->egl.eglSwapBuffersWithDamageKHR(dp->disp.dpy, s->surface, rects, n_rects);
}
+
+ return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
}
-EGLBoolean eglSwapBuffersImpl(EGLDisplay dpy, EGLSurface surface)
-{
+EGLBoolean eglSwapBuffersImpl(EGLDisplay dpy, EGLSurface surface) {
return eglSwapBuffersWithDamageKHRImpl(dpy, surface, nullptr, 0);
}
-EGLBoolean eglCopyBuffersImpl( EGLDisplay dpy, EGLSurface surface,
- NativePixmapType target)
-{
+EGLBoolean eglCopyBuffersImpl(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, surface);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
return s->cnx->egl.eglCopyBuffers(dp->disp.dpy, s->surface, target);
}
-const char* eglQueryStringImpl(EGLDisplay dpy, EGLint name)
-{
+const char* eglQueryStringImpl(EGLDisplay dpy, EGLint name) {
if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) {
// Return list of client extensions
return gClientExtensionString;
}
const egl_display_t* dp = validate_display(dpy);
- if (!dp) return (const char *) nullptr;
+ if (!dp) return (const char*)nullptr;
switch (name) {
case EGL_VENDOR:
@@ -1486,13 +1406,12 @@
default:
break;
}
- return setError(EGL_BAD_PARAMETER, (const char *)nullptr);
+ return setError(EGL_BAD_PARAMETER, (const char*)nullptr);
}
-EGLAPI const char* eglQueryStringImplementationANDROIDImpl(EGLDisplay dpy, EGLint name)
-{
+EGLAPI const char* eglQueryStringImplementationANDROIDImpl(EGLDisplay dpy, EGLint name) {
const egl_display_t* dp = validate_display(dpy);
- if (!dp) return (const char *) nullptr;
+ if (!dp) return (const char*)nullptr;
switch (name) {
case EGL_VENDOR:
@@ -1506,24 +1425,22 @@
default:
break;
}
- return setError(EGL_BAD_PARAMETER, (const char *)nullptr);
+ return setError(EGL_BAD_PARAMETER, (const char*)nullptr);
}
// ----------------------------------------------------------------------------
// EGL 1.1
// ----------------------------------------------------------------------------
-EGLBoolean eglSurfaceAttribImpl(
- EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
-{
+EGLBoolean eglSurfaceAttribImpl(EGLDisplay dpy, EGLSurface surface, EGLint attribute,
+ EGLint value) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, surface);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- egl_surface_t * const s = get_surface(surface);
+ egl_surface_t* const s = get_surface(surface);
if (attribute == EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID) {
if (!s->getNativeWindow()) {
@@ -1546,50 +1463,40 @@
} else if (s->setCta8613Attribute(attribute, value)) {
return EGL_TRUE;
} else if (s->cnx->egl.eglSurfaceAttrib) {
- return s->cnx->egl.eglSurfaceAttrib(
- dp->disp.dpy, s->surface, attribute, value);
+ return s->cnx->egl.eglSurfaceAttrib(dp->disp.dpy, s->surface, attribute, value);
}
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
-EGLBoolean eglBindTexImageImpl(
- EGLDisplay dpy, EGLSurface surface, EGLint buffer)
-{
+EGLBoolean eglBindTexImageImpl(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, surface);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (s->cnx->egl.eglBindTexImage) {
- return s->cnx->egl.eglBindTexImage(
- dp->disp.dpy, s->surface, buffer);
+ return s->cnx->egl.eglBindTexImage(dp->disp.dpy, s->surface, buffer);
}
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
-EGLBoolean eglReleaseTexImageImpl(
- EGLDisplay dpy, EGLSurface surface, EGLint buffer)
-{
+EGLBoolean eglReleaseTexImageImpl(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, surface);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (s->cnx->egl.eglReleaseTexImage) {
- return s->cnx->egl.eglReleaseTexImage(
- dp->disp.dpy, s->surface, buffer);
+ return s->cnx->egl.eglReleaseTexImage(dp->disp.dpy, s->surface, buffer);
}
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
-EGLBoolean eglSwapIntervalImpl(EGLDisplay dpy, EGLint interval)
-{
+EGLBoolean eglSwapIntervalImpl(EGLDisplay dpy, EGLint interval) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
@@ -1602,16 +1509,13 @@
return res;
}
-
// ----------------------------------------------------------------------------
// EGL 1.2
// ----------------------------------------------------------------------------
-EGLBoolean eglWaitClientImpl(void)
-{
+EGLBoolean eglWaitClientImpl(void) {
egl_connection_t* const cnx = &gEGLImpl;
- if (!cnx->dso)
- return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
+ if (!cnx->dso) return setError(EGL_BAD_CONTEXT, (EGLBoolean)EGL_FALSE);
EGLBoolean res;
if (cnx->egl.eglWaitClient) {
@@ -1622,8 +1526,7 @@
return res;
}
-EGLBoolean eglBindAPIImpl(EGLenum api)
-{
+EGLBoolean eglBindAPIImpl(EGLenum api) {
// bind this API on all EGLs
EGLBoolean res = EGL_TRUE;
egl_connection_t* const cnx = &gEGLImpl;
@@ -1633,8 +1536,7 @@
return res;
}
-EGLenum eglQueryAPIImpl(void)
-{
+EGLenum eglQueryAPIImpl(void) {
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglQueryAPI) {
return cnx->egl.eglQueryAPI();
@@ -1644,8 +1546,7 @@
return EGL_OPENGL_ES_API;
}
-EGLBoolean eglReleaseThreadImpl(void)
-{
+EGLBoolean eglReleaseThreadImpl(void) {
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglReleaseThread) {
cnx->egl.eglReleaseThread();
@@ -1658,16 +1559,15 @@
return EGL_TRUE;
}
-EGLSurface eglCreatePbufferFromClientBufferImpl(
- EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
- EGLConfig config, const EGLint *attrib_list)
-{
+EGLSurface eglCreatePbufferFromClientBufferImpl(EGLDisplay dpy, EGLenum buftype,
+ EGLClientBuffer buffer, EGLConfig config,
+ const EGLint* attrib_list) {
egl_connection_t* cnx = nullptr;
const egl_display_t* dp = validate_display_connection(dpy, &cnx);
if (!dp) return EGL_FALSE;
if (cnx->egl.eglCreatePbufferFromClientBuffer) {
- return cnx->egl.eglCreatePbufferFromClientBuffer(
- dp->disp.dpy, buftype, buffer, config, attrib_list);
+ return cnx->egl.eglCreatePbufferFromClientBuffer(dp->disp.dpy, buftype, buffer, config,
+ attrib_list);
}
return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE);
}
@@ -1676,34 +1576,28 @@
// EGL_EGLEXT_VERSION 3
// ----------------------------------------------------------------------------
-EGLBoolean eglLockSurfaceKHRImpl(EGLDisplay dpy, EGLSurface surface,
- const EGLint *attrib_list)
-{
+EGLBoolean eglLockSurfaceKHRImpl(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, surface);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (s->cnx->egl.eglLockSurfaceKHR) {
- return s->cnx->egl.eglLockSurfaceKHR(
- dp->disp.dpy, s->surface, attrib_list);
+ return s->cnx->egl.eglLockSurfaceKHR(dp->disp.dpy, s->surface, attrib_list);
}
return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
}
-EGLBoolean eglUnlockSurfaceKHRImpl(EGLDisplay dpy, EGLSurface surface)
-{
+EGLBoolean eglUnlockSurfaceKHRImpl(EGLDisplay dpy, EGLSurface surface) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SurfaceRef _s(dp, surface);
- if (!_s.get())
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (s->cnx->egl.eglUnlockSurfaceKHR) {
return s->cnx->egl.eglUnlockSurfaceKHR(dp->disp.dpy, s->surface);
}
@@ -1725,7 +1619,7 @@
// EGL_GL_COLORSPACE_LINEAR_KHR, EGL_GL_COLORSPACE_SRGB_KHR and
// EGL_GL_COLORSPACE_DEFAULT_EXT if EGL_EXT_image_gl_colorspace is supported,
// but some drivers don't like the DEFAULT value and generate an error.
- for (const AttrType *attr = attrib_list; attr && attr[0] != EGL_NONE; attr += 2) {
+ for (const AttrType* attr = attrib_list; attr && attr[0] != EGL_NONE; attr += 2) {
if (attr[0] == EGL_GL_COLORSPACE_KHR &&
dp->haveExtension("EGL_EXT_image_gl_colorspace")) {
if (attr[1] != EGL_GL_COLORSPACE_LINEAR_KHR &&
@@ -1746,7 +1640,8 @@
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && eglCreateImageFunc) {
result = eglCreateImageFunc(dp->disp.dpy, c ? c->context : EGL_NO_CONTEXT, target, buffer,
- needsAndroidPEglMitigation() ? strippedAttribs.data() : attrib_list);
+ needsAndroidPEglMitigation() ? strippedAttribs.data()
+ : attrib_list);
}
return result;
}
@@ -1980,104 +1875,91 @@
.eglGetSyncAttribKHR);
}
-EGLStreamKHR eglCreateStreamKHRImpl(EGLDisplay dpy, const EGLint *attrib_list)
-{
+EGLStreamKHR eglCreateStreamKHRImpl(EGLDisplay dpy, const EGLint* attrib_list) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_NO_STREAM_KHR;
EGLStreamKHR result = EGL_NO_STREAM_KHR;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglCreateStreamKHR) {
- result = cnx->egl.eglCreateStreamKHR(
- dp->disp.dpy, attrib_list);
+ result = cnx->egl.eglCreateStreamKHR(dp->disp.dpy, attrib_list);
}
return result;
}
-EGLBoolean eglDestroyStreamKHRImpl(EGLDisplay dpy, EGLStreamKHR stream)
-{
+EGLBoolean eglDestroyStreamKHRImpl(EGLDisplay dpy, EGLStreamKHR stream) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglDestroyStreamKHR) {
- result = cnx->egl.eglDestroyStreamKHR(
- dp->disp.dpy, stream);
+ result = cnx->egl.eglDestroyStreamKHR(dp->disp.dpy, stream);
}
return result;
}
-EGLBoolean eglStreamAttribKHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
- EGLenum attribute, EGLint value)
-{
+EGLBoolean eglStreamAttribKHRImpl(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute,
+ EGLint value) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglStreamAttribKHR) {
- result = cnx->egl.eglStreamAttribKHR(
- dp->disp.dpy, stream, attribute, value);
+ result = cnx->egl.eglStreamAttribKHR(dp->disp.dpy, stream, attribute, value);
}
return result;
}
-EGLBoolean eglQueryStreamKHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
- EGLenum attribute, EGLint *value)
-{
+EGLBoolean eglQueryStreamKHRImpl(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute,
+ EGLint* value) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglQueryStreamKHR) {
- result = cnx->egl.eglQueryStreamKHR(
- dp->disp.dpy, stream, attribute, value);
+ result = cnx->egl.eglQueryStreamKHR(dp->disp.dpy, stream, attribute, value);
}
return result;
}
-EGLBoolean eglQueryStreamu64KHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
- EGLenum attribute, EGLuint64KHR *value)
-{
+EGLBoolean eglQueryStreamu64KHRImpl(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute,
+ EGLuint64KHR* value) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglQueryStreamu64KHR) {
- result = cnx->egl.eglQueryStreamu64KHR(
- dp->disp.dpy, stream, attribute, value);
+ result = cnx->egl.eglQueryStreamu64KHR(dp->disp.dpy, stream, attribute, value);
}
return result;
}
-EGLBoolean eglQueryStreamTimeKHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
- EGLenum attribute, EGLTimeKHR *value)
-{
+EGLBoolean eglQueryStreamTimeKHRImpl(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute,
+ EGLTimeKHR* value) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglQueryStreamTimeKHR) {
- result = cnx->egl.eglQueryStreamTimeKHR(
- dp->disp.dpy, stream, attribute, value);
+ result = cnx->egl.eglQueryStreamTimeKHR(dp->disp.dpy, stream, attribute, value);
}
return result;
}
EGLSurface eglCreateStreamProducerSurfaceKHRImpl(EGLDisplay dpy, EGLConfig config,
- EGLStreamKHR stream, const EGLint *attrib_list)
-{
+ EGLStreamKHR stream, const EGLint* attrib_list) {
egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_NO_SURFACE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglCreateStreamProducerSurfaceKHR) {
- EGLSurface surface = cnx->egl.eglCreateStreamProducerSurfaceKHR(
- dp->disp.dpy, config, stream, attrib_list);
+ EGLSurface surface = cnx->egl.eglCreateStreamProducerSurfaceKHR(dp->disp.dpy, config,
+ stream, attrib_list);
if (surface != EGL_NO_SURFACE) {
egl_surface_t* s = new egl_surface_t(dp, config, nullptr, surface,
EGL_GL_COLORSPACE_LINEAR_KHR, cnx);
@@ -2087,77 +1969,63 @@
return EGL_NO_SURFACE;
}
-EGLBoolean eglStreamConsumerGLTextureExternalKHRImpl(EGLDisplay dpy,
- EGLStreamKHR stream)
-{
+EGLBoolean eglStreamConsumerGLTextureExternalKHRImpl(EGLDisplay dpy, EGLStreamKHR stream) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglStreamConsumerGLTextureExternalKHR) {
- result = cnx->egl.eglStreamConsumerGLTextureExternalKHR(
- dp->disp.dpy, stream);
+ result = cnx->egl.eglStreamConsumerGLTextureExternalKHR(dp->disp.dpy, stream);
}
return result;
}
-EGLBoolean eglStreamConsumerAcquireKHRImpl(EGLDisplay dpy,
- EGLStreamKHR stream)
-{
+EGLBoolean eglStreamConsumerAcquireKHRImpl(EGLDisplay dpy, EGLStreamKHR stream) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglStreamConsumerAcquireKHR) {
- result = cnx->egl.eglStreamConsumerAcquireKHR(
- dp->disp.dpy, stream);
+ result = cnx->egl.eglStreamConsumerAcquireKHR(dp->disp.dpy, stream);
}
return result;
}
-EGLBoolean eglStreamConsumerReleaseKHRImpl(EGLDisplay dpy,
- EGLStreamKHR stream)
-{
+EGLBoolean eglStreamConsumerReleaseKHRImpl(EGLDisplay dpy, EGLStreamKHR stream) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglStreamConsumerReleaseKHR) {
- result = cnx->egl.eglStreamConsumerReleaseKHR(
- dp->disp.dpy, stream);
+ result = cnx->egl.eglStreamConsumerReleaseKHR(dp->disp.dpy, stream);
}
return result;
}
-EGLNativeFileDescriptorKHR eglGetStreamFileDescriptorKHRImpl(
- EGLDisplay dpy, EGLStreamKHR stream)
-{
+EGLNativeFileDescriptorKHR eglGetStreamFileDescriptorKHRImpl(EGLDisplay dpy, EGLStreamKHR stream) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_NO_FILE_DESCRIPTOR_KHR;
EGLNativeFileDescriptorKHR result = EGL_NO_FILE_DESCRIPTOR_KHR;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglGetStreamFileDescriptorKHR) {
- result = cnx->egl.eglGetStreamFileDescriptorKHR(
- dp->disp.dpy, stream);
+ result = cnx->egl.eglGetStreamFileDescriptorKHR(dpy, stream);
}
return result;
}
-EGLStreamKHR eglCreateStreamFromFileDescriptorKHRImpl(
- EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor)
-{
+EGLStreamKHR eglCreateStreamFromFileDescriptorKHRImpl(EGLDisplay dpy,
+ EGLNativeFileDescriptorKHR file_descriptor) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_NO_STREAM_KHR;
EGLStreamKHR result = EGL_NO_STREAM_KHR;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglCreateStreamFromFileDescriptorKHR) {
- result = cnx->egl.eglCreateStreamFromFileDescriptorKHR(
- dp->disp.dpy, file_descriptor);
+ result = cnx->egl.eglCreateStreamFromFileDescriptorKHR(dp->disp.dpy, file_descriptor);
}
return result;
}
@@ -2207,8 +2075,7 @@
// ANDROID extensions
// ----------------------------------------------------------------------------
-EGLint eglDupNativeFenceFDANDROIDImpl(EGLDisplay dpy, EGLSyncKHR sync)
-{
+EGLint eglDupNativeFenceFDANDROIDImpl(EGLDisplay dpy, EGLSyncKHR sync) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) return EGL_NO_NATIVE_FENCE_FD_ANDROID;
@@ -2221,8 +2088,7 @@
}
EGLBoolean eglPresentationTimeANDROIDImpl(EGLDisplay dpy, EGLSurface surface,
- EGLnsecsANDROID time)
-{
+ EGLnsecsANDROID time) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
return EGL_FALSE;
@@ -2234,22 +2100,21 @@
return EGL_FALSE;
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
native_window_set_buffers_timestamp(s->getNativeWindow(), time);
return EGL_TRUE;
}
-EGLClientBuffer eglGetNativeClientBufferANDROIDImpl(const AHardwareBuffer *buffer) {
+EGLClientBuffer eglGetNativeClientBufferANDROIDImpl(const AHardwareBuffer* buffer) {
if (!buffer) return setError(EGL_BAD_PARAMETER, (EGLClientBuffer) nullptr);
- return const_cast<ANativeWindowBuffer *>(AHardwareBuffer_to_ANativeWindowBuffer(buffer));
+ return const_cast<ANativeWindowBuffer*>(AHardwareBuffer_to_ANativeWindowBuffer(buffer));
}
// ----------------------------------------------------------------------------
// NVIDIA extensions
// ----------------------------------------------------------------------------
-EGLuint64NV eglGetSystemTimeFrequencyNVImpl()
-{
+EGLuint64NV eglGetSystemTimeFrequencyNVImpl() {
EGLuint64NV ret = 0;
egl_connection_t* const cnx = &gEGLImpl;
@@ -2260,8 +2125,7 @@
return setErrorQuiet(EGL_BAD_DISPLAY, (EGLuint64NV)0);
}
-EGLuint64NV eglGetSystemTimeNVImpl()
-{
+EGLuint64NV eglGetSystemTimeNVImpl() {
EGLuint64NV ret = 0;
egl_connection_t* const cnx = &gEGLImpl;
@@ -2275,9 +2139,8 @@
// ----------------------------------------------------------------------------
// Partial update extension
// ----------------------------------------------------------------------------
-EGLBoolean eglSetDamageRegionKHRImpl(EGLDisplay dpy, EGLSurface surface,
- EGLint *rects, EGLint n_rects)
-{
+EGLBoolean eglSetDamageRegionKHRImpl(EGLDisplay dpy, EGLSurface surface, EGLint* rects,
+ EGLint n_rects) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -2290,17 +2153,15 @@
return EGL_FALSE;
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (s->cnx->egl.eglSetDamageRegionKHR) {
- return s->cnx->egl.eglSetDamageRegionKHR(dp->disp.dpy, s->surface,
- rects, n_rects);
+ return s->cnx->egl.eglSetDamageRegionKHR(dp->disp.dpy, s->surface, rects, n_rects);
}
return EGL_FALSE;
}
-EGLBoolean eglGetNextFrameIdANDROIDImpl(EGLDisplay dpy, EGLSurface surface,
- EGLuint64KHR *frameId) {
+EGLBoolean eglGetNextFrameIdANDROIDImpl(EGLDisplay dpy, EGLSurface surface, EGLuint64KHR* frameId) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
@@ -2311,7 +2172,7 @@
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (!s->getNativeWindow()) {
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
@@ -2332,8 +2193,8 @@
}
EGLBoolean eglGetCompositorTimingANDROIDImpl(EGLDisplay dpy, EGLSurface surface,
- EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values)
-{
+ EGLint numTimestamps, const EGLint* names,
+ EGLnsecsANDROID* values) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
@@ -2344,7 +2205,7 @@
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (!s->getNativeWindow()) {
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
@@ -2370,25 +2231,24 @@
}
}
- int ret = native_window_get_compositor_timing(s->getNativeWindow(),
- compositeDeadline, compositeInterval, compositeToPresentLatency);
+ int ret = native_window_get_compositor_timing(s->getNativeWindow(), compositeDeadline,
+ compositeInterval, compositeToPresentLatency);
switch (ret) {
- case 0:
- return EGL_TRUE;
- case -ENOSYS:
- return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
- default:
- // This should not happen. Return an error that is not in the spec
- // so it's obvious something is very wrong.
- ALOGE("eglGetCompositorTiming: Unexpected error.");
- return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE);
+ case 0:
+ return EGL_TRUE;
+ case -ENOSYS:
+ return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
+ default:
+ // This should not happen. Return an error that is not in the spec
+ // so it's obvious something is very wrong.
+ ALOGE("eglGetCompositorTiming: Unexpected error.");
+ return setError(EGL_NOT_INITIALIZED, (EGLBoolean)EGL_FALSE);
}
}
-EGLBoolean eglGetCompositorTimingSupportedANDROIDImpl(
- EGLDisplay dpy, EGLSurface surface, EGLint name)
-{
+EGLBoolean eglGetCompositorTimingSupportedANDROIDImpl(EGLDisplay dpy, EGLSurface surface,
+ EGLint name) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
@@ -2399,7 +2259,7 @@
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
ANativeWindow* window = s->getNativeWindow();
if (!window) {
@@ -2417,9 +2277,8 @@
}
EGLBoolean eglGetFrameTimestampsANDROIDImpl(EGLDisplay dpy, EGLSurface surface,
- EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps,
- EGLnsecsANDROID *values)
-{
+ EGLuint64KHR frameId, EGLint numTimestamps,
+ const EGLint* timestamps, EGLnsecsANDROID* values) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
@@ -2430,7 +2289,7 @@
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
if (!s->getNativeWindow()) {
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
@@ -2480,10 +2339,11 @@
}
}
- int ret = native_window_get_frame_timestamps(s->getNativeWindow(), frameId,
- requestedPresentTime, acquireTime, latchTime, firstRefreshStartTime,
- lastRefreshStartTime, gpuCompositionDoneTime, displayPresentTime,
- dequeueReadyTime, releaseTime);
+ int ret =
+ native_window_get_frame_timestamps(s->getNativeWindow(), frameId, requestedPresentTime,
+ acquireTime, latchTime, firstRefreshStartTime,
+ lastRefreshStartTime, gpuCompositionDoneTime,
+ displayPresentTime, dequeueReadyTime, releaseTime);
switch (ret) {
case 0:
@@ -2502,9 +2362,8 @@
}
}
-EGLBoolean eglGetFrameTimestampSupportedANDROIDImpl(
- EGLDisplay dpy, EGLSurface surface, EGLint timestamp)
-{
+EGLBoolean eglGetFrameTimestampSupportedANDROIDImpl(EGLDisplay dpy, EGLSurface surface,
+ EGLint timestamp) {
const egl_display_t* dp = validate_display(dpy);
if (!dp) {
return setError(EGL_BAD_DISPLAY, (EGLBoolean)EGL_FALSE);
@@ -2515,7 +2374,7 @@
return setError(EGL_BAD_SURFACE, (EGLBoolean)EGL_FALSE);
}
- egl_surface_t const * const s = get_surface(surface);
+ egl_surface_t const* const s = get_surface(surface);
ANativeWindow* window = s->getNativeWindow();
if (!window) {
@@ -2537,8 +2396,7 @@
return EGL_TRUE;
case EGL_DISPLAY_PRESENT_TIME_ANDROID: {
int value = 0;
- window->query(window,
- NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT, &value);
+ window->query(window, NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT, &value);
return value == 0 ? EGL_FALSE : EGL_TRUE;
}
default:
@@ -2546,25 +2404,25 @@
}
}
-const GLubyte * glGetStringImpl(GLenum name) {
- const GLubyte * ret = egl_get_string_for_current_context(name);
+const GLubyte* glGetStringImpl(GLenum name) {
+ const GLubyte* ret = egl_get_string_for_current_context(name);
if (ret == NULL) {
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
- if(_c) ret = _c->glGetString(name);
+ gl_hooks_t::gl_t const* const _c = &getGlThreadSpecific()->gl;
+ if (_c) ret = _c->glGetString(name);
}
return ret;
}
-const GLubyte * glGetStringiImpl(GLenum name, GLuint index) {
- const GLubyte * ret = egl_get_string_for_current_context(name, index);
+const GLubyte* glGetStringiImpl(GLenum name, GLuint index) {
+ const GLubyte* ret = egl_get_string_for_current_context(name, index);
if (ret == NULL) {
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
- if(_c) ret = _c->glGetStringi(name, index);
+ gl_hooks_t::gl_t const* const _c = &getGlThreadSpecific()->gl;
+ if (_c) ret = _c->glGetStringi(name, index);
}
return ret;
}
-void glGetBooleanvImpl(GLenum pname, GLboolean * data) {
+void glGetBooleanvImpl(GLenum pname, GLboolean* data) {
if (pname == GL_NUM_EXTENSIONS) {
int num_exts = egl_get_num_extensions_for_current_context();
if (num_exts >= 0) {
@@ -2573,11 +2431,11 @@
}
}
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+ gl_hooks_t::gl_t const* const _c = &getGlThreadSpecific()->gl;
if (_c) _c->glGetBooleanv(pname, data);
}
-void glGetFloatvImpl(GLenum pname, GLfloat * data) {
+void glGetFloatvImpl(GLenum pname, GLfloat* data) {
if (pname == GL_NUM_EXTENSIONS) {
int num_exts = egl_get_num_extensions_for_current_context();
if (num_exts >= 0) {
@@ -2586,11 +2444,11 @@
}
}
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+ gl_hooks_t::gl_t const* const _c = &getGlThreadSpecific()->gl;
if (_c) _c->glGetFloatv(pname, data);
}
-void glGetIntegervImpl(GLenum pname, GLint * data) {
+void glGetIntegervImpl(GLenum pname, GLint* data) {
if (pname == GL_NUM_EXTENSIONS) {
int num_exts = egl_get_num_extensions_for_current_context();
if (num_exts >= 0) {
@@ -2599,11 +2457,11 @@
}
}
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+ gl_hooks_t::gl_t const* const _c = &getGlThreadSpecific()->gl;
if (_c) _c->glGetIntegerv(pname, data);
}
-void glGetInteger64vImpl(GLenum pname, GLint64 * data) {
+void glGetInteger64vImpl(GLenum pname, GLint64* data) {
if (pname == GL_NUM_EXTENSIONS) {
int num_exts = egl_get_num_extensions_for_current_context();
if (num_exts >= 0) {
@@ -2612,7 +2470,7 @@
}
}
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+ gl_hooks_t::gl_t const* const _c = &getGlThreadSpecific()->gl;
if (_c) _c->glGetInteger64v(pname, data);
}
@@ -2621,8 +2479,8 @@
EGLFuncPointer address;
};
+// clang-format off
static const implementation_map_t sPlatformImplMap[] = {
- // clang-format off
{ "eglGetDisplay", (EGLFuncPointer)&eglGetDisplayImpl },
{ "eglGetPlatformDisplay", (EGLFuncPointer)&eglGetPlatformDisplayImpl },
{ "eglInitialize", (EGLFuncPointer)&eglInitializeImpl },
@@ -2709,11 +2567,10 @@
{ "glGetFloatv", (EGLFuncPointer)&glGetFloatvImpl },
{ "glGetIntegerv", (EGLFuncPointer)&glGetIntegervImpl },
{ "glGetInteger64v", (EGLFuncPointer)&glGetInteger64vImpl },
- // clang-format on
};
+// clang-format on
-EGLFuncPointer FindPlatformImplAddr(const char* name)
-{
+EGLFuncPointer FindPlatformImplAddr(const char* name) {
static const bool DEBUG = false;
if (name == nullptr) {
@@ -2727,7 +2584,8 @@
return nullptr;
}
if (!strcmp(name, sPlatformImplMap[i].name)) {
- ALOGV("FindPlatformImplAddr found %llu for sPlatformImplMap[%i].address (%s)", (unsigned long long)sPlatformImplMap[i].address, i, name);
+ ALOGV("FindPlatformImplAddr found %llu for sPlatformImplMap[%i].address (%s)",
+ (unsigned long long)sPlatformImplMap[i].address, i, name);
return sPlatformImplMap[i].address;
}
}
diff --git a/opengl/libs/EGL/egl_tls.cpp b/opengl/libs/EGL/egl_tls.cpp
index 8d118e0..dd1dcc2 100644
--- a/opengl/libs/EGL/egl_tls.cpp
+++ b/opengl/libs/EGL/egl_tls.cpp
@@ -16,10 +16,10 @@
#include "egl_tls.h"
-#include <stdlib.h>
-
#include <android-base/properties.h>
#include <log/log.h>
+#include <stdlib.h>
+
#include "CallStack.h"
#include "egl_platform_entries.h"
@@ -28,33 +28,46 @@
pthread_key_t egl_tls_t::sKey = TLS_KEY_NOT_INITIALIZED;
pthread_once_t egl_tls_t::sOnceKey = PTHREAD_ONCE_INIT;
-egl_tls_t::egl_tls_t()
- : error(EGL_SUCCESS), ctx(nullptr), logCallWithNoContext(true) {
-}
+egl_tls_t::egl_tls_t() : error(EGL_SUCCESS), ctx(nullptr), logCallWithNoContext(true) {}
-const char *egl_tls_t::egl_strerror(EGLint err) {
+const char* egl_tls_t::egl_strerror(EGLint err) {
switch (err) {
- case EGL_SUCCESS: return "EGL_SUCCESS";
- case EGL_NOT_INITIALIZED: return "EGL_NOT_INITIALIZED";
- case EGL_BAD_ACCESS: return "EGL_BAD_ACCESS";
- case EGL_BAD_ALLOC: return "EGL_BAD_ALLOC";
- case EGL_BAD_ATTRIBUTE: return "EGL_BAD_ATTRIBUTE";
- case EGL_BAD_CONFIG: return "EGL_BAD_CONFIG";
- case EGL_BAD_CONTEXT: return "EGL_BAD_CONTEXT";
- case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE";
- case EGL_BAD_DISPLAY: return "EGL_BAD_DISPLAY";
- case EGL_BAD_MATCH: return "EGL_BAD_MATCH";
- case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP";
- case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW";
- case EGL_BAD_PARAMETER: return "EGL_BAD_PARAMETER";
- case EGL_BAD_SURFACE: return "EGL_BAD_SURFACE";
- case EGL_CONTEXT_LOST: return "EGL_CONTEXT_LOST";
- default: return "UNKNOWN";
+ case EGL_SUCCESS:
+ return "EGL_SUCCESS";
+ case EGL_NOT_INITIALIZED:
+ return "EGL_NOT_INITIALIZED";
+ case EGL_BAD_ACCESS:
+ return "EGL_BAD_ACCESS";
+ case EGL_BAD_ALLOC:
+ return "EGL_BAD_ALLOC";
+ case EGL_BAD_ATTRIBUTE:
+ return "EGL_BAD_ATTRIBUTE";
+ case EGL_BAD_CONFIG:
+ return "EGL_BAD_CONFIG";
+ case EGL_BAD_CONTEXT:
+ return "EGL_BAD_CONTEXT";
+ case EGL_BAD_CURRENT_SURFACE:
+ return "EGL_BAD_CURRENT_SURFACE";
+ case EGL_BAD_DISPLAY:
+ return "EGL_BAD_DISPLAY";
+ case EGL_BAD_MATCH:
+ return "EGL_BAD_MATCH";
+ case EGL_BAD_NATIVE_PIXMAP:
+ return "EGL_BAD_NATIVE_PIXMAP";
+ case EGL_BAD_NATIVE_WINDOW:
+ return "EGL_BAD_NATIVE_WINDOW";
+ case EGL_BAD_PARAMETER:
+ return "EGL_BAD_PARAMETER";
+ case EGL_BAD_SURFACE:
+ return "EGL_BAD_SURFACE";
+ case EGL_CONTEXT_LOST:
+ return "EGL_CONTEXT_LOST";
+ default:
+ return "UNKNOWN";
}
}
-void egl_tls_t::validateTLSKey()
-{
+void egl_tls_t::validateTLSKey() {
struct TlsKeyInitializer {
static void create() { pthread_key_create(&sKey, destructTLSData); }
};
@@ -88,14 +101,12 @@
"EGL TLS data still exists after eglReleaseThread");
}
-void egl_tls_t::setErrorEtcImpl(
- const char* caller, int line, EGLint error, bool quiet) {
+void egl_tls_t::setErrorEtcImpl(const char* caller, int line, EGLint error, bool quiet) {
validateTLSKey();
egl_tls_t* tls = getTLS();
if (tls->error != error) {
if (!quiet) {
- ALOGE("%s:%d error %x (%s)",
- caller, line, error, egl_strerror(error));
+ ALOGE("%s:%d error %x (%s)", caller, line, error, egl_strerror(error));
if (base::GetBoolProperty("debug.egl.callstack", false)) {
CallStack::log(LOG_TAG);
}
@@ -111,7 +122,6 @@
return true;
}
return false;
-
}
egl_tls_t* egl_tls_t::getTLS() {
@@ -161,10 +171,9 @@
if (sKey == TLS_KEY_NOT_INITIALIZED) {
return EGL_NO_CONTEXT;
}
- egl_tls_t* tls = (egl_tls_t *)pthread_getspecific(sKey);
+ egl_tls_t* tls = (egl_tls_t*)pthread_getspecific(sKey);
if (!tls) return EGL_NO_CONTEXT;
return tls->ctx;
}
-
} // namespace android
diff --git a/opengl/libs/EGL/egl_tls.h b/opengl/libs/EGL/egl_tls.h
index 86a375c..b5fcc1a 100644
--- a/opengl/libs/EGL/egl_tls.h
+++ b/opengl/libs/EGL/egl_tls.h
@@ -18,12 +18,9 @@
#define ANDROID_EGL_TLS_H
#include <EGL/egl.h>
-
#include <pthread.h>
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
class DbgContext;
@@ -32,15 +29,14 @@
static pthread_key_t sKey;
static pthread_once_t sOnceKey;
- EGLint error;
- EGLContext ctx;
- bool logCallWithNoContext;
+ EGLint error;
+ EGLContext ctx;
+ bool logCallWithNoContext;
egl_tls_t();
static void validateTLSKey();
static void destructTLSData(void* data);
- static void setErrorEtcImpl(
- const char* caller, int line, EGLint error, bool quiet);
+ static void setErrorEtcImpl(const char* caller, int line, EGLint error, bool quiet);
public:
static egl_tls_t* getTLS();
@@ -50,24 +46,20 @@
static void setContext(EGLContext ctx);
static EGLContext getContext();
static bool logNoContextCall();
- static const char *egl_strerror(EGLint err);
+ static const char* egl_strerror(EGLint err);
- template<typename T>
- static T setErrorEtc(const char* caller,
- int line, EGLint error, T returnValue, bool quiet = false) {
+ template <typename T>
+ static T setErrorEtc(const char* caller, int line, EGLint error, T returnValue,
+ bool quiet = false) {
setErrorEtcImpl(caller, line, error, quiet);
return returnValue;
}
};
-#define setError(_e, _r) \
- egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
+#define setError(_e, _r) egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
-#define setErrorQuiet(_e, _r) \
- egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r, true)
+#define setErrorQuiet(_e, _r) egl_tls_t::setErrorEtc(__FUNCTION__, __LINE__, _e, _r, true)
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
#endif // ANDROID_EGL_TLS_H
diff --git a/opengl/libs/EGL/egl_trace.h b/opengl/libs/EGL/egl_trace.h
index 7664de2..ffdf676 100644
--- a/opengl/libs/EGL/egl_trace.h
+++ b/opengl/libs/EGL/egl_trace.h
@@ -18,16 +18,14 @@
#if defined(__ANDROID__)
-#include <stdint.h>
-
#include <cutils/trace.h>
+#include <stdint.h>
// See <cutils/trace.h> for more ATRACE_* macros.
// ATRACE_NAME traces from its location until the end of its enclosing scope.
-#define _PASTE(x, y) x ## y
-#define PASTE(x, y) _PASTE(x,y)
-#define ATRACE_NAME(name) android::EglScopedTrace PASTE(___tracer, __LINE__) (ATRACE_TAG, name)
+#define PASTE(x, y) x##y
+#define ATRACE_NAME(name) android::EglScopedTrace PASTE(___tracer, __LINE__)(ATRACE_TAG, name)
// ATRACE_CALL is an ATRACE_NAME that uses the current function name.
#define ATRACE_CALL() ATRACE_NAME(__FUNCTION__)
@@ -36,13 +34,9 @@
class EglScopedTrace {
public:
- inline EglScopedTrace(uint64_t tag, const char* name) : mTag(tag) {
- atrace_begin(mTag, name);
- }
+ inline EglScopedTrace(uint64_t tag, const char* name) : mTag(tag) { atrace_begin(mTag, name); }
- inline ~EglScopedTrace() {
- atrace_end(mTag);
- }
+ inline ~EglScopedTrace() { atrace_end(mTag); }
private:
uint64_t mTag;
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index 5fbffbd..fcc11f1 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -17,40 +17,32 @@
#ifndef ANDROID_EGLDEFS_H
#define ANDROID_EGLDEFS_H
+#include <log/log.h>
+
#include "../hooks.h"
#include "egl_platform_entries.h"
-#include <log/log.h>
-
#define VERSION_MAJOR 1
#define VERSION_MINOR 4
#define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
-// EGLDisplay are global, not attached to a given thread
+// EGLDisplay are global, not attached to a given thread
const unsigned int NUM_DISPLAYS = 1;
-// ----------------------------------------------------------------------------
+extern const char* const platform_names[];
-extern char const * const platform_names[];
-
-// clang-format off
struct egl_connection_t {
- enum {
- GLESv1_INDEX = 0,
- GLESv2_INDEX = 1
- };
+ enum { GLESv1_INDEX = 0, GLESv2_INDEX = 1 };
- inline egl_connection_t() : dso(nullptr),
- libEgl(nullptr),
- libGles1(nullptr),
- libGles2(nullptr),
- systemDriverUnloaded(false) {
-
- char const* const* entries = platform_names;
+ inline egl_connection_t()
+ : dso(nullptr),
+ libEgl(nullptr),
+ libGles1(nullptr),
+ libGles2(nullptr),
+ systemDriverUnloaded(false) {
+ const char* const* entries = platform_names;
EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform);
while (*entries) {
const char* name = *entries;
@@ -66,41 +58,34 @@
}
}
- void * dso;
- gl_hooks_t * hooks[2];
- EGLint major;
- EGLint minor;
- EGLint driverVersion;
- egl_t egl;
+ void* dso;
+ gl_hooks_t* hooks[2];
+ EGLint major;
+ EGLint minor;
+ EGLint driverVersion;
+ egl_t egl;
// Functions implemented or redirected by platform libraries
- platform_impl_t platform;
+ platform_impl_t platform;
- void* libEgl;
- void* libGles1;
- void* libGles2;
+ void* libEgl;
+ void* libGles1;
+ void* libGles2;
- bool systemDriverUnloaded;
- bool useAngle; // Was ANGLE successfully loaded
+ bool systemDriverUnloaded;
+ bool useAngle; // Was ANGLE successfully loaded
};
-// clang-format on
-
-// ----------------------------------------------------------------------------
extern gl_hooks_t gHooks[2];
extern gl_hooks_t gHooksNoContext;
extern pthread_key_t gGLWrapperKey;
extern "C" void gl_unimplemented();
extern "C" void gl_noop();
-
-extern char const * const gl_names[];
-extern char const * const gl_names_1[];
-extern char const * const egl_names[];
-
+extern const char* const gl_names[];
+extern const char* const gl_names_1[];
+extern const char* const egl_names[];
extern egl_connection_t gEGLImpl;
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
#endif /* ANDROID_EGLDEFS_H */
diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp
index fedc789..b3d6f74 100644
--- a/opengl/libs/EGL/getProcAddress.cpp
+++ b/opengl/libs/EGL/getProcAddress.cpp
@@ -16,15 +16,12 @@
#include <ctype.h>
#include <errno.h>
-#include <stdlib.h>
-
#include <log/log.h>
+#include <stdlib.h>
#include "egldefs.h"
-// ----------------------------------------------------------------------------
namespace android {
-// ----------------------------------------------------------------------------
#undef API_ENTRY
#undef CALL_GL_EXTENSION_API
@@ -34,6 +31,7 @@
#undef GL_EXTENSION_LIST
#undef GET_TLS
+// clang-format off
#if defined(__arm__)
#define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
@@ -239,13 +237,13 @@
name(248) name(249) name(250) name(251) name(252) name(253) name(254) name(255)
-GL_EXTENSION_LIST( GL_EXTENSION )
+GL_EXTENSION_LIST(GL_EXTENSION)
-#define GL_EXTENSION_ARRAY(_n) GL_EXTENSION_NAME(_n),
+#define GL_EXTENSION_ARRAY(_n) GL_EXTENSION_NAME(_n),
+// clang-format on
-extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS] = {
- GL_EXTENSION_LIST( GL_EXTENSION_ARRAY )
- };
+extern const __eglMustCastToProperFunctionPointerType
+ gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS] = {GL_EXTENSION_LIST(GL_EXTENSION_ARRAY)};
#undef GET_TLS
#undef GL_EXTENSION_LIST
@@ -255,7 +253,4 @@
#undef API_ENTRY
#undef CALL_GL_EXTENSION_API
-// ----------------------------------------------------------------------------
}; // namespace android
-// ----------------------------------------------------------------------------
-