| 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 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 gl::QueryD3D11DeviceObjectFromANGLE(); | 486 gl::QueryD3D11DeviceObjectFromANGLE(); |
| 487 | 487 |
| 488 gfx::Size texture_size(50, 50); | 488 gfx::Size texture_size(50, 50); |
| 489 base::win::ScopedComPtr<ID3D11Texture2D> texture = | 489 base::win::ScopedComPtr<ID3D11Texture2D> texture = |
| 490 CreateNV12Texture(d3d11_device, texture_size); | 490 CreateNV12Texture(d3d11_device, texture_size); |
| 491 | 491 |
| 492 scoped_refptr<gl::GLImageDXGI> image_dxgi( | 492 scoped_refptr<gl::GLImageDXGI> image_dxgi( |
| 493 new gl::GLImageDXGI(texture_size, nullptr)); | 493 new gl::GLImageDXGI(texture_size, nullptr)); |
| 494 image_dxgi->SetTexture(texture, 0); | 494 image_dxgi->SetTexture(texture, 0); |
| 495 | 495 |
| 496 ui::DCRendererLayerParams params(false, gfx::Rect(), 1, gfx::Transform(), | 496 ui::DCRendererLayerParams params( |
| 497 image_dxgi.get(), | 497 false, gfx::Rect(), 1, gfx::Transform(), |
| 498 gfx::RectF(gfx::Rect(texture_size)), | 498 image_dxgi.get(), |
| 499 gfx::Rect(window_size), 0, 0, 1.0, 0); | 499 gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(texture_size), 0, 0, 1.0, |
| 500 0); |
| 500 surface_->ScheduleDCLayer(params); | 501 surface_->ScheduleDCLayer(params); |
| 501 | 502 |
| 502 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers()); | 503 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers()); |
| 504 |
| 505 // Scaling up the swapchain with the same image should cause it to be |
| 506 // transformed again, but not presented again. |
| 507 ui::DCRendererLayerParams params2( |
| 508 false, gfx::Rect(), 1, gfx::Transform(), |
| 509 image_dxgi.get(), |
| 510 gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0, |
| 511 0); |
| 512 surface_->ScheduleDCLayer(params2); |
| 513 |
| 514 EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers()); |
| 503 Sleep(1000); | 515 Sleep(1000); |
| 504 | 516 |
| 505 SkColor expected_color = SkColorSetRGB(0xff, 0xb7, 0xff); | 517 SkColor expected_color = SkColorSetRGB(0xff, 0xb7, 0xff); |
| 506 SkColor actual_color = | 518 SkColor actual_color = |
| 507 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75)); | 519 ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75)); |
| 508 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color)) | 520 EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color)) |
| 509 << std::hex << "Expected " << expected_color << " Actual " | 521 << std::hex << "Expected " << expected_color << " Actual " |
| 510 << actual_color; | 522 << actual_color; |
| 511 | 523 |
| 512 context = nullptr; | 524 context = nullptr; |
| 513 DestroySurface(std::move(surface_)); | 525 DestroySurface(std::move(surface_)); |
| 514 } | 526 } |
| 515 | 527 |
| 516 } // namespace | 528 } // namespace |
| 517 } // namespace gpu | 529 } // namespace gpu |
| OLD | NEW |