blob: ada7d099972b59bc25b15b4edd83a9adbd401747 [file] [log] [blame]
Daniel Nicoarad47f4a92017-05-30 15:38:30 -04001/*
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 GRAPHICS_COMPOSER_CALLBACK_H
18#define GRAPHICS_COMPOSER_CALLBACK_H
19
20#include <android/hardware/graphics/composer/2.1/IComposerCallback.h>
21
22#include <mutex>
23#include <unordered_set>
24
25namespace android {
26namespace hardware {
27namespace graphics {
28namespace composer {
29namespace V2_1 {
30namespace tests {
31
32// IComposerCallback to be installed with IComposerClient::registerCallback.
33class GraphicsComposerCallback : public IComposerCallback {
34 public:
35 void setVsyncAllowed(bool allowed);
36
37 std::vector<Display> getDisplays() const;
38
39 int getInvalidHotplugCount() const;
40
41 int getInvalidRefreshCount() const;
42
43 int getInvalidVsyncCount() const;
44
45 private:
46 Return<void> onHotplug(Display display, Connection connection) override;
47 Return<void> onRefresh(Display display) override;
48 Return<void> onVsync(Display display, int64_t) override;
49
50 mutable std::mutex mMutex;
51 // the set of all currently connected displays
52 std::unordered_set<Display> mDisplays;
53 // true only when vsync is enabled
54 bool mVsyncAllowed = false;
55
56 // track invalid callbacks
57 int mInvalidHotplugCount = 0;
58 int mInvalidRefreshCount = 0;
59 int mInvalidVsyncCount = 0;
60};
61
62} // namespace tests
63} // namespace V2_1
64} // namespace composer
65} // namespace graphics
66} // namespace hardware
67} // namespace android
68
69#endif // GRAPHICS_COMPOSER_CALLBACK_H