Remove mentions of EGL_ANDROID_image_crop
This extension was initially a hack to fix a hardware problem on the
Nexus 4. It is undocumented and no current hardware implements it in
its EGL driver. Remove all code that interacts with it.
Bug: b/15287899
Test: Pixel XL boots
Change-Id: I28d4899537a587dda694feb11eaf3e7c7a2ab0a5
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 87333d0..d231790 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -280,14 +280,6 @@
return NO_ERROR;
}
-bool BufferLayerConsumer::canUseImageCrop(const Rect& crop) const {
- // If the crop rect is not at the origin, we can't set the crop on the
- // EGLImage because that's not allowed by the EGL_ANDROID_image_crop
- // extension. In the future we can add a layered extension that
- // removes this restriction if there is hardware that can support it.
- return mRE.supportsImageCrop() && crop.left == 0 && crop.top == 0;
-}
-
status_t BufferLayerConsumer::updateAndReleaseLocked(const BufferItem& item,
PendingRelease* pendingRelease) {
status_t err = NO_ERROR;
@@ -365,8 +357,7 @@
return NO_INIT;
}
- const Rect& imageCrop = canUseImageCrop(mCurrentCrop) ? mCurrentCrop : Rect::EMPTY_RECT;
- status_t err = mCurrentTextureImage->createIfNeeded(imageCrop);
+ status_t err = mCurrentTextureImage->createIfNeeded();
if (err != NO_ERROR) {
BLC_LOGW("bindTextureImage: can't create image on slot=%d", mCurrentTexture);
mRE.bindExternalTextureImage(mTexName, *mRE.createImage());
@@ -435,9 +426,8 @@
BLC_LOGD("computeCurrentTransformMatrixLocked: "
"mCurrentTextureImage is nullptr");
}
- const Rect& cropRect = canUseImageCrop(mCurrentCrop) ? Rect::EMPTY_RECT : mCurrentCrop;
- GLConsumer::computeTransformMatrix(mCurrentTransformMatrix, buf, cropRect, mCurrentTransform,
- mFilteringEnabled);
+ GLConsumer::computeTransformMatrix(mCurrentTransformMatrix, buf, mCurrentCrop,
+ mCurrentTransform, mFilteringEnabled);
}
nsecs_t BufferLayerConsumer::getTimestamp() {
@@ -615,23 +605,12 @@
BufferLayerConsumer::Image::~Image() = default;
-status_t BufferLayerConsumer::Image::createIfNeeded(const Rect& imageCrop) {
- const int32_t cropWidth = imageCrop.width();
- const int32_t cropHeight = imageCrop.height();
- if (mCreated && mCropWidth == cropWidth && mCropHeight == cropHeight) {
- return OK;
- }
+status_t BufferLayerConsumer::Image::createIfNeeded() {
+ if (mCreated) return OK;
mCreated = mImage->setNativeWindowBuffer(mGraphicBuffer->getNativeBuffer(),
- mGraphicBuffer->getUsage() & GRALLOC_USAGE_PROTECTED,
- cropWidth, cropHeight);
- if (mCreated) {
- mCropWidth = cropWidth;
- mCropHeight = cropHeight;
- } else {
- mCropWidth = 0;
- mCropHeight = 0;
-
+ mGraphicBuffer->getUsage() & GRALLOC_USAGE_PROTECTED);
+ if (!mCreated) {
const sp<GraphicBuffer>& buffer = mGraphicBuffer;
ALOGE("Failed to create image. size=%ux%u st=%u usage=%#" PRIx64 " fmt=%d",
buffer->getWidth(), buffer->getHeight(), buffer->getStride(), buffer->getUsage(),
diff --git a/services/surfaceflinger/BufferLayerConsumer.h b/services/surfaceflinger/BufferLayerConsumer.h
index f81cdb1..943b8a8 100644
--- a/services/surfaceflinger/BufferLayerConsumer.h
+++ b/services/surfaceflinger/BufferLayerConsumer.h
@@ -228,9 +228,8 @@
Image(const Image& rhs) = delete;
Image& operator=(const Image& rhs) = delete;
- // createIfNeeded creates an RE::Image if required (we haven't created
- // one yet, or the crop-rect has changed).
- status_t createIfNeeded(const Rect& imageCrop);
+ // createIfNeeded creates an RE::Image if we haven't created one yet.
+ status_t createIfNeeded();
const sp<GraphicBuffer>& graphicBuffer() { return mGraphicBuffer; }
const native_handle* graphicBufferHandle() {
diff --git a/services/surfaceflinger/RenderEngine/GLExtensions.cpp b/services/surfaceflinger/RenderEngine/GLExtensions.cpp
index dc09a37..23480b4 100644
--- a/services/surfaceflinger/RenderEngine/GLExtensions.cpp
+++ b/services/surfaceflinger/RenderEngine/GLExtensions.cpp
@@ -99,10 +99,6 @@
if (hasEGLExtension("EGL_KHR_wait_sync")) {
mHasWaitSync = true;
}
-
- if (hasEGLExtension("EGL_ANDROID_image_crop")) {
- mHasImageCrop = true;
- }
if (hasEGLExtension("EGL_EXT_protected_content")) {
mHasProtectedContent = true;
}
diff --git a/services/surfaceflinger/RenderEngine/GLExtensions.h b/services/surfaceflinger/RenderEngine/GLExtensions.h
index 0d8c10b..a6a5053 100644
--- a/services/surfaceflinger/RenderEngine/GLExtensions.h
+++ b/services/surfaceflinger/RenderEngine/GLExtensions.h
@@ -39,7 +39,6 @@
bool mHasNativeFenceSync = false;
bool mHasFenceSync = false;
bool mHasWaitSync = false;
- bool mHasImageCrop = false;
bool mHasProtectedContent = false;
bool mHasContextPriority = false;
@@ -66,7 +65,6 @@
bool hasNativeFenceSync() const { return mHasNativeFenceSync; }
bool hasFenceSync() const { return mHasFenceSync; }
bool hasWaitSync() const { return mHasWaitSync; }
- bool hasImageCrop() const { return mHasImageCrop; }
bool hasProtectedContent() const { return mHasProtectedContent; }
bool hasContextPriority() const { return mHasContextPriority; }
diff --git a/services/surfaceflinger/RenderEngine/Image.cpp b/services/surfaceflinger/RenderEngine/Image.cpp
index 0d06422..6e0a880 100644
--- a/services/surfaceflinger/RenderEngine/Image.cpp
+++ b/services/surfaceflinger/RenderEngine/Image.cpp
@@ -33,11 +33,10 @@
Image::Image(const RenderEngine& engine) : mEGLDisplay(engine.getEGLDisplay()) {}
Image::~Image() {
- setNativeWindowBuffer(nullptr, false, 0, 0);
+ setNativeWindowBuffer(nullptr, false);
}
-static std::vector<EGLint> buildAttributeList(bool isProtected, int32_t cropWidth,
- int32_t cropHeight) {
+static std::vector<EGLint> buildAttributeList(bool isProtected) {
std::vector<EGLint> attrs;
attrs.reserve(16);
@@ -49,24 +48,12 @@
attrs.push_back(EGL_TRUE);
}
- if (cropWidth > 0 && cropHeight > 0) {
- attrs.push_back(EGL_IMAGE_CROP_LEFT_ANDROID);
- attrs.push_back(0);
- attrs.push_back(EGL_IMAGE_CROP_TOP_ANDROID);
- attrs.push_back(0);
- attrs.push_back(EGL_IMAGE_CROP_RIGHT_ANDROID);
- attrs.push_back(cropWidth);
- attrs.push_back(EGL_IMAGE_CROP_BOTTOM_ANDROID);
- attrs.push_back(cropHeight);
- }
-
attrs.push_back(EGL_NONE);
return attrs;
}
-bool Image::setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected, int32_t cropWidth,
- int32_t cropHeight) {
+bool Image::setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected) {
if (mEGLImage != EGL_NO_IMAGE_KHR) {
if (!eglDestroyImageKHR(mEGLDisplay, mEGLImage)) {
ALOGE("failed to destroy image: %#x", eglGetError());
@@ -75,7 +62,7 @@
}
if (buffer) {
- std::vector<EGLint> attrs = buildAttributeList(isProtected, cropWidth, cropHeight);
+ std::vector<EGLint> attrs = buildAttributeList(isProtected);
mEGLImage = eglCreateImageKHR(mEGLDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
static_cast<EGLClientBuffer>(buffer), attrs.data());
if (mEGLImage == EGL_NO_IMAGE_KHR) {
diff --git a/services/surfaceflinger/RenderEngine/Image.h b/services/surfaceflinger/RenderEngine/Image.h
index 1ae7e09..c38fe0a 100644
--- a/services/surfaceflinger/RenderEngine/Image.h
+++ b/services/surfaceflinger/RenderEngine/Image.h
@@ -29,8 +29,7 @@
class Image {
public:
virtual ~Image() = 0;
- virtual bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected,
- int32_t cropWidth, int32_t cropHeight) = 0;
+ virtual bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected) = 0;
};
namespace impl {
@@ -45,8 +44,7 @@
Image(const Image&) = delete;
Image& operator=(const Image&) = delete;
- bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected, int32_t cropWidth,
- int32_t cropHeight) override;
+ bool setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected) override;
private:
// methods internal to RenderEngine
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
index d745770..0b8b838 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
@@ -175,10 +175,6 @@
return mEGLConfig;
}
-bool RenderEngine::supportsImageCrop() const {
- return GLExtensions::getInstance().hasImageCrop();
-}
-
bool RenderEngine::isCurrent() const {
return mEGLDisplay == eglGetCurrentDisplay() && mEGLContext == eglGetCurrentContext();
}
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h
index 1196216..0b0bbf7 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.h
@@ -69,8 +69,6 @@
// dump the extension strings. always call the base class.
virtual void dump(String8& result) = 0;
- virtual bool supportsImageCrop() const = 0;
-
virtual bool isCurrent() const = 0;
virtual bool setCurrentSurface(const RE::Surface& surface) = 0;
virtual void resetCurrentSurface() = 0;
@@ -193,8 +191,6 @@
// dump the extension strings. always call the base class.
void dump(String8& result) override;
- bool supportsImageCrop() const override;
-
bool isCurrent() const;
bool setCurrentSurface(const RE::Surface& surface) override;
void resetCurrentSurface() override;
diff --git a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
index ac08293..7caf864 100644
--- a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
+++ b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
@@ -37,7 +37,6 @@
MOCK_METHOD0(createImage, std::unique_ptr<RE::Image>());
MOCK_CONST_METHOD0(primeCache, void());
MOCK_METHOD1(dump, void(String8&));
- MOCK_CONST_METHOD0(supportsImageCrop, bool());
MOCK_CONST_METHOD0(isCurrent, bool());
MOCK_METHOD1(setCurrentSurface, bool(const RE::Surface&));
MOCK_METHOD0(resetCurrentSurface, void());
@@ -98,9 +97,8 @@
Image();
~Image() override;
- MOCK_METHOD4(setNativeWindowBuffer,
- bool(ANativeWindowBuffer* buffer, bool isProtected, int32_t cropWidth,
- int32_t cropHeight));
+ MOCK_METHOD2(setNativeWindowBuffer,
+ bool(ANativeWindowBuffer* buffer, bool isProtected));
};
} // namespace mock