1d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara/* 2d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * Copyright (C) 2017 The Android Open Source Project 3d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * 4d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * Licensed under the Apache License, Version 2.0 (the "License"); 5d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * you may not use this file except in compliance with the License. 6d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * You may obtain a copy of the License at 7d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * 8d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * http://www.apache.org/licenses/LICENSE-2.0 9d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * 10d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * Unless required by applicable law or agreed to in writing, software 11d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * distributed under the License is distributed on an "AS IS" BASIS, 12d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * See the License for the specific language governing permissions and 14d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara * limitations under the License. 15d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara */ 16d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 1796a098a80d9904f57d0ed65f9de8d210175a11c0Chia-I Wu#pragma once 18d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 19d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara#include <android/hardware/graphics/composer/2.1/IComposerCallback.h> 20d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 21d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara#include <mutex> 22d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara#include <unordered_set> 23d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 24d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoaranamespace android { 25d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoaranamespace hardware { 26d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoaranamespace graphics { 27d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoaranamespace composer { 28d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoaranamespace V2_1 { 2996a098a80d9904f57d0ed65f9de8d210175a11c0Chia-I Wunamespace vts { 30d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 31d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara// IComposerCallback to be installed with IComposerClient::registerCallback. 32d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoaraclass GraphicsComposerCallback : public IComposerCallback { 338b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu public: 348b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu void setVsyncAllowed(bool allowed); 35d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 368b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu std::vector<Display> getDisplays() const; 37d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 388b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu int getInvalidHotplugCount() const; 39d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 408b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu int getInvalidRefreshCount() const; 41d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 428b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu int getInvalidVsyncCount() const; 43d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 448b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu private: 458b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu Return<void> onHotplug(Display display, Connection connection) override; 468b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu Return<void> onRefresh(Display display) override; 478b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu Return<void> onVsync(Display display, int64_t) override; 48d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 498b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu mutable std::mutex mMutex; 508b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu // the set of all currently connected displays 518b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu std::unordered_set<Display> mDisplays; 528b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu // true only when vsync is enabled 538b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu bool mVsyncAllowed = true; 54d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 558b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu // track invalid callbacks 568b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu int mInvalidHotplugCount = 0; 578b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu int mInvalidRefreshCount = 0; 588b20c5c8817534def44224c9ab6dbe166e7383d6Chia-I Wu int mInvalidVsyncCount = 0; 59d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara}; 60d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara 6196a098a80d9904f57d0ed65f9de8d210175a11c0Chia-I Wu} // namespace vts 62d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara} // namespace V2_1 63d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara} // namespace composer 64d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara} // namespace graphics 65d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara} // namespace hardware 66d47f4a9d650ba807a9654d661374cd849f6bd251Daniel Nicoara} // namespace android 67