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

Unified Diff: ui/gl/gl_surface_egl.cc

Issue 1480333002: egl/x11: Created a child window to control resizes and prevent flashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved up the call to InitializeNativeWindow() Created 5 years 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/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_egl_x11.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_egl.cc
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 8352ff6b1f501b4a7091092720272ccd4ce7476a..06ccae7500c75d76a9242af1875098ef058aa1c0 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -26,12 +26,6 @@
#include "ui/gl/scoped_make_current.h"
#include "ui/gl/sync_control_vsync_provider.h"
-#if defined(USE_X11)
-extern "C" {
-#include <X11/Xlib.h>
-}
-#endif
-
#if defined (USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
@@ -472,10 +466,10 @@ EGLDisplay GLSurfaceEGL::InitializeDisplay() {
NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window)
: window_(window),
- surface_(NULL),
- supports_post_sub_buffer_(false),
config_(NULL),
size_(1, 1),
+ surface_(NULL),
+ supports_post_sub_buffer_(false),
swap_interval_(1) {
#if defined(OS_ANDROID)
if (window)
@@ -504,6 +498,13 @@ bool NativeViewGLSurfaceEGL::Initialize(
return false;
}
+ // We need to make sure that window_ is correctly initialized with all
+ // the platform-dependant quirks, if any, before creating the surface.
+ if (!InitializeNativeWindow()) {
+ LOG(ERROR) << "Error trying to initialize the native window.";
+ return false;
+ }
+
std::vector<EGLint> egl_window_attributes;
if (g_egl_window_fixed_size_supported) {
@@ -546,6 +547,10 @@ bool NativeViewGLSurfaceEGL::Initialize(
return true;
}
+bool NativeViewGLSurfaceEGL::InitializeNativeWindow() {
+ return true;
+}
+
void NativeViewGLSurfaceEGL::Destroy() {
if (surface_) {
if (!eglDestroySurface(GetDisplay(), surface_)) {
@@ -557,80 +562,7 @@ void NativeViewGLSurfaceEGL::Destroy() {
}
EGLConfig NativeViewGLSurfaceEGL::GetConfig() {
-#if !defined(USE_X11)
return g_config;
-#else
- if (!config_) {
- // Get a config compatible with the window
- DCHECK(window_);
- XWindowAttributes win_attribs;
- if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) {
- return NULL;
- }
-
- // Try matching the window depth with an alpha channel,
- // because we're worried the destination alpha width could
- // constrain blending precision.
- const int kBufferSizeOffset = 1;
- const int kAlphaSizeOffset = 3;
- EGLint config_attribs[] = {
- EGL_BUFFER_SIZE, ~0,
- EGL_ALPHA_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_RED_SIZE, 8,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
- EGL_NONE
- };
- config_attribs[kBufferSizeOffset] = win_attribs.depth;
-
- EGLint num_configs;
- if (!eglChooseConfig(g_display,
- config_attribs,
- &config_,
- 1,
- &num_configs)) {
- LOG(ERROR) << "eglChooseConfig failed with error "
- << GetLastEGLErrorString();
- return NULL;
- }
-
- if (num_configs) {
- EGLint config_depth;
- if (!eglGetConfigAttrib(g_display,
- config_,
- EGL_BUFFER_SIZE,
- &config_depth)) {
- LOG(ERROR) << "eglGetConfigAttrib failed with error "
- << GetLastEGLErrorString();
- return NULL;
- }
-
- if (config_depth == win_attribs.depth) {
- return config_;
- }
- }
-
- // Try without an alpha channel.
- config_attribs[kAlphaSizeOffset] = 0;
- if (!eglChooseConfig(g_display,
- config_attribs,
- &config_,
- 1,
- &num_configs)) {
- LOG(ERROR) << "eglChooseConfig failed with error "
- << GetLastEGLErrorString();
- return NULL;
- }
-
- if (num_configs == 0) {
- LOG(ERROR) << "No suitable EGL configs found.";
- return NULL;
- }
- }
- return config_;
-#endif
}
bool NativeViewGLSurfaceEGL::IsOffscreen() {
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_egl_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698