Merge "fix VtsHalGraphicsComposerV2_2TargetTest timeout failed" am: 81c9e603ea

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1921757

Change-Id: Ief5601ad2311b6e24f15167859c1bbec251988df
This commit is contained in:
Treehugger Robot 2021-12-16 21:19:47 +00:00 committed by Automerger Merge Worker
commit f864ffeb60
4 changed files with 31 additions and 16 deletions

View file

@ -30,7 +30,7 @@ void GraphicsComposerCallback::setVsyncAllowed(bool allowed) {
std::vector<Display> GraphicsComposerCallback::getDisplays() const {
std::lock_guard<std::mutex> lock(mMutex);
return std::vector<Display>(mDisplays.begin(), mDisplays.end());
return mDisplays;
}
int GraphicsComposerCallback::getInvalidHotplugCount() const {
@ -51,12 +51,17 @@ int GraphicsComposerCallback::getInvalidVsyncCount() const {
Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection connection) {
std::lock_guard<std::mutex> lock(mMutex);
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (connection == Connection::CONNECTED) {
if (!mDisplays.insert(display).second) {
if (it == mDisplays.end()) {
mDisplays.push_back(display);
} else {
mInvalidHotplugCount++;
}
} else if (connection == Connection::DISCONNECTED) {
if (!mDisplays.erase(display)) {
if (it != mDisplays.end()) {
mDisplays.erase(it);
} else {
mInvalidHotplugCount++;
}
}
@ -67,7 +72,8 @@ Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection con
Return<void> GraphicsComposerCallback::onRefresh(Display display) {
std::lock_guard<std::mutex> lock(mMutex);
if (mDisplays.count(display) == 0) {
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (it == mDisplays.end()) {
mInvalidRefreshCount++;
}
@ -77,7 +83,8 @@ Return<void> GraphicsComposerCallback::onRefresh(Display display) {
Return<void> GraphicsComposerCallback::onVsync(Display display, int64_t) {
std::lock_guard<std::mutex> lock(mMutex);
if (!mVsyncAllowed || mDisplays.count(display) == 0) {
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (!mVsyncAllowed || it == mDisplays.end()) {
mInvalidVsyncCount++;
}

View file

@ -19,7 +19,7 @@
#include <android/hardware/graphics/composer/2.1/IComposerCallback.h>
#include <mutex>
#include <unordered_set>
#include <vector>
namespace android {
namespace hardware {
@ -48,7 +48,7 @@ class GraphicsComposerCallback : public IComposerCallback {
mutable std::mutex mMutex;
// the set of all currently connected displays
std::unordered_set<Display> mDisplays;
std::vector<Display> mDisplays;
// true only when vsync is enabled
bool mVsyncAllowed = true;

View file

@ -25,7 +25,7 @@ void GraphicsComposerCallback::setVsyncAllowed(bool allowed) {
std::vector<Display> GraphicsComposerCallback::getDisplays() const {
std::lock_guard<std::mutex> lock(mMutex);
return std::vector<Display>(mDisplays.begin(), mDisplays.end());
return mDisplays;
}
int32_t GraphicsComposerCallback::getInvalidHotplugCount() const {
@ -71,12 +71,17 @@ GraphicsComposerCallback::takeLastVsyncPeriodChangeTimeline() {
Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection connection) {
std::lock_guard<std::mutex> lock(mMutex);
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (connection == Connection::CONNECTED) {
if (!mDisplays.insert(display).second) {
if (it == mDisplays.end()) {
mDisplays.push_back(display);
} else {
mInvalidHotplugCount++;
}
} else if (connection == Connection::DISCONNECTED) {
if (!mDisplays.erase(display)) {
if (it != mDisplays.end()) {
mDisplays.erase(it);
} else {
mInvalidHotplugCount++;
}
}
@ -87,7 +92,8 @@ Return<void> GraphicsComposerCallback::onHotplug(Display display, Connection con
Return<void> GraphicsComposerCallback::onRefresh(Display display) {
std::lock_guard<std::mutex> lock(mMutex);
if (mDisplays.count(display) == 0) {
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (it == mDisplays.end()) {
mInvalidRefreshCount++;
}
@ -106,7 +112,8 @@ Return<void> GraphicsComposerCallback::onVsync(Display, int64_t) {
Return<void> GraphicsComposerCallback::onVsync_2_4(Display display, int64_t, VsyncPeriodNanos) {
std::lock_guard<std::mutex> lock(mMutex);
if (!mVsyncAllowed || mDisplays.count(display) == 0) {
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (!mVsyncAllowed || it == mDisplays.end()) {
mInvalidVsync_2_4Count++;
}
@ -117,7 +124,8 @@ Return<void> GraphicsComposerCallback::onVsyncPeriodTimingChanged(
Display display, const VsyncPeriodChangeTimeline& updatedTimeline) {
std::lock_guard<std::mutex> lock(mMutex);
if (mDisplays.count(display) == 0) {
auto it = std::find(mDisplays.begin(), mDisplays.end(), display);
if (it == mDisplays.end()) {
mInvalidVsyncPeriodChangeCount++;
}
@ -134,4 +142,4 @@ Return<void> GraphicsComposerCallback::onSeamlessPossible(Display) {
return Void();
}
} // namespace android::hardware::graphics::composer::V2_4::vts
} // namespace android::hardware::graphics::composer::V2_4::vts

View file

@ -18,7 +18,7 @@
#include <android/hardware/graphics/composer/2.4/IComposerCallback.h>
#include <mutex>
#include <unordered_set>
#include <vector>
namespace android::hardware::graphics::composer::V2_4::vts {
@ -56,7 +56,7 @@ class GraphicsComposerCallback : public IComposerCallback {
mutable std::mutex mMutex;
// the set of all currently connected displays
std::unordered_set<Display> mDisplays;
std::vector<Display> mDisplays;
// true only when vsync is enabled
bool mVsyncAllowed = true;