| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/x11/x11_surface_factory.h" | 5 #include "ui/ozone/platform/x11/x11_surface_factory.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
| 11 #include "ui/gfx/vsync_provider.h" | 12 #include "ui/gfx/vsync_provider.h" |
| 12 #include "ui/gfx/x/x11_types.h" | 13 #include "ui/gfx/x/x11_types.h" |
| 13 #include "ui/ozone/common/egl_util.h" | 14 #include "ui/ozone/common/egl_util.h" |
| 14 #include "ui/ozone/public/surface_ozone_egl.h" | 15 #include "ui/ozone/public/surface_ozone_egl.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class X11SurfaceEGL : public SurfaceOzoneEGL { | 21 class X11SurfaceEGL : public SurfaceOzoneEGL { |
| 21 public: | 22 public: |
| 22 explicit X11SurfaceEGL(gfx::AcceleratedWidget widget) : widget_(widget) {} | 23 explicit X11SurfaceEGL(gfx::AcceleratedWidget widget) : widget_(widget) {} |
| 23 ~X11SurfaceEGL() override {} | 24 ~X11SurfaceEGL() override {} |
| 24 | 25 |
| 25 intptr_t GetNativeWindow() override { return widget_; } | 26 intptr_t GetNativeWindow() override { return widget_; } |
| 26 | 27 |
| 27 bool OnSwapBuffers() override { return true; } | 28 bool OnSwapBuffers() override { return true; } |
| 28 | 29 |
| 29 void OnSwapBuffersAsync(const SwapCompletionCallback& callback) override { | 30 void OnSwapBuffersAsync(const SwapCompletionCallback& callback) override { |
| 30 NOTREACHED(); | 31 NOTREACHED(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 bool ResizeNativeWindow(const gfx::Size& viewport_size) override { | 34 bool ResizeNativeWindow(const gfx::Size& viewport_size) override { |
| 34 return true; | 35 return true; |
| 35 } | 36 } |
| 36 | 37 |
| 37 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { | 38 std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { |
| 38 return nullptr; | 39 return nullptr; |
| 39 } | 40 } |
| 40 | 41 |
| 41 void* /* EGLConfig */ GetEGLSurfaceConfig( | 42 void* /* EGLConfig */ GetEGLSurfaceConfig( |
| 42 const EglConfigCallbacks& egl) override; | 43 const EglConfigCallbacks& egl) override; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 gfx::AcceleratedWidget widget_; | 46 gfx::AcceleratedWidget widget_; |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(X11SurfaceEGL); | 48 DISALLOW_COPY_AND_ASSIGN(X11SurfaceEGL); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 109 } |
| 109 return config; | 110 return config; |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace | 113 } // namespace |
| 113 | 114 |
| 114 X11SurfaceFactory::X11SurfaceFactory() {} | 115 X11SurfaceFactory::X11SurfaceFactory() {} |
| 115 | 116 |
| 116 X11SurfaceFactory::~X11SurfaceFactory() {} | 117 X11SurfaceFactory::~X11SurfaceFactory() {} |
| 117 | 118 |
| 118 scoped_ptr<SurfaceOzoneEGL> X11SurfaceFactory::CreateEGLSurfaceForWidget( | 119 std::unique_ptr<SurfaceOzoneEGL> X11SurfaceFactory::CreateEGLSurfaceForWidget( |
| 119 gfx::AcceleratedWidget widget) { | 120 gfx::AcceleratedWidget widget) { |
| 120 return make_scoped_ptr(new X11SurfaceEGL(widget)); | 121 return base::WrapUnique(new X11SurfaceEGL(widget)); |
| 121 } | 122 } |
| 122 | 123 |
| 123 bool X11SurfaceFactory::LoadEGLGLES2Bindings( | 124 bool X11SurfaceFactory::LoadEGLGLES2Bindings( |
| 124 AddGLLibraryCallback add_gl_library, | 125 AddGLLibraryCallback add_gl_library, |
| 125 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 126 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
| 126 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); | 127 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); |
| 127 } | 128 } |
| 128 | 129 |
| 129 intptr_t X11SurfaceFactory::GetNativeDisplay() { | 130 intptr_t X11SurfaceFactory::GetNativeDisplay() { |
| 130 return reinterpret_cast<intptr_t>(gfx::GetXDisplay()); | 131 return reinterpret_cast<intptr_t>(gfx::GetXDisplay()); |
| 131 } | 132 } |
| 132 | 133 |
| 133 } // namespace ui | 134 } // namespace ui |
| OLD | NEW |