• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 <compositionengine/CompositionRefreshArgs.h>
20 #include <compositionengine/DisplayColorProfile.h>
21 #include <compositionengine/LayerFE.h>
22 #include <compositionengine/Output.h>
23 #include <compositionengine/OutputLayer.h>
24 #include <compositionengine/RenderSurface.h>
25 #include <compositionengine/impl/GpuCompositionResult.h>
26 #include <compositionengine/impl/OutputCompositionState.h>
27 #include <gmock/gmock.h>
28 
29 namespace android::compositionengine::mock {
30 
31 class Output : public virtual compositionengine::Output {
32 public:
33     Output();
34     virtual ~Output();
35 
36     MOCK_CONST_METHOD0(isValid, bool());
37     MOCK_CONST_METHOD0(getDisplayId, std::optional<DisplayId>());
38 
39     MOCK_METHOD1(setCompositionEnabled, void(bool));
40     MOCK_METHOD1(setLayerCachingEnabled, void(bool));
41     MOCK_METHOD1(setLayerCachingTexturePoolEnabled, void(bool));
42     MOCK_METHOD3(setProjection, void(ui::Rotation, const Rect&, const Rect&));
43     MOCK_METHOD1(setNextBrightness, void(float));
44     MOCK_METHOD1(setDisplaySize, void(const ui::Size&));
45     MOCK_CONST_METHOD0(getTransformHint, ui::Transform::RotationFlags());
46 
47     MOCK_METHOD(void, setLayerFilter, (ui::LayerFilter));
48     MOCK_METHOD(bool, includesLayer, (ui::LayerFilter), (const));
49     MOCK_METHOD(bool, includesLayer, (const sp<compositionengine::LayerFE>&), (const));
50 
51     MOCK_METHOD1(setColorTransform, void(const compositionengine::CompositionRefreshArgs&));
52     MOCK_METHOD1(setColorProfile, void(const ColorProfile&));
53     MOCK_METHOD2(setDisplayBrightness, void(float, float));
54 
55     MOCK_CONST_METHOD1(dump, void(std::string&));
56     MOCK_CONST_METHOD2(dumpPlannerInfo, void(const Vector<String16>&, std::string&));
57     MOCK_CONST_METHOD0(getName, const std::string&());
58     MOCK_METHOD1(setName, void(const std::string&));
59 
60     MOCK_CONST_METHOD0(getDisplayColorProfile, compositionengine::DisplayColorProfile*());
61     MOCK_METHOD1(setDisplayColorProfile,
62                  void(std::unique_ptr<compositionengine::DisplayColorProfile>));
63 
64     MOCK_CONST_METHOD0(getRenderSurface, compositionengine::RenderSurface*());
65     MOCK_METHOD1(setRenderSurface, void(std::unique_ptr<compositionengine::RenderSurface>));
66 
67     MOCK_CONST_METHOD0(getState, const OutputCompositionState&());
68     MOCK_METHOD0(editState, OutputCompositionState&());
69 
70     MOCK_METHOD(Region, getDirtyRegion, (), (const));
71 
72     MOCK_CONST_METHOD1(getOutputLayerForLayer,
73                        compositionengine::OutputLayer*(const sp<compositionengine::LayerFE>&));
74     MOCK_METHOD0(clearOutputLayers, void());
75     MOCK_METHOD1(injectOutputLayerForTest,
76                  compositionengine::OutputLayer*(const sp<compositionengine::LayerFE>&));
77     MOCK_CONST_METHOD0(getOutputLayerCount, size_t());
78     MOCK_CONST_METHOD1(getOutputLayerOrderedByZByIndex, OutputLayer*(size_t));
79 
80     MOCK_METHOD1(setReleasedLayers, void(ReleasedLayers&&));
81 
82     MOCK_METHOD2(prepare, void(const compositionengine::CompositionRefreshArgs&, LayerFESet&));
83     MOCK_METHOD1(present, void(const compositionengine::CompositionRefreshArgs&));
84 
85     MOCK_METHOD1(uncacheBuffers, void(const std::vector<uint64_t>&));
86     MOCK_METHOD2(rebuildLayerStacks,
87                  void(const compositionengine::CompositionRefreshArgs&, LayerFESet&));
88     MOCK_METHOD2(collectVisibleLayers,
89                  void(const compositionengine::CompositionRefreshArgs&,
90                       compositionengine::Output::CoverageState&));
91     MOCK_METHOD2(ensureOutputLayerIfVisible,
92                  void(sp<compositionengine::LayerFE>&, compositionengine::Output::CoverageState&));
93     MOCK_METHOD1(setReleasedLayers, void(const compositionengine::CompositionRefreshArgs&));
94 
95     MOCK_METHOD1(updateCompositionState, void(const CompositionRefreshArgs&));
96     MOCK_METHOD0(planComposition, void());
97     MOCK_METHOD1(writeCompositionState, void(const CompositionRefreshArgs&));
98     MOCK_METHOD1(updateColorProfile, void(const compositionengine::CompositionRefreshArgs&));
99 
100     MOCK_METHOD0(beginFrame, void());
101 
102     MOCK_METHOD0(prepareFrame, void());
103     MOCK_METHOD0(prepareFrameAsync, GpuCompositionResult());
104     MOCK_METHOD1(chooseCompositionStrategy,
105                  bool(std::optional<android::HWComposer::DeviceRequestedChanges>*));
106     MOCK_METHOD1(chooseCompositionStrategyAsync,
107                  std::future<bool>(std::optional<android::HWComposer::DeviceRequestedChanges>*));
108     MOCK_METHOD1(applyCompositionStrategy,
109                  void(const std::optional<android::HWComposer::DeviceRequestedChanges>&));
110 
111     MOCK_METHOD1(devOptRepaintFlash, void(const compositionengine::CompositionRefreshArgs&));
112 
113     MOCK_METHOD1(finishFrame, void(GpuCompositionResult&&));
114 
115     MOCK_METHOD3(composeSurfaces,
116                  std::optional<base::unique_fd>(const Region&,
117                                                 std::shared_ptr<renderengine::ExternalTexture>,
118                                                 base::unique_fd&));
119     MOCK_CONST_METHOD0(getSkipColorTransform, bool());
120 
121     MOCK_METHOD0(postFramebuffer, void());
122     MOCK_METHOD1(renderCachedSets, void(const CompositionRefreshArgs&));
123     MOCK_METHOD0(presentAndGetFrameFences, compositionengine::Output::FrameFences());
124 
125     MOCK_METHOD3(generateClientCompositionRequests,
126                  std::vector<LayerFE::LayerSettings>(bool, ui::Dataspace, std::vector<compositionengine::LayerFE*>&));
127     MOCK_METHOD2(appendRegionFlashRequests,
128                  void(const Region&, std::vector<LayerFE::LayerSettings>&));
129     MOCK_METHOD1(setExpensiveRenderingExpected, void(bool));
130     MOCK_METHOD1(cacheClientCompositionRequests, void(uint32_t));
131     MOCK_METHOD1(canPredictCompositionStrategy, bool(const CompositionRefreshArgs&));
132     MOCK_METHOD1(setPredictCompositionStrategy, void(bool));
133     MOCK_METHOD1(setTreat170mAsSrgb, void(bool));
134     MOCK_METHOD(void, setHintSessionGpuFence, (std::unique_ptr<FenceTime> && gpuFence));
135     MOCK_METHOD(bool, isPowerHintSessionEnabled, ());
136 };
137 
138 } // namespace android::compositionengine::mock
139