OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/ozone/platform/x11/x11_surface_factory.h" | |
6 | |
7 #include "base/files/file_path.h" | |
8 #include "ui/gfx/vsync_provider.h" | |
9 #include "ui/ozone/public/surface_ozone_egl.h" | |
10 #include "ui/platform_window/x11/x11_window.h" | |
11 | |
12 namespace ui { | |
13 | |
14 class X11SurfaceEGL : public SurfaceOzoneEGL { | |
15 public: | |
16 X11SurfaceEGL(gfx::AcceleratedWidget widget) : widget_(widget) {} | |
17 ~X11SurfaceEGL() {} | |
18 | |
19 intptr_t GetNativeWindow() override { return widget_; } | |
20 | |
21 bool OnSwapBuffers() override { return true; } | |
22 | |
23 bool ResizeNativeWindow(const gfx::Size& viewport_size) override { | |
24 NOTIMPLEMENTED(); | |
25 return true; | |
26 } | |
27 | |
28 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { | |
29 return scoped_ptr<gfx::VSyncProvider>(); | |
30 } | |
31 | |
32 // There is currently a bug where the EGL property says it supports partial | |
33 // swap, but actually using it causes an error. | |
34 bool SupportsPartialSwap() override { return false; } | |
35 | |
36 private: | |
37 gfx::AcceleratedWidget widget_; | |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(X11SurfaceEGL); | |
40 }; | |
41 | |
42 X11SurfaceFactory::X11SurfaceFactory() { | |
43 } | |
44 | |
45 X11SurfaceFactory::~X11SurfaceFactory() { | |
46 } | |
47 | |
48 // SurfaceFactoryOzone: | |
49 scoped_ptr<SurfaceOzoneEGL> X11SurfaceFactory::CreateEGLSurfaceForWidget( | |
50 gfx::AcceleratedWidget widget) { | |
51 return scoped_ptr<SurfaceOzoneEGL>(new X11SurfaceEGL(widget)); | |
52 } | |
53 | |
54 bool X11SurfaceFactory::LoadEGLGLES2Bindings( | |
55 AddGLLibraryCallback add_gl_library, | |
56 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.
| |
57 base::NativeLibraryLoadError error; | |
58 base::NativeLibrary gles_library = | |
59 base::LoadNativeLibrary(base::FilePath("libGLESv2.so.2"), &error); | |
60 if (!gles_library) { | |
61 LOG(WARNING) << "Failed to load GLES library: " << error.ToString(); | |
62 return false; | |
63 } | |
64 | |
65 base::NativeLibrary egl_library = | |
66 base::LoadNativeLibrary(base::FilePath("libEGL.so.1"), &error); | |
67 if (!egl_library) { | |
68 LOG(WARNING) << "Failed to load EGL library: " << error.ToString(); | |
69 base::UnloadNativeLibrary(gles_library); | |
70 return false; | |
71 } | |
72 | |
73 GLGetProcAddressProc get_proc_address = | |
74 reinterpret_cast<GLGetProcAddressProc>( | |
75 base::GetFunctionPointerFromNativeLibrary(egl_library, | |
76 "eglGetProcAddress")); | |
77 if (!get_proc_address) { | |
78 LOG(ERROR) << "eglGetProcAddress not found."; | |
79 base::UnloadNativeLibrary(egl_library); | |
80 base::UnloadNativeLibrary(gles_library); | |
81 return false; | |
82 } | |
83 | |
84 set_gl_get_proc_address.Run(get_proc_address); | |
85 add_gl_library.Run(egl_library); | |
86 add_gl_library.Run(gles_library); | |
87 | |
88 return true; | |
89 } | |
90 | |
91 intptr_t X11SurfaceFactory::GetNativeDisplay() { | |
92 return reinterpret_cast<intptr_t>(gfx::GetXDisplay()); | |
93 } | |
94 | |
95 } // namespace ui | |
OLD | NEW |