• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2025 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 <memory>
20 #include <span>
21 #include <string>
22 
23 #include <android-base/expected.h>
24 
25 #include "test_framework/core/DisplayConfiguration.h"
26 
27 namespace android::surfaceflinger::tests::end2end::test_framework::fake_hwc3 {
28 
29 class Hwc3Composer;
30 
31 class Hwc3Controller final {
32     struct Passkey;  // Uses the passkey idiom to restrict construction.
33 
34   public:
35     // Gets the service name for the HWC3 instance that will be created and registered
36     [[nodiscard]] static auto getServiceName() -> std::string;
37 
38     // Makes the HWC3 controller instance.
39     [[nodiscard]] static auto make(std::span<const core::DisplayConfiguration> displays)
40             -> base::expected<std::shared_ptr<fake_hwc3::Hwc3Controller>, std::string>;
41 
42     explicit Hwc3Controller(Passkey passkey);
43 
44     // Adds a new display to the HWC3, which will become a hotplug connect event.
45     void addDisplay(const core::DisplayConfiguration& config);
46 
47     // Removes a new display from the HWC3, which will become a hotplug disconnect event.
48     void removeDisplay(core::DisplayConfiguration::Id displayId);
49 
50   private:
51     static constexpr std::string baseServiceName = "fake";
52 
53     [[nodiscard]] auto init(std::span<const core::DisplayConfiguration> displays)
54             -> base::expected<void, std::string>;
55 
56     std::shared_ptr<Hwc3Composer> mComposer;
57 };
58 
59 }  // namespace android::surfaceflinger::tests::end2end::test_framework::fake_hwc3
60