Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Unified Diff: ui/ozone/platform/x11/x11_surface_factory.cc

Issue 750593003: Ozone X11 platform Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/x11/x11_surface_factory.cc
diff --git a/ui/ozone/platform/x11/x11_surface_factory.cc b/ui/ozone/platform/x11/x11_surface_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..071f80e1646cfd5333f6bc33b0446b2424d617c5
--- /dev/null
+++ b/ui/ozone/platform/x11/x11_surface_factory.cc
@@ -0,0 +1,95 @@
+// Copyright 2014 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/ozone/platform/x11/x11_surface_factory.h"
+
+#include "base/files/file_path.h"
+#include "ui/gfx/vsync_provider.h"
+#include "ui/ozone/public/surface_ozone_egl.h"
+#include "ui/platform_window/x11/x11_window.h"
+
+namespace ui {
+
+class X11SurfaceEGL : public SurfaceOzoneEGL {
+ public:
+ X11SurfaceEGL(gfx::AcceleratedWidget widget) : widget_(widget) {}
+ ~X11SurfaceEGL() {}
+
+ intptr_t GetNativeWindow() override { return widget_; }
+
+ bool OnSwapBuffers() override { return true; }
+
+ bool ResizeNativeWindow(const gfx::Size& viewport_size) override {
+ NOTIMPLEMENTED();
+ return true;
+ }
+
+ scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override {
+ return scoped_ptr<gfx::VSyncProvider>();
+ }
+
+ // There is currently a bug where the EGL property says it supports partial
+ // swap, but actually using it causes an error.
+ bool SupportsPartialSwap() override { return false; }
+
+ private:
+ gfx::AcceleratedWidget widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(X11SurfaceEGL);
+};
+
+X11SurfaceFactory::X11SurfaceFactory() {
+}
+
+X11SurfaceFactory::~X11SurfaceFactory() {
+}
+
+// SurfaceFactoryOzone:
+scoped_ptr<SurfaceOzoneEGL> X11SurfaceFactory::CreateEGLSurfaceForWidget(
+ gfx::AcceleratedWidget widget) {
+ return scoped_ptr<SurfaceOzoneEGL>(new X11SurfaceEGL(widget));
+}
+
+bool X11SurfaceFactory::LoadEGLGLES2Bindings(
+ AddGLLibraryCallback add_gl_library,
+ SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
spang 2014/11/24 18:56:54 I think we have copied this enough times that it d
achaulk 2014/11/24 19:28:39 Acknowledged.
+ base::NativeLibraryLoadError error;
+ base::NativeLibrary gles_library =
+ base::LoadNativeLibrary(base::FilePath("libGLESv2.so.2"), &error);
+ if (!gles_library) {
+ LOG(WARNING) << "Failed to load GLES library: " << error.ToString();
+ return false;
+ }
+
+ base::NativeLibrary egl_library =
+ base::LoadNativeLibrary(base::FilePath("libEGL.so.1"), &error);
+ if (!egl_library) {
+ LOG(WARNING) << "Failed to load EGL library: " << error.ToString();
+ base::UnloadNativeLibrary(gles_library);
+ return false;
+ }
+
+ GLGetProcAddressProc get_proc_address =
+ reinterpret_cast<GLGetProcAddressProc>(
+ base::GetFunctionPointerFromNativeLibrary(egl_library,
+ "eglGetProcAddress"));
+ if (!get_proc_address) {
+ LOG(ERROR) << "eglGetProcAddress not found.";
+ base::UnloadNativeLibrary(egl_library);
+ base::UnloadNativeLibrary(gles_library);
+ return false;
+ }
+
+ set_gl_get_proc_address.Run(get_proc_address);
+ add_gl_library.Run(egl_library);
+ add_gl_library.Run(gles_library);
+
+ return true;
+}
+
+intptr_t X11SurfaceFactory::GetNativeDisplay() {
+ return reinterpret_cast<intptr_t>(gfx::GetXDisplay());
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698