Commit 5caaba8e authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

gl: x11: rename gl_surface_egl_x11 to gl_surfae_egl_x11_gles

Currently, NativeViewGLSurfaceEGL has a bunch of code guarded by
USE_X11. This should be unified and placed under X11 interfaces
managed in compile time. What is more, this code must be shared
with ozone/x11 as well.

Thus, to avoid confusions in names of the classes/files, rename
gl_surface_egl_x11 to gl_surface_egl_x11_gless and rename the
class NativeViewGLSurfaceEGLX11 to NativeViewGLSurfaceEGLX11GLES2
as that is always used when --use-gl=egl is passed.

In the next CL, I will extract all the x11 code from
NativeViewGLSurfaceEGL and place it to NativeViewGLSurfaceEGLX11.
The reason why this is going to be managed in such a way is that
currently when Angle is used with X11, NativeViewGLSurfaceEGL is
used instead of NativeViewGLSurfaceEGLX11. And, thus, all the
code that is guarded by USE_X11 is compiled and executed.

Thus, when --use-gl=angle is passed (this is default for x11/linux
now), NativeViewGLSurfaceEGLX11 will be used. And when
--use-gl=egl is passed, NativeViewGLSurfaceEGLX11GLES2 will be used
(it initializes native platform window as well, which is not
required in case of angle).

Bug: 1036285
Change-Id: I9bfe89a24c36ce80061137eae05f3c4dc00aa1c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2116629
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753983}
parent 3892f0db
...@@ -255,8 +255,8 @@ jumbo_component("gl") { ...@@ -255,8 +255,8 @@ jumbo_component("gl") {
if (use_x11) { if (use_x11) {
sources += [ sources += [
"gl_surface_egl_x11.cc", "gl_surface_egl_x11_gles2.cc",
"gl_surface_egl_x11.h", "gl_surface_egl_x11_gles2.h",
"gl_surface_glx_x11.cc", "gl_surface_glx_x11.cc",
"gl_surface_glx_x11.h", "gl_surface_glx_x11.h",
] ]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/gl/gl_surface_egl_x11.h" #include "ui/gl/gl_surface_egl_x11_gles2.h"
#include "ui/gfx/x/x11.h" #include "ui/gfx/x/x11.h"
#include "ui/gl/egl_util.h" #include "ui/gl/egl_util.h"
...@@ -12,15 +12,16 @@ using ui::X11EventSource; ...@@ -12,15 +12,16 @@ using ui::X11EventSource;
namespace gl { namespace gl {
NativeViewGLSurfaceEGLX11::NativeViewGLSurfaceEGLX11(EGLNativeWindowType window) NativeViewGLSurfaceEGLX11GLES2::NativeViewGLSurfaceEGLX11GLES2(
EGLNativeWindowType window)
: NativeViewGLSurfaceEGL(0, nullptr), parent_window_(window) {} : NativeViewGLSurfaceEGL(0, nullptr), parent_window_(window) {}
bool NativeViewGLSurfaceEGLX11::InitializeNativeWindow() { bool NativeViewGLSurfaceEGLX11GLES2::InitializeNativeWindow() {
Display* x11_display = GetNativeDisplay(); Display* x11_display = GetNativeDisplay();
XWindowAttributes attributes; XWindowAttributes attributes;
if (!XGetWindowAttributes(x11_display, parent_window_, &attributes)) { if (!XGetWindowAttributes(x11_display, parent_window_, &attributes)) {
LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_ LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_
<< "."; << ".";
return false; return false;
} }
...@@ -44,7 +45,7 @@ bool NativeViewGLSurfaceEGLX11::InitializeNativeWindow() { ...@@ -44,7 +45,7 @@ bool NativeViewGLSurfaceEGLX11::InitializeNativeWindow() {
return true; return true;
} }
void NativeViewGLSurfaceEGLX11::Destroy() { void NativeViewGLSurfaceEGLX11GLES2::Destroy() {
NativeViewGLSurfaceEGL::Destroy(); NativeViewGLSurfaceEGL::Destroy();
if (window_) { if (window_) {
...@@ -55,13 +56,13 @@ void NativeViewGLSurfaceEGLX11::Destroy() { ...@@ -55,13 +56,13 @@ void NativeViewGLSurfaceEGLX11::Destroy() {
} }
} }
EGLConfig NativeViewGLSurfaceEGLX11::GetConfig() { EGLConfig NativeViewGLSurfaceEGLX11GLES2::GetConfig() {
if (!config_) { if (!config_) {
// Get a config compatible with the window // Get a config compatible with the window
DCHECK(window_); DCHECK(window_);
XWindowAttributes win_attribs; XWindowAttributes win_attribs;
if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) { if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) {
return NULL; return nullptr;
} }
// Try matching the window depth with an alpha channel, // Try matching the window depth with an alpha channel,
...@@ -83,25 +84,19 @@ EGLConfig NativeViewGLSurfaceEGLX11::GetConfig() { ...@@ -83,25 +84,19 @@ EGLConfig NativeViewGLSurfaceEGLX11::GetConfig() {
EGLDisplay display = GetHardwareDisplay(); EGLDisplay display = GetHardwareDisplay();
EGLint num_configs; EGLint num_configs;
if (!eglChooseConfig(display, if (!eglChooseConfig(display, config_attribs, &config_, 1, &num_configs)) {
config_attribs,
&config_,
1,
&num_configs)) {
LOG(ERROR) << "eglChooseConfig failed with error " LOG(ERROR) << "eglChooseConfig failed with error "
<< GetLastEGLErrorString(); << GetLastEGLErrorString();
return NULL; return nullptr;
} }
if (num_configs) { if (num_configs) {
EGLint config_depth; EGLint config_depth;
if (!eglGetConfigAttrib(display, if (!eglGetConfigAttrib(display, config_, EGL_BUFFER_SIZE,
config_,
EGL_BUFFER_SIZE,
&config_depth)) { &config_depth)) {
LOG(ERROR) << "eglGetConfigAttrib failed with error " LOG(ERROR) << "eglGetConfigAttrib failed with error "
<< GetLastEGLErrorString(); << GetLastEGLErrorString();
return NULL; return nullptr;
} }
if (config_depth == win_attribs.depth) { if (config_depth == win_attribs.depth) {
...@@ -111,28 +106,24 @@ EGLConfig NativeViewGLSurfaceEGLX11::GetConfig() { ...@@ -111,28 +106,24 @@ EGLConfig NativeViewGLSurfaceEGLX11::GetConfig() {
// Try without an alpha channel. // Try without an alpha channel.
config_attribs[kAlphaSizeOffset] = 0; config_attribs[kAlphaSizeOffset] = 0;
if (!eglChooseConfig(display, if (!eglChooseConfig(display, config_attribs, &config_, 1, &num_configs)) {
config_attribs,
&config_,
1,
&num_configs)) {
LOG(ERROR) << "eglChooseConfig failed with error " LOG(ERROR) << "eglChooseConfig failed with error "
<< GetLastEGLErrorString(); << GetLastEGLErrorString();
return NULL; return nullptr;
} }
if (num_configs == 0) { if (num_configs == 0) {
LOG(ERROR) << "No suitable EGL configs found."; LOG(ERROR) << "No suitable EGL configs found.";
return NULL; return nullptr;
} }
} }
return config_; return config_;
} }
bool NativeViewGLSurfaceEGLX11::Resize(const gfx::Size& size, bool NativeViewGLSurfaceEGLX11GLES2::Resize(const gfx::Size& size,
float scale_factor, float scale_factor,
const gfx::ColorSpace& color_space, const gfx::ColorSpace& color_space,
bool has_alpha) { bool has_alpha) {
if (size == GetSize()) if (size == GetSize())
return true; return true;
...@@ -145,7 +136,7 @@ bool NativeViewGLSurfaceEGLX11::Resize(const gfx::Size& size, ...@@ -145,7 +136,7 @@ bool NativeViewGLSurfaceEGLX11::Resize(const gfx::Size& size,
return true; return true;
} }
bool NativeViewGLSurfaceEGLX11::DispatchXEvent(XEvent* xev) { bool NativeViewGLSurfaceEGLX11GLES2::DispatchXEvent(XEvent* xev) {
if (xev->type != Expose || xev->xexpose.window != window_) if (xev->type != Expose || xev->xexpose.window != window_)
return false; return false;
...@@ -156,7 +147,7 @@ bool NativeViewGLSurfaceEGLX11::DispatchXEvent(XEvent* xev) { ...@@ -156,7 +147,7 @@ bool NativeViewGLSurfaceEGLX11::DispatchXEvent(XEvent* xev) {
return true; return true;
} }
NativeViewGLSurfaceEGLX11::~NativeViewGLSurfaceEGLX11() { NativeViewGLSurfaceEGLX11GLES2::~NativeViewGLSurfaceEGLX11GLES2() {
Destroy(); Destroy();
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_GL_GL_SURFACE_EGL_X11_H_ #ifndef UI_GL_GL_SURFACE_EGL_X11_GLES2_H_
#define UI_GL_GL_SURFACE_EGL_X11_H_ #define UI_GL_GL_SURFACE_EGL_X11_GLES2_H_
#include <stdint.h> #include <stdint.h>
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
namespace gl { namespace gl {
// Encapsulates an EGL surface bound to a view using the X Window System. // Encapsulates an EGL surface bound to a view using the X Window System.
class GL_EXPORT NativeViewGLSurfaceEGLX11 : public NativeViewGLSurfaceEGL { class GL_EXPORT NativeViewGLSurfaceEGLX11GLES2 : public NativeViewGLSurfaceEGL {
public: public:
explicit NativeViewGLSurfaceEGLX11(EGLNativeWindowType window); explicit NativeViewGLSurfaceEGLX11GLES2(EGLNativeWindowType window);
// NativeViewGLSurfaceEGL overrides. // NativeViewGLSurfaceEGL overrides.
EGLConfig GetConfig() override; EGLConfig GetConfig() override;
...@@ -30,16 +30,16 @@ class GL_EXPORT NativeViewGLSurfaceEGLX11 : public NativeViewGLSurfaceEGL { ...@@ -30,16 +30,16 @@ class GL_EXPORT NativeViewGLSurfaceEGLX11 : public NativeViewGLSurfaceEGL {
bool InitializeNativeWindow() override; bool InitializeNativeWindow() override;
private: private:
~NativeViewGLSurfaceEGLX11() override; ~NativeViewGLSurfaceEGLX11GLES2() override;
// XEventDispatcher: // XEventDispatcher:
bool DispatchXEvent(XEvent* xev) override; bool DispatchXEvent(XEvent* xev) override;
EGLNativeWindowType parent_window_; EGLNativeWindowType parent_window_;
DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGLX11); DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGLX11GLES2);
}; };
} // namespace gl } // namespace gl
#endif // UI_GL_GL_SURFACE_EGL_X11_H_ #endif // UI_GL_GL_SURFACE_EGL_X11_GLES2_H_
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "ui/gl/gl_share_group.h" #include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_egl.h" #include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_egl_x11.h" #include "ui/gl/gl_surface_egl_x11_gles2.h"
#include "ui/gl/gl_surface_glx.h" #include "ui/gl/gl_surface_glx.h"
#include "ui/gl/gl_surface_glx_x11.h" #include "ui/gl/gl_surface_glx_x11.h"
#include "ui/gl/gl_surface_stub.h" #include "ui/gl/gl_surface_stub.h"
...@@ -80,7 +80,7 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { ...@@ -80,7 +80,7 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
case kGLImplementationSwiftShaderGL: case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2: case kGLImplementationEGLGLES2:
DCHECK(window != gfx::kNullAcceleratedWidget); DCHECK(window != gfx::kNullAcceleratedWidget);
return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window)); return InitializeGLSurface(new NativeViewGLSurfaceEGLX11GLES2(window));
case kGLImplementationEGLANGLE: case kGLImplementationEGLANGLE:
DCHECK(window != gfx::kNullAcceleratedWidget); DCHECK(window != gfx::kNullAcceleratedWidget);
return InitializeGLSurface(new NativeViewGLSurfaceEGL(window, nullptr)); return InitializeGLSurface(new NativeViewGLSurfaceEGL(window, nullptr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment