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

Commit cfb660d1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "hwc3_idle_timer_control"

* changes:
  sf: change the mock method for callback APIs
  sf: Add basic implementation of onVsyncIdle
parents e1d18723 1a417af2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:
    HWComposer();
    ~HWComposer() override;

    MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback*));
    MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback&));
    MOCK_CONST_METHOD3(getDisplayIdentificationData,
                       bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*));
    MOCK_CONST_METHOD1(hasCapability, bool(hal::Capability));
+22 −12
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#include <algorithm>
#include <cinttypes>

#include "HWC2.h"

namespace android {

using hardware::hidl_handle;
@@ -169,40 +171,47 @@ mat4 makeMat4(std::vector<float> in) {

class AidlIComposerCallbackWrapper : public BnComposerCallback {
public:
    AidlIComposerCallbackWrapper(sp<V2_4::IComposerCallback> callback)
          : mCallback(std::move(callback)) {}
    AidlIComposerCallbackWrapper(HWC2::ComposerCallback& callback) : mCallback(callback) {}

    ::ndk::ScopedAStatus onHotplug(int64_t in_display, bool in_connected) override {
        const auto connection = in_connected ? V2_4::IComposerCallback::Connection::CONNECTED
                                             : V2_4::IComposerCallback::Connection::DISCONNECTED;
        mCallback->onHotplug(translate<Display>(in_display), connection);
        mCallback.onComposerHalHotplug(translate<Display>(in_display), connection);
        return ::ndk::ScopedAStatus::ok();
    }

    ::ndk::ScopedAStatus onRefresh(int64_t in_display) override {
        mCallback->onRefresh(translate<Display>(in_display));
        mCallback.onComposerHalRefresh(translate<Display>(in_display));
        return ::ndk::ScopedAStatus::ok();
    }

    ::ndk::ScopedAStatus onSeamlessPossible(int64_t in_display) override {
        mCallback->onSeamlessPossible(translate<Display>(in_display));
        mCallback.onComposerHalSeamlessPossible(translate<Display>(in_display));
        return ::ndk::ScopedAStatus::ok();
    }

    ::ndk::ScopedAStatus onVsync(int64_t in_display, int64_t in_timestamp,
                                 int32_t in_vsyncPeriodNanos) override {
        mCallback->onVsync_2_4(translate<Display>(in_display), in_timestamp,
        mCallback.onComposerHalVsync(translate<Display>(in_display), in_timestamp,
                                     static_cast<uint32_t>(in_vsyncPeriodNanos));
        return ::ndk::ScopedAStatus::ok();
    }

    ::ndk::ScopedAStatus onVsyncPeriodTimingChanged(
            int64_t in_display, const AidlVsyncPeriodChangeTimeline& in_updatedTimeline) override {
        mCallback->onVsyncPeriodTimingChanged(translate<Display>(in_display),
        mCallback.onComposerHalVsyncPeriodTimingChanged(translate<Display>(in_display),
                                                        translate<V2_4::VsyncPeriodChangeTimeline>(
                                                                in_updatedTimeline));
        return ::ndk::ScopedAStatus::ok();
    }

    ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override {
        mCallback.onComposerHalVsyncIdle(translate<Display>(in_display));
        return ::ndk::ScopedAStatus::ok();
    }

private:
    sp<V2_4::IComposerCallback> mCallback;
    HWC2::ComposerCallback& mCallback;
};

std::string AidlComposer::instance(const std::string& serviceName) {
@@ -262,10 +271,11 @@ std::string AidlComposer::dumpDebugInfo() {
    return info;
}

void AidlComposer::registerCallback(const sp<IComposerCallback>& callback) {
void AidlComposer::registerCallback(HWC2::ComposerCallback& callback) {
    if (mAidlComposerCallback) {
        ALOGE("Callback already registered");
    }

    mAidlComposerCallback = ndk::SharedRefBase::make<AidlIComposerCallbackWrapper>(callback);
    AIBinder_setMinSchedulerPolicy(mAidlComposerCallback->asBinder().get(), SCHED_FIFO, 2);

+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public:
    std::vector<IComposer::Capability> getCapabilities() override;
    std::string dumpDebugInfo() override;

    void registerCallback(const sp<IComposerCallback>& callback) override;
    void registerCallback(HWC2::ComposerCallback& callback) override;

    // Reset all pending commands in the command buffer. Useful if you want to
    // skip a frame but have already queued some commands.
+15 −10
Original line number Diff line number Diff line
@@ -34,11 +34,17 @@
#include <aidl/android/hardware/graphics/composer3/Color.h>
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
#include <aidl/android/hardware/graphics/composer3/IComposerCallback.h>

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion -Wextra"

namespace android::Hwc2 {
namespace android {
namespace HWC2 {
struct ComposerCallback;
} // namespace HWC2

namespace Hwc2 {

namespace types = hardware::graphics::common;

@@ -46,6 +52,7 @@ namespace V2_1 = hardware::graphics::composer::V2_1;
namespace V2_2 = hardware::graphics::composer::V2_2;
namespace V2_3 = hardware::graphics::composer::V2_3;
namespace V2_4 = hardware::graphics::composer::V2_4;
namespace V3_0 = ::aidl::android::hardware::graphics::composer3;

using types::V1_0::ColorTransform;
using types::V1_0::Transform;
@@ -89,7 +96,7 @@ public:
    virtual std::vector<IComposer::Capability> getCapabilities() = 0;
    virtual std::string dumpDebugInfo() = 0;

    virtual void registerCallback(const sp<IComposerCallback>& callback) = 0;
    virtual void registerCallback(HWC2::ComposerCallback& callback) = 0;

    // Reset all pending commands in the command buffer. Useful if you want to
    // skip a frame but have already queued some commands.
@@ -109,9 +116,8 @@ public:
    virtual Error destroyLayer(Display display, Layer layer) = 0;

    virtual Error getActiveConfig(Display display, Config* outConfig) = 0;
    virtual Error getChangedCompositionTypes(
            Display display, std::vector<Layer>* outLayers,
            std::vector<aidl::android::hardware::graphics::composer3::Composition>* outTypes) = 0;
    virtual Error getChangedCompositionTypes(Display display, std::vector<Layer>* outLayers,
                                             std::vector<V3_0::Composition>* outTypes) = 0;
    virtual Error getColorModes(Display display, std::vector<ColorMode>* outModes) = 0;
    virtual Error getDisplayAttribute(Display display, Config config,
                                      IComposerClient::Attribute attribute, int32_t* outValue) = 0;
@@ -225,10 +231,8 @@ public:
                                       const DisplayBrightnessOptions& options) = 0;

    // Composer HAL 2.4
    virtual Error getDisplayCapabilities(
            Display display,
            std::vector<aidl::android::hardware::graphics::composer3::DisplayCapability>*
                    outCapabilities) = 0;
    virtual Error getDisplayCapabilities(Display display,
                                         std::vector<V3_0::DisplayCapability>* outCapabilities) = 0;
    virtual V2_4::Error getDisplayConnectionType(
            Display display, IComposerClient::DisplayConnectionType* outType) = 0;
    virtual V2_4::Error getDisplayVsyncPeriod(Display display,
@@ -263,4 +267,5 @@ public:
    virtual Error getPreferredBootDisplayConfig(Display displayId, Config*) = 0;
};

} // namespace android::Hwc2
} // namespace Hwc2
} // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ struct ComposerCallback {
    virtual void onComposerHalVsyncPeriodTimingChanged(hal::HWDisplayId,
                                                       const hal::VsyncPeriodChangeTimeline&) = 0;
    virtual void onComposerHalSeamlessPossible(hal::HWDisplayId) = 0;
    virtual void onComposerHalVsyncIdle(hal::HWDisplayId) = 0;

protected:
    ~ComposerCallback() = default;
Loading