Commit 55bd2333 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

Add DisplayTest.DisplayTransformHint

Add DisplayTest, DisplayTransformHint to verify Display output
size is expected for the combination of display transform hint and
whether the output surface supports display transform hint.

Bug: 1031043
Change-Id: I295798268fdde818b37a4fee7ed6097346ed17e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1956121Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722969}
parent 7b16a121
......@@ -38,6 +38,7 @@
#include "gpu/GLES2/gl2extchromium.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/overlay_transform.h"
using testing::_;
using testing::AnyNumber;
......@@ -4031,4 +4032,68 @@ TEST_F(DisplayTest, DrawOcclusionWithRoundedCornerPartialOcclude) {
TearDownDisplay();
}
TEST_F(DisplayTest, DisplayTransformHint) {
SetUpSoftwareDisplay(RendererSettings());
StubDisplayClient client;
display_->Initialize(&client, manager_.surface_manager());
id_allocator_.GenerateId();
LocalSurfaceId local_surface_id(
id_allocator_.GetCurrentLocalSurfaceIdAllocation().local_surface_id());
display_->SetLocalSurfaceId(local_surface_id, 1.f);
constexpr gfx::Size kSize = gfx::Size(100, 80);
constexpr gfx::Size kTransposedSize =
gfx::Size(kSize.height(), kSize.width());
display_->Resize(kSize);
const struct {
bool support_display_transform;
gfx::OverlayTransform display_transform_hint;
gfx::Size expected_size;
} kTestCases[] = {
// Output size is always the display size when output surface does not
// support display transform hint.
{false, gfx::OVERLAY_TRANSFORM_NONE, kSize},
{false, gfx::OVERLAY_TRANSFORM_ROTATE_90, kSize},
{false, gfx::OVERLAY_TRANSFORM_ROTATE_180, kSize},
{false, gfx::OVERLAY_TRANSFORM_ROTATE_270, kSize},
// Output size is transposed on 90/270 degree rotation when output surface
// supports display transform hint.
{true, gfx::OVERLAY_TRANSFORM_NONE, kSize},
{true, gfx::OVERLAY_TRANSFORM_ROTATE_90, kTransposedSize},
{true, gfx::OVERLAY_TRANSFORM_ROTATE_180, kSize},
{true, gfx::OVERLAY_TRANSFORM_ROTATE_270, kTransposedSize},
};
size_t expected_frame_sent = 0u;
for (const auto& test : kTestCases) {
SCOPED_TRACE(testing::Message()
<< "support_display_transform="
<< test.support_display_transform
<< ", display_transform_hint=" << test.display_transform_hint);
output_surface_->set_support_display_transform_hint(
test.support_display_transform);
constexpr gfx::Rect kOutputRect(gfx::Point(0, 0), kSize);
constexpr gfx::Rect kDamageRect(10, 10, 1, 1);
CompositorFrame frame = CompositorFrameBuilder()
.AddRenderPass(kOutputRect, kDamageRect)
.Build();
frame.metadata.display_transform_hint = test.display_transform_hint;
support_->SubmitCompositorFrame(local_surface_id, std::move(frame));
display_->DrawAndSwap();
EXPECT_EQ(++expected_frame_sent, output_surface_->num_sent_frames());
EXPECT_EQ(test.expected_size,
software_output_device_->viewport_pixel_size());
}
TearDownDisplay();
}
} // namespace viz
......@@ -36,7 +36,6 @@
#include "components/viz/service/surfaces/surface_manager.h"
#include "ui/gfx/geometry/angle_conversions.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/overlay_transform.h"
#include "ui/gfx/overlay_transform_utils.h"
namespace viz {
......
......@@ -103,8 +103,15 @@ unsigned FakeOutputSurface::UpdateGpuFence() {
void FakeOutputSurface::SetUpdateVSyncParametersCallback(
UpdateVSyncParametersCallback callback) {}
void FakeOutputSurface::SetDisplayTransformHint(
gfx::OverlayTransform transform) {
if (support_display_transform_hint_)
display_transform_hint_ = transform;
}
gfx::OverlayTransform FakeOutputSurface::GetDisplayTransform() {
return gfx::OVERLAY_TRANSFORM_NONE;
return support_display_transform_hint_ ? display_transform_hint_
: gfx::OVERLAY_TRANSFORM_NONE;
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
......
......@@ -17,6 +17,7 @@
#include "components/viz/service/display/output_surface_frame.h"
#include "components/viz/service/display/software_output_device.h"
#include "components/viz/test/test_context_provider.h"
#include "ui/gfx/overlay_transform.h"
namespace viz {
......@@ -81,7 +82,7 @@ class FakeOutputSurface : public OutputSurface {
unsigned UpdateGpuFence() override;
void SetUpdateVSyncParametersCallback(
UpdateVSyncParametersCallback callback) override;
void SetDisplayTransformHint(gfx::OverlayTransform transform) override {}
void SetDisplayTransformHint(gfx::OverlayTransform transform) override;
gfx::OverlayTransform GetDisplayTransform() override;
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
void SetNeedsSwapSizeNotifications(
......@@ -111,6 +112,10 @@ class FakeOutputSurface : public OutputSurface {
return last_set_draw_rectangle_;
}
void set_support_display_transform_hint(bool support) {
support_display_transform_hint_ = support;
}
protected:
explicit FakeOutputSurface(scoped_refptr<ContextProvider> context_provider);
explicit FakeOutputSurface(
......@@ -127,6 +132,9 @@ class FakeOutputSurface : public OutputSurface {
gfx::ColorSpace last_reshape_color_space_;
gfx::Rect last_set_draw_rectangle_;
bool support_display_transform_hint_ = false;
gfx::OverlayTransform display_transform_hint_ = gfx::OVERLAY_TRANSFORM_NONE;
private:
void SwapBuffersAck();
......
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