| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "gpu/ipc/service/direct_composition_surface_win.h" | 5 #include "gpu/ipc/service/direct_composition_surface_win.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "base/win/scoped_gdi_object.h" | 10 #include "base/win/scoped_gdi_object.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 surface->GetLayerSwapChainForTesting(1); | 319 surface->GetLayerSwapChainForTesting(1); |
| 320 ASSERT_FALSE(swap_chain); | 320 ASSERT_FALSE(swap_chain); |
| 321 | 321 |
| 322 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); | 322 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); |
| 323 | 323 |
| 324 swap_chain = surface->GetLayerSwapChainForTesting(1); | 324 swap_chain = surface->GetLayerSwapChainForTesting(1); |
| 325 ASSERT_TRUE(swap_chain); | 325 ASSERT_TRUE(swap_chain); |
| 326 | 326 |
| 327 UINT last_present_count = 0; | 327 UINT last_present_count = 0; |
| 328 EXPECT_TRUE(SUCCEEDED(swap_chain->GetLastPresentCount(&last_present_count))); | 328 EXPECT_TRUE(SUCCEEDED(swap_chain->GetLastPresentCount(&last_present_count))); |
| 329 EXPECT_EQ(1u, last_present_count); | 329 |
| 330 // One present is normal, and a second present because it's the first frame |
| 331 // and the other buffer needs to be drawn to. |
| 332 EXPECT_EQ(2u, last_present_count); |
| 330 | 333 |
| 331 surface->ScheduleDCLayer(params); | 334 surface->ScheduleDCLayer(params); |
| 332 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); | 335 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); |
| 333 | 336 |
| 334 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain2 = | 337 base::win::ScopedComPtr<IDXGISwapChain1> swap_chain2 = |
| 335 surface->GetLayerSwapChainForTesting(1); | 338 surface->GetLayerSwapChainForTesting(1); |
| 336 EXPECT_EQ(swap_chain2, swap_chain); | 339 EXPECT_EQ(swap_chain2, swap_chain); |
| 337 | 340 |
| 338 // It's the same image, so it should have the same swapchain. | 341 // It's the same image, so it should have the same swapchain. |
| 339 EXPECT_TRUE(SUCCEEDED(swap_chain->GetLastPresentCount(&last_present_count))); | 342 EXPECT_TRUE(SUCCEEDED(swap_chain->GetLastPresentCount(&last_present_count))); |
| 340 EXPECT_EQ(1u, last_present_count); | 343 EXPECT_EQ(2u, last_present_count); |
| 341 | 344 |
| 342 // The size of the swapchain changed, so it should be recreated. | 345 // The size of the swapchain changed, so it should be recreated. |
| 343 ui::DCRendererLayerParams params2(false, gfx::Rect(), 1, gfx::Transform(), | 346 ui::DCRendererLayerParams params2(false, gfx::Rect(), 1, gfx::Transform(), |
| 344 image_dxgi.get(), | 347 image_dxgi.get(), |
| 345 gfx::RectF(gfx::Rect(texture_size)), | 348 gfx::RectF(gfx::Rect(texture_size)), |
| 346 gfx::Rect(0, 0, 25, 25), 0, 0, 1.0, 0); | 349 gfx::Rect(0, 0, 25, 25), 0, 0, 1.0, 0); |
| 347 surface->ScheduleDCLayer(params2); | 350 surface->ScheduleDCLayer(params2); |
| 348 | 351 |
| 349 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); | 352 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers()); |
| 350 | 353 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color)) | 498 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color)) |
| 496 << std::hex << "Expected " << expected_color << " Actual " | 499 << std::hex << "Expected " << expected_color << " Actual " |
| 497 << actual_color; | 500 << actual_color; |
| 498 | 501 |
| 499 context = nullptr; | 502 context = nullptr; |
| 500 DestroySurface(std::move(surface_)); | 503 DestroySurface(std::move(surface_)); |
| 501 } | 504 } |
| 502 | 505 |
| 503 } // namespace | 506 } // namespace |
| 504 } // namespace gpu | 507 } // namespace gpu |
| OLD | NEW |