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

Unified Diff: ui/ozone/common/egl_util.cc

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 years, 4 months 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
« no previous file with comments | « ui/ozone/common/egl_util.h ('k') | ui/ozone/common/gpu/ozone_gpu_message_params.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/common/egl_util.cc
diff --git a/ui/ozone/common/egl_util.cc b/ui/ozone/common/egl_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8000360c7b0c4a99be228bcdb2f46b5a788a398a
--- /dev/null
+++ b/ui/ozone/common/egl_util.cc
@@ -0,0 +1,65 @@
+// 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/common/egl_util.h"
+
+#include "base/files/file_path.h"
+
+namespace ui {
+namespace {
+
+const char kDefaultEglSoname[] = "libEGL.so.1";
+const char kDefaultGlesSoname[] = "libGLESv2.so.2";
+
+} // namespace
+
+bool LoadDefaultEGLGLES2Bindings(
+ SurfaceFactoryOzone::AddGLLibraryCallback add_gl_library,
+ SurfaceFactoryOzone::SetGLGetProcAddressProcCallback
+ set_gl_get_proc_address) {
+ return LoadEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address,
+ kDefaultEglSoname, kDefaultGlesSoname);
+}
+
+bool LoadEGLGLES2Bindings(
+ SurfaceFactoryOzone::AddGLLibraryCallback add_gl_library,
+ SurfaceFactoryOzone::SetGLGetProcAddressProcCallback
+ set_gl_get_proc_address,
+ const char* egl_library_name,
+ const char* gles_library_name) {
+ base::NativeLibraryLoadError error;
+ base::NativeLibrary gles_library =
+ base::LoadNativeLibrary(base::FilePath(gles_library_name), &error);
+ if (!gles_library) {
+ LOG(WARNING) << "Failed to load GLES library: " << error.ToString();
+ return false;
+ }
+
+ base::NativeLibrary egl_library =
+ base::LoadNativeLibrary(base::FilePath(egl_library_name), &error);
+ if (!egl_library) {
+ LOG(WARNING) << "Failed to load EGL library: " << error.ToString();
+ base::UnloadNativeLibrary(gles_library);
+ return false;
+ }
+
+ SurfaceFactoryOzone::GLGetProcAddressProc get_proc_address =
+ reinterpret_cast<SurfaceFactoryOzone::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;
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/common/egl_util.h ('k') | ui/ozone/common/gpu/ozone_gpu_message_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698