1 /* 2 * Copyright 2024 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 17 #pragma once 18 19 #include <gmock/gmock.h> 20 21 #include "DisplayHardware/HWComposer.h" 22 23 namespace android::mock { 24 25 class HWComposer : public android::HWComposer { 26 public: 27 using HWDisplayId = android::hardware::graphics::composer::hal::HWDisplayId; 28 using PowerMode = android::hardware::graphics::composer::hal::PowerMode; 29 30 HWComposer(); 31 ~HWComposer() override; 32 33 MOCK_METHOD(void, setCallback, (HWC2::ComposerCallback&), (override)); 34 MOCK_METHOD(bool, getDisplayIdentificationData, 35 (HWDisplayId, uint8_t*, DisplayIdentificationData*), (const, override)); 36 MOCK_METHOD(bool, hasCapability, (aidl::android::hardware::graphics::composer3::Capability), 37 (const, override)); 38 MOCK_METHOD(bool, hasDisplayCapability, 39 (HalDisplayId, aidl::android::hardware::graphics::composer3::DisplayCapability), 40 (const, override)); 41 42 MOCK_METHOD(size_t, getMaxVirtualDisplayCount, (), (const, override)); 43 MOCK_METHOD(size_t, getMaxVirtualDisplayDimension, (), (const, override)); 44 MOCK_METHOD(bool, allocateVirtualDisplay, (HalVirtualDisplayId, ui::Size, ui::PixelFormat*), 45 (override)); 46 MOCK_METHOD(void, allocatePhysicalDisplay, 47 (hal::HWDisplayId, PhysicalDisplayId, uint8_t port, std::optional<ui::Size>), 48 (override)); 49 50 MOCK_METHOD(std::shared_ptr<HWC2::Layer>, createLayer, (HalDisplayId), (override)); 51 MOCK_METHOD(status_t, getDeviceCompositionChanges, 52 (HalDisplayId, bool, std::optional<std::chrono::steady_clock::time_point>, nsecs_t, 53 Fps, std::optional<android::HWComposer::DeviceRequestedChanges>*)); 54 MOCK_METHOD(status_t, setClientTarget, 55 (HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&, ui::Dataspace, 56 float), 57 (override)); 58 MOCK_METHOD(status_t, presentAndGetReleaseFences, 59 (HalDisplayId, std::optional<std::chrono::steady_clock::time_point>), (override)); 60 MOCK_METHOD(status_t, executeCommands, (HalDisplayId)); 61 MOCK_METHOD(status_t, setPowerMode, (PhysicalDisplayId, PowerMode), (override)); 62 MOCK_METHOD(status_t, setColorTransform, (HalDisplayId, const mat4&), (override)); 63 MOCK_METHOD(void, disconnectDisplay, (HalDisplayId), (override)); 64 MOCK_METHOD(sp<Fence>, getPresentFence, (HalDisplayId), (const, override)); 65 MOCK_METHOD(nsecs_t, getPresentTimestamp, (PhysicalDisplayId), (const, override)); 66 MOCK_METHOD(sp<Fence>, getLayerReleaseFence, (HalDisplayId, HWC2::Layer*), (const, override)); 67 MOCK_METHOD(status_t, setOutputBuffer, 68 (HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&), (override)); 69 MOCK_METHOD(void, clearReleaseFences, (HalDisplayId), (override)); 70 MOCK_METHOD(status_t, getHdrCapabilities, (HalDisplayId, HdrCapabilities*), (override)); 71 MOCK_METHOD(int32_t, getSupportedPerFrameMetadata, (HalDisplayId), (const, override)); 72 MOCK_METHOD(std::vector<ui::RenderIntent>, getRenderIntents, (HalDisplayId, ui::ColorMode), 73 (const, override)); 74 MOCK_METHOD(mat4, getDataspaceSaturationMatrix, (HalDisplayId, ui::Dataspace), (override)); 75 MOCK_METHOD(status_t, getDisplayedContentSamplingAttributes, 76 (HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*), (override)); 77 MOCK_METHOD(status_t, setDisplayContentSamplingEnabled, (HalDisplayId, bool, uint8_t, uint64_t), 78 (override)); 79 MOCK_METHOD(status_t, getDisplayedContentSample, 80 (HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*), (override)); 81 MOCK_METHOD(ftl::Future<status_t>, setDisplayBrightness, 82 (PhysicalDisplayId, float, float, const Hwc2::Composer::DisplayBrightnessOptions&), 83 (override)); 84 MOCK_METHOD(std::optional<DisplayIdentificationInfo>, onHotplug, 85 (hal::HWDisplayId, HWComposer::HotplugEvent), (override)); 86 MOCK_METHOD(bool, updatesDeviceProductInfoOnHotplugReconnect, (), (const, override)); 87 MOCK_METHOD(std::optional<PhysicalDisplayId>, onVsync, (hal::HWDisplayId, int64_t)); 88 MOCK_METHOD(void, setVsyncEnabled, (PhysicalDisplayId, hal::Vsync), (override)); 89 MOCK_METHOD(bool, isConnected, (PhysicalDisplayId), (const, override)); 90 MOCK_METHOD(std::vector<HWComposer::HWCDisplayMode>, getModes, (PhysicalDisplayId, int32_t), 91 (const, override)); 92 MOCK_METHOD((ftl::Expected<hal::HWConfigId, status_t>), getActiveMode, (PhysicalDisplayId), 93 (const, override)); 94 MOCK_METHOD(std::vector<ui::ColorMode>, getColorModes, (PhysicalDisplayId), (const, override)); 95 MOCK_METHOD(status_t, setActiveColorMode, (PhysicalDisplayId, ui::ColorMode, ui::RenderIntent), 96 (override)); 97 MOCK_METHOD(ui::DisplayConnectionType, getDisplayConnectionType, (PhysicalDisplayId), 98 (const, override)); 99 MOCK_METHOD(bool, isVsyncPeriodSwitchSupported, (PhysicalDisplayId), (const, override)); 100 MOCK_METHOD((ftl::Expected<nsecs_t, status_t>), getDisplayVsyncPeriod, (PhysicalDisplayId), 101 (const, override)); 102 MOCK_METHOD(status_t, setActiveModeWithConstraints, 103 (PhysicalDisplayId, hal::HWConfigId, const hal::VsyncPeriodChangeConstraints&, 104 hal::VsyncPeriodChangeTimeline*), 105 (override)); 106 MOCK_METHOD(status_t, setBootDisplayMode, (PhysicalDisplayId, hal::HWConfigId), (override)); 107 MOCK_METHOD(status_t, clearBootDisplayMode, (PhysicalDisplayId), (override)); 108 MOCK_METHOD(std::optional<hal::HWConfigId>, getPreferredBootDisplayMode, (PhysicalDisplayId), 109 (override)); 110 111 MOCK_METHOD(std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>, 112 getHdrConversionCapabilities, (), (const, override)); 113 MOCK_METHOD(status_t, setHdrConversionStrategy, 114 (aidl::android::hardware::graphics::common::HdrConversionStrategy, 115 aidl::android::hardware::graphics::common::Hdr*), 116 (override)); 117 MOCK_METHOD(status_t, setAutoLowLatencyMode, (PhysicalDisplayId, bool), (override)); 118 MOCK_METHOD(status_t, getSupportedContentTypes, 119 (PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override)); 120 MOCK_METHOD(status_t, setContentType, (PhysicalDisplayId, hal::ContentType)), (override); 121 MOCK_METHOD((const std::unordered_map<std::string, bool>&), getSupportedLayerGenericMetadata, 122 (), (const, override)); 123 MOCK_METHOD(void, dump, (std::string&), (const, override)); 124 MOCK_METHOD(void, dumpOverlayProperties, (std::string&), (const, override)); 125 MOCK_METHOD(android::Hwc2::Composer*, getComposer, (), (const, override)); 126 127 MOCK_METHOD(hal::HWDisplayId, getPrimaryHwcDisplayId, (), (const, override)); 128 MOCK_METHOD(PhysicalDisplayId, getPrimaryDisplayId, (), (const, override)); 129 MOCK_METHOD(bool, isHeadless, (), (const, override)); 130 131 MOCK_METHOD(std::optional<PhysicalDisplayId>, toPhysicalDisplayId, (hal::HWDisplayId), 132 (const, override)); 133 MOCK_METHOD(std::optional<hal::HWDisplayId>, fromPhysicalDisplayId, (PhysicalDisplayId), 134 (const, override)); 135 MOCK_METHOD(status_t, getDisplayDecorationSupport, 136 (PhysicalDisplayId, 137 std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>* 138 support), 139 (override)); 140 MOCK_METHOD(status_t, setIdleTimerEnabled, (PhysicalDisplayId, std::chrono::milliseconds), 141 (override)); 142 MOCK_METHOD(bool, hasDisplayIdleTimerCapability, (PhysicalDisplayId), (const, override)); 143 MOCK_METHOD(Hwc2::AidlTransform, getPhysicalDisplayOrientation, (PhysicalDisplayId), 144 (const, override)); 145 MOCK_METHOD(bool, getValidateSkipped, (HalDisplayId), (const, override)); 146 MOCK_METHOD(const aidl::android::hardware::graphics::composer3::OverlayProperties&, 147 getOverlaySupport, (), (const, override)); 148 MOCK_METHOD(status_t, setRefreshRateChangedCallbackDebugEnabled, (PhysicalDisplayId, bool)); 149 MOCK_METHOD(status_t, notifyExpectedPresent, (PhysicalDisplayId, TimePoint, Fps)); 150 MOCK_METHOD(HWC2::Display::LutFileDescriptorMapper&, getLutFileDescriptorMapper, (), 151 (override)); 152 MOCK_METHOD(int32_t, getMaxLayerPictureProfiles, (PhysicalDisplayId)); 153 MOCK_METHOD(status_t, setDisplayPictureProfileHandle, 154 (PhysicalDisplayId, const PictureProfileHandle&)); 155 MOCK_METHOD(status_t, startHdcpNegotiation, 156 (PhysicalDisplayId, const aidl::android::hardware::drm::HdcpLevels&)); 157 MOCK_METHOD(status_t, getLuts, 158 (PhysicalDisplayId, const std::vector<sp<GraphicBuffer>>&, 159 std::vector<aidl::android::hardware::graphics::composer3::Luts>*)); 160 }; 161 162 } // namespace android::mock 163