| 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 fe1d83c520e1df0e8eac9a5aac102dd0487897a4..99eb7c4f6d1f213b20702cb8c02a6b19bfc80836 100644
|
| --- a/gpu/ipc/service/direct_composition_surface_win_unittest.cc
|
| +++ b/gpu/ipc/service/direct_composition_surface_win_unittest.cc
|
| @@ -113,8 +113,8 @@ base::win::ScopedComPtr<ID3D11Texture2D> CreateNV12Texture(
|
| desc.BindFlags = 0;
|
|
|
| std::vector<char> image_data(size.width() * size.height() * 3 / 2);
|
| - // Y, U, and V should all be Oxff. Output color should be pink.
|
| - memset(&image_data[0], 0xff, size.width() * size.height() * 3 / 2);
|
| + // Y, U, and V should all be 160. Output color should be pink.
|
| + memset(&image_data[0], 160, size.width() * size.height() * 3 / 2);
|
|
|
| D3D11_SUBRESOURCE_DATA data = {};
|
| data.pSysMem = (const void*)&image_data[0];
|
| @@ -316,8 +316,8 @@ TEST(DirectCompositionSurfaceTest, NoPresentTwice) {
|
| ui::DCRendererLayerParams params(
|
| false, gfx::Rect(), 1, gfx::Transform(),
|
| std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
|
| - gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0,
|
| - 0);
|
| + gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0, 0,
|
| + gfx::ColorSpace::CreateREC709());
|
| surface->ScheduleDCLayer(params);
|
|
|
| base::win::ScopedComPtr<IDXGISwapChain1> swap_chain =
|
| @@ -352,7 +352,7 @@ TEST(DirectCompositionSurfaceTest, NoPresentTwice) {
|
| false, gfx::Rect(), 1, gfx::Transform(),
|
| std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
|
| gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(0, 0, 25, 25), 0, 0, 1.0,
|
| - 0);
|
| + 0, gfx::ColorSpace::CreateREC709());
|
| surface->ScheduleDCLayer(params2);
|
|
|
| EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface->SwapBuffers());
|
| @@ -467,47 +467,72 @@ bool AreColorsSimilar(int a, int b) {
|
| abs(SkColorGetB(a) - SkColorGetB(b)) < kMargin;
|
| }
|
|
|
| -TEST_F(DirectCompositionPixelTest, VideoSwapchain) {
|
| - if (!CheckIfDCSupported())
|
| - return;
|
| - InitializeSurface();
|
| - surface_->SetEnableDCLayers(true);
|
| - gfx::Size window_size(100, 100);
|
| +class DirectCompositionVideoPixelTest : public DirectCompositionPixelTest {
|
| + protected:
|
| + void TestVideo(const gfx::ColorSpace& color_space, SkColor expected_color) {
|
| + if (!CheckIfDCSupported())
|
| + return;
|
| + InitializeSurface();
|
| + surface_->SetEnableDCLayers(true);
|
| + gfx::Size window_size(100, 100);
|
|
|
| - scoped_refptr<gl::GLContext> context = gl::init::CreateGLContext(
|
| - nullptr, surface_.get(), gl::GLContextAttribs());
|
| - EXPECT_TRUE(surface_->Resize(window_size, 1.0, true));
|
| + scoped_refptr<gl::GLContext> context = gl::init::CreateGLContext(
|
| + nullptr, surface_.get(), gl::GLContextAttribs());
|
| + EXPECT_TRUE(surface_->Resize(window_size, 1.0, true));
|
|
|
| - base::win::ScopedComPtr<ID3D11Device> d3d11_device =
|
| - gl::QueryD3D11DeviceObjectFromANGLE();
|
| + base::win::ScopedComPtr<ID3D11Device> d3d11_device =
|
| + gl::QueryD3D11DeviceObjectFromANGLE();
|
|
|
| - gfx::Size texture_size(50, 50);
|
| - base::win::ScopedComPtr<ID3D11Texture2D> texture =
|
| - CreateNV12Texture(d3d11_device, texture_size);
|
| + gfx::Size texture_size(50, 50);
|
| + base::win::ScopedComPtr<ID3D11Texture2D> texture =
|
| + CreateNV12Texture(d3d11_device, texture_size);
|
|
|
| - scoped_refptr<gl::GLImageDXGI> image_dxgi(
|
| - new gl::GLImageDXGI(texture_size, nullptr));
|
| - image_dxgi->SetTexture(texture, 0);
|
| + scoped_refptr<gl::GLImageDXGI> image_dxgi(
|
| + new gl::GLImageDXGI(texture_size, nullptr));
|
| + image_dxgi->SetTexture(texture, 0);
|
|
|
| - ui::DCRendererLayerParams params(
|
| - false, gfx::Rect(), 1, gfx::Transform(),
|
| - std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
|
| - gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0,
|
| - 0);
|
| - surface_->ScheduleDCLayer(params);
|
| + ui::DCRendererLayerParams params(
|
| + false, gfx::Rect(), 1, gfx::Transform(),
|
| + std::vector<scoped_refptr<gl::GLImage>>{image_dxgi},
|
| + gfx::RectF(gfx::Rect(texture_size)), gfx::Rect(window_size), 0, 0, 1.0,
|
| + 0, color_space);
|
| + surface_->ScheduleDCLayer(params);
|
|
|
| - EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers());
|
| - Sleep(1000);
|
| + EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers());
|
| + Sleep(1000);
|
|
|
| - SkColor expected_color = SkColorSetRGB(0xff, 0xb7, 0xff);
|
| - SkColor actual_color =
|
| - ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75));
|
| - EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color))
|
| - << std::hex << "Expected " << expected_color << " Actual "
|
| - << actual_color;
|
| + SkColor actual_color =
|
| + ReadBackWindowPixel(window_.hwnd(), gfx::Point(75, 75));
|
| + EXPECT_TRUE(AreColorsSimilar(expected_color, actual_color))
|
| + << std::hex << "Expected " << expected_color << " Actual "
|
| + << actual_color;
|
|
|
| - context = nullptr;
|
| - DestroySurface(std::move(surface_));
|
| + context = nullptr;
|
| + DestroySurface(std::move(surface_));
|
| + }
|
| +};
|
| +
|
| +TEST_F(DirectCompositionVideoPixelTest, BT601) {
|
| + TestVideo(gfx::ColorSpace::CreateREC601(), SkColorSetRGB(0xdb, 0x81, 0xe8));
|
| +}
|
| +
|
| +TEST_F(DirectCompositionVideoPixelTest, BT709) {
|
| + TestVideo(gfx::ColorSpace::CreateREC709(), SkColorSetRGB(0xe1, 0x90, 0xeb));
|
| +}
|
| +
|
| +TEST_F(DirectCompositionVideoPixelTest, SRGB) {
|
| + // SRGB doesn't make sense on an NV12 input, but don't crash.
|
| + TestVideo(gfx::ColorSpace::CreateSRGB(), SkColorSetRGB(0xd7, 0x89, 0xe0));
|
| +}
|
| +
|
| +TEST_F(DirectCompositionVideoPixelTest, SCRGBLinear) {
|
| + // SCRGB doesn't make sense on an NV12 input, but don't crash.
|
| + TestVideo(gfx::ColorSpace::CreateSCRGBLinear(),
|
| + SkColorSetRGB(0xd7, 0x89, 0xe0));
|
| +}
|
| +TEST_F(DirectCompositionVideoPixelTest, InvalidColorSpace) {
|
| + // Invalid color space should be treated as BT.709
|
| + TestVideo(gfx::ColorSpace(), SkColorSetRGB(0xe1, 0x90, 0xeb));
|
| }
|
|
|
| TEST_F(DirectCompositionPixelTest, SoftwareVideoSwapchain) {
|
| @@ -545,7 +570,8 @@ TEST_F(DirectCompositionPixelTest, SoftwareVideoSwapchain) {
|
| ui::DCRendererLayerParams params(
|
| false, gfx::Rect(), 1, gfx::Transform(),
|
| std::vector<scoped_refptr<gl::GLImage>>{y_image, uv_image},
|
| - gfx::RectF(gfx::Rect(y_size)), gfx::Rect(window_size), 0, 0, 1.0, 0);
|
| + gfx::RectF(gfx::Rect(y_size)), gfx::Rect(window_size), 0, 0, 1.0, 0,
|
| + gfx::ColorSpace::CreateREC709());
|
| surface_->ScheduleDCLayer(params);
|
|
|
| EXPECT_EQ(gfx::SwapResult::SWAP_ACK, surface_->SwapBuffers());
|
| @@ -561,5 +587,6 @@ TEST_F(DirectCompositionPixelTest, SoftwareVideoSwapchain) {
|
| context = nullptr;
|
| DestroySurface(std::move(surface_));
|
| }
|
| +
|
| } // namespace
|
| } // namespace gpu
|
|
|