mirror of
https://gitee.com/openharmony/xts_hats
synced 2024-11-27 09:00:57 +00:00
adapt
Signed-off-by: qwx1028698 <quannini@huawei.com> Change-Id: Iff8852c9d84358a1c906ddd00de446b636a53e5a Change-Id: I19121fee87044fa4e532b84e523ec8e58080d511
This commit is contained in:
parent
2167c36540
commit
6d768488a0
@ -311,6 +311,7 @@ static void AdjustLayerSettings(std::vector<LayerSettings> &settings, uint32_t w
|
||||
if ((setting.bufferSize.w == 0) || (setting.bufferSize.h == 0)) {
|
||||
DISPLAY_TEST_LOGE("buffer size adjust for %{public}d %{public}d to %{public}d %{public}d",
|
||||
setting.bufferSize.w, setting.bufferSize.h, setting.displayRect.w, setting.displayRect.h);
|
||||
|
||||
setting.bufferSize.w = setting.displayRect.w;
|
||||
setting.bufferSize.h = setting.displayRect.h;
|
||||
}
|
||||
@ -345,6 +346,21 @@ static inline void PresentAndCheck(std::vector<LayerSettings> &layerSettings,
|
||||
}
|
||||
}
|
||||
|
||||
static int PrepareAndCommit()
|
||||
{
|
||||
DISPLAY_TEST_LOGE();
|
||||
std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
|
||||
DISPLAY_TEST_CHK_RETURN((display == nullptr), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("can not get display"));
|
||||
|
||||
int ret = display->PrepareDisplayLayers(); // 确定顶压策略(是否走GPU合成)、刷新layer列表
|
||||
DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
|
||||
DISPLAY_TEST_LOGE("PrepareDisplayLayers failed"));
|
||||
|
||||
ret = display->Commit(); // 送显
|
||||
DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("Commit failed"));
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
void LayerRotateTest::TearDown()
|
||||
{
|
||||
HdiTestDevice::GetInstance().Clear();
|
||||
@ -390,7 +406,6 @@ int32_t VblankCtr::WaitVblank(uint32_t ms)
|
||||
bool ret = false;
|
||||
DISPLAY_TEST_LOGE();
|
||||
std::unique_lock<std::mutex> lck(vblankMutex_);
|
||||
hasVblank_ = false; // must wait next vblank
|
||||
ret = vblankCondition_.wait_for(lck, std::chrono::milliseconds(ms), [=] { return hasVblank_; });
|
||||
DISPLAY_TEST_LOGE();
|
||||
if (!ret) {
|
||||
@ -532,11 +547,23 @@ TEST_F(DeviceTest, CtrlTest)
|
||||
ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "RegDisplayVBlankCallback failed";
|
||||
ret = display->SetDisplayVsyncEnabled(true);
|
||||
ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
|
||||
|
||||
std::vector<LayerSettings> settings = {
|
||||
{
|
||||
.rectRatio = { 0, 0, 1.0f, 1.0f },
|
||||
.color = PINK
|
||||
},
|
||||
};
|
||||
std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
|
||||
ASSERT_TRUE((layers.size() > 0));
|
||||
VblankCtr::GetInstance().hasVblank_ = false;
|
||||
PrepareAndCommit();
|
||||
ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_2000); // 2000ms
|
||||
ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "WaitVblank timeout";
|
||||
ret = display->SetDisplayVsyncEnabled(false);
|
||||
ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
|
||||
usleep(SLEEP_CONT_100 * SLEEP_CONT_2000); // wait for 100ms avoid the last vsync.
|
||||
VblankCtr::GetInstance().hasVblank_ = false;
|
||||
ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_2000); // 2000ms
|
||||
ASSERT_TRUE(ret != DISPLAY_SUCCESS) << "vblank do not disable";
|
||||
}
|
||||
|
@ -57,12 +57,12 @@ public:
|
||||
}
|
||||
void NotifyVblank(unsigned int sequence, uint64_t ns, const void* data);
|
||||
int32_t WaitVblank(uint32_t ms);
|
||||
bool hasVblank_ = false;
|
||||
private:
|
||||
std::mutex vblankMutex_;
|
||||
std::condition_variable vblankCondition_;
|
||||
VblankCtr() {}
|
||||
~VblankCtr();
|
||||
bool hasVblank_ = false;
|
||||
};
|
||||
} // OHOS
|
||||
} // HDI
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "hdi_test_render_utils.h"
|
||||
#include "timer.h"
|
||||
#include <sys/time.h>
|
||||
#include <thread>
|
||||
|
||||
using namespace OHOS::HDI::Display::Buffer::V1_0;
|
||||
using namespace OHOS::HDI::Display::Composer::V1_1;
|
||||
@ -39,10 +40,12 @@ using namespace testing::ext;
|
||||
static sptr<Composer::V1_1::IDisplayComposerInterface> g_composerDevice = nullptr;
|
||||
static std::shared_ptr<IDisplayBuffer> g_gralloc = nullptr;
|
||||
static std::vector<uint32_t> g_displayIds;
|
||||
const int SLEEP_CONT_10 = 10;
|
||||
const int SLEEP_CONT_100 = 100;
|
||||
const int SLEEP_CONT_2000 = 2000;
|
||||
static bool g_isOnSeamlessChangeCalled = false;
|
||||
static bool g_isOnModeCalled = false;
|
||||
static bool g_threadCtrl = false;
|
||||
|
||||
static inline std::shared_ptr<HdiTestDisplay> GetFirstDisplay()
|
||||
{
|
||||
@ -104,6 +107,14 @@ static int PrepareAndCommit()
|
||||
return DISPLAY_SUCCESS;
|
||||
}
|
||||
|
||||
static void LoopCommit()
|
||||
{
|
||||
while (!g_threadCtrl) {
|
||||
PrepareAndCommit();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_10));
|
||||
}
|
||||
}
|
||||
|
||||
static void TestVBlankCallback(unsigned int sequence, uint64_t ns, void* data)
|
||||
{
|
||||
static uint64_t lastns;
|
||||
@ -224,7 +235,6 @@ int32_t VblankCtr::WaitVblank(uint32_t ms)
|
||||
bool ret = false;
|
||||
DISPLAY_TEST_LOGE();
|
||||
std::unique_lock<std::mutex> lck(vblankMutex_);
|
||||
hasVblank_ = false; // must wait next vblank
|
||||
ret = vblankCondition_.wait_for(lck, std::chrono::milliseconds(ms), [=] { return hasVblank_; });
|
||||
DISPLAY_TEST_LOGE();
|
||||
if (!ret) {
|
||||
@ -825,12 +835,14 @@ HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7700, TestSize.Level1)
|
||||
};
|
||||
std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
|
||||
ASSERT_TRUE((layers.size() > 0));
|
||||
VblankCtr::GetInstance().hasVblank_ = false;
|
||||
PrepareAndCommit();
|
||||
ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_100); // 100ms
|
||||
ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "WaitVblank timeout";
|
||||
ret = display->SetDisplayVsyncEnabled(false);
|
||||
ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
|
||||
usleep(SLEEP_CONT_100 * SLEEP_CONT_2000); // wait for 100ms avoid the last vsync.
|
||||
VblankCtr::GetInstance().hasVblank_ = false;
|
||||
ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_100); // 100ms
|
||||
ASSERT_TRUE(ret != DISPLAY_SUCCESS) << "vblank do not disable";
|
||||
|
||||
@ -886,9 +898,11 @@ HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7900, TestSize.Level1)
|
||||
if (ret == DISPLAY_SUCCESS) {
|
||||
std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
|
||||
ASSERT_TRUE((layers.size() > 0));
|
||||
PrepareAndCommit(); // 送显
|
||||
|
||||
g_threadCtrl = false;
|
||||
std::thread commitThread(LoopCommit);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_100));
|
||||
g_threadCtrl = true;
|
||||
commitThread.join();
|
||||
ASSERT_EQ(g_isOnModeCalled, true);
|
||||
|
||||
DestroyLayer(layers[0]);
|
||||
|
@ -47,12 +47,12 @@ public:
|
||||
}
|
||||
void NotifyVblank(unsigned int sequence, uint64_t ns, const void* data);
|
||||
int32_t WaitVblank(uint32_t ms);
|
||||
bool hasVblank_ = false;
|
||||
private:
|
||||
std::mutex vblankMutex_;
|
||||
std::condition_variable vblankCondition_;
|
||||
VblankCtr() {}
|
||||
~VblankCtr();
|
||||
bool hasVblank_ = false;
|
||||
};
|
||||
} // namespace SYSTEMTEST
|
||||
} // namespace Display
|
||||
|
Loading…
Reference in New Issue
Block a user