Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: gpu/ipc/service/direct_composition_surface_win_unittest.cc

Issue 2766423003: Allow creating opaque swapchains in DirectCompositionSurfaceWin (Closed)
Patch Set: fix logic, add unit test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698