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 #include <composer-vts/2.1/GraphicsComposerCallback.h> 18 19 namespace android { 20 namespace hardware { 21 namespace graphics { 22 namespace composer { 23 namespace V2_1 { 24 namespace vts { 25 setVsyncAllowed(bool allowed)26void GraphicsComposerCallback::setVsyncAllowed(bool allowed) { 27 std::lock_guard<std::mutex> lock(mMutex); 28 mVsyncAllowed = allowed; 29 } 30 getDisplays() const31std::vector<Display> GraphicsComposerCallback::getDisplays() const { 32 std::lock_guard<std::mutex> lock(mMutex); 33 return std::vector<Display>(mDisplays.begin(), mDisplays.end()); 34 } 35 getInvalidHotplugCount() const36int GraphicsComposerCallback::getInvalidHotplugCount() const { 37 std::lock_guard<std::mutex> lock(mMutex); 38 return mInvalidHotplugCount; 39 } 40 getInvalidRefreshCount() const41int GraphicsComposerCallback::getInvalidRefreshCount() const { 42 std::lock_guard<std::mutex> lock(mMutex); 43 return mInvalidRefreshCount; 44 } 45 getInvalidVsyncCount() const46int GraphicsComposerCallback::getInvalidVsyncCount() const { 47 std::lock_guard<std::mutex> lock(mMutex); 48 return mInvalidVsyncCount; 49 } 50 onHotplug(Display display,Connection connection)51Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection connection) { 52 std::lock_guard<std::mutex> lock(mMutex); 53 54 if (connection == Connection::CONNECTED) { 55 if (!mDisplays.insert(display).second) { 56 mInvalidHotplugCount++; 57 } 58 } else if (connection == Connection::DISCONNECTED) { 59 if (!mDisplays.erase(display)) { 60 mInvalidHotplugCount++; 61 } 62 } 63 64 return Void(); 65 } 66 onRefresh(Display display)67Return<void> GraphicsComposerCallback::onRefresh(Display display) { 68 std::lock_guard<std::mutex> lock(mMutex); 69 70 if (mDisplays.count(display) == 0) { 71 mInvalidRefreshCount++; 72 } 73 74 return Void(); 75 } 76 onVsync(Display display,int64_t)77Return<void> GraphicsComposerCallback::onVsync(Display display, int64_t) { 78 std::lock_guard<std::mutex> lock(mMutex); 79 80 if (!mVsyncAllowed || mDisplays.count(display) == 0) { 81 mInvalidVsyncCount++; 82 } 83 84 return Void(); 85 } 86 87 } // namespace vts 88 } // namespace V2_1 89 } // namespace composer 90 } // namespace graphics 91 } // namespace hardware 92 } // namespace android 93