Merge "Combine server tests into one test target BufferHubServer_test"
diff --git a/libs/binder/ndk/Android.bp b/libs/binder/ndk/Android.bp
index dc4e000..1b69dfd 100644
--- a/libs/binder/ndk/Android.bp
+++ b/libs/binder/ndk/Android.bp
@@ -23,6 +23,8 @@
"include_apex",
],
+ cflags: ["-Wall", "-Wextra", "-Werror"],
+
srcs: [
"ibinder.cpp",
"ibinder_jni.cpp",
diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel.h b/libs/binder/ndk/include_ndk/android/binder_parcel.h
index 866af70..2258210 100644
--- a/libs/binder/ndk/include_ndk/android/binder_parcel.h
+++ b/libs/binder/ndk/include_ndk/android/binder_parcel.h
@@ -149,7 +149,49 @@
* not required to be null-terminated. If the object at index is null, then this should be null.
*/
typedef const char* (*AParcel_stringArrayElementGetter)(const void* arrayData, size_t index,
- size_t* outLength);
+ int32_t* outLength);
+
+/**
+ * This is called to allocate an array of size 'length'. If length is -1, then a 'null' array (or
+ * equivalent) should be created.
+ *
+ * See also AParcel_readParcelableArray
+ *
+ * \param arrayData some external representation of an array
+ * \param length the length to allocate this array to
+ *
+ * \return true if allocation succeeded. If length is -1, a true return here means that a 'null'
+ * value (or equivalent) was successfully stored.
+ */
+typedef bool (*AParcel_parcelableArrayAllocator)(void* arrayData, int32_t length);
+
+/**
+ * This is called to parcel the underlying data from an arrayData object at index.
+ *
+ * See also AParcel_writeParcelableArray
+ *
+ * \param parcel parcel to write the parcelable to
+ * \param arrayData some external representation of an array of parcelables (a user-defined type).
+ * \param index the index of the value to be retrieved.
+ *
+ * \return status (usually returned from other parceling functions). STATUS_OK for success.
+ */
+typedef binder_status_t (*AParcel_writeParcelableElement)(AParcel* parcel, const void* arrayData,
+ size_t index);
+
+/**
+ * This is called to set an underlying value in an arrayData object at index.
+ *
+ * See also AParcel_readParcelableArray
+ *
+ * \param parcel parcel to read the parcelable from
+ * \param arrayData some external representation of an array of parcelables (a user-defined type).
+ * \param index the index of the value to be set.
+ *
+ * \return status (usually returned from other parceling functions). STATUS_OK for success.
+ */
+typedef binder_status_t (*AParcel_readParcelableElement)(const AParcel* parcel, void* arrayData,
+ size_t index);
// @START-PRIMITIVE-VECTOR-GETTERS
/**
@@ -497,6 +539,40 @@
AParcel_stringArrayElementAllocator elementAllocator)
__INTRODUCED_IN(29);
+/**
+ * Writes an array of parcelables (user-defined types) to the next location in a non-null parcel.
+ *
+ * \param parcel the parcel to write to.
+ * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
+ * \param length the length of arrayData or -1 if this represents a null array.
+ * \param elementWriter function to be called for every array index to write the user-defined type
+ * at that location.
+ *
+ * \return STATUS_OK on successful write.
+ */
+binder_status_t AParcel_writeParcelableArray(AParcel* parcel, const void* arrayData, int32_t length,
+ AParcel_writeParcelableElement elementWriter)
+ __INTRODUCED_IN(29);
+
+/**
+ * Reads an array of parcelables (user-defined types) from the next location in a non-null parcel.
+ *
+ * First, allocator will be called with the length of the array. If the allocation succeeds and the
+ * length is greater than zero, elementReader will be called for every index to read the
+ * corresponding parcelable.
+ *
+ * \param parcel the parcel to read from.
+ * \param arrayData some external representation of an array.
+ * \param allocator the callback that will be called to allocate the array.
+ * \param elementReader the callback that will be called to fill out individual elements.
+ *
+ * \return STATUS_OK on successful read.
+ */
+binder_status_t AParcel_readParcelableArray(const AParcel* parcel, void* arrayData,
+ AParcel_parcelableArrayAllocator allocator,
+ AParcel_readParcelableElement elementReader)
+ __INTRODUCED_IN(29);
+
// @START-PRIMITIVE-READ-WRITE
/**
* Writes int32_t value to the next location in a non-null parcel.
diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h b/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h
index f99c3a9..fcdf7af 100644
--- a/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h
+++ b/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h
@@ -299,7 +299,7 @@
* index.
*/
static inline const char* AParcel_stdVectorStringElementGetter(const void* vectorData, size_t index,
- size_t* outLength) {
+ int32_t* outLength) {
const std::vector<std::string>* vec = static_cast<const std::vector<std::string>*>(vectorData);
const std::string& element = vec->at(index);
@@ -327,7 +327,7 @@
*/
static inline const char* AParcel_nullableStdVectorStringElementGetter(const void* vectorData,
size_t index,
- size_t* outLength) {
+ int32_t* outLength) {
const std::optional<std::vector<std::optional<std::string>>>* vec =
static_cast<const std::optional<std::vector<std::optional<std::string>>>*>(vectorData);
const std::optional<std::string>& element = vec->value().at(index);
@@ -420,6 +420,46 @@
AParcel_nullableStdVectorStringElementAllocator);
}
+/**
+ * Writes a parcelable object of type P inside a std::vector<P> at index 'index' to 'parcel'.
+ */
+template <typename P>
+binder_status_t AParcel_writeStdVectorParcelableElement(AParcel* parcel, const void* vectorData,
+ size_t index) {
+ const std::vector<P>* vector = static_cast<const std::vector<P>*>(vectorData);
+ return vector->at(index).writeToParcel(parcel);
+}
+
+/**
+ * Reads a parcelable object of type P inside a std::vector<P> at index 'index' from 'parcel'.
+ */
+template <typename P>
+binder_status_t AParcel_readStdVectorParcelableElement(const AParcel* parcel, void* vectorData,
+ size_t index) {
+ std::vector<P>* vector = static_cast<std::vector<P>*>(vectorData);
+ return vector->at(index).readFromParcel(parcel);
+}
+
+/**
+ * Convenience API for writing a std::vector<P>
+ */
+template <typename P>
+static inline binder_status_t AParcel_writeVector(AParcel* parcel, const std::vector<P>& vec) {
+ const void* vectorData = static_cast<const void*>(&vec);
+ return AParcel_writeParcelableArray(parcel, vectorData, vec.size(),
+ AParcel_writeStdVectorParcelableElement<P>);
+}
+
+/**
+ * Convenience API for reading a std::vector<P>
+ */
+template <typename P>
+static inline binder_status_t AParcel_readVector(const AParcel* parcel, std::vector<P>* vec) {
+ void* vectorData = static_cast<void*>(vec);
+ return AParcel_readParcelableArray(parcel, vectorData, AParcel_stdVectorExternalAllocator<P>,
+ AParcel_readStdVectorParcelableElement<P>);
+}
+
// @START
/**
* Writes a vector of int32_t to the next location in a non-null parcel.
diff --git a/libs/binder/ndk/libbinder_ndk.map.txt b/libs/binder/ndk/libbinder_ndk.map.txt
index 4328b6e..ee7132f 100644
--- a/libs/binder/ndk/libbinder_ndk.map.txt
+++ b/libs/binder/ndk/libbinder_ndk.map.txt
@@ -40,6 +40,7 @@
AParcel_readInt32Array;
AParcel_readInt64;
AParcel_readInt64Array;
+ AParcel_readParcelableArray;
AParcel_readParcelFileDescriptor;
AParcel_readStatusHeader;
AParcel_readString;
@@ -64,6 +65,7 @@
AParcel_writeInt32Array;
AParcel_writeInt64;
AParcel_writeInt64Array;
+ AParcel_writeParcelableArray;
AParcel_writeParcelFileDescriptor;
AParcel_writeStatusHeader;
AParcel_writeString;
diff --git a/libs/binder/ndk/parcel.cpp b/libs/binder/ndk/parcel.cpp
index 2d68559..ae2276e 100644
--- a/libs/binder/ndk/parcel.cpp
+++ b/libs/binder/ndk/parcel.cpp
@@ -173,7 +173,7 @@
Parcel* rawParcel = parcel->get();
- for (size_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; i++) {
status = (rawParcel->*write)(getter(arrayData, i));
if (status != STATUS_OK) return PruneStatusT(status);
@@ -197,7 +197,7 @@
if (length <= 0) return STATUS_OK;
- for (size_t i = 0; i < length; i++) {
+ for (int32_t i = 0; i < length; i++) {
T readTarget;
status = (rawParcel->*read)(&readTarget);
if (status != STATUS_OK) return PruneStatusT(status);
@@ -376,12 +376,12 @@
if (status != STATUS_OK) return status;
if (length <= 0) return STATUS_OK;
- for (size_t i = 0; i < length; i++) {
- size_t length = 0;
- const char* str = getter(arrayData, i, &length);
- if (str == nullptr && length != -1) return STATUS_BAD_VALUE;
+ for (int32_t i = 0; i < length; i++) {
+ int32_t elementLength = 0;
+ const char* str = getter(arrayData, i, &elementLength);
+ if (str == nullptr && elementLength != -1) return STATUS_BAD_VALUE;
- binder_status_t status = AParcel_writeString(parcel, str, length);
+ binder_status_t status = AParcel_writeString(parcel, str, elementLength);
if (status != STATUS_OK) return status;
}
@@ -392,7 +392,7 @@
// allocator.
struct StringArrayElementAllocationAdapter {
void* arrayData; // stringData from the NDK
- size_t index; // index into the string array
+ int32_t index; // index into the string array
AParcel_stringArrayElementAllocator elementAllocator;
static bool Allocator(void* stringData, int32_t length, char** buffer) {
@@ -433,6 +433,45 @@
return STATUS_OK;
}
+binder_status_t AParcel_writeParcelableArray(AParcel* parcel, const void* arrayData, int32_t length,
+ AParcel_writeParcelableElement elementWriter) {
+ // we have no clue if arrayData represents a null object or not, we can only infer from length
+ bool arrayIsNull = length < 0;
+ binder_status_t status = WriteAndValidateArraySize(parcel, arrayIsNull, length);
+ if (status != STATUS_OK) return status;
+ if (length <= 0) return STATUS_OK;
+
+ for (int32_t i = 0; i < length; i++) {
+ binder_status_t status = elementWriter(parcel, arrayData, i);
+ if (status != STATUS_OK) return status;
+ }
+
+ return STATUS_OK;
+}
+
+binder_status_t AParcel_readParcelableArray(const AParcel* parcel, void* arrayData,
+ AParcel_parcelableArrayAllocator allocator,
+ AParcel_readParcelableElement elementReader) {
+ const Parcel* rawParcel = parcel->get();
+
+ int32_t length;
+ status_t status = rawParcel->readInt32(&length);
+
+ if (status != STATUS_OK) return PruneStatusT(status);
+ if (length < -1) return STATUS_BAD_VALUE;
+
+ if (!allocator(arrayData, length)) return STATUS_NO_MEMORY;
+
+ if (length == -1) return STATUS_OK; // null array
+
+ for (int32_t i = 0; i < length; i++) {
+ binder_status_t status = elementReader(parcel, arrayData, i);
+ if (status != STATUS_OK) return status;
+ }
+
+ return STATUS_OK;
+}
+
// See gen_parcel_helper.py. These auto-generated read/write methods use the same types for
// libbinder and this library.
// @START
diff --git a/libs/renderengine/gl/GLESRenderEngine.cpp b/libs/renderengine/gl/GLESRenderEngine.cpp
index 15bdcbc..1395551 100644
--- a/libs/renderengine/gl/GLESRenderEngine.cpp
+++ b/libs/renderengine/gl/GLESRenderEngine.cpp
@@ -242,34 +242,20 @@
bool useContextPriority = extensions.hasContextPriority() &&
(featureFlags & RenderEngine::USE_HIGH_PRIORITY_CONTEXT);
- EGLContext protectedContext = EGL_NO_CONTEXT;
- if (extensions.hasProtectedContent()) {
- protectedContext = createEglContext(display, config, nullptr, useContextPriority,
- Protection::PROTECTED);
- ALOGE_IF(protectedContext == EGL_NO_CONTEXT, "Can't create protected context");
- }
-
- EGLContext ctxt = createEglContext(display, config, protectedContext, useContextPriority,
- Protection::UNPROTECTED);
+ EGLContext ctxt = createEglContext(display, config, EGL_NO_CONTEXT, useContextPriority);
// if can't create a GL context, we can only abort.
LOG_ALWAYS_FATAL_IF(ctxt == EGL_NO_CONTEXT, "EGLContext creation failed");
EGLSurface dummy = EGL_NO_SURFACE;
if (!extensions.hasSurfacelessContext()) {
- dummy = createDummyEglPbufferSurface(display, config, hwcFormat, Protection::UNPROTECTED);
+ dummy = createDummyEglPbufferSurface(display, config, hwcFormat);
LOG_ALWAYS_FATAL_IF(dummy == EGL_NO_SURFACE, "can't create dummy pbuffer");
}
+
EGLBoolean success = eglMakeCurrent(display, dummy, dummy, ctxt);
LOG_ALWAYS_FATAL_IF(!success, "can't make dummy pbuffer current");
- EGLSurface protectedDummy = EGL_NO_SURFACE;
- if (protectedContext != EGL_NO_CONTEXT && !extensions.hasSurfacelessContext()) {
- protectedDummy =
- createDummyEglPbufferSurface(display, config, hwcFormat, Protection::PROTECTED);
- ALOGE_IF(protectedDummy == EGL_NO_SURFACE, "can't create protected dummy pbuffer");
- }
-
extensions.initWithGLStrings(glGetString(GL_VENDOR), glGetString(GL_RENDERER),
glGetString(GL_VERSION), glGetString(GL_EXTENSIONS));
@@ -285,8 +271,7 @@
break;
case GLES_VERSION_2_0:
case GLES_VERSION_3_0:
- engine = std::make_unique<GLESRenderEngine>(featureFlags, display, config, ctxt, dummy,
- protectedContext, protectedDummy);
+ engine = std::make_unique<GLESRenderEngine>(featureFlags, display, config, ctxt, dummy);
break;
}
@@ -341,15 +326,12 @@
}
GLESRenderEngine::GLESRenderEngine(uint32_t featureFlags, EGLDisplay display, EGLConfig config,
- EGLContext ctxt, EGLSurface dummy, EGLContext protectedContext,
- EGLSurface protectedDummy)
+ EGLContext ctxt, EGLSurface dummy)
: renderengine::impl::RenderEngine(featureFlags),
mEGLDisplay(display),
mEGLConfig(config),
mEGLContext(ctxt),
mDummySurface(dummy),
- mProtectedEGLContext(protectedContext),
- mProtectedDummySurface(protectedDummy),
mVpWidth(0),
mVpHeight(0),
mUseColorManagement(featureFlags & USE_COLOR_MANAGEMENT) {
@@ -359,17 +341,6 @@
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
- // Initialize protected EGL Context.
- if (mProtectedEGLContext != EGL_NO_CONTEXT) {
- EGLBoolean success = eglMakeCurrent(display, mProtectedDummySurface, mProtectedDummySurface,
- mProtectedEGLContext);
- ALOGE_IF(!success, "can't make protected context current");
- glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glPixelStorei(GL_PACK_ALIGNMENT, 4);
- success = eglMakeCurrent(display, mDummySurface, mDummySurface, mEGLContext);
- LOG_ALWAYS_FATAL_IF(!success, "can't make default context current");
- }
-
const uint16_t protTexData[] = {0};
glGenTextures(1, &mProtectedTexName);
glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
@@ -424,8 +395,7 @@
}
void GLESRenderEngine::primeCache() const {
- ProgramCache::getInstance().primeCache(mInProtectedContext ? mProtectedEGLContext : mEGLContext,
- mFeatureFlags & USE_COLOR_MANAGEMENT);
+ ProgramCache::getInstance().primeCache(mFeatureFlags & USE_COLOR_MANAGEMENT);
}
bool GLESRenderEngine::isCurrent() const {
@@ -569,7 +539,6 @@
const GLenum target = GL_TEXTURE_EXTERNAL_OES;
glBindTexture(target, texName);
- glTexParameteri(target, GL_TEXTURE_PROTECTED_EXT, glImage.isProtected() ? GL_TRUE : GL_FALSE);
if (glImage.getEGLImage() != EGL_NO_IMAGE_KHR) {
glEGLImageTargetTexture2DOES(target, static_cast<GLeglImageOES>(glImage.getEGLImage()));
}
@@ -583,8 +552,6 @@
// Bind the texture and turn our EGLImage into a texture
glBindTexture(GL_TEXTURE_2D, textureName);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_PROTECTED_EXT,
- mInProtectedContext ? GL_TRUE : GL_FALSE);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)eglImage);
// Bind the Framebuffer to render into
@@ -617,27 +584,6 @@
} while (true);
}
-bool GLESRenderEngine::supportsProtectedContent() const {
- return GLExtensions::getInstance().hasProtectedContent() &&
- mProtectedEGLContext != EGL_NO_CONTEXT;
-}
-
-bool GLESRenderEngine::useProtectedContext(bool useProtectedContext) {
- if (useProtectedContext == mInProtectedContext) {
- return true;
- }
- if (useProtectedContext && mProtectedEGLContext == EGL_NO_CONTEXT) {
- return false;
- }
- const EGLSurface surface = useProtectedContext ? mProtectedDummySurface : mDummySurface;
- const EGLContext context = useProtectedContext ? mProtectedEGLContext : mEGLContext;
- const bool success = eglMakeCurrent(mEGLDisplay, surface, surface, context) == EGL_TRUE;
- if (success) {
- mInProtectedContext = useProtectedContext;
- }
- return success;
-}
-
status_t GLESRenderEngine::drawLayers(const DisplaySettings& /*settings*/,
const std::vector<LayerSettings>& /*layers*/,
ANativeWindowBuffer* const /*buffer*/,
@@ -876,9 +822,7 @@
Description::dataSpaceToTransferFunction(outputTransfer);
}
- ProgramCache::getInstance().useProgram(mInProtectedContext ? mProtectedEGLContext
- : mEGLContext,
- managedState);
+ ProgramCache::getInstance().useProgram(managedState);
glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount());
@@ -889,9 +833,7 @@
writePPM(out.str().c_str(), mVpWidth, mVpHeight);
}
} else {
- ProgramCache::getInstance().useProgram(mInProtectedContext ? mProtectedEGLContext
- : mEGLContext,
- mState);
+ ProgramCache::getInstance().useProgram(mState);
glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount());
}
@@ -915,18 +857,17 @@
void GLESRenderEngine::dump(std::string& result) {
const GLExtensions& extensions = GLExtensions::getInstance();
- ProgramCache& cache = ProgramCache::getInstance();
StringAppendF(&result, "EGL implementation : %s\n", extensions.getEGLVersion());
StringAppendF(&result, "%s\n", extensions.getEGLExtensions());
+
StringAppendF(&result, "GLES: %s, %s, %s\n", extensions.getVendor(), extensions.getRenderer(),
extensions.getVersion());
StringAppendF(&result, "%s\n", extensions.getExtensions());
- StringAppendF(&result, "RenderEngine is in protected context : %d\n", mInProtectedContext);
- StringAppendF(&result, "RenderEngine program cache size for unprotected context: %zu\n",
- cache.getSize(mEGLContext));
- StringAppendF(&result, "RenderEngine program cache size for protected context: %zu\n",
- cache.getSize(mProtectedEGLContext));
+
+ StringAppendF(&result, "RenderEngine program cache size: %zu\n",
+ ProgramCache::getInstance().getSize());
+
StringAppendF(&result, "RenderEngine last dataspace conversion: (%s) to (%s)\n",
dataspaceDetails(static_cast<android_dataspace>(mDataSpace)).c_str(),
dataspaceDetails(static_cast<android_dataspace>(mOutputDataSpace)).c_str());
@@ -951,8 +892,7 @@
}
EGLContext GLESRenderEngine::createEglContext(EGLDisplay display, EGLConfig config,
- EGLContext shareContext, bool useContextPriority,
- Protection protection) {
+ EGLContext shareContext, bool useContextPriority) {
EGLint renderableType = 0;
if (config == EGL_NO_CONFIG) {
renderableType = EGL_OPENGL_ES3_BIT;
@@ -971,17 +911,13 @@
}
std::vector<EGLint> contextAttributes;
- contextAttributes.reserve(7);
+ contextAttributes.reserve(5);
contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
contextAttributes.push_back(contextClientVersion);
if (useContextPriority) {
contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
contextAttributes.push_back(EGL_CONTEXT_PRIORITY_HIGH_IMG);
}
- if (protection == Protection::PROTECTED) {
- contextAttributes.push_back(EGL_PROTECTED_CONTENT_EXT);
- contextAttributes.push_back(EGL_TRUE);
- }
contextAttributes.push_back(EGL_NONE);
EGLContext context = eglCreateContext(display, config, shareContext, contextAttributes.data());
@@ -1002,21 +938,17 @@
}
EGLSurface GLESRenderEngine::createDummyEglPbufferSurface(EGLDisplay display, EGLConfig config,
- int hwcFormat, Protection protection) {
+ int hwcFormat) {
EGLConfig dummyConfig = config;
if (dummyConfig == EGL_NO_CONFIG) {
dummyConfig = chooseEglConfig(display, hwcFormat, /*logConfig*/ true);
}
std::vector<EGLint> attributes;
- attributes.reserve(7);
+ attributes.reserve(5);
attributes.push_back(EGL_WIDTH);
attributes.push_back(1);
attributes.push_back(EGL_HEIGHT);
attributes.push_back(1);
- if (protection == Protection::PROTECTED) {
- attributes.push_back(EGL_PROTECTED_CONTENT_EXT);
- attributes.push_back(EGL_TRUE);
- }
attributes.push_back(EGL_NONE);
return eglCreatePbufferSurface(display, dummyConfig, attributes.data());
diff --git a/libs/renderengine/gl/GLESRenderEngine.h b/libs/renderengine/gl/GLESRenderEngine.h
index 07e5585..21d5b81 100644
--- a/libs/renderengine/gl/GLESRenderEngine.h
+++ b/libs/renderengine/gl/GLESRenderEngine.h
@@ -45,8 +45,7 @@
static EGLConfig chooseEglConfig(EGLDisplay display, int format, bool logConfig);
GLESRenderEngine(uint32_t featureFlags, // See RenderEngine::FeatureFlag
- EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy,
- EGLContext protectedContext, EGLSurface protectedDummy);
+ EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy);
~GLESRenderEngine() override;
std::unique_ptr<Framebuffer> createFramebuffer() override;
@@ -69,9 +68,6 @@
void unbindFrameBuffer(Framebuffer* framebuffer) override;
void checkErrors() const override;
- bool isProtected() const override { return mInProtectedContext; }
- bool supportsProtectedContent() const override;
- bool useProtectedContext(bool useProtectedContext) override;
status_t drawLayers(const DisplaySettings& settings, const std::vector<LayerSettings>& layers,
ANativeWindowBuffer* const buffer,
base::unique_fd* displayFence) const override;
@@ -116,22 +112,20 @@
static GlesVersion parseGlesVersion(const char* str);
static EGLContext createEglContext(EGLDisplay display, EGLConfig config,
- EGLContext shareContext, bool useContextPriority,
- Protection protection);
+ EGLContext shareContext, bool useContextPriority);
static EGLSurface createDummyEglPbufferSurface(EGLDisplay display, EGLConfig config,
- int hwcFormat, Protection protection);
+ int hwcFormat);
// A data space is considered HDR data space if it has BT2020 color space
// with PQ or HLG transfer function.
bool isHdrDataSpace(const ui::Dataspace dataSpace) const;
bool needsXYZTransformMatrix() const;
+ void setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy);
EGLDisplay mEGLDisplay;
EGLConfig mEGLConfig;
EGLContext mEGLContext;
EGLSurface mDummySurface;
- EGLContext mProtectedEGLContext;
- EGLSurface mProtectedDummySurface;
GLuint mProtectedTexName;
GLint mMaxViewportDims[2];
GLint mMaxTextureSize;
@@ -152,7 +146,6 @@
mat4 mBt2020ToSrgb;
mat4 mBt2020ToDisplayP3;
- bool mInProtectedContext = false;
int32_t mFboHeight = 0;
// Current dataspace of layer being rendered
diff --git a/libs/renderengine/gl/GLFramebuffer.cpp b/libs/renderengine/gl/GLFramebuffer.cpp
index 4a519bb..f4de91a 100644
--- a/libs/renderengine/gl/GLFramebuffer.cpp
+++ b/libs/renderengine/gl/GLFramebuffer.cpp
@@ -39,7 +39,7 @@
eglDestroyImageKHR(mEGLDisplay, mEGLImage);
}
-bool GLFramebuffer::setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer, bool isProtected) {
+bool GLFramebuffer::setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer) {
if (mEGLImage != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(mEGLDisplay, mEGLImage);
mEGLImage = EGL_NO_IMAGE_KHR;
@@ -48,13 +48,8 @@
}
if (nativeBuffer) {
- EGLint attributes[] = {
- isProtected ? EGL_PROTECTED_CONTENT_EXT : EGL_NONE,
- isProtected ? EGL_TRUE : EGL_NONE,
- EGL_NONE,
- };
mEGLImage = eglCreateImageKHR(mEGLDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
- nativeBuffer, attributes);
+ nativeBuffer, nullptr);
if (mEGLImage == EGL_NO_IMAGE_KHR) {
return false;
}
diff --git a/libs/renderengine/gl/GLFramebuffer.h b/libs/renderengine/gl/GLFramebuffer.h
index 5043c59..358ab47 100644
--- a/libs/renderengine/gl/GLFramebuffer.h
+++ b/libs/renderengine/gl/GLFramebuffer.h
@@ -35,7 +35,7 @@
explicit GLFramebuffer(const GLESRenderEngine& engine);
~GLFramebuffer() override;
- bool setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer, bool isProtected) override;
+ bool setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer) override;
EGLImageKHR getEGLImage() const { return mEGLImage; }
uint32_t getTextureName() const { return mTextureName; }
uint32_t getFramebufferName() const { return mFramebufferName; }
diff --git a/libs/renderengine/gl/GLImage.cpp b/libs/renderengine/gl/GLImage.cpp
index 587cb31..a9529a7 100644
--- a/libs/renderengine/gl/GLImage.cpp
+++ b/libs/renderengine/gl/GLImage.cpp
@@ -65,7 +65,6 @@
ALOGE("failed to create EGLImage: %#x", eglGetError());
return false;
}
- mProtected = isProtected;
}
return true;
diff --git a/libs/renderengine/gl/GLImage.h b/libs/renderengine/gl/GLImage.h
index 59d6ce3..c897d8e 100644
--- a/libs/renderengine/gl/GLImage.h
+++ b/libs/renderengine/gl/GLImage.h
@@ -39,12 +39,10 @@
bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected) override;
EGLImageKHR getEGLImage() const { return mEGLImage; }
- bool isProtected() const { return mProtected; }
private:
EGLDisplay mEGLDisplay;
EGLImageKHR mEGLImage = EGL_NO_IMAGE_KHR;
- bool mProtected = false;
DISALLOW_COPY_AND_ASSIGN(GLImage);
};
diff --git a/libs/renderengine/gl/ProgramCache.cpp b/libs/renderengine/gl/ProgramCache.cpp
index bf2354d..41870d2 100644
--- a/libs/renderengine/gl/ProgramCache.cpp
+++ b/libs/renderengine/gl/ProgramCache.cpp
@@ -77,8 +77,7 @@
return f;
}
-void ProgramCache::primeCache(EGLContext context, bool useColorManagement) {
- auto& cache = mCaches[context];
+void ProgramCache::primeCache(bool useColorManagement) {
uint32_t shaderCount = 0;
uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK | Key::ALPHA_MASK | Key::TEXTURE_MASK
| Key::ROUNDED_CORNERS_MASK;
@@ -93,8 +92,8 @@
if (tex != Key::TEXTURE_OFF && tex != Key::TEXTURE_EXT && tex != Key::TEXTURE_2D) {
continue;
}
- if (cache.count(shaderKey) == 0) {
- cache.emplace(shaderKey, generateProgram(shaderKey));
+ if (mCache.count(shaderKey) == 0) {
+ mCache.emplace(shaderKey, generateProgram(shaderKey));
shaderCount++;
}
}
@@ -110,8 +109,8 @@
shaderKey.set(Key::OPACITY_MASK,
(i & 1) ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT);
shaderKey.set(Key::ALPHA_MASK, (i & 2) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE);
- if (cache.count(shaderKey) == 0) {
- cache.emplace(shaderKey, generateProgram(shaderKey));
+ if (mCache.count(shaderKey) == 0) {
+ mCache.emplace(shaderKey, generateProgram(shaderKey));
shaderCount++;
}
}
@@ -696,21 +695,20 @@
return std::make_unique<Program>(needs, vs.string(), fs.string());
}
-void ProgramCache::useProgram(EGLContext context, const Description& description) {
+void ProgramCache::useProgram(const Description& description) {
// generate the key for the shader based on the description
Key needs(computeKey(description));
// look-up the program in the cache
- auto& cache = mCaches[context];
- auto it = cache.find(needs);
- if (it == cache.end()) {
+ auto it = mCache.find(needs);
+ if (it == mCache.end()) {
// we didn't find our program, so generate one...
nsecs_t time = systemTime();
- it = cache.emplace(needs, generateProgram(needs)).first;
+ it = mCache.emplace(needs, generateProgram(needs)).first;
time = systemTime() - time;
- ALOGV(">>> generated new program for context %p: needs=%08X, time=%u ms (%zu programs)",
- context, needs.mKey, uint32_t(ns2ms(time)), cache.size());
+ ALOGV(">>> generated new program: needs=%08X, time=%u ms (%zu programs)", needs.mKey,
+ uint32_t(ns2ms(time)), mCache.size());
}
// here we have a suitable program for this description
diff --git a/libs/renderengine/gl/ProgramCache.h b/libs/renderengine/gl/ProgramCache.h
index 400ad74..653aaf0 100644
--- a/libs/renderengine/gl/ProgramCache.h
+++ b/libs/renderengine/gl/ProgramCache.h
@@ -20,7 +20,6 @@
#include <memory>
#include <unordered_map>
-#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <renderengine/private/Description.h>
#include <utils/Singleton.h>
@@ -179,13 +178,13 @@
~ProgramCache() = default;
// Generate shaders to populate the cache
- void primeCache(const EGLContext context, bool useColorManagement);
+ void primeCache(bool useColorManagement);
- size_t getSize(const EGLContext context) { return mCaches[context].size(); }
+ size_t getSize() const { return mCache.size(); }
// useProgram lookup a suitable program in the cache or generates one
// if none can be found.
- void useProgram(const EGLContext context, const Description& description);
+ void useProgram(const Description& description);
private:
// compute a cache Key from a Description
@@ -207,8 +206,7 @@
// Key/Value map used for caching Programs. Currently the cache
// is never shrunk (and the GL program objects are never deleted).
- std::unordered_map<EGLContext, std::unordered_map<Key, std::unique_ptr<Program>, Key::Hash>>
- mCaches;
+ std::unordered_map<Key, std::unique_ptr<Program>, Key::Hash> mCache;
};
} // namespace gl
diff --git a/libs/renderengine/include/renderengine/Framebuffer.h b/libs/renderengine/include/renderengine/Framebuffer.h
index 66eb9ef..558b9c7 100644
--- a/libs/renderengine/include/renderengine/Framebuffer.h
+++ b/libs/renderengine/include/renderengine/Framebuffer.h
@@ -27,7 +27,7 @@
public:
virtual ~Framebuffer() = default;
- virtual bool setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer, bool isProtected) = 0;
+ virtual bool setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer) = 0;
};
} // namespace renderengine
diff --git a/libs/renderengine/include/renderengine/RenderEngine.h b/libs/renderengine/include/renderengine/RenderEngine.h
index 5e88159..8eaa2d2 100644
--- a/libs/renderengine/include/renderengine/RenderEngine.h
+++ b/libs/renderengine/include/renderengine/RenderEngine.h
@@ -53,11 +53,6 @@
class RenderEngine;
}
-enum class Protection {
- UNPROTECTED = 1,
- PROTECTED = 2,
-};
-
class RenderEngine {
public:
enum FeatureFlag {
@@ -155,10 +150,6 @@
// ----- BEGIN NEW INTERFACE -----
- virtual bool isProtected() const = 0;
- virtual bool supportsProtectedContent() const = 0;
- virtual bool useProtectedContext(bool useProtectedContext) = 0;
-
// Renders layers for a particular display via GPU composition. This method
// should be called for every display that needs to be rendered via the GPU.
// @param settings The display-wide settings that should be applied prior to
@@ -191,12 +182,12 @@
public:
BindNativeBufferAsFramebuffer(RenderEngine& engine, ANativeWindowBuffer* buffer)
: mEngine(engine), mFramebuffer(mEngine.createFramebuffer()), mStatus(NO_ERROR) {
- mStatus = mFramebuffer->setNativeWindowBuffer(buffer, mEngine.isProtected())
+ mStatus = mFramebuffer->setNativeWindowBuffer(buffer)
? mEngine.bindFrameBuffer(mFramebuffer.get())
: NO_MEMORY;
}
~BindNativeBufferAsFramebuffer() {
- mFramebuffer->setNativeWindowBuffer(nullptr, false);
+ mFramebuffer->setNativeWindowBuffer(nullptr);
mEngine.unbindFrameBuffer(mFramebuffer.get());
}
status_t getStatus() const { return mStatus; }
diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h
index 98ae286..55d68f6 100644
--- a/services/surfaceflinger/BufferLayer.h
+++ b/services/surfaceflinger/BufferLayer.h
@@ -71,10 +71,6 @@
// isVisible - true if this layer is visible, false otherwise
bool isVisible() const override EXCLUDES(mStateMutex);
- // isProtected - true if the layer may contain protected content in the
- // GRALLOC_USAGE_PROTECTED sense.
- bool isProtected() const override;
-
// isFixedSize - true if content has a fixed size
bool isFixedSize() const override;
@@ -159,6 +155,13 @@
virtual void setHwcLayerBuffer(DisplayId displayId) EXCLUDES(mStateMutex) = 0;
+ // -----------------------------------------------------------------------
+
+public:
+ // isProtected - true if the layer may contain protected content in the
+ // GRALLOC_USAGE_PROTECTED sense.
+ bool isProtected() const;
+
protected:
// Loads the corresponding system property once per process
static bool latchUnsignaledBuffers();
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 2003fb1..3ad07ae 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -366,15 +366,6 @@
return mDisplaySurface->prepareFrame(compositionType);
}
-void DisplayDevice::setProtected(bool useProtected) {
- uint64_t usageFlags = GRALLOC_USAGE_HW_RENDER;
- if (useProtected) {
- usageFlags |= GRALLOC_USAGE_PROTECTED;
- }
- const int status = native_window_set_usage(mNativeWindow.get(), usageFlags);
- ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for protected content: %d", status);
-}
-
sp<GraphicBuffer> DisplayDevice::dequeueBuffer() {
int fd;
ANativeWindowBuffer* buffer;
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 2c2a3ab..ba85432 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -146,7 +146,6 @@
ui::Dataspace* outDataspace, ui::ColorMode* outMode,
ui::RenderIntent* outIntent) const;
- void setProtected(bool useProtected);
// Queues the drawn buffer for consumption by HWC.
void queueBuffer(HWComposer& hwc);
// Allocates a buffer as scratch space for GPU composition
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index fb75e4c..57ef65a 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -399,12 +399,6 @@
bool isHiddenByPolicy() const EXCLUDES(mStateMutex);
/*
- * isProtected - true if the layer may contain protected content in the
- * GRALLOC_USAGE_PROTECTED sense.
- */
- virtual bool isProtected() const { return false; }
-
- /*
* isFixedSize - true if content has a fixed size
*/
virtual bool isFixedSize() const { return true; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a5ba054..e6a43c5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5439,11 +5439,10 @@
ALOGW("FB is protected: PERMISSION_DENIED");
return PERMISSION_DENIED;
}
- auto& engine(getRenderEngine());
// this binds the given EGLImage as a framebuffer for the
// duration of this scope.
- renderengine::BindNativeBufferAsFramebuffer bufferBond(engine, buffer);
+ renderengine::BindNativeBufferAsFramebuffer bufferBond(getRenderEngine(), buffer);
if (bufferBond.getStatus() != NO_ERROR) {
ALOGE("got ANWB binding error while taking screenshot");
return INVALID_OPERATION;
@@ -5455,9 +5454,9 @@
// dependent on the context's EGLConfig.
renderScreenImplLocked(renderArea, traverseLayers, useIdentityTransform);
- base::unique_fd syncFd = engine.flush();
+ base::unique_fd syncFd = getRenderEngine().flush();
if (syncFd < 0) {
- engine.finish();
+ getRenderEngine().finish();
}
*outSyncFd = syncFd.release();
diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
index b7c09ed..5a6aa92 100644
--- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
@@ -286,10 +286,8 @@
static void setupCommonScreensCaptureCallExpectations(CompositionTest* test) {
// Called once with a non-null value to set a framebuffer, and then
// again with nullptr to clear it.
- EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(NotNull(), false))
- .WillOnce(Return(true));
- EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(IsNull(), false))
- .WillOnce(Return(true));
+ EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(NotNull())).WillOnce(Return(true));
+ EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(IsNull())).WillOnce(Return(true));
EXPECT_CALL(*test->mRenderEngine, checkErrors()).WillRepeatedly(Return());
EXPECT_CALL(*test->mRenderEngine, createFramebuffer())
@@ -346,10 +344,8 @@
Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
ui::Transform::ROT_0))
.Times(1);
- EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(NotNull(), false))
- .WillOnce(Return(true));
- EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(IsNull(), false))
- .WillOnce(Return(true));
+ EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(NotNull())).WillOnce(Return(true));
+ EXPECT_CALL(*test->mReFrameBuffer, setNativeWindowBuffer(IsNull())).WillOnce(Return(true));
EXPECT_CALL(*test->mRenderEngine, createFramebuffer())
.WillOnce(Return(
ByMove(std::unique_ptr<renderengine::Framebuffer>(test->mReFrameBuffer))));
diff --git a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
index 1bee271..11e5631 100644
--- a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
+++ b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
@@ -74,9 +74,6 @@
MOCK_METHOD1(drawMesh, void(const Mesh&));
MOCK_CONST_METHOD0(getMaxTextureSize, size_t());
MOCK_CONST_METHOD0(getMaxViewportDims, size_t());
- MOCK_CONST_METHOD0(isProtected, bool());
- MOCK_CONST_METHOD0(supportsProtectedContent, bool());
- MOCK_METHOD1(useProtectedContext, bool(bool));
MOCK_CONST_METHOD4(drawLayers,
status_t(const DisplaySettings&, const std::vector<LayerSettings>&,
ANativeWindowBuffer* const, base::unique_fd*));
@@ -87,7 +84,8 @@
Image();
~Image() override;
- MOCK_METHOD2(setNativeWindowBuffer, bool(ANativeWindowBuffer*, bool));
+ MOCK_METHOD2(setNativeWindowBuffer,
+ bool(ANativeWindowBuffer* buffer, bool isProtected));
};
class Framebuffer : public renderengine::Framebuffer {
@@ -95,7 +93,7 @@
Framebuffer();
~Framebuffer() override;
- MOCK_METHOD2(setNativeWindowBuffer, bool(ANativeWindowBuffer*, bool));
+ MOCK_METHOD1(setNativeWindowBuffer, bool(ANativeWindowBuffer*));
};
} // namespace mock