Commit 7cab6365 authored by Zhenyao Mo's avatar Zhenyao Mo Committed by Commit Bot

Fix a few direct composition unit tests behaviors.

Right now some tests depend on previous tests' global states setting
to be able to run correctly.

This CL is set these states correctly for these tests so they can run
independently from previous tests.

BUG=968345
TEST=gl_unittests with --gtest_filter=SkipVideoLayerEmptyContentsRect|NV12SwapChain
R=sunnyps@chromium.org

Change-Id: I535b70065971e2803a09c1cedf7e243a4df6ace5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1633534
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664640}
parent ac570015
......@@ -38,7 +38,7 @@ namespace {
// Only one DirectComposition surface can be rendered into at a time. Track
// here which IDCompositionSurface is being rendered into. If another context
// is made current, then this surface will be suspended.
IDCompositionSurface* g_current_surface;
IDCompositionSurface* g_current_surface = nullptr;
// Returns true if swap chain tearing is supported.
bool IsSwapChainTearingSupported() {
......
......@@ -289,6 +289,7 @@ DXGI_FORMAT DirectCompositionSurfaceWin::GetOverlayFormatUsed() {
// static
void DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(
bool supported) {
InitializeHardwareOverlaySupport();
if (supported) {
g_nv12_overlay_support_flags |= DXGI_OVERLAY_SUPPORT_FLAG_SCALING;
g_yuy2_overlay_support_flags |= DXGI_OVERLAY_SUPPORT_FLAG_SCALING;
......@@ -296,11 +297,14 @@ void DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(
g_nv12_overlay_support_flags &= ~DXGI_OVERLAY_SUPPORT_FLAG_SCALING;
g_yuy2_overlay_support_flags &= ~DXGI_OVERLAY_SUPPORT_FLAG_SCALING;
}
DCHECK_EQ(supported, AreScaledOverlaysSupported());
}
// static
void DirectCompositionSurfaceWin::SetPreferYUY2OverlaysForTesting() {
InitializeHardwareOverlaySupport();
g_overlay_format_used = DXGI_FORMAT_YUY2;
DCHECK_EQ(DXGI_FORMAT_YUY2, GetOverlayFormatUsed());
}
// static
......
......@@ -76,8 +76,6 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL {
static void SetPreferYUY2OverlaysForTesting();
bool InitializeNativeWindow();
// GLSurfaceEGL implementation.
bool Initialize(GLSurfaceFormat format) override;
void Destroy() override;
......
......@@ -115,6 +115,7 @@ class DirectCompositionSurfaceTest : public testing::Test {
surface_ = CreateDirectCompositionSurfaceWin();
context_ = CreateGLContext(surface_);
surface_->SetEnableDCLayers(true);
DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(false);
}
void TearDown() override {
......@@ -376,7 +377,7 @@ TEST_F(DirectCompositionSurfaceTest, SwapchainSizeWithScaledOverlays) {
// HW supports scaled overlays
// The input texture size is maller than the window size.
surface_->SetScaledOverlaysSupportedForTesting(true);
DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(true);
ui::DCRendererLayerParams params;
params.y_image = image_dxgi;
......@@ -435,10 +436,6 @@ TEST_F(DirectCompositionSurfaceTest, SwapchainSizeWithoutScaledOverlays) {
image_dxgi->SetTexture(texture, 0);
image_dxgi->SetColorSpace(gfx::ColorSpace::CreateREC709());
// HW doesn't support scaled overlays
// The input texture size is bigger than the window size.
surface_->SetScaledOverlaysSupportedForTesting(false);
ui::DCRendererLayerParams params;
params.y_image = image_dxgi;
params.uv_image = image_dxgi;
......@@ -913,6 +910,9 @@ TEST_F(DirectCompositionPixelTest, SkipVideoLayerEmptyContentsRect) {
TEST_F(DirectCompositionPixelTest, NV12SwapChain) {
if (!surface_)
return;
// Swap chain size is overridden to content rect size only if scaled overlays
// are supported.
DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(true);
gfx::Size window_size(100, 100);
gfx::Size texture_size(50, 50);
......@@ -981,6 +981,9 @@ TEST_F(DirectCompositionPixelTest, NonZeroBoundsOffset) {
TEST_F(DirectCompositionPixelTest, ResizeVideoLayer) {
if (!surface_)
return;
// Swap chain size is overridden to content rect size only if scaled overlays
// are supported.
DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(true);
gfx::Size window_size(100, 100);
EXPECT_TRUE(surface_->Resize(window_size, 1.0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment