Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05b3da48 authored by Brian Lindahl's avatar Brian Lindahl Committed by Automerger Merge Worker
Browse files

Merge "Force HALs to explicitly enable legacy method for clearing buffer...

Merge "Force HALs to explicitly enable legacy method for clearing buffer caches" into udc-dev am: def2c211 am: 900a24cb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23715006



Change-Id: I3a1422bdbd090b0a3803bcc4cf2b1779d934bc72
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 58a338d2 900a24cb
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include "AidlComposerHal.h"

#include <SurfaceFlingerProperties.h>
#include <android-base/file.h>
#include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h>
@@ -249,7 +250,9 @@ AidlComposer::AidlComposer(const std::string& serviceName) {
        ALOGE("getInterfaceVersion for AidlComposer constructor failed %s",
              status.getDescription().c_str());
    }
    if (version == 1) {
    mSupportsBufferSlotsToClear = version > 1;
    if (!mSupportsBufferSlotsToClear) {
        if (sysprop::clear_slots_with_set_layer_buffer(false)) {
            mClearSlotBuffer = sp<GraphicBuffer>::make(1, 1, PIXEL_FORMAT_RGBX_8888,
                                                       GraphicBuffer::USAGE_HW_COMPOSER |
                                                               GraphicBuffer::USAGE_SW_READ_OFTEN |
@@ -260,6 +263,7 @@ AidlComposer::AidlComposer(const std::string& serviceName) {
                return;
            }
        }
    }

    ALOGI("Loaded AIDL composer3 HAL service");
}
@@ -844,12 +848,12 @@ Error AidlComposer::setLayerBufferSlotsToClear(Display display, Layer layer,
    Error error = Error::NONE;
    mMutex.lock_shared();
    if (auto writer = getWriter(display)) {
        // Backwards compatible way of clearing buffer is to set the layer buffer with a placeholder
        // buffer, using the slot that needs to cleared... tricky.
        if (mClearSlotBuffer == nullptr) {
        if (mSupportsBufferSlotsToClear) {
            writer->get().setLayerBufferSlotsToClear(translate<int64_t>(display),
                                                     translate<int64_t>(layer), slotsToClear);
        } else {
            // Backwards compatible way of clearing buffer slots is to set the layer buffer with a
            // placeholder buffer, using the slot that needs to cleared... tricky.
        } else if (mClearSlotBuffer != nullptr) {
            for (uint32_t slot : slotsToClear) {
                // Don't clear the active buffer slot because we need to restore the active buffer
                // after clearing the requested buffer slots with a placeholder buffer.
+2 −0
Original line number Diff line number Diff line
@@ -285,6 +285,8 @@ private:
    // threading annotations.
    ftl::SharedMutex mMutex;

    // Whether or not explicitly clearing buffer slots is supported.
    bool mSupportsBufferSlotsToClear;
    // Buffer slots for layers are cleared by setting the slot buffer to this buffer.
    sp<GraphicBuffer> mClearSlotBuffer;

+11 −2
Original line number Diff line number Diff line
@@ -24,12 +24,14 @@

#include "HidlComposerHal.h"

#include <SurfaceFlingerProperties.h>
#include <android/binder_manager.h>
#include <composer-command-buffer/2.2/ComposerCommandBuffer.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/HidlTransportUtils.h>
#include <log/log.h>
#include <utils/Trace.h>

#include "HWC2.h"
#include "Hal.h"

@@ -189,6 +191,9 @@ std::vector<To> translate(const hidl_vec<From>& in) {
}

sp<GraphicBuffer> allocateClearSlotBuffer() {
    if (!sysprop::clear_slots_with_set_layer_buffer(false)) {
        return nullptr;
    }
    sp<GraphicBuffer> buffer = sp<GraphicBuffer>::make(1, 1, PIXEL_FORMAT_RGBX_8888,
                                                       GraphicBuffer::USAGE_HW_COMPOSER |
                                                               GraphicBuffer::USAGE_SW_READ_OFTEN |
@@ -246,7 +251,7 @@ HidlComposer::HidlComposer(const std::string& serviceName)
        LOG_ALWAYS_FATAL("failed to create composer client");
    }

    if (!mClearSlotBuffer) {
    if (!mClearSlotBuffer && sysprop::clear_slots_with_set_layer_buffer(false)) {
        LOG_ALWAYS_FATAL("Failed to allocate a buffer for clearing layer buffer slots");
        return;
    }
@@ -716,6 +721,10 @@ Error HidlComposer::setLayerBufferSlotsToClear(Display display, Layer layer,
    if (slotsToClear.empty()) {
        return Error::NONE;
    }
    // This can be null when the HAL hasn't explicitly enabled this feature.
    if (mClearSlotBuffer == nullptr) {
        return Error::NONE;
    }
    //  Backwards compatible way of clearing buffer is to set the layer buffer with a placeholder
    // buffer, using the slot that needs to cleared... tricky.
    for (uint32_t slot : slotsToClear) {
+4 −0
Original line number Diff line number Diff line
@@ -375,5 +375,9 @@ bool ignore_hdr_camera_layers(bool defaultValue) {
    return SurfaceFlingerProperties::ignore_hdr_camera_layers().value_or(defaultValue);
}

bool clear_slots_with_set_layer_buffer(bool defaultValue) {
    return SurfaceFlingerProperties::clear_slots_with_set_layer_buffer().value_or(defaultValue);
}

} // namespace sysprop
} // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ bool enable_sdr_dimming(bool defaultValue);

bool ignore_hdr_camera_layers(bool defaultValue);

bool clear_slots_with_set_layer_buffer(bool defaultValue);

} // namespace sysprop
} // namespace android
#endif // SURFACEFLINGERPROPERTIES_H_
Loading