Commit 06046d63 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11 and Ozone: make sure gfx::AcceleratedWidget to be uint32_t

Currently, Ozone/X11 defines gfx::AcceleratedWidget as
int32_t whereas non-Ozone/X11 defines that as x11::Window
or uint32_t. To fix the inconsistency and allow use_x11 &&
use_ozone builds, make non-Ozone/X11 uses Ozone's definition
of gfx::AcceleratedWidget.

Also adds missing includes.

Bug: 1098267
Change-Id: If9e98dd440c5d077990e390a0a10855723676b76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2260554Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#782872}
parent 33f18bf2
......@@ -210,7 +210,7 @@ GlobalMenuBarX11::GlobalMenuBarX11(BrowserView* browser_view,
: browser_(browser_view->browser()),
profile_(browser_->profile()),
browser_view_(browser_view),
window_(host->GetAcceleratedWidget()),
window_(static_cast<x11::Window>(host->GetAcceleratedWidget())),
tab_restore_service_(nullptr),
last_command_id_(kFirstUnreservedCommandId - 1) {
GlobalMenuBarRegistrarX11::GetInstance()->OnMenuBarCreated(this);
......
......@@ -12,7 +12,6 @@
#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/gpu_export.h"
#include "gpu/ipc/common/gpu_command_buffer_traits.h"
#include "gpu/ipc/common/surface_handle.h"
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/ipc/gfx_param_traits.h"
#include "url/ipc/url_param_traits.h"
......@@ -33,8 +32,4 @@ IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(viz::ResourceFormat, viz::RESOURCE_FORMAT_MAX)
#if defined(USE_X11)
IPC_ENUM_TRAITS(gpu::SurfaceHandle)
#endif
#endif // GPU_IPC_COMMON_GPU_PARAM_TRAITS_MACROS_H_
......@@ -191,7 +191,9 @@ class UIControlsX11 : public UIControlsAura {
void RunClosureAfterAllPendingUIEvents(base::OnceClosure closure) {
if (closure.is_null())
return;
ui::XEventWaiter::Create(host_->GetAcceleratedWidget(), std::move(closure));
ui::XEventWaiter::Create(
static_cast<x11::Window>(host_->GetAcceleratedWidget()),
std::move(closure));
}
private:
......
......@@ -13,7 +13,7 @@ namespace test {
void PostEventToWindowTreeHost(const XEvent& xevent, WindowTreeHost* host) {
XDisplay* xdisplay = gfx::GetXDisplay();
x11::Window xwindow = host->GetAcceleratedWidget();
x11::Window xwindow = static_cast<x11::Window>(host->GetAcceleratedWidget());
XEvent event = xevent;
event.xany.display = xdisplay;
event.xany.window = static_cast<uint32_t>(xwindow);
......
......@@ -77,7 +77,8 @@ void TestCompositorHostX11::Show() {
// to ensure the map is complete.
XSync(display, x11::False);
allocator_.GenerateId();
compositor_.SetAcceleratedWidget(window_);
compositor_.SetAcceleratedWidget(
static_cast<gfx::AcceleratedWidget>(window_));
compositor_.SetScaleAndSize(1.0f, bounds_.size(),
allocator_.GetCurrentLocalSurfaceIdAllocation());
compositor_.SetVisible(true);
......
......@@ -110,12 +110,6 @@ typedef struct _AtkObject AtkObject;
}
#endif
#if defined(USE_X11)
namespace x11 {
enum class Window : uint32_t;
}
#endif
namespace gfx {
#if defined(USE_AURA)
......@@ -239,10 +233,6 @@ typedef intptr_t NativeViewId;
#if defined(OS_WIN)
typedef HWND AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget = nullptr;
#elif defined(USE_X11)
typedef x11::Window AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget =
static_cast<x11::Window>(0);
#elif defined(OS_IOS)
typedef UIView* AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
......@@ -252,8 +242,8 @@ constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
#elif defined(OS_ANDROID)
typedef ANativeWindow* AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
#elif defined(USE_OZONE)
typedef int32_t AcceleratedWidget;
#elif defined(USE_OZONE) || defined(USE_X11)
typedef uint32_t AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
#else
#error unknown platform
......
......@@ -50,8 +50,8 @@ TEST(GLContextGLXTest, MAYBE_DoNotDestroyOnFailedMakeCurrent) {
XSync(xdisplay, x11::False);
GLImageTestSupport::InitializeGL(base::nullopt);
auto surface =
gl::InitializeGLSurface(base::MakeRefCounted<GLSurfaceGLXX11>(xwindow));
auto surface = gl::InitializeGLSurface(base::MakeRefCounted<GLSurfaceGLXX11>(
static_cast<gfx::AcceleratedWidget>(xwindow)));
scoped_refptr<GLContext> context =
gl::init::CreateGLContext(nullptr, surface.get(), GLContextAttribs());
......
......@@ -80,10 +80,12 @@ scoped_refptr<GLSurface> CreateViewGLSurfaceX11(gfx::AcceleratedWidget window) {
case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2:
DCHECK(window != gfx::kNullAcceleratedWidget);
return InitializeGLSurface(new NativeViewGLSurfaceEGLX11GLES2(window));
return InitializeGLSurface(
new NativeViewGLSurfaceEGLX11GLES2(static_cast<x11::Window>(window)));
case kGLImplementationEGLANGLE:
DCHECK(window != gfx::kNullAcceleratedWidget);
return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window));
return InitializeGLSurface(
new NativeViewGLSurfaceEGLX11(static_cast<x11::Window>(window)));
case kGLImplementationMockGL:
case kGLImplementationStubGL:
return new GLSurfaceStub;
......
......@@ -89,8 +89,8 @@ void GLOzoneEglCast::TerminateDisplay() {
scoped_refptr<gl::GLSurface> GLOzoneEglCast::CreateViewGLSurface(
gfx::AcceleratedWidget widget) {
// Verify requested widget dimensions match our current display size.
DCHECK_EQ(widget >> 16, display_size_.width());
DCHECK_EQ(widget & 0xffff, display_size_.height());
DCHECK_EQ(static_cast<int>(widget >> 16), display_size_.width());
DCHECK_EQ(static_cast<int>(widget & 0xffff), display_size_.height());
return gl::InitializeGLSurface(new GLSurfaceCast(widget, this));
}
......
......@@ -251,9 +251,11 @@ void TestMoveLoop::EndMoveLoop() {
SimpleTestDragDropClient::SimpleTestDragDropClient(
aura::Window* window,
DesktopNativeCursorManager* cursor_manager)
: DesktopDragDropClientAuraX11(window,
cursor_manager,
window->GetHost()->GetAcceleratedWidget()) {}
: DesktopDragDropClientAuraX11(
window,
cursor_manager,
static_cast<x11::Window>(window->GetHost()->GetAcceleratedWidget())) {
}
SimpleTestDragDropClient::~SimpleTestDragDropClient() = default;
......@@ -283,7 +285,9 @@ TestDragDropClient::TestDragDropClient(
aura::Window* window,
DesktopNativeCursorManager* cursor_manager)
: SimpleTestDragDropClient(window, cursor_manager),
source_window_(window->GetHost()->GetAcceleratedWidget()) {}
source_window_(
static_cast<x11::Window>(window->GetHost()->GetAcceleratedWidget())) {
}
TestDragDropClient::~TestDragDropClient() = default;
......@@ -591,8 +595,8 @@ void ChromeSourceTargetStep2(SimpleTestDragDropClient* client,
aura::client::SetDragDropDelegate(target_widget->GetNativeWindow(),
delegate.get());
client->SetTopmostXWindow(
target_widget->GetNativeView()->GetHost()->GetAcceleratedWidget());
client->SetTopmostXWindow(static_cast<x11::Window>(
target_widget->GetNativeView()->GetHost()->GetAcceleratedWidget()));
gfx::Rect target_widget_bounds_in_screen =
target_widget->GetWindowBoundsInScreen();
......
......@@ -4,6 +4,8 @@
#include "ui/views/widget/desktop_aura/desktop_screen_x11.h"
#include <set>
#include <string>
#include <vector>
#include "base/command_line.h"
......@@ -66,7 +68,7 @@ gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint(
gfx::ConvertPointToPixel(GetXDisplayScaleFactor(), point), {});
return window != x11::Window::None
? views::DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
window)
static_cast<gfx::AcceleratedWidget>(window))
: nullptr;
}
......@@ -81,7 +83,7 @@ gfx::NativeWindow DesktopScreenX11::GetLocalProcessWindowAtPoint(
ignore_widgets);
return window != x11::Window::None
? views::DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
window)
static_cast<gfx::AcceleratedWidget>(window))
: nullptr;
}
......
......@@ -143,8 +143,8 @@ class DesktopWindowTreeHostX11Test : public test::DesktopWidgetTestInteractive {
TEST_F(DesktopWindowTreeHostX11Test, Deactivate) {
std::unique_ptr<Widget> widget(CreateWidget(gfx::Rect(100, 100, 100, 100)));
ActivationWaiter waiter(
widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
ActivationWaiter waiter(static_cast<x11::Window>(
widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()));
widget->Show();
widget->Activate();
waiter.Wait();
......@@ -244,8 +244,8 @@ TEST_F(DesktopWindowTreeHostX11Test, InputMethodFocus) {
// Waiter should be created as early as possible so that PropertyNotify has
// time to be set before widget is activated.
ActivationWaiter waiter(
widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
ActivationWaiter waiter(static_cast<x11::Window>(
widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()));
std::unique_ptr<Textfield> textfield(new Textfield);
textfield->SetBounds(0, 0, 200, 20);
......
......@@ -285,7 +285,10 @@ void TestMoveLoop::EndMoveLoop() {
SimpleTestDragDropClient::SimpleTestDragDropClient(
aura::Window* window,
DesktopNativeCursorManager* cursor_manager)
: ui::XDragDropClient(this, window->GetHost()->GetAcceleratedWidget()) {}
: ui::XDragDropClient(
this,
static_cast<x11::Window>(window->GetHost()->GetAcceleratedWidget())) {
}
SimpleTestDragDropClient::~SimpleTestDragDropClient() = default;
......@@ -390,7 +393,9 @@ TestDragDropClient::TestDragDropClient(
aura::Window* window,
DesktopNativeCursorManager* cursor_manager)
: SimpleTestDragDropClient(window, cursor_manager),
source_window_(window->GetHost()->GetAcceleratedWidget()) {}
source_window_(
static_cast<x11::Window>(window->GetHost()->GetAcceleratedWidget())) {
}
TestDragDropClient::~TestDragDropClient() = default;
......
......@@ -163,11 +163,11 @@ class X11TopmostWindowFinderTest : public test::DesktopWidgetTestInteractive {
// NULL if the topmost window does not have an associated aura::Window.
aura::Window* FindTopmostLocalProcessWindowAt(int screen_x, int screen_y) {
ui::X11TopmostWindowFinder finder;
auto widget =
finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y), {});
auto widget = static_cast<gfx::AcceleratedWidget>(
finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y), {}));
return widget != gfx::kNullAcceleratedWidget
? DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
static_cast<gfx::AcceleratedWidget>(widget))
widget)
: nullptr;
}
......@@ -182,10 +182,11 @@ class X11TopmostWindowFinderTest : public test::DesktopWidgetTestInteractive {
ignore.insert(ignore_window->GetHost()->GetAcceleratedWidget());
ui::X11TopmostWindowFinder finder;
auto widget =
finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y), ignore);
static_cast<gfx::AcceleratedWidget>(finder.FindLocalProcessWindowAt(
gfx::Point(screen_x, screen_y), ignore));
return widget != gfx::kNullAcceleratedWidget
? DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
static_cast<gfx::AcceleratedWidget>(widget))
widget)
: nullptr;
}
......@@ -200,14 +201,16 @@ TEST_F(X11TopmostWindowFinderTest, Basic) {
std::unique_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 200, 100)));
aura::Window* window1 = widget1->GetNativeWindow();
x11::Window x11_window1 = window1->GetHost()->GetAcceleratedWidget();
x11::Window x11_window1 =
static_cast<x11::Window>(window1->GetHost()->GetAcceleratedWidget());
x11::Window x11_window2 = CreateAndShowXWindow(gfx::Rect(200, 100, 100, 200));
std::unique_ptr<Widget> widget3(
CreateAndShowWidget(gfx::Rect(100, 190, 200, 110)));
aura::Window* window3 = widget3->GetNativeWindow();
x11::Window x11_window3 = window3->GetHost()->GetAcceleratedWidget();
x11::Window x11_window3 =
static_cast<x11::Window>(window3->GetHost()->GetAcceleratedWidget());
x11::Window windows[] = {x11_window1, x11_window2, x11_window3};
StackingClientListWaiter waiter(windows, base::size(windows));
......@@ -249,7 +252,8 @@ TEST_F(X11TopmostWindowFinderTest, Minimized) {
std::unique_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 100, 100)));
aura::Window* window1 = widget1->GetNativeWindow();
x11::Window x11_window1 = window1->GetHost()->GetAcceleratedWidget();
x11::Window x11_window1 =
static_cast<x11::Window>(window1->GetHost()->GetAcceleratedWidget());
x11::Window x11_window2 = CreateAndShowXWindow(gfx::Rect(300, 100, 100, 100));
x11::Window windows[] = {x11_window1, x11_window2};
......@@ -287,8 +291,8 @@ TEST_F(X11TopmostWindowFinderTest, NonRectangular) {
std::unique_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 100, 100)));
x11::Window window1 =
widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
x11::Window window1 = static_cast<x11::Window>(
widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
auto shape1 = std::make_unique<Widget::ShapeRects>();
shape1->emplace_back(0, 10, 10, 90);
shape1->emplace_back(10, 0, 90, 100);
......@@ -331,8 +335,8 @@ TEST_F(X11TopmostWindowFinderTest, NonRectangularEmptyShape) {
std::unique_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 100, 100)));
x11::Window window1 =
widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
x11::Window window1 = static_cast<x11::Window>(
widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
auto shape1 = std::make_unique<Widget::ShapeRects>();
shape1->emplace_back();
// Widget takes ownership of |shape1|.
......@@ -353,8 +357,8 @@ TEST_F(X11TopmostWindowFinderTest, NonRectangularNullShape) {
std::unique_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 100, 100)));
x11::Window window1 =
widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
x11::Window window1 = static_cast<x11::Window>(
widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
auto shape1 = std::make_unique<Widget::ShapeRects>();
shape1->emplace_back();
widget1->SetShape(std::move(shape1));
......
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