Commit 94988d84 authored by Kramer Ge's avatar Kramer Ge Committed by Chromium LUCI CQ

[ozone/wayland]SetOpaqueRegion() should accept surface-local region

Directly passing bounds_px will shift opaque region by surface location.
This happens to WaylandAuxiliaryWindow. Use region_px instead for
correctness.

Change-Id: I48180cc5b9da3864f497e6a1d1a4f0b8ce7c0b23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563361Reviewed-by: default avatarMaksim Sisov (GMT+2) <msisov@igalia.com>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832379}
parent 6d16d3a8
...@@ -75,8 +75,9 @@ class WaylandSurface { ...@@ -75,8 +75,9 @@ class WaylandSurface {
// Sets the region that is opaque on this surface in physical pixels. This is // Sets the region that is opaque on this surface in physical pixels. This is
// expected to be called whenever the region that the surface span changes or // expected to be called whenever the region that the surface span changes or
// the opacity changes. // the opacity changes. |region_px| is specified surface-local, in physical
void SetOpaqueRegion(const gfx::Rect& bounds_px); // pixels.
void SetOpaqueRegion(const gfx::Rect& region_px);
// Set the source rectangle of the associated wl_surface. // Set the source rectangle of the associated wl_surface.
// See: // See:
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/events/ozone/events_ozone.h" #include "ui/events/ozone/events_ozone.h"
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/ozone/common/features.h" #include "ui/ozone/common/features.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h" #include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h" #include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
...@@ -148,7 +149,7 @@ void WaylandWindow::SetBounds(const gfx::Rect& bounds_px) { ...@@ -148,7 +149,7 @@ void WaylandWindow::SetBounds(const gfx::Rect& bounds_px) {
return; return;
bounds_px_ = bounds_px; bounds_px_ = bounds_px;
root_surface_->SetOpaqueRegion(bounds_px); root_surface_->SetOpaqueRegion(gfx::Rect(bounds_px_.size()));
delegate_->OnBoundsChanged(bounds_px_); delegate_->OnBoundsChanged(bounds_px_);
} }
...@@ -403,7 +404,7 @@ bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) { ...@@ -403,7 +404,7 @@ bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
// Will do nothing for menus because they have got their scale above. // Will do nothing for menus because they have got their scale above.
UpdateBufferScale(false); UpdateBufferScale(false);
root_surface_->SetOpaqueRegion(bounds_px_); root_surface_->SetOpaqueRegion(gfx::Rect(bounds_px_.size()));
return true; return true;
} }
......
...@@ -1593,6 +1593,7 @@ TEST_P(WaylandWindowTest, SetOpaqueRegion) { ...@@ -1593,6 +1593,7 @@ TEST_P(WaylandWindowTest, SetOpaqueRegion) {
Sync(); Sync();
VerifyAndClearExpectations(); VerifyAndClearExpectations();
EXPECT_EQ(mock_surface->opaque_region(), new_bounds);
new_bounds.set_size(gfx::Size(1000, 534)); new_bounds.set_size(gfx::Size(1000, 534));
SendConfigureEvent(xdg_surface_, new_bounds.width(), new_bounds.height(), 2, SendConfigureEvent(xdg_surface_, new_bounds.width(), new_bounds.height(), 2,
...@@ -1604,6 +1605,7 @@ TEST_P(WaylandWindowTest, SetOpaqueRegion) { ...@@ -1604,6 +1605,7 @@ TEST_P(WaylandWindowTest, SetOpaqueRegion) {
Sync(); Sync();
VerifyAndClearExpectations(); VerifyAndClearExpectations();
EXPECT_EQ(mock_surface->opaque_region(), new_bounds);
} }
TEST_P(WaylandWindowTest, OnCloseRequest) { TEST_P(WaylandWindowTest, OnCloseRequest) {
...@@ -1647,6 +1649,8 @@ TEST_P(WaylandWindowTest, AuxiliaryWindowSimpleParent) { ...@@ -1647,6 +1649,8 @@ TEST_P(WaylandWindowTest, AuxiliaryWindowSimpleParent) {
EXPECT_EQ(test_subsurface->position(), subsurface_bounds.origin()); EXPECT_EQ(test_subsurface->position(), subsurface_bounds.origin());
EXPECT_FALSE(test_subsurface->sync()); EXPECT_FALSE(test_subsurface->sync());
EXPECT_EQ(mock_surface_subsurface->opaque_region(),
gfx::Rect(subsurface_bounds.size()));
auto* parent_resource = auto* parent_resource =
server_ server_
...@@ -1876,6 +1880,8 @@ TEST_P(WaylandWindowTest, AuxiliaryWindowNestedParent) { ...@@ -1876,6 +1880,8 @@ TEST_P(WaylandWindowTest, AuxiliaryWindowNestedParent) {
auto new_origin = subsurface_bounds.origin() - auto new_origin = subsurface_bounds.origin() -
menu_window_bounds.origin().OffsetFromOrigin(); menu_window_bounds.origin().OffsetFromOrigin();
EXPECT_EQ(test_subsurface->position(), new_origin); EXPECT_EQ(test_subsurface->position(), new_origin);
EXPECT_EQ(mock_surface_subsurface->opaque_region(),
gfx::Rect(subsurface_bounds.size()));
menu_window->SetPointerFocus(false); menu_window->SetPointerFocus(false);
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "ui/ozone/platform/wayland/test/mock_surface.h" #include "ui/ozone/platform/wayland/test/mock_surface.h"
#include "ui/ozone/platform/wayland/test/test_region.h"
namespace wl { namespace wl {
namespace { namespace {
...@@ -20,7 +22,7 @@ void Attach(wl_client* client, ...@@ -20,7 +22,7 @@ void Attach(wl_client* client,
void SetOpaqueRegion(wl_client* client, void SetOpaqueRegion(wl_client* client,
wl_resource* resource, wl_resource* resource,
wl_resource* region) { wl_resource* region) {
GetUserDataAs<MockSurface>(resource)->SetOpaqueRegion(region); GetUserDataAs<MockSurface>(resource)->SetOpaqueRegionImpl(region);
} }
void SetInputRegion(wl_client* client, void SetInputRegion(wl_client* client,
...@@ -100,6 +102,15 @@ MockSurface* MockSurface::FromResource(wl_resource* resource) { ...@@ -100,6 +102,15 @@ MockSurface* MockSurface::FromResource(wl_resource* resource) {
return GetUserDataAs<MockSurface>(resource); return GetUserDataAs<MockSurface>(resource);
} }
void MockSurface::SetOpaqueRegionImpl(wl_resource* region) {
auto bounds = GetUserDataAs<TestRegion>(region)->getBounds();
opaque_region_ =
gfx::Rect(bounds.fLeft, bounds.fTop, bounds.fRight - bounds.fLeft,
bounds.fBottom - bounds.fTop);
SetOpaqueRegion(region);
}
void MockSurface::AttachNewBuffer(wl_resource* buffer_resource, void MockSurface::AttachNewBuffer(wl_resource* buffer_resource,
int32_t x, int32_t x,
int32_t y) { int32_t y) {
......
...@@ -56,6 +56,8 @@ class MockSurface : public ServerObject { ...@@ -56,6 +56,8 @@ class MockSurface : public ServerObject {
void set_viewport(TestViewport* viewport) { viewport_ = viewport; } void set_viewport(TestViewport* viewport) { viewport_ = viewport; }
TestViewport* viewport() { return viewport_; } TestViewport* viewport() { return viewport_; }
gfx::Rect opaque_region() const { return opaque_region_; }
void set_frame_callback(wl_resource* callback_resource) { void set_frame_callback(wl_resource* callback_resource) {
DCHECK(!frame_callback_); DCHECK(!frame_callback_);
frame_callback_ = callback_resource; frame_callback_ = callback_resource;
...@@ -66,6 +68,7 @@ class MockSurface : public ServerObject { ...@@ -66,6 +68,7 @@ class MockSurface : public ServerObject {
bool has_role() const { return !!xdg_surface_ || !!sub_surface_; } bool has_role() const { return !!xdg_surface_ || !!sub_surface_; }
void SetOpaqueRegionImpl(wl_resource* region);
void AttachNewBuffer(wl_resource* buffer_resource, int32_t x, int32_t y); void AttachNewBuffer(wl_resource* buffer_resource, int32_t x, int32_t y);
void DestroyPrevAttachedBuffer(); void DestroyPrevAttachedBuffer();
void ReleaseBuffer(wl_resource* buffer); void ReleaseBuffer(wl_resource* buffer);
...@@ -75,6 +78,7 @@ class MockSurface : public ServerObject { ...@@ -75,6 +78,7 @@ class MockSurface : public ServerObject {
MockXdgSurface* xdg_surface_ = nullptr; MockXdgSurface* xdg_surface_ = nullptr;
TestSubSurface* sub_surface_ = nullptr; TestSubSurface* sub_surface_ = nullptr;
TestViewport* viewport_ = nullptr; TestViewport* viewport_ = nullptr;
gfx::Rect opaque_region_ = {-1, -1, 0, 0};
wl_resource* frame_callback_ = nullptr; wl_resource* frame_callback_ = nullptr;
......
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