| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
| 6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
| 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
| 8 // Win/EGL. | 8 // Win/EGL. |
| 9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
| 10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // Initialize the GPU thread for rendering. We only need to setup once | 232 // Initialize the GPU thread for rendering. We only need to setup once |
| 233 // for all test cases. | 233 // for all test cases. |
| 234 class VideoDecodeAcceleratorTestEnvironment : public ::testing::Environment { | 234 class VideoDecodeAcceleratorTestEnvironment : public ::testing::Environment { |
| 235 public: | 235 public: |
| 236 VideoDecodeAcceleratorTestEnvironment() | 236 VideoDecodeAcceleratorTestEnvironment() |
| 237 : rendering_thread_("GLRenderingVDAClientThread") {} | 237 : rendering_thread_("GLRenderingVDAClientThread") {} |
| 238 | 238 |
| 239 void SetUp() override { | 239 void SetUp() override { |
| 240 rendering_thread_.Start(); | 240 rendering_thread_.Start(); |
| 241 | 241 |
| 242 base::WaitableEvent done(false, false); | 242 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 243 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 243 rendering_thread_.task_runner()->PostTask( | 244 rendering_thread_.task_runner()->PostTask( |
| 244 FROM_HERE, base::Bind(&RenderingHelper::InitializeOneOff, &done)); | 245 FROM_HERE, base::Bind(&RenderingHelper::InitializeOneOff, &done)); |
| 245 done.Wait(); | 246 done.Wait(); |
| 246 | 247 |
| 247 #if defined(USE_OZONE) | 248 #if defined(USE_OZONE) |
| 248 gpu_helper_.reset(new ui::OzoneGpuTestHelper()); | 249 gpu_helper_.reset(new ui::OzoneGpuTestHelper()); |
| 249 // Need to initialize after the rendering side since the rendering side | 250 // Need to initialize after the rendering side since the rendering side |
| 250 // initializes the "GPU" parts of Ozone. | 251 // initializes the "GPU" parts of Ozone. |
| 251 // | 252 // |
| 252 // This also needs to be done in the test environment since this shouldn't | 253 // This also needs to be done in the test environment since this shouldn't |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) | 657 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) |
| 657 pixel_format = media::PIXEL_FORMAT_ARGB; | 658 pixel_format = media::PIXEL_FORMAT_ARGB; |
| 658 | 659 |
| 659 LOG_ASSERT((pixel_format_ == PIXEL_FORMAT_UNKNOWN) || | 660 LOG_ASSERT((pixel_format_ == PIXEL_FORMAT_UNKNOWN) || |
| 660 (pixel_format_ == pixel_format)); | 661 (pixel_format_ == pixel_format)); |
| 661 pixel_format_ = pixel_format; | 662 pixel_format_ = pixel_format; |
| 662 | 663 |
| 663 texture_target_ = texture_target; | 664 texture_target_ = texture_target; |
| 664 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { | 665 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { |
| 665 uint32_t texture_id; | 666 uint32_t texture_id; |
| 666 base::WaitableEvent done(false, false); | 667 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 668 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 667 rendering_helper_->CreateTexture(texture_target_, &texture_id, dimensions, | 669 rendering_helper_->CreateTexture(texture_target_, &texture_id, dimensions, |
| 668 &done); | 670 &done); |
| 669 done.Wait(); | 671 done.Wait(); |
| 670 | 672 |
| 671 scoped_refptr<TextureRef> texture_ref; | 673 scoped_refptr<TextureRef> texture_ref; |
| 672 base::Closure delete_texture_cb = | 674 base::Closure delete_texture_cb = |
| 673 base::Bind(&RenderingHelper::DeleteTexture, | 675 base::Bind(&RenderingHelper::DeleteTexture, |
| 674 base::Unretained(rendering_helper_), texture_id); | 676 base::Unretained(rendering_helper_), texture_id); |
| 675 | 677 |
| 676 if (g_test_import) { | 678 if (g_test_import) { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 | 1113 |
| 1112 void VideoDecodeAcceleratorTest::SetUp() { | 1114 void VideoDecodeAcceleratorTest::SetUp() { |
| 1113 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 1115 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
| 1114 } | 1116 } |
| 1115 | 1117 |
| 1116 void VideoDecodeAcceleratorTest::TearDown() { | 1118 void VideoDecodeAcceleratorTest::TearDown() { |
| 1117 g_env->GetRenderingTaskRunner()->PostTask( | 1119 g_env->GetRenderingTaskRunner()->PostTask( |
| 1118 FROM_HERE, base::Bind(&STLDeleteElements<std::vector<TestVideoFile*>>, | 1120 FROM_HERE, base::Bind(&STLDeleteElements<std::vector<TestVideoFile*>>, |
| 1119 &test_video_files_)); | 1121 &test_video_files_)); |
| 1120 | 1122 |
| 1121 base::WaitableEvent done(false, false); | 1123 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 1124 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 1122 g_env->GetRenderingTaskRunner()->PostTask( | 1125 g_env->GetRenderingTaskRunner()->PostTask( |
| 1123 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, | 1126 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, |
| 1124 base::Unretained(&rendering_helper_), &done)); | 1127 base::Unretained(&rendering_helper_), &done)); |
| 1125 done.Wait(); | 1128 done.Wait(); |
| 1126 | 1129 |
| 1127 rendering_helper_.TearDown(); | 1130 rendering_helper_.TearDown(); |
| 1128 } | 1131 } |
| 1129 | 1132 |
| 1130 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( | 1133 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( |
| 1131 base::FilePath::StringType data, | 1134 base::FilePath::StringType data, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 video_file->min_fps_render /= num_concurrent_decoders; | 1192 video_file->min_fps_render /= num_concurrent_decoders; |
| 1190 if (video_file->min_fps_no_render != -1) | 1193 if (video_file->min_fps_no_render != -1) |
| 1191 video_file->min_fps_no_render /= num_concurrent_decoders; | 1194 video_file->min_fps_no_render /= num_concurrent_decoders; |
| 1192 } | 1195 } |
| 1193 } | 1196 } |
| 1194 | 1197 |
| 1195 void VideoDecodeAcceleratorTest::InitializeRenderingHelper( | 1198 void VideoDecodeAcceleratorTest::InitializeRenderingHelper( |
| 1196 const RenderingHelperParams& helper_params) { | 1199 const RenderingHelperParams& helper_params) { |
| 1197 rendering_helper_.Setup(); | 1200 rendering_helper_.Setup(); |
| 1198 | 1201 |
| 1199 base::WaitableEvent done(false, false); | 1202 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 1203 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 1200 g_env->GetRenderingTaskRunner()->PostTask( | 1204 g_env->GetRenderingTaskRunner()->PostTask( |
| 1201 FROM_HERE, | 1205 FROM_HERE, |
| 1202 base::Bind(&RenderingHelper::Initialize, | 1206 base::Bind(&RenderingHelper::Initialize, |
| 1203 base::Unretained(&rendering_helper_), helper_params, &done)); | 1207 base::Unretained(&rendering_helper_), helper_params, &done)); |
| 1204 done.Wait(); | 1208 done.Wait(); |
| 1205 } | 1209 } |
| 1206 | 1210 |
| 1207 void VideoDecodeAcceleratorTest::CreateAndStartDecoder( | 1211 void VideoDecodeAcceleratorTest::CreateAndStartDecoder( |
| 1208 GLRenderingVDAClient* client, | 1212 GLRenderingVDAClient* client, |
| 1209 ClientStateNotification<ClientState>* note) { | 1213 ClientStateNotification<ClientState>* note) { |
| 1210 g_env->GetRenderingTaskRunner()->PostTask( | 1214 g_env->GetRenderingTaskRunner()->PostTask( |
| 1211 FROM_HERE, base::Bind(&GLRenderingVDAClient::CreateAndStartDecoder, | 1215 FROM_HERE, base::Bind(&GLRenderingVDAClient::CreateAndStartDecoder, |
| 1212 base::Unretained(client))); | 1216 base::Unretained(client))); |
| 1213 ASSERT_EQ(note->Wait(), CS_DECODER_SET); | 1217 ASSERT_EQ(note->Wait(), CS_DECODER_SET); |
| 1214 } | 1218 } |
| 1215 | 1219 |
| 1216 void VideoDecodeAcceleratorTest::WaitUntilDecodeFinish( | 1220 void VideoDecodeAcceleratorTest::WaitUntilDecodeFinish( |
| 1217 ClientStateNotification<ClientState>* note) { | 1221 ClientStateNotification<ClientState>* note) { |
| 1218 for (int i = 0; i < CS_MAX; i++) { | 1222 for (int i = 0; i < CS_MAX; i++) { |
| 1219 if (note->Wait() == CS_DESTROYED) | 1223 if (note->Wait() == CS_DESTROYED) |
| 1220 break; | 1224 break; |
| 1221 } | 1225 } |
| 1222 } | 1226 } |
| 1223 | 1227 |
| 1224 void VideoDecodeAcceleratorTest::WaitUntilIdle() { | 1228 void VideoDecodeAcceleratorTest::WaitUntilIdle() { |
| 1225 base::WaitableEvent done(false, false); | 1229 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 1230 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 1226 g_env->GetRenderingTaskRunner()->PostTask( | 1231 g_env->GetRenderingTaskRunner()->PostTask( |
| 1227 FROM_HERE, | 1232 FROM_HERE, |
| 1228 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 1233 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
| 1229 done.Wait(); | 1234 done.Wait(); |
| 1230 } | 1235 } |
| 1231 | 1236 |
| 1232 void VideoDecodeAcceleratorTest::OutputLogFile( | 1237 void VideoDecodeAcceleratorTest::OutputLogFile( |
| 1233 const base::FilePath::CharType* log_path, | 1238 const base::FilePath::CharType* log_path, |
| 1234 const std::string& content) { | 1239 const std::string& content) { |
| 1235 base::File file(base::FilePath(log_path), | 1240 base::File file(base::FilePath(log_path), |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 int min_fps = suppress_rendering ? video_file->min_fps_no_render | 1427 int min_fps = suppress_rendering ? video_file->min_fps_no_render |
| 1423 : video_file->min_fps_render; | 1428 : video_file->min_fps_render; |
| 1424 if (min_fps > 0 && !test_reuse_delay) | 1429 if (min_fps > 0 && !test_reuse_delay) |
| 1425 EXPECT_GT(client->frames_per_second(), min_fps); | 1430 EXPECT_GT(client->frames_per_second(), min_fps); |
| 1426 } | 1431 } |
| 1427 } | 1432 } |
| 1428 | 1433 |
| 1429 if (render_as_thumbnails) { | 1434 if (render_as_thumbnails) { |
| 1430 std::vector<unsigned char> rgb; | 1435 std::vector<unsigned char> rgb; |
| 1431 bool alpha_solid; | 1436 bool alpha_solid; |
| 1432 base::WaitableEvent done(false, false); | 1437 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 1438 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 1433 g_env->GetRenderingTaskRunner()->PostTask( | 1439 g_env->GetRenderingTaskRunner()->PostTask( |
| 1434 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, | 1440 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, |
| 1435 base::Unretained(&rendering_helper_), &rgb, | 1441 base::Unretained(&rendering_helper_), &rgb, |
| 1436 &alpha_solid, &done)); | 1442 &alpha_solid, &done)); |
| 1437 done.Wait(); | 1443 done.Wait(); |
| 1438 | 1444 |
| 1439 std::vector<std::string> golden_md5s; | 1445 std::vector<std::string> golden_md5s; |
| 1440 std::string md5_string = base::MD5String( | 1446 std::string md5_string = base::MD5String( |
| 1441 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); | 1447 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); |
| 1442 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); | 1448 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 media::VaapiWrapper::PreSandboxInitialization(); | 1782 media::VaapiWrapper::PreSandboxInitialization(); |
| 1777 #endif | 1783 #endif |
| 1778 | 1784 |
| 1779 media::g_env = | 1785 media::g_env = |
| 1780 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1786 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
| 1781 testing::AddGlobalTestEnvironment( | 1787 testing::AddGlobalTestEnvironment( |
| 1782 new media::VideoDecodeAcceleratorTestEnvironment())); | 1788 new media::VideoDecodeAcceleratorTestEnvironment())); |
| 1783 | 1789 |
| 1784 return RUN_ALL_TESTS(); | 1790 return RUN_ALL_TESTS(); |
| 1785 } | 1791 } |
| OLD | NEW |