• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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/ComposerHal.h"
22 
23 namespace android {
24 
25 class GraphicBuffer;
26 
27 namespace Hwc2::mock {
28 
29 using android::hardware::graphics::common::V1_0::ColorTransform;
30 using android::hardware::graphics::common::V1_0::Transform;
31 using android::hardware::graphics::common::V1_1::RenderIntent;
32 using android::hardware::graphics::common::V1_2::ColorMode;
33 using android::hardware::graphics::common::V1_2::Dataspace;
34 using android::hardware::graphics::common::V1_2::Hdr;
35 using android::hardware::graphics::common::V1_2::PixelFormat;
36 
37 using android::hardware::graphics::composer::V2_1::Config;
38 using android::hardware::graphics::composer::V2_1::Display;
39 using android::hardware::graphics::composer::V2_1::Error;
40 using android::hardware::graphics::composer::V2_1::IComposer;
41 using android::hardware::graphics::composer::V2_1::Layer;
42 using android::hardware::graphics::composer::V2_4::IComposerCallback;
43 using android::hardware::graphics::composer::V2_4::IComposerClient;
44 
45 class Composer : public Hwc2::Composer {
46 public:
47     using Display = android::hardware::graphics::composer::V2_1::Display;
48     Composer();
49     ~Composer() override;
50 
51     MOCK_METHOD0(getCapabilities, std::vector<IComposer::Capability>());
52     MOCK_METHOD0(dumpDebugInfo, std::string());
53     MOCK_METHOD1(registerCallback, void(const sp<IComposerCallback>&));
54     MOCK_METHOD0(resetCommands, void());
55     MOCK_METHOD0(executeCommands, Error());
56     MOCK_METHOD0(getMaxVirtualDisplayCount, uint32_t());
57     MOCK_METHOD5(createVirtualDisplay,
58                  Error(uint32_t, uint32_t, PixelFormat*, std::optional<Display>, Display*));
59     MOCK_METHOD1(destroyVirtualDisplay, Error(Display));
60     MOCK_METHOD1(acceptDisplayChanges, Error(Display));
61     MOCK_METHOD2(createLayer, Error(Display, Layer* outLayer));
62     MOCK_METHOD2(destroyLayer, Error(Display, Layer));
63     MOCK_METHOD2(getActiveConfig, Error(Display, Config*));
64     MOCK_METHOD3(getChangedCompositionTypes,
65                  Error(Display, std::vector<Layer>*, std::vector<IComposerClient::Composition>*));
66     MOCK_METHOD2(getColorModes, Error(Display, std::vector<ColorMode>*));
67     MOCK_METHOD4(getDisplayAttribute,
68                  Error(Display, Config config, IComposerClient::Attribute, int32_t*));
69     MOCK_METHOD2(getDisplayConfigs, Error(Display, std::vector<Config>*));
70     MOCK_METHOD2(getDisplayName, Error(Display, std::string*));
71     MOCK_METHOD4(getDisplayRequests,
72                  Error(Display, uint32_t*, std::vector<Layer>*, std::vector<uint32_t>*));
73     MOCK_METHOD2(getDozeSupport, Error(Display, bool*));
74     MOCK_METHOD5(getHdrCapabilities, Error(Display, std::vector<Hdr>*, float*, float*, float*));
75     MOCK_METHOD1(getPerFrameMetadataKeys,
76                  std::vector<IComposerClient::PerFrameMetadataKey>(Display));
77     MOCK_METHOD2(getDataspaceSaturationMatrix, Error(Dataspace, mat4*));
78     MOCK_METHOD3(getDisplayIdentificationData, Error(Display, uint8_t*, std::vector<uint8_t>*));
79     MOCK_METHOD3(getReleaseFences, Error(Display, std::vector<Layer>*, std::vector<int>*));
80     MOCK_METHOD2(presentDisplay, Error(Display, int*));
81     MOCK_METHOD2(setActiveConfig, Error(Display, Config));
82     MOCK_METHOD6(setClientTarget,
83                  Error(Display, uint32_t, const sp<GraphicBuffer>&, int, Dataspace,
84                        const std::vector<IComposerClient::Rect>&));
85     MOCK_METHOD3(setColorMode, Error(Display, ColorMode, RenderIntent));
86     MOCK_METHOD3(setColorTransform, Error(Display, const float*, ColorTransform));
87     MOCK_METHOD3(setOutputBuffer, Error(Display, const native_handle_t*, int));
88     MOCK_METHOD2(setPowerMode, Error(Display, IComposerClient::PowerMode));
89     MOCK_METHOD2(setVsyncEnabled, Error(Display, IComposerClient::Vsync));
90     MOCK_METHOD1(setClientTargetSlotCount, Error(Display));
91     MOCK_METHOD3(validateDisplay, Error(Display, uint32_t*, uint32_t*));
92     MOCK_METHOD5(presentOrValidateDisplay, Error(Display, uint32_t*, uint32_t*, int*, uint32_t*));
93     MOCK_METHOD4(setCursorPosition, Error(Display, Layer, int32_t, int32_t));
94     MOCK_METHOD5(setLayerBuffer, Error(Display, Layer, uint32_t, const sp<GraphicBuffer>&, int));
95     MOCK_METHOD3(setLayerSurfaceDamage,
96                  Error(Display, Layer, const std::vector<IComposerClient::Rect>&));
97     MOCK_METHOD3(setLayerBlendMode, Error(Display, Layer, IComposerClient::BlendMode));
98     MOCK_METHOD3(setLayerColor, Error(Display, Layer, const IComposerClient::Color&));
99     MOCK_METHOD3(setLayerCompositionType, Error(Display, Layer, IComposerClient::Composition));
100     MOCK_METHOD3(setLayerDataspace, Error(Display, Layer, Dataspace));
101     MOCK_METHOD3(setLayerPerFrameMetadata,
102                  Error(Display, Layer, const std::vector<IComposerClient::PerFrameMetadata>&));
103     MOCK_METHOD3(setLayerDisplayFrame, Error(Display, Layer, const IComposerClient::Rect&));
104     MOCK_METHOD3(setLayerPlaneAlpha, Error(Display, Layer, float));
105     MOCK_METHOD3(setLayerSidebandStream, Error(Display, Layer, const native_handle_t*));
106     MOCK_METHOD3(setLayerSourceCrop, Error(Display, Layer, const IComposerClient::FRect&));
107     MOCK_METHOD3(setLayerTransform, Error(Display, Layer, Transform));
108     MOCK_METHOD3(setLayerVisibleRegion,
109                  Error(Display, Layer, const std::vector<IComposerClient::Rect>&));
110     MOCK_METHOD3(setLayerZOrder, Error(Display, Layer, uint32_t));
111     MOCK_METHOD3(getRenderIntents, Error(Display, ColorMode, std::vector<RenderIntent>*));
112     MOCK_METHOD3(setLayerColorTransform, Error(Display, Layer, const float*));
113     MOCK_METHOD4(getDisplayedContentSamplingAttributes,
114                  Error(Display, PixelFormat*, Dataspace*, uint8_t*));
115     MOCK_METHOD4(setDisplayContentSamplingEnabled, Error(Display, bool, uint8_t, uint64_t));
116     MOCK_METHOD4(getDisplayedContentSample,
117                  Error(Display, uint64_t, uint64_t, DisplayedFrameStats*));
118     MOCK_METHOD3(setLayerPerFrameMetadataBlobs,
119                  Error(Display, Layer, const std::vector<IComposerClient::PerFrameMetadataBlob>&));
120     MOCK_METHOD2(setDisplayBrightness, Error(Display, float));
121     MOCK_METHOD0(isVsyncPeriodSwitchSupported, bool());
122     MOCK_METHOD2(getDisplayCapabilities, Error(Display, std::vector<DisplayCapability>*));
123     MOCK_METHOD2(getDisplayConnectionType,
124                  V2_4::Error(Display, IComposerClient::DisplayConnectionType*));
125     MOCK_METHOD3(getSupportedDisplayVsyncPeriods,
126                  V2_4::Error(Display, Config, std::vector<VsyncPeriodNanos>*));
127     MOCK_METHOD2(getDisplayVsyncPeriod, V2_4::Error(Display, VsyncPeriodNanos*));
128     MOCK_METHOD4(setActiveConfigWithConstraints,
129                  V2_4::Error(Display, Config, const IComposerClient::VsyncPeriodChangeConstraints&,
130                              VsyncPeriodChangeTimeline*));
131     MOCK_METHOD2(setAutoLowLatencyMode, V2_4::Error(Display, bool));
132     MOCK_METHOD2(getSupportedContentTypes,
133                  V2_4::Error(Display, std::vector<IComposerClient::ContentType>*));
134     MOCK_METHOD2(setContentType, V2_4::Error(Display, IComposerClient::ContentType));
135     MOCK_METHOD5(setLayerGenericMetadata,
136                  V2_4::Error(Display, Layer, const std::string&, bool,
137                              const std::vector<uint8_t>&));
138     MOCK_METHOD1(getLayerGenericMetadataKeys,
139                  V2_4::Error(std::vector<IComposerClient::LayerGenericMetadataKey>*));
140     MOCK_METHOD2(getClientTargetProperty, Error(Display, IComposerClient::ClientTargetProperty*));
141 };
142 
143 } // namespace Hwc2::mock
144 } // namespace android
145