diff options
| -rw-r--r-- | libs/gui/Surface.cpp | 23 | ||||
| -rw-r--r-- | libs/gui/include/gui/Surface.h | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 6 |
3 files changed, 22 insertions, 8 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 93b41914bf..e6eb327c6f 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -829,8 +829,9 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { mDefaultHeight = output.height; mNextFrameNumber = output.nextFrameNumber; - // Disable transform hint if sticky transform is set. - if (mStickyTransform == 0) { + // Ignore transform hint if sticky transform is set or transform to display inverse flag is + // set. + if (mStickyTransform == 0 && !transformToDisplayInverse()) { mTransformHint = output.transformHint; } @@ -1271,6 +1272,11 @@ int Surface::dispatchGetConsumerUsage64(va_list args) { return getConsumerUsage(usage); } +bool Surface::transformToDisplayInverse() { + return (mTransform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) == + NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; +} + int Surface::connect(int api) { static sp<IProducerListener> listener = new DummyProducerListener(); return connect(api, listener); @@ -1293,8 +1299,10 @@ int Surface::connect( mDefaultHeight = output.height; mNextFrameNumber = output.nextFrameNumber; - // Disable transform hint if sticky transform is set. - if (mStickyTransform == 0) { + // Ignore transform hint if sticky transform is set or transform to display inverse flag is + // set. Transform hint should be ignored if the client is expected to always submit buffers + // in the same orientation. + if (mStickyTransform == 0 && !transformToDisplayInverse()) { mTransformHint = output.transformHint; } @@ -1591,6 +1599,13 @@ int Surface::setBuffersTransform(uint32_t transform) ATRACE_CALL(); ALOGV("Surface::setBuffersTransform"); Mutex::Autolock lock(mMutex); + // Ensure NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY is sticky. If the client sets the flag, do not + // override it until the surface is disconnected. This is a temporary workaround for camera + // until they switch to using Buffer State Layers. Currently if client sets the buffer transform + // it may be overriden by the buffer producer when the producer sets the buffer transform. + if (transformToDisplayInverse()) { + transform |= NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; + } mTransform = transform; return NO_ERROR; } diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h index 248e105d04..0c471bb701 100644 --- a/libs/gui/include/gui/Surface.h +++ b/libs/gui/include/gui/Surface.h @@ -230,6 +230,7 @@ private: int dispatchGetWideColorSupport(va_list args); int dispatchGetHdrSupport(va_list args); int dispatchGetConsumerUsage64(va_list args); + bool transformToDisplayInverse(); protected: virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd); diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 2bbac72ffe..1527c34122 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -1230,10 +1230,8 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const { void Layer::updateTransformHint(const sp<const DisplayDevice>& display) const { uint32_t orientation = 0; - // Disable setting transform hint if the debug flag is set or if the - // getTransformToDisplayInverse flag is set and the client wants to submit buffers - // in one orientation. - if (!mFlinger->mDebugDisableTransformHint && !getTransformToDisplayInverse()) { + // Disable setting transform hint if the debug flag is set. + if (!mFlinger->mDebugDisableTransformHint) { // The transform hint is used to improve performance, but we can // only have a single transform hint, it cannot // apply to all displays. |