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

Side by Side Diff: ui/ozone/platform/x11/x11_surface_factory.cc

Issue 2270463002: Add OzoneGLImpl interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/x11/x11_surface_factory.h ('k') | ui/ozone/public/gl_ozone.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/khronos/EGL/egl.h" 9 #include "third_party/khronos/EGL/egl.h"
10 #include "ui/gfx/x/x11_types.h" 10 #include "ui/gfx/x/x11_types.h"
11 #include "ui/gl/egl_util.h" 11 #include "ui/gl/egl_util.h"
12 #include "ui/gl/gl_surface_egl.h" 12 #include "ui/gl/gl_surface_egl.h"
13 #include "ui/ozone/common/egl_util.h" 13 #include "ui/ozone/common/egl_util.h"
14 #include "ui/ozone/common/gl_ozone_egl.h"
14 15
15 namespace ui { 16 namespace ui {
16 17
17 namespace { 18 namespace {
18 19
19 // GLSurface implementation for Ozone X11 EGL. 20 // GLSurface implementation for Ozone X11 EGL.
20 class GLSurfaceEGLOzoneX11 : public gl::NativeViewGLSurfaceEGL { 21 class GLSurfaceEGLOzoneX11 : public gl::NativeViewGLSurfaceEGL {
21 public: 22 public:
22 explicit GLSurfaceEGLOzoneX11(EGLNativeWindowType window); 23 explicit GLSurfaceEGLOzoneX11(EGLNativeWindowType window);
23 24
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 XResizeWindow(gfx::GetXDisplay(), window_, size.width(), size.height()); 113 XResizeWindow(gfx::GetXDisplay(), window_, size.width(), size.height());
113 eglWaitNative(EGL_CORE_NATIVE_ENGINE); 114 eglWaitNative(EGL_CORE_NATIVE_ENGINE);
114 115
115 return true; 116 return true;
116 } 117 }
117 118
118 GLSurfaceEGLOzoneX11::~GLSurfaceEGLOzoneX11() { 119 GLSurfaceEGLOzoneX11::~GLSurfaceEGLOzoneX11() {
119 Destroy(); 120 Destroy();
120 } 121 }
121 122
123 class GLOzoneEGLX11 : public GLOzoneEGL {
124 public:
125 GLOzoneEGLX11() {}
126 ~GLOzoneEGLX11() override {}
127
128 scoped_refptr<gl::GLSurface> CreateViewGLSurface(
129 gfx::AcceleratedWidget window) override {
130 return gl::InitializeGLSurface(new GLSurfaceEGLOzoneX11(window));
131 }
132
133 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
134 const gfx::Size& size) override {
135 return gl::InitializeGLSurface(new gl::PbufferGLSurfaceEGL(size));
136 }
137
138 protected:
139 intptr_t GetNativeDisplay() override {
140 return reinterpret_cast<intptr_t>(gfx::GetXDisplay());
141 }
142
143 bool LoadGLES2Bindings() override { return LoadDefaultEGLGLES2Bindings(); }
144
145 private:
146 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLX11);
147 };
148
122 } // namespace 149 } // namespace
123 150
124 X11SurfaceFactory::X11SurfaceFactory() {} 151 X11SurfaceFactory::X11SurfaceFactory() {
152 egl_implementation_.reset(new GLOzoneEGLX11());
153 }
125 154
126 X11SurfaceFactory::~X11SurfaceFactory() {} 155 X11SurfaceFactory::~X11SurfaceFactory() {}
127 156
128 scoped_refptr<gl::GLSurface> X11SurfaceFactory::CreateViewGLSurface( 157 std::vector<gl::GLImplementation>
129 gl::GLImplementation implementation, 158 X11SurfaceFactory::GetAllowedGLImplementations() {
130 gfx::AcceleratedWidget widget) { 159 std::vector<gl::GLImplementation> impls;
131 if (implementation != gl::kGLImplementationEGLGLES2) { 160 impls.push_back(gl::kGLImplementationEGLGLES2);
132 NOTREACHED(); 161 impls.push_back(gl::kGLImplementationOSMesaGL);
133 return nullptr; 162 return impls;
134 }
135
136 return gl::InitializeGLSurface(new GLSurfaceEGLOzoneX11(widget));
137 } 163 }
138 164
139 scoped_refptr<gl::GLSurface> X11SurfaceFactory::CreateOffscreenGLSurface( 165 GLOzone* X11SurfaceFactory::GetGLOzone(gl::GLImplementation implementation) {
140 gl::GLImplementation implementation, 166 switch (implementation) {
141 const gfx::Size& size) { 167 case gl::kGLImplementationEGLGLES2:
142 if (implementation != gl::kGLImplementationEGLGLES2) { 168 return egl_implementation_.get();
143 NOTREACHED(); 169 default:
144 return nullptr; 170 return nullptr;
145 } 171 }
146
147 return gl::InitializeGLSurface(new gl::PbufferGLSurfaceEGL(size));
148 }
149
150 bool X11SurfaceFactory::LoadEGLGLES2Bindings() {
151 return LoadDefaultEGLGLES2Bindings();
152 }
153
154 intptr_t X11SurfaceFactory::GetNativeDisplay() {
155 return reinterpret_cast<intptr_t>(gfx::GetXDisplay());
156 } 172 }
157 173
158 } // namespace ui 174 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/x11/x11_surface_factory.h ('k') | ui/ozone/public/gl_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698