Revert "Revert "Use renderengine::drawLayers api everywhere.""
This reverts commit 79108df863d454369ee61cdb70f6d14c8414e30e.
Reason for revert: merged in forward fix - GL_BLEND is now explictly
disabled before initially clearing the buffer.
Bug: 118461793
Test: b/123878751 cannot be reproduced.
Change-Id: Ia49163b40016e746500d9954e1863d0706bc65e1
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 6826050..7ed8184 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -272,6 +272,7 @@
// Update the BufferLayerConsumer state.
mCurrentTexture = slot;
mCurrentTextureBuffer = nextTextureBuffer;
+ mCurrentTextureBufferStaleForGpu = false;
mCurrentTextureImageFreed = nullptr;
mCurrentCrop = item.mCrop;
mCurrentTransform = item.mTransform;
@@ -294,48 +295,7 @@
status_t BufferLayerConsumer::bindTextureImageLocked() {
ATRACE_CALL();
- mRE.checkErrors();
-
- // It is possible for the current slot's buffer to be freed before a new one
- // is bound. In that scenario we still want to bind the image.
- if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT && mCurrentTextureBuffer == nullptr) {
- BLC_LOGE("bindTextureImage: no currently-bound texture");
- mRE.bindExternalTextureImage(mTexName, *mRE.createImage());
- return NO_INIT;
- }
-
- renderengine::Image* imageToRender;
-
- // mCurrentTextureImageFreed is non-null iff mCurrentTexture ==
- // BufferQueue::INVALID_BUFFER_SLOT, so we can omit that check.
- if (mCurrentTextureImageFreed) {
- imageToRender = mCurrentTextureImageFreed.get();
- } else if (mImages[mCurrentTexture]) {
- imageToRender = mImages[mCurrentTexture].get();
- } else {
- std::unique_ptr<renderengine::Image> image = mRE.createImage();
- bool success = image->setNativeWindowBuffer(mCurrentTextureBuffer->getNativeBuffer(),
- mCurrentTextureBuffer->getUsage() &
- GRALLOC_USAGE_PROTECTED);
- if (!success) {
- BLC_LOGE("bindTextureImage: Failed to create image. size=%ux%u st=%u usage=%#" PRIx64
- " fmt=%d",
- mCurrentTextureBuffer->getWidth(), mCurrentTextureBuffer->getHeight(),
- mCurrentTextureBuffer->getStride(), mCurrentTextureBuffer->getUsage(),
- mCurrentTextureBuffer->getPixelFormat());
- BLC_LOGW("bindTextureImage: can't create image on slot=%d", mCurrentTexture);
- mRE.bindExternalTextureImage(mTexName, *image);
- return UNKNOWN_ERROR;
- }
- imageToRender = image.get();
- // Cache the image here so that we can reuse it.
- mImages[mCurrentTexture] = std::move(image);
- }
-
- mRE.bindExternalTextureImage(mTexName, *imageToRender);
-
- // Wait for the new buffer to be ready.
- return doFenceWaitLocked();
+ return mRE.bindExternalTextureBuffer(mTexName, mCurrentTextureBuffer, mCurrentFence, false);
}
status_t BufferLayerConsumer::syncForReleaseLocked(const sp<Fence>& releaseFence) {
@@ -433,16 +393,29 @@
return mCurrentApi;
}
-sp<GraphicBuffer> BufferLayerConsumer::getCurrentBuffer(int* outSlot) const {
+sp<GraphicBuffer> BufferLayerConsumer::getCurrentBuffer(int* outSlot, sp<Fence>* outFence) const {
Mutex::Autolock lock(mMutex);
if (outSlot != nullptr) {
*outSlot = mCurrentTexture;
}
+ if (outFence != nullptr) {
+ *outFence = mCurrentFence;
+ }
+
return mCurrentTextureBuffer;
}
+bool BufferLayerConsumer::getAndSetCurrentBufferCacheHint() {
+ Mutex::Autolock lock(mMutex);
+ bool useCache = mCurrentTextureBufferStaleForGpu;
+ // Set the staleness bit here, as this function is only called during a
+ // client composition path.
+ mCurrentTextureBufferStaleForGpu = true;
+ return useCache;
+}
+
Rect BufferLayerConsumer::getCurrentCrop() const {
Mutex::Autolock lock(mMutex);
return (mCurrentScalingMode == NATIVE_WINDOW_SCALING_MODE_SCALE_CROP)