summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurtuza Raja <quic_mraja@quicinc.com>2022-04-16 10:57:44 +0530
committerMurtuza Raja <quic_mraja@quicinc.com>2022-04-16 10:58:53 +0530
commit41072e7c8c5c3f03c051b2689bc88e51c03d25e4 (patch)
treefa9616b8965b8d391b2fd3c3b6dd1b281b5dffc0
parent4c1c677f971065a40a79fc7db0b81f27f3e67f7a (diff)
parentc2d8c62c743da5ba1bb6b8a40cf066ff0b607eb6 (diff)
Merge commit 'c2d8c62c743da5ba1bb6b8a40cf066ff0b607eb6' into ks-aosp.lnx.12.0.r1-rel
Change-Id: I37d9d228b86752974fab86facb0fbcbbd16ab9f3
-rw-r--r--libs/nativedisplay/include/surfacetexture/EGLConsumer.h3
-rw-r--r--libs/nativedisplay/surfacetexture/EGLConsumer.cpp19
-rw-r--r--libs/ui/include/ui/GraphicBuffer.h5
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.cpp11
4 files changed, 35 insertions, 3 deletions
diff --git a/libs/nativedisplay/include/surfacetexture/EGLConsumer.h b/libs/nativedisplay/include/surfacetexture/EGLConsumer.h
index 444722bf83..5fe8ce60ef 100644
--- a/libs/nativedisplay/include/surfacetexture/EGLConsumer.h
+++ b/libs/nativedisplay/include/surfacetexture/EGLConsumer.h
@@ -21,6 +21,7 @@
#include <gui/BufferQueueDefs.h>
#include <ui/FenceTime.h>
#include <ui/GraphicBuffer.h>
+#include <ui/GraphicTypes.h>
#include <utils/Mutex.h>
namespace android {
@@ -198,7 +199,7 @@ protected:
// mGraphicBuffer is the buffer that was used to create this image.
sp<GraphicBuffer> mGraphicBuffer;
-
+ ui::Dataspace mDataSpace;
// mEglImage is the EGLImage created from mGraphicBuffer.
EGLImageKHR mEglImage;
diff --git a/libs/nativedisplay/surfacetexture/EGLConsumer.cpp b/libs/nativedisplay/surfacetexture/EGLConsumer.cpp
index 2f31888bf6..96d063b43d 100644
--- a/libs/nativedisplay/surfacetexture/EGLConsumer.cpp
+++ b/libs/nativedisplay/surfacetexture/EGLConsumer.cpp
@@ -601,7 +601,9 @@ void EGLConsumer::onAbandonLocked() {
}
EGLConsumer::EglImage::EglImage(sp<GraphicBuffer> graphicBuffer)
- : mGraphicBuffer(graphicBuffer), mEglImage(EGL_NO_IMAGE_KHR), mEglDisplay(EGL_NO_DISPLAY) {}
+ : mGraphicBuffer(graphicBuffer), mEglImage(EGL_NO_IMAGE_KHR), mEglDisplay(EGL_NO_DISPLAY) {
+ mDataSpace = ui::Dataspace::UNKNOWN;
+}
EGLConsumer::EglImage::~EglImage() {
if (mEglImage != EGL_NO_IMAGE_KHR) {
@@ -616,7 +618,16 @@ status_t EGLConsumer::EglImage::createIfNeeded(EGLDisplay eglDisplay, bool force
// If there's an image and it's no longer valid, destroy it.
bool haveImage = mEglImage != EGL_NO_IMAGE_KHR;
bool displayInvalid = mEglDisplay != eglDisplay;
- if (haveImage && (displayInvalid || forceCreation)) {
+
+ ui::Dataspace dataspace;
+ bool dataspaceChanged = false;
+ if (mGraphicBuffer->getDataspace(&dataspace) == 0 ) {
+ dataspaceChanged = (mDataSpace != dataspace)? true:false;
+ if(dataspaceChanged)
+ ALOGI("createIfNeeded: Recreate new EGLImage since dataspace changed");
+ }
+
+ if (haveImage && (displayInvalid || forceCreation || dataspaceChanged)) {
if (!eglDestroyImageKHR(mEglDisplay, mEglImage)) {
ALOGE("createIfNeeded: eglDestroyImageKHR failed");
}
@@ -640,6 +651,10 @@ status_t EGLConsumer::EglImage::createIfNeeded(EGLDisplay eglDisplay, bool force
buffer->getPixelFormat());
return UNKNOWN_ERROR;
}
+
+ if (dataspaceChanged) {
+ mDataSpace = dataspace;
+ }
return OK;
}
diff --git a/libs/ui/include/ui/GraphicBuffer.h b/libs/ui/include/ui/GraphicBuffer.h
index 57be686592..542da2cdd0 100644
--- a/libs/ui/include/ui/GraphicBuffer.h
+++ b/libs/ui/include/ui/GraphicBuffer.h
@@ -29,6 +29,7 @@
#include <ui/GraphicBufferMapper.h>
#include <ui/PixelFormat.h>
#include <ui/Rect.h>
+#include <ui/GraphicTypes.h>
#include <utils/Flattenable.h>
#include <utils/RefBase.h>
@@ -155,6 +156,10 @@ public:
Rect getBounds() const { return Rect(width, height); }
uint64_t getId() const { return mId; }
+ status_t getDataspace(ui::Dataspace* outDataspace){
+ return mBufferMapper.getDataspace(handle, outDataspace);
+ }
+
uint32_t getGenerationNumber() const { return mGenerationNumber; }
void setGenerationNumber(uint32_t generation) {
mGenerationNumber = generation;
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 07de93f49b..f0405fb232 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -559,6 +559,13 @@ status_t HWComposer::getDeviceCompositionChanges(
sp<Fence> HWComposer::getPresentFence(HalDisplayId displayId) const {
RETURN_IF_INVALID_DISPLAY(displayId, Fence::NO_FENCE);
+
+ auto& hwcDisplay = mDisplayData.at(displayId).hwcDisplay;
+
+ if (!hwcDisplay->isConnected()) {
+ return Fence::NO_FENCE;
+ }
+
return mDisplayData.at(displayId).lastPresentFence;
}
@@ -583,6 +590,10 @@ status_t HWComposer::presentAndGetReleaseFences(
auto& displayData = mDisplayData[displayId];
auto& hwcDisplay = displayData.hwcDisplay;
+ if (!hwcDisplay->isConnected()) {
+ return NO_ERROR;
+ }
+
if (displayData.validateWasSkipped) {
displayData.validateWasSkipped = false;
// explicitly flush all pending commands