diff options
author | dnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 00:13:32 +0000 |
---|---|---|
committer | dnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 00:13:32 +0000 |
commit | b0565110b2ba7abd5beb21cbbce3041f7b2d171f (patch) | |
tree | 986fe47844d0374f37b4d420184e5990d7570405 | |
parent | 5d11eff456ebdd84b7af0f9144d0c83abd69004c (diff) | |
download | chromium_src-b0565110b2ba7abd5beb21cbbce3041f7b2d171f.zip chromium_src-b0565110b2ba7abd5beb21cbbce3041f7b2d171f.tar.gz chromium_src-b0565110b2ba7abd5beb21cbbce3041f7b2d171f.tar.bz2 |
Updated Wayland API in Chromium
Thanks to Kristian Høgsberg (krh@bitplanet.net) who submited the Wayland API changes.
I've also updated the native_widget_wayland.* to match the current implementations.
BUG=
TEST=
Review URL: http://codereview.chromium.org/7862021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101198 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/gfx/gl/gl_surface_wayland.cc | 2 | ||||
-rw-r--r-- | ui/gfx/pango_util.cc | 2 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_wayland.cc | 3 | ||||
-rw-r--r-- | ui/wayland/wayland_display.cc | 42 | ||||
-rw-r--r-- | ui/wayland/wayland_display.h | 12 | ||||
-rw-r--r-- | ui/wayland/wayland_input_device.cc | 3 | ||||
-rw-r--r-- | ui/wayland/wayland_screen.cc | 3 | ||||
-rw-r--r-- | ui/wayland/wayland_shm_buffer.cc | 3 | ||||
-rw-r--r-- | views/widget/native_widget_wayland.cc | 17 | ||||
-rw-r--r-- | views/widget/native_widget_wayland.h | 12 |
10 files changed, 37 insertions, 62 deletions
diff --git a/ui/gfx/gl/gl_surface_wayland.cc b/ui/gfx/gl/gl_surface_wayland.cc index dd0f8c7..80aa303 100644 --- a/ui/gfx/gl/gl_surface_wayland.cc +++ b/ui/gfx/gl/gl_surface_wayland.cc @@ -56,8 +56,6 @@ bool PixmapGLSurfaceEGL::Initialize() { pixmap_ = wl_egl_pixmap_create( size_.width(), size_.height(), - ui::WaylandDisplay::GetDisplay( - GLSurfaceEGL::GetNativeDisplay())->visual(), 0); surface_ = eglCreatePixmapSurface(gfx::GLSurfaceEGL::GetDisplay(), gfx::GLSurfaceEGL::GetConfig(), diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc index e04aa48..16186fb 100644 --- a/ui/gfx/pango_util.cc +++ b/ui/gfx/pango_util.cc @@ -16,6 +16,8 @@ #if !defined(USE_WAYLAND) #include "ui/gfx/gtk_util.h" +#else +#include "ui/gfx/linux_util.h" #endif #include "ui/gfx/skia_util.h" diff --git a/ui/gfx/surface/accelerated_surface_wayland.cc b/ui/gfx/surface/accelerated_surface_wayland.cc index 29d0e7d..a83fb78 100644 --- a/ui/gfx/surface/accelerated_surface_wayland.cc +++ b/ui/gfx/surface/accelerated_surface_wayland.cc @@ -17,13 +17,10 @@ AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) image_(NULL), pixmap_(NULL), texture_(0) { - ui::WaylandDisplay* dpy = ui::WaylandDisplay::GetDisplay( - gfx::GLSurfaceEGL::GetNativeDisplay()); EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); pixmap_ = wl_egl_pixmap_create(size_.width(), size_.height(), - dpy->visual(), 0); image_ = eglCreateImageKHR( diff --git a/ui/wayland/wayland_display.cc b/ui/wayland/wayland_display.cc index 3c7246c..cf79de9 100644 --- a/ui/wayland/wayland_display.cc +++ b/ui/wayland/wayland_display.cc @@ -26,7 +26,7 @@ WaylandDisplay* WaylandDisplay::Connect(char* name) { // Register the display initialization handler and iterate over the initial // connection events sent by the server. This is required since the display // will send registration events needed to initialize everything else. This - // will create the compositor, visuals, etc.., which are required in creating + // will create the compositor, etc.., which are required in creating // a drawing context. wl_display_add_global_listener(display->display_, WaylandDisplay::DisplayHandleGlobal, @@ -44,8 +44,7 @@ WaylandDisplay* WaylandDisplay::GetDisplay(wl_display* display) { WaylandDisplay::WaylandDisplay(char* name) : display_(NULL), compositor_(NULL), shell_(NULL), - shm_(NULL), - visual_(NULL) { + shm_(NULL) { display_ = wl_display_connect(name); } @@ -54,8 +53,6 @@ WaylandDisplay::~WaylandDisplay() { wl_display_destroy(display_); if (compositor_) wl_compositor_destroy(compositor_); - if (visual_) - wl_visual_destroy(visual_); if (shell_) wl_shell_destroy(shell_); if (shm_) @@ -96,18 +93,13 @@ void WaylandDisplay::DisplayHandleGlobal(wl_display* display, void* data) { WaylandDisplay* disp = static_cast<WaylandDisplay*>(data); - static const wl_compositor_listener kCompositorListener = { - WaylandDisplay::CompositorHandleVisual, - }; static const wl_shell_listener kShellListener = { WaylandDisplay::ShellHandleConfigure, }; if (strcmp(interface, "wl_compositor") == 0) { - disp->compositor_ = wl_compositor_create(display, id, 1); - wl_compositor_add_listener(disp->compositor_, - &kCompositorListener, - disp); + disp->compositor_ = static_cast<wl_compositor*>( + wl_display_bind(display, id, &wl_compositor_interface)); } else if (strcmp(interface, "wl_output") == 0) { WaylandScreen* screen = new WaylandScreen(disp, id); disp->screen_list_.push_back(screen); @@ -115,30 +107,12 @@ void WaylandDisplay::DisplayHandleGlobal(wl_display* display, WaylandInputDevice *input_device = new WaylandInputDevice(display, id); disp->input_list_.push_back(input_device); } else if (strcmp(interface, "wl_shell") == 0) { - disp->shell_ = wl_shell_create(display, id, 1); + disp->shell_ = static_cast<wl_shell*>( + wl_display_bind(display, id, &wl_shell_interface)); wl_shell_add_listener(disp->shell_, &kShellListener, disp); } else if (strcmp(interface, "wl_shm") == 0) { - disp->shm_ = wl_shm_create(display, id, 1); - } -} - -// static -void WaylandDisplay::CompositorHandleVisual(void* data, - wl_compositor* compositor, - uint32_t id, - uint32_t token) { - WaylandDisplay* display = static_cast<WaylandDisplay*>(data); - - // The compositor may support multiple types of visuals but we really only - // need one. - switch (token) { - case WL_COMPOSITOR_VISUAL_ARGB32: - break; - case WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32: - display->visual_ = wl_visual_create(display->display_, id, 1); - break; - case WL_COMPOSITOR_VISUAL_XRGB32: - break; + disp->shm_ = static_cast<wl_shm*>( + wl_display_bind(display, id, &wl_shm_interface)); } } diff --git a/ui/wayland/wayland_display.h b/ui/wayland/wayland_display.h index 424c45c..f122e55 100644 --- a/ui/wayland/wayland_display.h +++ b/ui/wayland/wayland_display.h @@ -16,7 +16,6 @@ struct wl_display; struct wl_shell; struct wl_shm; struct wl_surface; -struct wl_visual; namespace ui { @@ -26,7 +25,7 @@ class WaylandScreen; // WaylandDisplay is a wrapper around wl_display. Once we get a valid // wl_display, the Wayland server will send different events to register -// the Wayland compositor, shell, visuals, screens, input devices, ... +// the Wayland compositor, shell, screens, input devices, ... class WaylandDisplay { public: // Attempt to create a connection to the display. If it fails this returns @@ -56,8 +55,6 @@ class WaylandDisplay { wl_shm* shm() const { return shm_; } - wl_visual* visual() const { return visual_; } - private: WaylandDisplay(char* name); @@ -69,12 +66,6 @@ class WaylandDisplay { uint32_t version, void* data); - // Used by the compositor initialization to register the different visuals. - static void CompositorHandleVisual(void* data, - wl_compositor* compositor, - uint32_t id, - uint32_t token); - // Used when the shell requires configuration. This is called when a // window is configured and receives its size. // TODO(dnicoara) Need to look if there is one shell per window. Then it @@ -93,7 +84,6 @@ class WaylandDisplay { wl_compositor* compositor_; wl_shell* shell_; wl_shm* shm_; - wl_visual* visual_; std::list<WaylandScreen*> screen_list_; std::list<WaylandInputDevice*> input_list_; diff --git a/ui/wayland/wayland_input_device.cc b/ui/wayland/wayland_input_device.cc index 05efd98..100e19d 100644 --- a/ui/wayland/wayland_input_device.cc +++ b/ui/wayland/wayland_input_device.cc @@ -16,7 +16,8 @@ namespace ui { WaylandInputDevice::WaylandInputDevice( wl_display* display, uint32_t id) - : input_device_(wl_input_device_create(display, id, 1)), + : input_device_(static_cast<wl_input_device*>( + wl_display_bind(display, id, &wl_input_device_interface))), pointer_focus_(NULL), keyboard_focus_(NULL), keyboard_modifiers_(0) { diff --git a/ui/wayland/wayland_screen.cc b/ui/wayland/wayland_screen.cc index 73a181b..c29bc56 100644 --- a/ui/wayland/wayland_screen.cc +++ b/ui/wayland/wayland_screen.cc @@ -18,7 +18,8 @@ WaylandScreen::WaylandScreen(WaylandDisplay* display, uint32_t id) WaylandScreen::OutputHandleMode, }; - output_ = wl_output_create(display_->display(), id, 1); + output_ = static_cast<wl_output*>( + wl_display_bind(display_->display(), id, &wl_output_interface)); wl_output_add_listener(output_, &kOutputListener, this); } diff --git a/ui/wayland/wayland_shm_buffer.cc b/ui/wayland/wayland_shm_buffer.cc index 2cd59ac..7406847 100644 --- a/ui/wayland/wayland_shm_buffer.cc +++ b/ui/wayland/wayland_shm_buffer.cc @@ -47,7 +47,8 @@ WaylandShmBuffer::WaylandShmBuffer(WaylandDisplay* display, data_surface_ = cairo_image_surface_create_for_data( data, CAIRO_FORMAT_ARGB32, width, height, stride); buffer_ = wl_shm_create_buffer(display->shm(), fd, - width, height, stride, display->visual()); + width, height, stride, + WL_SHM_FORMAT_PREMULTIPLIED_ARGB32); close(fd); } diff --git a/views/widget/native_widget_wayland.cc b/views/widget/native_widget_wayland.cc index ea1a1c3..2c9b67d 100644 --- a/views/widget/native_widget_wayland.cc +++ b/views/widget/native_widget_wayland.cc @@ -77,8 +77,7 @@ void NativeWidgetWayland::InitNativeWidget(const Widget::InitParams& params) { egl_window_ = wl_egl_window_create(wayland_window_->surface(), allocation_.width(), - allocation_.height(), - wayland_display_->visual()); + allocation_.height()); SetNativeWindowProperty(kNativeWidgetKey, this); @@ -86,7 +85,9 @@ void NativeWidgetWayland::InitNativeWidget(const Widget::InitParams& params) { if (Widget::compositor_factory()) { compositor_ = (*Widget::compositor_factory())(); } else { - compositor_ = ui::Compositor::Create(egl_window_, allocation_.size()); + compositor_ = ui::Compositor::Create(this, + egl_window_, + allocation_.size()); } if (compositor_.get()) delegate_->AsWidget()->GetRootView()->SetPaintToLayer(true); @@ -244,9 +245,9 @@ void NativeWidgetWayland::CenterWindow(const gfx::Size& size) { NOTIMPLEMENTED(); } -void NativeWidgetWayland::GetWindowBoundsAndMaximizedState( +void NativeWidgetWayland::GetWindowPlacement( gfx::Rect* bounds, - bool* maximized) const { + ui::WindowShowState* show_state) const { NOTIMPLEMENTED(); } @@ -366,7 +367,7 @@ void NativeWidgetWayland::ShowMaximizedWithBounds( saved_allocation_ = restored_bounds; } -void NativeWidgetWayland::ShowWithState(ShowState state) { +void NativeWidgetWayland::ShowWithWindowState(ui::WindowShowState state) { NOTIMPLEMENTED(); } @@ -505,6 +506,10 @@ bool NativeWidgetWayland::ConvertPointFromAncestor( return false; } +void NativeWidgetWayland::ScheduleCompositorPaint() { + SchedulePaintInRect(allocation_); +} + // Overridden from NativeWidget gfx::AcceleratedWidget NativeWidgetWayland::GetAcceleratedWidget() { return egl_window_; diff --git a/views/widget/native_widget_wayland.h b/views/widget/native_widget_wayland.h index 59bfee2..f5bfa45 100644 --- a/views/widget/native_widget_wayland.h +++ b/views/widget/native_widget_wayland.h @@ -9,6 +9,7 @@ #include <wayland-client.h> #include "base/memory/scoped_vector.h" +#include "ui/gfx/compositor/compositor.h" #include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_surface.h" #include "ui/gfx/size.h" @@ -38,6 +39,7 @@ class NativeWidgetDelegate; // Widget implementation for Wayland class NativeWidgetWayland : public internal::NativeWidgetPrivate, + public ui::CompositorDelegate, public ui::WaylandWidget { public: explicit NativeWidgetWayland(internal::NativeWidgetDelegate* delegate); @@ -72,8 +74,9 @@ class NativeWidgetWayland : public internal::NativeWidgetPrivate, virtual bool HasMouseCapture() const OVERRIDE; virtual InputMethod* CreateInputMethod() OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; - virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, - bool* maximized) const OVERRIDE; + virtual void GetWindowPlacement( + gfx::Rect* bounds, + ui::WindowShowState* show_state) const OVERRIDE; virtual void SetWindowTitle(const std::wstring& title) OVERRIDE; virtual void SetWindowIcons(const SkBitmap& window_icon, const SkBitmap& app_icon) OVERRIDE; @@ -98,7 +101,7 @@ class NativeWidgetWayland : public internal::NativeWidgetPrivate, virtual void Hide() OVERRIDE; virtual void ShowMaximizedWithBounds( const gfx::Rect& restored_bounds) OVERRIDE; - virtual void ShowWithState(ShowState state) OVERRIDE; + virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE; virtual bool IsVisible() const OVERRIDE; virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; @@ -135,6 +138,9 @@ class NativeWidgetWayland : public internal::NativeWidgetPrivate, private: typedef ScopedVector<ui::ViewProp> ViewProps; + // Overridden from ui::CompositorDelegate + virtual void ScheduleCompositorPaint(); + // Overridden from NativeWidget virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |