blob: 29b9de35a783a8e7a297e89de6641a4d59f20f67 [file] [log] [blame]
Chia-I Wu8cc5a152017-02-24 14:34:02 -08001/*
2 * Copyright (C) 2017 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#ifndef VTS_HAL_GRAPHICS_COMPOSER_UTILS
18#define VTS_HAL_GRAPHICS_COMPOSER_UTILS
19
20#include <memory>
21#include <string>
22#include <unordered_map>
23#include <unordered_set>
24#include <vector>
25
26#include <android/hardware/graphics/composer/2.1/IComposer.h>
Courtney Goeltzenleuchter5ecd86a2018-01-12 14:00:56 -080027#include <composer-command-buffer/2.1/ComposerCommandBuffer.h>
Chia-I Wu8cc5a152017-02-24 14:34:02 -080028#include <utils/StrongPointer.h>
29
Daniel Nicoarad47f4a92017-05-30 15:38:30 -040030#include "TestCommandReader.h"
31
Chia-I Wu8cc5a152017-02-24 14:34:02 -080032namespace android {
33namespace hardware {
34namespace graphics {
35namespace composer {
36namespace V2_1 {
37namespace tests {
38
39using android::hardware::graphics::common::V1_0::ColorMode;
40using android::hardware::graphics::common::V1_0::Dataspace;
41using android::hardware::graphics::common::V1_0::Hdr;
42using android::hardware::graphics::common::V1_0::PixelFormat;
43
44class ComposerClient;
45
46// A wrapper to IComposer.
47class Composer {
48 public:
49 Composer();
Daniel Nicoarad47f4a92017-05-30 15:38:30 -040050 explicit Composer(const std::string& name);
Chia-I Wu8cc5a152017-02-24 14:34:02 -080051
52 sp<IComposer> getRaw() const;
53
54 // Returns true when the composer supports the specified capability.
55 bool hasCapability(IComposer::Capability capability) const;
56
57 std::vector<IComposer::Capability> getCapabilities();
58 std::string dumpDebugInfo();
59 std::unique_ptr<ComposerClient> createClient();
60
61 private:
62 void init();
63
64 sp<IComposer> mComposer;
65 std::unordered_set<IComposer::Capability> mCapabilities;
66};
67
68// A wrapper to IComposerClient.
69class ComposerClient {
70 public:
71 ComposerClient(const sp<IComposerClient>& client);
72 ~ComposerClient();
73
74 sp<IComposerClient> getRaw() const;
75
76 void registerCallback(const sp<IComposerCallback>& callback);
77 uint32_t getMaxVirtualDisplayCount();
78
79 Display createVirtualDisplay(uint32_t width, uint32_t height,
80 PixelFormat formatHint,
81 uint32_t outputBufferSlotCount,
82 PixelFormat* outFormat);
83 void destroyVirtualDisplay(Display display);
84
85 Layer createLayer(Display display, uint32_t bufferSlotCount);
86 void destroyLayer(Display display, Layer layer);
87
88 Config getActiveConfig(Display display);
89 bool getClientTargetSupport(Display display, uint32_t width, uint32_t height,
90 PixelFormat format, Dataspace dataspace);
91 std::vector<ColorMode> getColorModes(Display display);
92 int32_t getDisplayAttribute(Display display, Config config,
93 IComposerClient::Attribute attribute);
94 std::vector<Config> getDisplayConfigs(Display display);
95 std::string getDisplayName(Display display);
96 IComposerClient::DisplayType getDisplayType(Display display);
97 bool getDozeSupport(Display display);
98 std::vector<Hdr> getHdrCapabilities(Display display, float* outMaxLuminance,
99 float* outMaxAverageLuminance,
100 float* outMinLuminance);
101
102 void setClientTargetSlotCount(Display display,
103 uint32_t clientTargetSlotCount);
104 void setActiveConfig(Display display, Config config);
105 void setColorMode(Display display, ColorMode mode);
106 void setPowerMode(Display display, IComposerClient::PowerMode mode);
107 void setVsyncEnabled(Display display, bool enabled);
108
Daniel Nicoarad47f4a92017-05-30 15:38:30 -0400109 void execute(TestCommandReader* reader, CommandWriterBase* writer);
110
Chia-I Wu8cc5a152017-02-24 14:34:02 -0800111 private:
112 sp<IComposerClient> mClient;
113
114 // Keep track of all virtual displays and layers. When a test fails with
115 // ASSERT_*, the destructor will clean up the resources for the test.
116 struct DisplayResource {
117 DisplayResource(bool isVirtual_) : isVirtual(isVirtual_) {}
118
119 bool isVirtual;
120 std::unordered_set<Layer> layers;
121 };
122 std::unordered_map<Display, DisplayResource> mDisplayResources;
123};
124
125} // namespace tests
126} // namespace V2_1
127} // namespace composer
128} // namespace graphics
129} // namespace hardware
130} // namespace android
131
132#endif // VTS_HAL_GRAPHICS_COMPOSER_UTILS