ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2021, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
ramindani | deb059e | 2021-11-18 01:57:25 +0000 | [diff] [blame] | 18 | #include <aidl/android/hardware/graphics/composer3/BnComposerCallback.h> |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 19 | #include <android-base/thread_annotations.h> |
| 20 | #include <mutex> |
ramindani | 7ce70fe | 2022-02-10 18:08:09 +0000 | [diff] [blame] | 21 | #include <vector> |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 22 | |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 23 | namespace aidl::android::hardware::graphics::composer3::vts { |
| 24 | |
ramindani | deb059e | 2021-11-18 01:57:25 +0000 | [diff] [blame] | 25 | class GraphicsComposerCallback : public BnComposerCallback { |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 26 | public: |
| 27 | void setVsyncAllowed(bool allowed); |
| 28 | |
| 29 | std::vector<int64_t> getDisplays() const; |
| 30 | |
| 31 | int32_t getInvalidHotplugCount() const; |
| 32 | |
| 33 | int32_t getInvalidRefreshCount() const; |
| 34 | |
| 35 | int32_t getInvalidVsyncCount() const; |
| 36 | |
| 37 | int32_t getInvalidVsyncPeriodChangeCount() const; |
| 38 | |
| 39 | int32_t getInvalidSeamlessPossibleCount() const; |
| 40 | |
Midas Chien | a0b56bd | 2022-01-13 23:27:33 +0800 | [diff] [blame] | 41 | int32_t getVsyncIdleCount() const; |
| 42 | |
| 43 | int64_t getVsyncIdleTime() const; |
| 44 | |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 45 | std::optional<VsyncPeriodChangeTimeline> takeLastVsyncPeriodChangeTimeline(); |
| 46 | |
| 47 | private: |
| 48 | virtual ::ndk::ScopedAStatus onHotplug(int64_t in_display, bool in_connected) override; |
| 49 | virtual ::ndk::ScopedAStatus onRefresh(int64_t in_display) override; |
| 50 | virtual ::ndk::ScopedAStatus onSeamlessPossible(int64_t in_display) override; |
| 51 | virtual ::ndk::ScopedAStatus onVsync(int64_t in_display, int64_t in_timestamp, |
| 52 | int32_t in_vsyncPeriodNanos) override; |
| 53 | virtual ::ndk::ScopedAStatus onVsyncPeriodTimingChanged( |
| 54 | int64_t in_display, |
| 55 | const ::aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline& |
| 56 | in_updatedTimeline) override; |
Midas Chien | a0b56bd | 2022-01-13 23:27:33 +0800 | [diff] [blame] | 57 | virtual ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override; |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 58 | |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 59 | mutable std::mutex mMutex; |
| 60 | // the set of all currently connected displays |
ramindani | 7ce70fe | 2022-02-10 18:08:09 +0000 | [diff] [blame] | 61 | std::vector<int64_t> mDisplays GUARDED_BY(mMutex); |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 62 | // true only when vsync is enabled |
| 63 | bool mVsyncAllowed GUARDED_BY(mMutex) = true; |
| 64 | |
| 65 | std::optional<VsyncPeriodChangeTimeline> mTimeline GUARDED_BY(mMutex); |
| 66 | |
Midas Chien | a0b56bd | 2022-01-13 23:27:33 +0800 | [diff] [blame] | 67 | int32_t mVsyncIdleCount GUARDED_BY(mMutex) = 0; |
| 68 | int64_t mVsyncIdleTime GUARDED_BY(mMutex) = 0; |
| 69 | |
ramindani | 1cb794e | 2021-10-13 20:45:23 +0000 | [diff] [blame] | 70 | // track invalid callbacks |
| 71 | int32_t mInvalidHotplugCount GUARDED_BY(mMutex) = 0; |
| 72 | int32_t mInvalidRefreshCount GUARDED_BY(mMutex) = 0; |
| 73 | int32_t mInvalidVsyncCount GUARDED_BY(mMutex) = 0; |
| 74 | int32_t mInvalidVsyncPeriodChangeCount GUARDED_BY(mMutex) = 0; |
| 75 | int32_t mInvalidSeamlessPossibleCount GUARDED_BY(mMutex) = 0; |
| 76 | }; |
| 77 | |
Midas Chien | a0b56bd | 2022-01-13 23:27:33 +0800 | [diff] [blame] | 78 | } // namespace aidl::android::hardware::graphics::composer3::vts |