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

Commit b533046e 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

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



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


#include "AidlComposerHal.h"
#include "AidlComposerHal.h"


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


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


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


#include "HidlComposerHal.h"
#include "HidlComposerHal.h"


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

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


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


sp<GraphicBuffer> allocateClearSlotBuffer() {
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,
    sp<GraphicBuffer> buffer = sp<GraphicBuffer>::make(1, 1, PIXEL_FORMAT_RGBX_8888,
                                                       GraphicBuffer::USAGE_HW_COMPOSER |
                                                       GraphicBuffer::USAGE_HW_COMPOSER |
                                                               GraphicBuffer::USAGE_SW_READ_OFTEN |
                                                               GraphicBuffer::USAGE_SW_READ_OFTEN |
@@ -246,7 +251,7 @@ HidlComposer::HidlComposer(const std::string& serviceName)
        LOG_ALWAYS_FATAL("failed to create composer client");
        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");
        LOG_ALWAYS_FATAL("Failed to allocate a buffer for clearing layer buffer slots");
        return;
        return;
    }
    }
@@ -716,6 +721,10 @@ Error HidlComposer::setLayerBufferSlotsToClear(Display display, Layer layer,
    if (slotsToClear.empty()) {
    if (slotsToClear.empty()) {
        return Error::NONE;
        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
    //  Backwards compatible way of clearing buffer is to set the layer buffer with a placeholder
    // buffer, using the slot that needs to cleared... tricky.
    // buffer, using the slot that needs to cleared... tricky.
    for (uint32_t slot : slotsToClear) {
    for (uint32_t slot : slotsToClear) {
+4 −0
Original line number Original line 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);
    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 sysprop
} // namespace android
} // namespace android
+2 −0
Original line number Original line Diff line number Diff line
@@ -102,6 +102,8 @@ bool enable_sdr_dimming(bool defaultValue);


bool ignore_hdr_camera_layers(bool defaultValue);
bool ignore_hdr_camera_layers(bool defaultValue);


bool clear_slots_with_set_layer_buffer(bool defaultValue);

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