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