Chromium Code Reviews| Index: gpu/ipc/service/direct_composition_surface_win_unittest.cc |
| diff --git a/gpu/ipc/service/direct_composition_surface_win_unittest.cc b/gpu/ipc/service/direct_composition_surface_win_unittest.cc |
| index 37922eb2f448a9597263eaa54f310b62ce4497d5..e8bc36a87d5f348c5fe552714ac2360c63d98d61 100644 |
| --- a/gpu/ipc/service/direct_composition_surface_win_unittest.cc |
| +++ b/gpu/ipc/service/direct_composition_surface_win_unittest.cc |
| @@ -212,6 +212,48 @@ TEST(DirectCompositionSurfaceTest, DXGIDCLayerSwitch) { |
| DestroySurface(std::move(surface)); |
| } |
| +// Ensure that the swapchain's alpha is correct. |
| +TEST(DirectCompositionSurfaceTest, SwitchAlpha) { |
| + if (!CheckIfDCSupported()) |
| + return; |
| + |
| + TestImageTransportSurfaceDelegate delegate; |
| + |
| + scoped_refptr<DirectCompositionSurfaceWin> surface( |
| + new DirectCompositionSurfaceWin(delegate.AsWeakPtr(), |
| + ui::GetHiddenWindow())); |
| + EXPECT_TRUE(surface->Initialize()); |
| + |
| + scoped_refptr<gl::GLContext> context = |
| + gl::init::CreateGLContext(nullptr, surface.get(), gl::GLContextAttribs()); |
| + EXPECT_TRUE(surface->Resize(gfx::Size(100, 100), 1.0, true)); |
| + EXPECT_FALSE(surface->swap_chain()); |
| + |
| + EXPECT_TRUE(surface->SetDrawRectangle(gfx::Rect(0, 0, 100, 100))); |
| + base::win::ScopedComPtr<IDXGISwapChain1> swap_chain = surface->swap_chain(); |
| + ASSERT_TRUE(swap_chain); |
|
sunnyps
2017/03/28 23:33:29
nit: Why ASSERT instead of EXPECT here and below?
jbauman
2017/03/28 23:40:58
If it's null then swap_chain->GetDesc1 will crash,
|
| + DXGI_SWAP_CHAIN_DESC1 desc; |
| + swap_chain->GetDesc1(&desc); |
| + EXPECT_EQ(DXGI_ALPHA_MODE_PREMULTIPLIED, desc.AlphaMode); |
| + |
| + // Resize to the same parameters should have no effect. |
| + EXPECT_TRUE(surface->Resize(gfx::Size(100, 100), 1.0, true)); |
| + EXPECT_TRUE(surface->swap_chain()); |
| + |
| + EXPECT_TRUE(surface->Resize(gfx::Size(100, 100), 1.0, false)); |
| + EXPECT_FALSE(surface->swap_chain()); |
| + |
| + EXPECT_TRUE(surface->SetDrawRectangle(gfx::Rect(0, 0, 100, 100))); |
| + |
| + swap_chain = surface->swap_chain(); |
| + ASSERT_TRUE(swap_chain); |
| + swap_chain->GetDesc1(&desc); |
| + EXPECT_EQ(DXGI_ALPHA_MODE_IGNORE, desc.AlphaMode); |
| + |
| + context = nullptr; |
| + DestroySurface(std::move(surface)); |
| +} |
| + |
| SkBitmap ReadBackWindow(HWND window, const gfx::Rect& snapshot_bounds) { |
| std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas( |
| snapshot_bounds.right(), snapshot_bounds.bottom(), false); |