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

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

Merge "composer: vts: send a refresh command when required + test fix"

parents 457c1469 5f9f9a45
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ cc_library_static {
    defaults: ["hidl_defaults"],
    srcs: [
        "ComposerVts.cpp",
        "GraphicsComposerCallback.cpp",
    ],
    static_libs: [
        "VtsHalHidlTargetTestBase",
+4 −0
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@ int32_t ComposerClient::getDisplayAttribute_2_4(
    return value;
}

void ComposerClient::registerCallback_2_4(const sp<IComposerCallback>& callback) {
    mClient->registerCallback_2_4(callback);
}

Error ComposerClient::getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) {
    Error error = Error::NONE;
    mClient->getDisplayVsyncPeriod(display, [&](const auto& tmpError, const auto& tmpVsyncPeriod) {
+137 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <composer-vts/2.4/GraphicsComposerCallback.h>

namespace android::hardware::graphics::composer::V2_4::vts {

void GraphicsComposerCallback::setVsyncAllowed(bool allowed) {
    std::lock_guard<std::mutex> lock(mMutex);
    mVsyncAllowed = allowed;
}

std::vector<Display> GraphicsComposerCallback::getDisplays() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return std::vector<Display>(mDisplays.begin(), mDisplays.end());
}

int32_t GraphicsComposerCallback::getInvalidHotplugCount() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return mInvalidHotplugCount;
}

int32_t GraphicsComposerCallback::getInvalidRefreshCount() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return mInvalidRefreshCount;
}

int32_t GraphicsComposerCallback::getInvalidVsyncCount() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return mInvalidVsyncCount;
}

int32_t GraphicsComposerCallback::getInvalidVsync_2_4Count() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return mInvalidVsync_2_4Count;
}

int32_t GraphicsComposerCallback::getInvalidVsyncPeriodChangeCount() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return mInvalidVsyncPeriodChangeCount;
}

int32_t GraphicsComposerCallback::getInvalidSeamlessPossibleCount() const {
    std::lock_guard<std::mutex> lock(mMutex);
    return mInvalidSeamlessPossibleCount;
}

std::optional<VsyncPeriodChangeTimeline>
GraphicsComposerCallback::takeLastVsyncPeriodChangeTimeline() {
    std::lock_guard<std::mutex> lock(mMutex);

    std::optional<VsyncPeriodChangeTimeline> ret;
    ret.swap(mTimeline);

    return ret;
}

Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection connection) {
    std::lock_guard<std::mutex> lock(mMutex);

    if (connection == Connection::CONNECTED) {
        if (!mDisplays.insert(display).second) {
            mInvalidHotplugCount++;
        }
    } else if (connection == Connection::DISCONNECTED) {
        if (!mDisplays.erase(display)) {
            mInvalidHotplugCount++;
        }
    }

    return Void();
}

Return<void> GraphicsComposerCallback::onRefresh(Display display) {
    std::lock_guard<std::mutex> lock(mMutex);

    if (mDisplays.count(display) == 0) {
        mInvalidRefreshCount++;
    }

    return Void();
}

Return<void> GraphicsComposerCallback::onVsync(Display, int64_t) {
    std::lock_guard<std::mutex> lock(mMutex);

    // On composer 2.4, onVsync is not expected at all
    mInvalidVsyncCount++;

    return Void();
}

Return<void> GraphicsComposerCallback::onVsync_2_4(Display display, int64_t, VsyncPeriodNanos) {
    std::lock_guard<std::mutex> lock(mMutex);

    if (!mVsyncAllowed || mDisplays.count(display) == 0) {
        mInvalidVsync_2_4Count++;
    }

    return Void();
}

Return<void> GraphicsComposerCallback::onVsyncPeriodTimingChanged(
        Display display, const VsyncPeriodChangeTimeline& updatedTimeline) {
    std::lock_guard<std::mutex> lock(mMutex);

    if (mDisplays.count(display) == 0) {
        mInvalidVsyncPeriodChangeCount++;
    }

    mTimeline = updatedTimeline;

    return Void();
}

Return<void> GraphicsComposerCallback::onSeamlessPossible(Display) {
    std::lock_guard<std::mutex> lock(mMutex);

    mInvalidSeamlessPossibleCount++;

    return Void();
}

}  // namespace android::hardware::graphics::composer::V2_4::vts
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ class ComposerClient : public V2_3::vts::ComposerClient {
    int32_t getDisplayAttribute_2_4(Display display, Config config,
                                    IComposerClient::Attribute attribute);

    void registerCallback_2_4(const sp<IComposerCallback>& callback);

    Error getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriods);

    Error setActiveConfigWithConstraints(
+74 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include <android/hardware/graphics/composer/2.4/IComposerCallback.h>

#include <mutex>
#include <unordered_set>

namespace android::hardware::graphics::composer::V2_4::vts {

using Display = V2_1::Display;

// IComposerCallback to be installed with IComposerClient::registerCallback.
class GraphicsComposerCallback : public IComposerCallback {
  public:
    void setVsyncAllowed(bool allowed);

    std::vector<Display> getDisplays() const;

    int32_t getInvalidHotplugCount() const;

    int32_t getInvalidRefreshCount() const;

    int32_t getInvalidVsyncCount() const;

    int32_t getInvalidVsync_2_4Count() const;

    int32_t getInvalidVsyncPeriodChangeCount() const;

    int32_t getInvalidSeamlessPossibleCount() const;

    std::optional<VsyncPeriodChangeTimeline> takeLastVsyncPeriodChangeTimeline();

  private:
    Return<void> onHotplug(Display display, Connection connection) override;
    Return<void> onRefresh(Display display) override;
    Return<void> onVsync(Display display, int64_t) override;
    Return<void> onVsync_2_4(Display display, int64_t, VsyncPeriodNanos vsyncPeriodNanos) override;
    Return<void> onVsyncPeriodTimingChanged(
            Display display, const VsyncPeriodChangeTimeline& updatedTimeline) override;
    Return<void> onSeamlessPossible(Display display) override;

    mutable std::mutex mMutex;
    // the set of all currently connected displays
    std::unordered_set<Display> mDisplays;
    // true only when vsync is enabled
    bool mVsyncAllowed = true;

    std::optional<VsyncPeriodChangeTimeline> mTimeline;

    // track invalid callbacks
    int32_t mInvalidHotplugCount = 0;
    int32_t mInvalidRefreshCount = 0;
    int32_t mInvalidVsyncCount = 0;
    int32_t mInvalidVsync_2_4Count = 0;
    int32_t mInvalidVsyncPeriodChangeCount = 0;
    int32_t mInvalidSeamlessPossibleCount = 0;
};

}  // namespace android::hardware::graphics::composer::V2_4::vts
Loading