summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authordnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-10 16:50:44 +0000
committerdnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-10 16:50:44 +0000
commitf1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b (patch)
tree0e711e1f5d167a35844627206d709485a730b804 /ui/gfx
parent11edb87b32bc384c4df1ff342a38647c076a722f (diff)
downloadchromium_src-f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b.zip
chromium_src-f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b.tar.gz
chromium_src-f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b.tar.bz2
Adding Wayland support for ui/gfx
* Added GL surface and context support for Wayland. * Updated ui/gfx files to allow Wayland support * All Wayland code is behind the use_wayland gyp flag This CL depends on http://codereview.chromium.org/7457023 BUG= TEST=Compiled Chrome with use_wayland disabled to verify that the changes didn't break anything Review URL: http://codereview.chromium.org/7467007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/canvas_skia_linux.cc5
-rw-r--r--ui/gfx/gl/egl_util.cc2
-rw-r--r--ui/gfx/gl/gl.gyp8
-rw-r--r--ui/gfx/gl/gl_bindings.h4
-rw-r--r--ui/gfx/gl/gl_context_linux.cc10
-rw-r--r--ui/gfx/gl/gl_implementation_linux.cc4
-rw-r--r--ui/gfx/gl/gl_surface_egl.cc17
-rw-r--r--ui/gfx/gl/gl_surface_egl.h2
-rw-r--r--ui/gfx/gl/gl_surface_wayland.cc165
-rw-r--r--ui/gfx/gtk_util.cc12
-rw-r--r--ui/gfx/gtk_util.h5
-rw-r--r--ui/gfx/native_widget_types.h32
-rw-r--r--ui/gfx/platform_font_gtk.cc41
-rw-r--r--ui/gfx/screen_wayland.cc57
-rw-r--r--ui/gfx/surface/accelerated_surface_wayland.cc51
-rw-r--r--ui/gfx/surface/accelerated_surface_wayland.h37
-rw-r--r--ui/gfx/surface/surface.gyp12
17 files changed, 439 insertions, 25 deletions
diff --git a/ui/gfx/canvas_skia_linux.cc b/ui/gfx/canvas_skia_linux.cc
index 17da4fc..7cf72d5 100644
--- a/ui/gfx/canvas_skia_linux.cc
+++ b/ui/gfx/canvas_skia_linux.cc
@@ -45,17 +45,20 @@ void UpdateCairoFontOptions() {
if (!cairo_font_options)
cairo_font_options = cairo_font_options_create();
- GtkSettings* gtk_settings = gtk_settings_get_default();
gint antialias = 0;
gint hinting = 0;
gchar* hint_style = NULL;
gchar* rgba_style = NULL;
+
+#if !defined(USE_WAYLAND)
+ GtkSettings* gtk_settings = gtk_settings_get_default();
g_object_get(gtk_settings,
"gtk-xft-antialias", &antialias,
"gtk-xft-hinting", &hinting,
"gtk-xft-hintstyle", &hint_style,
"gtk-xft-rgba", &rgba_style,
NULL);
+#endif
// g_object_get() doesn't tell us whether the properties were present or not,
// but if they aren't (because gnome-settings-daemon isn't running), we'll get
diff --git a/ui/gfx/gl/egl_util.cc b/ui/gfx/gl/egl_util.cc
index 29eb92d..becc260 100644
--- a/ui/gfx/gl/egl_util.cc
+++ b/ui/gfx/gl/egl_util.cc
@@ -5,6 +5,8 @@
#include "ui/gfx/gl/egl_util.h"
#include "third_party/angle/include/EGL/egl.h"
+
+// This needs to be after the EGL includes
#include "ui/gfx/gl/gl_bindings.h"
namespace gfx {
diff --git a/ui/gfx/gl/gl.gyp b/ui/gfx/gl/gl.gyp
index 5771682..8e799ce 100644
--- a/ui/gfx/gl/gl.gyp
+++ b/ui/gfx/gl/gl.gyp
@@ -58,6 +58,7 @@
'gl_surface_mac.cc',
'gl_surface_stub.cc',
'gl_surface_stub.h',
+ 'gl_surface_wayland.cc',
'gl_surface_win.cc',
'gl_surface_osmesa.cc',
'gl_surface_osmesa.h',
@@ -116,7 +117,12 @@
'<(DEPTH)/third_party/angle/include',
],
}],
- ['use_x11 == 1', {
+ ['use_wayland == 1', {
+ 'sources!': [
+ 'gl_surface_linux.cc',
+ ],
+ }],
+ ['use_x11 == 1 and use_wayland != 1', {
'sources': [
'gl_context_glx.cc',
'gl_context_glx.h',
diff --git a/ui/gfx/gl/gl_bindings.h b/ui/gfx/gl/gl_bindings.h
index 34f9772..fc47b60 100644
--- a/ui/gfx/gl/gl_bindings.h
+++ b/ui/gfx/gl/gl_bindings.h
@@ -64,6 +64,10 @@ typedef void* GLeglImageOES;
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
+#elif defined(USE_WAYLAND)
+typedef struct wl_display *EGLNativeDisplayType;
+typedef struct wl_egl_pixmap *EGLNativePixmapType;
+typedef struct wl_egl_window *EGLNativeWindowType;
#else
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
diff --git a/ui/gfx/gl/gl_context_linux.cc b/ui/gfx/gl/gl_context_linux.cc
index 238bd5f..083b1ff 100644
--- a/ui/gfx/gl/gl_context_linux.cc
+++ b/ui/gfx/gl/gl_context_linux.cc
@@ -26,6 +26,7 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(
GLShareGroup* share_group,
GLSurface* compatible_surface) {
switch (GetGLImplementation()) {
+#if !defined(USE_WAYLAND)
case kGLImplementationOSMesaGL: {
scoped_refptr<GLContext> context(new GLContextOSMesa(share_group));
if (!context->Initialize(compatible_surface))
@@ -33,15 +34,16 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(
return context;
}
- case kGLImplementationEGLGLES2: {
- scoped_refptr<GLContext> context(new GLContextEGL(share_group));
+ case kGLImplementationDesktopGL: {
+ scoped_refptr<GLContext> context(new GLContextGLX(share_group));
if (!context->Initialize(compatible_surface))
return NULL;
return context;
}
- case kGLImplementationDesktopGL: {
- scoped_refptr<GLContext> context(new GLContextGLX(share_group));
+#endif
+ case kGLImplementationEGLGLES2: {
+ scoped_refptr<GLContext> context(new GLContextEGL(share_group));
if (!context->Initialize(compatible_surface))
return NULL;
diff --git a/ui/gfx/gl/gl_implementation_linux.cc b/ui/gfx/gl/gl_implementation_linux.cc
index 7baf2f6..97e3087 100644
--- a/ui/gfx/gl/gl_implementation_linux.cc
+++ b/ui/gfx/gl/gl_implementation_linux.cc
@@ -53,6 +53,7 @@ bool InitializeGLBindings(GLImplementation implementation) {
return true;
switch (implementation) {
+#if !defined(USE_WAYLAND)
case kGLImplementationOSMesaGL: {
FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path)) {
@@ -106,6 +107,7 @@ bool InitializeGLBindings(GLImplementation implementation) {
InitializeGLBindingsGLX();
break;
}
+#endif // !defined(USE_WAYLAND)
case kGLImplementationEGLGLES2: {
base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so");
if (!gles_library)
@@ -158,8 +160,10 @@ bool InitializeGLBindings(GLImplementation implementation) {
void InitializeDebugGLBindings() {
InitializeDebugGLBindingsEGL();
InitializeDebugGLBindingsGL();
+#if !defined(USE_WAYLAND)
InitializeDebugGLBindingsGLX();
InitializeDebugGLBindingsOSMESA();
+#endif
}
} // namespace gfx
diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc
index 5bc03ad..2f95385 100644
--- a/ui/gfx/gl/gl_surface_egl.cc
+++ b/ui/gfx/gl/gl_surface_egl.cc
@@ -15,12 +15,16 @@
// it brings in #defines that cause conflicts.
#include "ui/gfx/gl/gl_bindings.h"
-#if defined(USE_X11)
+#if defined(USE_X11) && !defined(USE_WAYLAND)
extern "C" {
#include <X11/Xlib.h>
}
#endif
+#if defined(USE_WAYLAND)
+#include "ui/wayland/wayland_display.h"
+#endif
+
namespace gfx {
namespace {
@@ -43,7 +47,9 @@ bool GLSurfaceEGL::InitializeOneOff() {
if (initialized)
return true;
-#if defined(USE_X11)
+#if defined(USE_WAYLAND)
+ g_native_display = ui::WaylandDisplay::Connect(NULL)->display();
+#elif defined(USE_X11)
g_native_display = XOpenDisplay(NULL);
#else
g_native_display = EGL_DEFAULT_DISPLAY;
@@ -67,7 +73,12 @@ bool GLSurfaceEGL::InitializeOneOff() {
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT
+#if defined(USE_WAYLAND)
+ | EGL_PIXMAP_BIT,
+#else
+ | EGL_PBUFFER_BIT,
+#endif
EGL_NONE
};
diff --git a/ui/gfx/gl/gl_surface_egl.h b/ui/gfx/gl/gl_surface_egl.h
index 1b03a75..e7caaff 100644
--- a/ui/gfx/gl/gl_surface_egl.h
+++ b/ui/gfx/gl/gl_surface_egl.h
@@ -20,6 +20,8 @@ typedef void* EGLSurface;
#if defined(OS_WIN)
typedef HDC EGLNativeDisplayType;
+#elif defined(USE_WAYLAND)
+typedef struct wl_display* EGLNativeDisplayType;
#else
typedef struct _XDisplay* EGLNativeDisplayType;
#endif
diff --git a/ui/gfx/gl/gl_surface_wayland.cc b/ui/gfx/gl/gl_surface_wayland.cc
new file mode 100644
index 0000000..dd0f8c7
--- /dev/null
+++ b/ui/gfx/gl/gl_surface_wayland.cc
@@ -0,0 +1,165 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/gl/gl_surface.h"
+
+#include <wayland-egl.h>
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/gl/egl_util.h"
+#include "ui/gfx/gl/gl_bindings.h"
+#include "ui/gfx/gl/gl_implementation.h"
+#include "ui/gfx/gl/gl_surface_egl.h"
+#include "ui/wayland/wayland_display.h"
+
+namespace {
+
+// Encapsulates a pixmap EGL surface.
+class PixmapGLSurfaceEGL : public gfx::GLSurfaceEGL {
+ public:
+ explicit PixmapGLSurfaceEGL(bool software, const gfx::Size& size);
+ virtual ~PixmapGLSurfaceEGL();
+
+ // Implement GLSurface.
+ virtual bool Initialize();
+ virtual void Destroy();
+ virtual bool IsOffscreen();
+ virtual bool SwapBuffers();
+ virtual gfx::Size GetSize();
+ virtual EGLSurface GetHandle();
+
+ private:
+ gfx::Size size_;
+ EGLSurface surface_;
+ EGLNativePixmapType pixmap_;
+
+ DISALLOW_COPY_AND_ASSIGN(PixmapGLSurfaceEGL);
+};
+
+PixmapGLSurfaceEGL::PixmapGLSurfaceEGL(bool software, const gfx::Size& size)
+ : size_(size),
+ surface_(NULL),
+ pixmap_(NULL) {
+ software_ = software;
+}
+
+PixmapGLSurfaceEGL::~PixmapGLSurfaceEGL() {
+ Destroy();
+}
+
+bool PixmapGLSurfaceEGL::Initialize() {
+ DCHECK(!surface_);
+ DCHECK(!pixmap_);
+
+ pixmap_ = wl_egl_pixmap_create(
+ size_.width(),
+ size_.height(),
+ ui::WaylandDisplay::GetDisplay(
+ GLSurfaceEGL::GetNativeDisplay())->visual(),
+ 0);
+ surface_ = eglCreatePixmapSurface(gfx::GLSurfaceEGL::GetDisplay(),
+ gfx::GLSurfaceEGL::GetConfig(),
+ pixmap_,
+ NULL);
+ if (!surface_) {
+ LOG(ERROR) << "eglCreatePixmapSurface failed with error "
+ << gfx::GetLastEGLErrorString();
+ Destroy();
+ return false;
+ }
+
+ return true;
+}
+
+void PixmapGLSurfaceEGL::Destroy() {
+ if (surface_) {
+ if (!eglDestroySurface(gfx::GLSurfaceEGL::GetDisplay(), surface_)) {
+ LOG(ERROR) << "eglDestroySurface failed with error "
+ << gfx::GetLastEGLErrorString();
+ }
+ surface_ = NULL;
+ }
+ if (pixmap_) {
+ wl_egl_pixmap_destroy(pixmap_);
+ pixmap_ = NULL;
+ }
+}
+
+bool PixmapGLSurfaceEGL::IsOffscreen() {
+ return true;
+}
+
+bool PixmapGLSurfaceEGL::SwapBuffers() {
+ NOTREACHED() << "Attempted to call SwapBuffers on a PixmapGLSurfaceEGL.";
+ return false;
+}
+
+gfx::Size PixmapGLSurfaceEGL::GetSize() {
+ return size_;
+}
+
+EGLSurface PixmapGLSurfaceEGL::GetHandle() {
+ return surface_;
+}
+
+}
+
+namespace gfx {
+
+bool GLSurface::InitializeOneOff() {
+ static bool initialized = false;
+ if (initialized)
+ return true;
+
+ static const GLImplementation kAllowedGLImplementations[] = {
+ kGLImplementationEGLGLES2
+ };
+
+ if (!InitializeRequestedGLBindings(
+ kAllowedGLImplementations,
+ kAllowedGLImplementations + arraysize(kAllowedGLImplementations),
+ kGLImplementationEGLGLES2)) {
+ LOG(ERROR) << "InitializeRequestedGLBindings failed.";
+ return false;
+ }
+
+ if (!GLSurfaceEGL::InitializeOneOff()) {
+ LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
+ return false;
+ }
+
+ initialized = true;
+ return true;
+}
+
+scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
+ bool software,
+ gfx::PluginWindowHandle window) {
+
+ if (software)
+ return NULL;
+
+ scoped_refptr<GLSurface> surface(
+ new NativeViewGLSurfaceEGL(software, window));
+ if (!surface->Initialize())
+ return NULL;
+
+ return surface;
+}
+
+scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
+ bool software,
+ const gfx::Size& size) {
+ if (software)
+ return NULL;
+
+ scoped_refptr<GLSurface> surface(new PixmapGLSurfaceEGL(software, size));
+ if (!surface->Initialize())
+ return NULL;
+
+ return surface;
+}
+
+} // namespace gfx
diff --git a/ui/gfx/gtk_util.cc b/ui/gfx/gtk_util.cc
index b1c7f44..fb5a31d 100644
--- a/ui/gfx/gtk_util.cc
+++ b/ui/gfx/gtk_util.cc
@@ -164,12 +164,22 @@ void SubtractRectanglesFromRegion(GdkRegion* region,
}
}
+PangoContext* GetPangoContext() {
+#if defined(USE_WAYLAND)
+ PangoFontMap* font_map = pango_cairo_font_map_get_default();
+ PangoContext* default_context = pango_font_map_create_context(font_map);
+#else
+ PangoContext* default_context = gdk_pango_context_get();
+#endif
+ return default_context;
+}
+
double GetPangoResolution() {
static double resolution;
static bool determined_resolution = false;
if (!determined_resolution) {
determined_resolution = true;
- PangoContext* default_context = gdk_pango_context_get();
+ PangoContext* default_context = GetPangoContext();
resolution = pango_cairo_context_get_resolution(default_context);
g_object_unref(default_context);
}
diff --git a/ui/gfx/gtk_util.h b/ui/gfx/gtk_util.h
index 1f72c01..7438165 100644
--- a/ui/gfx/gtk_util.h
+++ b/ui/gfx/gtk_util.h
@@ -19,6 +19,8 @@ typedef struct _GdkPixbuf GdkPixbuf;
typedef struct _GdkRegion GdkRegion;
typedef struct _GdkCursor GdkCursor;
+typedef struct _PangoContext PangoContext;
+
class CommandLine;
class SkBitmap;
@@ -40,6 +42,9 @@ UI_EXPORT GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap);
UI_EXPORT void SubtractRectanglesFromRegion(GdkRegion* region,
const std::vector<Rect>& cutouts);
+// Creates and returns a PangoContext. The caller owns the context.
+PangoContext* GetPangoContext();
+
// Returns the resolution (DPI) used by pango. A negative values means the
// resolution hasn't been set.
double GetPangoResolution();
diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h
index a5afdbd..251b4d5 100644
--- a/ui/gfx/native_widget_types.h
+++ b/ui/gfx/native_widget_types.h
@@ -55,6 +55,18 @@ class NSView;
class NSWindow;
class NSTextField;
#endif // __OBJC__
+#elif defined(USE_WAYLAND)
+typedef struct _PangoFontDescription PangoFontDescription;
+typedef struct _cairo cairo_t;
+typedef struct _GdkPixbuf GdkPixbuf;
+struct wl_egl_window;
+
+namespace ui {
+class WaylandWindow;
+class WaylandCursor;
+}
+
+typedef struct _GdkRegion GdkRegion;
#elif defined(TOOLKIT_USES_GTK)
typedef struct _PangoFontDescription PangoFontDescription;
typedef struct _GdkCursor GdkCursor;
@@ -87,6 +99,18 @@ typedef CGContext* NativeDrawingContext;
typedef void* NativeCursor;
typedef void* NativeMenu;
typedef void* NativeViewAccessible;
+#elif defined(USE_WAYLAND)
+typedef PangoFontDescription* NativeFont;
+typedef ui::WaylandWindow* NativeView;
+typedef ui::WaylandWindow* NativeWindow;
+typedef void* NativeEditView;
+typedef cairo_t* NativeDrawingContext;
+typedef void* NativeCursor;
+typedef void* NativeMenu;
+// TODO(dnicoara) This should be replaced with a cairo region or maybe
+// a Wayland specific region
+typedef GdkRegion* NativeRegion;
+typedef void* NativeViewAccessible;
#elif defined(USE_X11)
typedef PangoFontDescription* NativeFont;
typedef GtkWidget* NativeView;
@@ -141,7 +165,7 @@ static inline NativeView NativeViewFromIdInBrowser(NativeViewId id) {
// Convert a NativeView to a NativeViewId. See the comments at the top of
// this file.
-#if defined(OS_WIN) || defined(OS_MACOSX)
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_WAYLAND)
static inline NativeViewId IdFromNativeView(NativeView view) {
return reinterpret_cast<NativeViewId>(view);
}
@@ -157,6 +181,9 @@ UI_EXPORT NativeViewId IdFromNativeView(NativeView view);
#if defined(OS_WIN)
typedef HWND PluginWindowHandle;
const PluginWindowHandle kNullPluginWindow = NULL;
+#elif defined(USE_WAYLAND)
+ typedef struct wl_egl_window* PluginWindowHandle;
+ const PluginWindowHandle kNullPluginWindow = NULL;
#elif defined(USE_X11)
typedef unsigned long PluginWindowHandle;
const PluginWindowHandle kNullPluginWindow = 0;
@@ -179,6 +206,9 @@ UI_EXPORT NativeViewId IdFromNativeView(NativeView view);
#if defined(OS_WIN)
typedef HWND AcceleratedWidget;
const AcceleratedWidget kNullAcceleratedWidget = NULL;
+#elif defined(USE_WAYLAND)
+typedef struct wl_egl_window* AcceleratedWidget;
+const AcceleratedWidget kNullAcceleratedWidget = NULL;
#elif defined(USE_X11)
typedef unsigned long AcceleratedWidget;
const AcceleratedWidget kNullAcceleratedWidget = 0;
diff --git a/ui/gfx/platform_font_gtk.cc b/ui/gfx/platform_font_gtk.cc
index 5ccc7c5..e743638 100644
--- a/ui/gfx/platform_font_gtk.cc
+++ b/ui/gfx/platform_font_gtk.cc
@@ -6,10 +6,9 @@
#include <algorithm>
#include <fontconfig/fontconfig.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
#include <map>
#include <pango/pango.h>
+#include <string>
#include "base/logging.h"
#include "base/string_piece.h"
@@ -20,6 +19,11 @@
#include "ui/gfx/font.h"
#include "ui/gfx/gtk_util.h"
+#if !defined(USE_WAYLAND)
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+#endif
+
namespace {
// The font family name which is used when a user's application font for
@@ -56,7 +60,7 @@ PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc) {
static PangoContext* context = NULL;
if (!context) {
- context = gdk_pango_context_get_for_screen(gdk_screen_get_default());
+ context = gfx::GetPangoContext();
pango_context_set_language(context, pango_language_get_default());
}
@@ -109,6 +113,25 @@ string16 FindBestMatchFontFamilyName(const char* family_name) {
return font_family;
}
+std::string GetDefaultFont() {
+#if defined(USE_WAYLAND)
+ return "sans 10";
+#else
+ GtkSettings* settings = gtk_settings_get_default();
+
+ gchar* font_name = NULL;
+ g_object_get(settings, "gtk-font-name", &font_name, NULL);
+
+ // Temporary CHECK for helping track down
+ // http://code.google.com/p/chromium/issues/detail?id=12530
+ CHECK(font_name) << " Unable to get gtk-font-name for default font.";
+
+ std::string default_font = std::string(font_name);
+ g_free(font_name);
+ return default_font;
+#endif
+}
+
} // namespace
namespace gfx {
@@ -120,20 +143,12 @@ Font* PlatformFontGtk::default_font_ = NULL;
PlatformFontGtk::PlatformFontGtk() {
if (default_font_ == NULL) {
- GtkSettings* settings = gtk_settings_get_default();
-
- gchar* font_name = NULL;
- g_object_get(settings, "gtk-font-name", &font_name, NULL);
-
- // Temporary CHECK for helping track down
- // http://code.google.com/p/chromium/issues/detail?id=12530
- CHECK(font_name) << " Unable to get gtk-font-name for default font.";
+ std::string font_name = GetDefaultFont();
PangoFontDescription* desc =
- pango_font_description_from_string(font_name);
+ pango_font_description_from_string(font_name.c_str());
default_font_ = new Font(desc);
pango_font_description_free(desc);
- g_free(font_name);
DCHECK(default_font_);
}
diff --git a/ui/gfx/screen_wayland.cc b/ui/gfx/screen_wayland.cc
new file mode 100644
index 0000000..037cc89
--- /dev/null
+++ b/ui/gfx/screen_wayland.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/screen.h"
+
+#include "base/logging.h"
+#include "ui/gfx/gl/gl_surface_egl.h"
+#include "ui/wayland/wayland_display.h"
+#include "ui/wayland/wayland_screen.h"
+
+namespace gfx {
+
+// static
+gfx::Point Screen::GetCursorScreenPoint() {
+ NOTIMPLEMENTED();
+ return gfx::Point();
+}
+
+gfx::Rect static GetPrimaryMonitorBounds() {
+ ui::WaylandDisplay* display = ui::WaylandDisplay::GetDisplay(
+ gfx::GLSurfaceEGL::GetNativeDisplay());
+ std::list<ui::WaylandScreen*> screens = display->GetScreenList();
+
+ return screens.empty() ? gfx::Rect() : screens.front()->GetAllocation();
+}
+
+// static
+gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeView view) {
+ // TODO(dnicoara): use |view|.
+ return GetPrimaryMonitorBounds();
+}
+
+// static
+gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) {
+ NOTIMPLEMENTED();
+ return gfx::Rect();
+}
+
+// static
+gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
+ return GetMonitorAreaNearestPoint(point);
+}
+
+// static
+gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
+ NOTIMPLEMENTED();
+ return gfx::Rect();
+}
+
+gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+} // namespace gfx
+
diff --git a/ui/gfx/surface/accelerated_surface_wayland.cc b/ui/gfx/surface/accelerated_surface_wayland.cc
new file mode 100644
index 0000000..29d0e7d
--- /dev/null
+++ b/ui/gfx/surface/accelerated_surface_wayland.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/surface/accelerated_surface_wayland.h"
+
+#include <wayland-egl.h>
+
+#include "third_party/angle/include/EGL/egl.h"
+#include "third_party/angle/include/EGL/eglext.h"
+#include "ui/gfx/gl/gl_bindings.h"
+#include "ui/gfx/gl/gl_surface_egl.h"
+#include "ui/wayland/wayland_display.h"
+
+AcceleratedSurface::AcceleratedSurface(const gfx::Size& size)
+ : 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(
+ edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (void*) pixmap_, NULL);
+
+ glGenTextures(1, &texture_);
+
+ GLint current_texture = 0;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &current_texture);
+
+ glBindTexture(GL_TEXTURE_2D, texture_);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_);
+
+ glBindTexture(GL_TEXTURE_2D, current_texture);
+}
+
+AcceleratedSurface::~AcceleratedSurface() {
+ glDeleteTextures(1, &texture_);
+ eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_);
+ wl_egl_pixmap_destroy(pixmap_);
+}
diff --git a/ui/gfx/surface/accelerated_surface_wayland.h b/ui/gfx/surface/accelerated_surface_wayland.h
new file mode 100644
index 0000000..c4418e4
--- /dev/null
+++ b/ui/gfx/surface/accelerated_surface_wayland.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_
+#define UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_
+#pragma once
+
+#include "base/memory/ref_counted.h"
+#include "ui/gfx/size.h"
+
+struct wl_egl_pixmap;
+
+// The GL context associated with the surface must be current when
+// an instance is created or destroyed.
+class AcceleratedSurface : public base::RefCounted<AcceleratedSurface> {
+ public:
+ AcceleratedSurface(const gfx::Size& size);
+ const gfx::Size& size() const { return size_; }
+ // The pointer returned is owned by this object
+ wl_egl_pixmap* pixmap() const { return pixmap_; }
+ uint32 texture() const { return texture_; }
+
+ private:
+ friend class base::RefCounted<AcceleratedSurface>;
+
+ ~AcceleratedSurface();
+
+ gfx::Size size_;
+ void* image_;
+ wl_egl_pixmap* pixmap_;
+ uint32 texture_;
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface);
+};
+
+#endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_
diff --git a/ui/gfx/surface/surface.gyp b/ui/gfx/surface/surface.gyp
index 17f372c..9e7081d 100644
--- a/ui/gfx/surface/surface.gyp
+++ b/ui/gfx/surface/surface.gyp
@@ -9,7 +9,7 @@
'target_defaults': {
'conditions': [
- ['toolkit_uses_gtk == 1', {
+ ['toolkit_uses_gtk == 1 or use_wayland == 1', {
'include_dirs': [
'<(DEPTH)/third_party/angle/include',
],
@@ -31,6 +31,8 @@
'accelerated_surface_linux.h',
'accelerated_surface_mac.cc',
'accelerated_surface_mac.h',
+ 'accelerated_surface_wayland.cc',
+ 'accelerated_surface_wayland.h',
'io_surface_support_mac.cc',
'io_surface_support_mac.h',
'transport_dib.h',
@@ -38,6 +40,14 @@
'transport_dib_mac.cc',
'transport_dib_win.cc',
],
+ 'conditions': [
+ ['use_wayland == 1', {
+ 'sources/': [
+ ['exclude', 'accelerated_surface_linux.cc'],
+ ['exclude', 'accelerated_surface_linux.h'],
+ ],
+ }],
+ ],
},
],
}