diff options
author | 2018-06-27 19:12:54 -0700 | |
---|---|---|
committer | 2018-06-29 15:43:48 -0700 | |
commit | 7108c3154b646d25a5d7916fe53b4de96a3657cb (patch) | |
tree | a013bb099d955682d01115331c2cd94a5ad5adf5 | |
parent | a309985732604bad22efe7f66d585befccaa985c (diff) |
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
-rw-r--r-- | libs/gui/GLConsumer.cpp | 71 | ||||
-rw-r--r-- | libs/gui/include/gui/GLConsumer.h | 6 | ||||
-rw-r--r-- | libs/gui/tests/SurfaceTextureClient_test.cpp | 27 | ||||
-rw-r--r-- | opengl/include/EGL/eglext.h | 11 | ||||
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 1 | ||||
-rw-r--r-- | opengl/specs/README | 5 | ||||
-rw-r--r-- | services/surfaceflinger/BufferLayerConsumer.cpp | 35 | ||||
-rw-r--r-- | services/surfaceflinger/BufferLayerConsumer.h | 5 | ||||
-rw-r--r-- | services/surfaceflinger/RenderEngine/GLExtensions.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/RenderEngine/GLExtensions.h | 2 | ||||
-rw-r--r-- | services/surfaceflinger/RenderEngine/Image.cpp | 21 | ||||
-rw-r--r-- | services/surfaceflinger/RenderEngine/Image.h | 6 | ||||
-rw-r--r-- | services/surfaceflinger/RenderEngine/RenderEngine.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/RenderEngine/RenderEngine.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h | 6 |
15 files changed, 36 insertions, 172 deletions
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp index 8efbef5404..6237aa09c2 100644 --- a/libs/gui/GLConsumer.cpp +++ b/libs/gui/GLConsumer.cpp @@ -46,7 +46,6 @@ #include <utils/Trace.h> extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); -#define CROP_EXT_STR "EGL_ANDROID_image_crop" #define PROT_CONTENT_EXT_STR "EGL_EXT_protected_content" #define EGL_PROTECTED_CONTENT_EXT 0x32C0 @@ -82,26 +81,6 @@ static const mat4 mtxIdentity; Mutex GLConsumer::sStaticInitLock; sp<GraphicBuffer> GLConsumer::sReleasedTexImageBuffer; -static bool hasEglAndroidImageCropImpl() { - EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - const char* exts = eglQueryStringImplementationANDROID(dpy, EGL_EXTENSIONS); - size_t cropExtLen = strlen(CROP_EXT_STR); - size_t extsLen = strlen(exts); - bool equal = !strcmp(CROP_EXT_STR, exts); - bool atStart = !strncmp(CROP_EXT_STR " ", exts, cropExtLen+1); - bool atEnd = (cropExtLen+1) < extsLen && - !strcmp(" " CROP_EXT_STR, exts + extsLen - (cropExtLen+1)); - bool inMiddle = strstr(exts, " " CROP_EXT_STR " "); - return equal || atStart || atEnd || inMiddle; -} - -static bool hasEglAndroidImageCrop() { - // Only compute whether the extension is present once the first time this - // function is called. - static bool hasIt = hasEglAndroidImageCropImpl(); - return hasIt; -} - static bool hasEglProtectedContentImpl() { EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); const char* exts = eglQueryString(dpy, EGL_EXTENSIONS); @@ -122,10 +101,6 @@ static bool hasEglProtectedContent() { return hasIt; } -static bool isEglImageCroppable(const Rect& crop) { - return hasEglAndroidImageCrop() && (crop.left == 0 && crop.top == 0); -} - GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex, uint32_t texTarget, bool useFenceSync, bool isControlledByApp) : ConsumerBase(bq, isControlledByApp), @@ -406,7 +381,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item, // ConsumerBase. // We may have to do this even when item.mGraphicBuffer == NULL (which // means the buffer was previously acquired). - err = mEglSlots[slot].mEglImage->createIfNeeded(mEglDisplay, item.mCrop); + err = mEglSlots[slot].mEglImage->createIfNeeded(mEglDisplay); if (err != NO_ERROR) { GLC_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d", mEglDisplay, slot); @@ -496,8 +471,7 @@ status_t GLConsumer::bindTextureImageLocked() { return NO_INIT; } - status_t err = mCurrentTextureImage->createIfNeeded(mEglDisplay, - mCurrentCrop); + status_t err = mCurrentTextureImage->createIfNeeded(mEglDisplay); if (err != NO_ERROR) { GLC_LOGW("bindTextureImage: can't create image on display=%p slot=%d", mEglDisplay, mCurrentTexture); @@ -511,9 +485,7 @@ status_t GLConsumer::bindTextureImageLocked() { // forcing the creation of a new image. if ((error = glGetError()) != GL_NO_ERROR) { glBindTexture(mTexTarget, mTexName); - status_t result = mCurrentTextureImage->createIfNeeded(mEglDisplay, - mCurrentCrop, - true); + status_t result = mCurrentTextureImage->createIfNeeded(mEglDisplay, true); if (result != NO_ERROR) { GLC_LOGW("bindTextureImage: can't create image on display=%p slot=%d", mEglDisplay, mCurrentTexture); @@ -769,8 +741,7 @@ void GLConsumer::computeCurrentTransformMatrixLocked() { GLC_LOGD("computeCurrentTransformMatrixLocked: " "mCurrentTextureImage is NULL"); } - computeTransformMatrix(mCurrentTransformMatrix, buf, - isEglImageCroppable(mCurrentCrop) ? Rect::EMPTY_RECT : mCurrentCrop, + computeTransformMatrix(mCurrentTransformMatrix, buf, mCurrentCrop, mCurrentTransform, mFilteringEnabled); } @@ -1063,8 +1034,7 @@ void GLConsumer::dumpLocked(String8& result, const char* prefix) const GLConsumer::EglImage::EglImage(sp<GraphicBuffer> graphicBuffer) : mGraphicBuffer(graphicBuffer), mEglImage(EGL_NO_IMAGE_KHR), - mEglDisplay(EGL_NO_DISPLAY), - mCropRect(Rect::EMPTY_RECT) { + mEglDisplay(EGL_NO_DISPLAY) { } GLConsumer::EglImage::~EglImage() { @@ -1077,13 +1047,11 @@ GLConsumer::EglImage::~EglImage() { } status_t GLConsumer::EglImage::createIfNeeded(EGLDisplay eglDisplay, - const Rect& cropRect, bool forceCreation) { // If there's an image and it's no longer valid, destroy it. bool haveImage = mEglImage != EGL_NO_IMAGE_KHR; bool displayInvalid = mEglDisplay != eglDisplay; - bool cropInvalid = hasEglAndroidImageCrop() && mCropRect != cropRect; - if (haveImage && (displayInvalid || cropInvalid || forceCreation)) { + if (haveImage && (displayInvalid || forceCreation)) { if (!eglDestroyImageKHR(mEglDisplay, mEglImage)) { ALOGE("createIfNeeded: eglDestroyImageKHR failed"); } @@ -1095,14 +1063,12 @@ status_t GLConsumer::EglImage::createIfNeeded(EGLDisplay eglDisplay, // If there's no image, create one. if (mEglImage == EGL_NO_IMAGE_KHR) { mEglDisplay = eglDisplay; - mCropRect = cropRect; - mEglImage = createImage(mEglDisplay, mGraphicBuffer, mCropRect); + mEglImage = createImage(mEglDisplay, mGraphicBuffer); } // Fail if we can't create a valid image. if (mEglImage == EGL_NO_IMAGE_KHR) { mEglDisplay = EGL_NO_DISPLAY; - mCropRect.makeInvalid(); 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(), @@ -1119,37 +1085,18 @@ void GLConsumer::EglImage::bindToTextureTarget(uint32_t texTarget) { } EGLImageKHR GLConsumer::EglImage::createImage(EGLDisplay dpy, - const sp<GraphicBuffer>& graphicBuffer, const Rect& crop) { + const sp<GraphicBuffer>& graphicBuffer) { EGLClientBuffer cbuf = static_cast<EGLClientBuffer>(graphicBuffer->getNativeBuffer()); const bool createProtectedImage = (graphicBuffer->getUsage() & GRALLOC_USAGE_PROTECTED) && hasEglProtectedContent(); EGLint attrs[] = { - EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, - EGL_IMAGE_CROP_LEFT_ANDROID, crop.left, - EGL_IMAGE_CROP_TOP_ANDROID, crop.top, - EGL_IMAGE_CROP_RIGHT_ANDROID, crop.right, - EGL_IMAGE_CROP_BOTTOM_ANDROID, crop.bottom, + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, createProtectedImage ? EGL_PROTECTED_CONTENT_EXT : EGL_NONE, createProtectedImage ? EGL_TRUE : EGL_NONE, EGL_NONE, }; - if (!crop.isValid()) { - // No crop rect to set, so leave the crop out of the attrib array. Make - // sure to propagate the protected content attrs if they are set. - attrs[2] = attrs[10]; - attrs[3] = attrs[11]; - attrs[4] = EGL_NONE; - } else if (!isEglImageCroppable(crop)) { - // The crop rect is not at the origin, so 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. - attrs[2] = attrs[10]; - attrs[3] = attrs[11]; - attrs[4] = EGL_NONE; - } eglInitialize(dpy, nullptr, nullptr); EGLImageKHR image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs); diff --git a/libs/gui/include/gui/GLConsumer.h b/libs/gui/include/gui/GLConsumer.h index 71ed3bf239..25f9d6b3f2 100644 --- a/libs/gui/include/gui/GLConsumer.h +++ b/libs/gui/include/gui/GLConsumer.h @@ -140,7 +140,8 @@ public: // Scale the crop down horizontally or vertically such that it has the // same aspect ratio as the buffer does. - static Rect scaleDownCrop(const Rect& crop, uint32_t bufferWidth, uint32_t bufferHeight); + static Rect scaleDownCrop(const Rect& crop, uint32_t bufferWidth, + uint32_t bufferHeight); // getTimestamp retrieves the timestamp associated with the texture image // set by the most recent call to updateTexImage. @@ -305,7 +306,6 @@ private: // createIfNeeded creates an EGLImage if required (we haven't created // one yet, or the EGLDisplay or crop-rect has changed). status_t createIfNeeded(EGLDisplay display, - const Rect& cropRect, bool forceCreate = false); // This calls glEGLImageTargetTexture2DOES to bind the image to the @@ -324,7 +324,7 @@ private: // createImage creates a new EGLImage from a GraphicBuffer. EGLImageKHR createImage(EGLDisplay dpy, - const sp<GraphicBuffer>& graphicBuffer, const Rect& crop); + const sp<GraphicBuffer>& graphicBuffer); // Disallow copying EglImage(const EglImage& rhs); diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp index d5b2f004ed..d8c9bcff84 100644 --- a/libs/gui/tests/SurfaceTextureClient_test.cpp +++ b/libs/gui/tests/SurfaceTextureClient_test.cpp @@ -29,7 +29,6 @@ #include <utils/Thread.h> extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); -#define CROP_EXT_STR "EGL_ANDROID_image_crop" namespace android { @@ -638,18 +637,6 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffers) } TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWithCrop) { - // Query to see if the image crop extension exists - EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - const char* exts = eglQueryStringImplementationANDROID(dpy, EGL_EXTENSIONS); - size_t cropExtLen = strlen(CROP_EXT_STR); - size_t extsLen = strlen(exts); - bool equal = !strcmp(CROP_EXT_STR, exts); - bool atStart = !strncmp(CROP_EXT_STR " ", exts, cropExtLen+1); - bool atEnd = (cropExtLen+1) < extsLen && - !strcmp(" " CROP_EXT_STR, exts + extsLen - (cropExtLen+1)); - bool inMiddle = strstr(exts, " " CROP_EXT_STR " "); - bool hasEglAndroidImageCrop = equal || atStart || atEnd || inMiddle; - android_native_buffer_t* buf[3]; float mtx[16] = {}; android_native_rect_t crop; @@ -669,17 +656,15 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 6)); // frees buffers mST->getTransformMatrix(mtx); - // If the egl image crop extension is not present, this accounts for the - // .5 texel shrink for each edge that's included in the transform matrix - // to avoid texturing outside the crop region. Otherwise the crop is not - // included in the transform matrix. - EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5, mtx[0]); + // This accounts for the .5 texel shrink for each edge that's included in + // the transform matrix to avoid texturing outside the crop region. + EXPECT_EQ(0.5f, mtx[0]); EXPECT_EQ(0.f, mtx[1]); EXPECT_EQ(0.f, mtx[2]); EXPECT_EQ(0.f, mtx[3]); EXPECT_EQ(0.f, mtx[4]); - EXPECT_EQ(hasEglAndroidImageCrop ? -1 : -0.5, mtx[5]); + EXPECT_EQ(-0.5f, mtx[5]); EXPECT_EQ(0.f, mtx[6]); EXPECT_EQ(0.f, mtx[7]); @@ -688,8 +673,8 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi EXPECT_EQ(1.f, mtx[10]); EXPECT_EQ(0.f, mtx[11]); - EXPECT_EQ(hasEglAndroidImageCrop ? 0 : 0.0625f, mtx[12]); - EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5625f, mtx[13]); + EXPECT_EQ(0.0625f, mtx[12]); + EXPECT_EQ(0.5625f, mtx[13]); EXPECT_EQ(0.f, mtx[14]); EXPECT_EQ(1.f, mtx[15]); } diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h index 44f4dbc929..0fd91eb262 100644 --- a/opengl/include/EGL/eglext.h +++ b/opengl/include/EGL/eglext.h @@ -1285,17 +1285,6 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); #define EGL_NATIVE_SURFACE_TIZEN 0x32A1 #endif /* EGL_TIZEN_image_native_surface */ -/* This is a private Android extension that does not exist in the EGL registry, - * formerly used to work around a hardware issue on Nexus 4. It is deprecated - * and unimplemented. It has been added to this header manually. */ -#ifndef EGL_ANDROID_image_crop -#define EGL_ANDROID_image_crop 1 -#define EGL_IMAGE_CROP_LEFT_ANDROID 0x3148 -#define EGL_IMAGE_CROP_TOP_ANDROID 0x3149 -#define EGL_IMAGE_CROP_RIGHT_ANDROID 0x314A -#define EGL_IMAGE_CROP_BOTTOM_ANDROID 0x314B -#endif - #ifdef __cplusplus } #endif diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 3312b031a0..f73967c124 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -136,7 +136,6 @@ char const * const gExtensionString = // "EGL_IMG_hibernate_process " // optional // "EGL_ANDROID_native_fence_sync " // strongly recommended // "EGL_ANDROID_framebuffer_target " // mandatory for HWC 1.1 -// "EGL_ANDROID_image_crop " // optional /* * EGL Extensions entry-points exposed to 3rd party applications diff --git a/opengl/specs/README b/opengl/specs/README index fdafb1bffb..6d597d5519 100644 --- a/opengl/specs/README +++ b/opengl/specs/README @@ -19,10 +19,7 @@ Khronos. 0x3145 EGL_SYNC_NATIVE_FENCE_FD_ANDROID (EGL_ANDROID_native_fence_sync) 0x3146 EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID (EGL_ANDROID_native_fence_sync) 0x3147 EGL_FRAMEBUFFER_TARGET_ANDROID (EGL_ANDROID_framebuffer_target) -0x3148 EGL_IMAGE_CROP_LEFT_ANDROID (EGL_ANDROID_image_crop) -0x3149 EGL_IMAGE_CROP_TOP_ANDROID (EGL_ANDROID_image_crop) -0x314A EGL_IMAGE_CROP_RIGHT_ANDROID (EGL_ANDROID_image_crop) -0x314B EGL_IMAGE_CROP_BOTTOM_ANDROID (EGL_ANDROID_image_crop) +0x3148 - 0x314B previously used by the undocumented, deprecated extension EGL_ANDROID_image_crop 0x314C EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID (EGL_ANDROID_front_buffer_auto_refresh) 0x314D EGL_GL_COLORSPACE_DEFAULT_EXT (EGL_EXT_image_gl_colorspace) 0x314E - 0x314F (unused) diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp index 87333d0ffd..d231790b41 100644 --- a/services/surfaceflinger/BufferLayerConsumer.cpp +++ b/services/surfaceflinger/BufferLayerConsumer.cpp @@ -280,14 +280,6 @@ status_t BufferLayerConsumer::acquireBufferLocked(BufferItem* item, nsecs_t pres 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 @@ status_t BufferLayerConsumer::bindTextureImageLocked() { 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 @@ void BufferLayerConsumer::computeCurrentTransformMatrixLocked() { 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(sp<GraphicBuffer> graphicBuffer, RE::RenderEng 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 f81cdb1d91..943b8a8103 100644 --- a/services/surfaceflinger/BufferLayerConsumer.h +++ b/services/surfaceflinger/BufferLayerConsumer.h @@ -228,9 +228,8 @@ private: 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 dc09a376bb..23480b412e 100644 --- a/services/surfaceflinger/RenderEngine/GLExtensions.cpp +++ b/services/surfaceflinger/RenderEngine/GLExtensions.cpp @@ -99,10 +99,6 @@ void GLExtensions::initWithEGLStrings(char const* eglVersion, char const* eglExt 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 0d8c10b0ac..a6a5053f89 100644 --- a/services/surfaceflinger/RenderEngine/GLExtensions.h +++ b/services/surfaceflinger/RenderEngine/GLExtensions.h @@ -39,7 +39,6 @@ class GLExtensions : public Singleton<GLExtensions> { bool mHasNativeFenceSync = false; bool mHasFenceSync = false; bool mHasWaitSync = false; - bool mHasImageCrop = false; bool mHasProtectedContent = false; bool mHasContextPriority = false; @@ -66,7 +65,6 @@ public: 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 0d06422a41..6e0a8803e9 100644 --- a/services/surfaceflinger/RenderEngine/Image.cpp +++ b/services/surfaceflinger/RenderEngine/Image.cpp @@ -33,11 +33,10 @@ namespace impl { 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 @@ static std::vector<EGLint> buildAttributeList(bool isProtected, int32_t cropWidt 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 @@ bool Image::setNativeWindowBuffer(ANativeWindowBuffer* buffer, bool isProtected, } 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 1ae7e09cba..c38fe0a2ff 100644 --- a/services/surfaceflinger/RenderEngine/Image.h +++ b/services/surfaceflinger/RenderEngine/Image.h @@ -29,8 +29,7 @@ namespace RE { 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 @@ public: 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 d745770bb7..0b8b83873f 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp +++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp @@ -175,10 +175,6 @@ EGLConfig RenderEngine::getEGLConfig() const { 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 1196216cbf..0b0bbf7688 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.h +++ b/services/surfaceflinger/RenderEngine/RenderEngine.h @@ -69,8 +69,6 @@ public: // 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 @@ public: // 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 ac082933a3..7caf8648ac 100644 --- a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h +++ b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h @@ -37,7 +37,6 @@ public: 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 @@ public: 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 |