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

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

Issue 2766423003: Allow creating opaque swapchains in DirectCompositionSurfaceWin (Closed)
Patch Set: rebase 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 864353fe72d95aacd1ac1d467db2c532a8e5d69b..96c4403632ec238ea8043e9d04a66ced4a4b18eb 100644
--- a/gpu/ipc/service/direct_composition_surface_win_unittest.cc
+++ b/gpu/ipc/service/direct_composition_surface_win_unittest.cc
@@ -213,6 +213,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);
+ 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));
+}
+
COLORREF ReadBackWindowPixel(HWND window, const gfx::Point& point) {
base::win::ScopedCreateDC mem_hdc(::CreateCompatibleDC(nullptr));
void* bits = nullptr;
« 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