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

Unified Diff: ui/gl/gl_surface_ozone.cc

Issue 750593003: Ozone X11 platform Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
Index: ui/gl/gl_surface_ozone.cc
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index 333290f91acbe6006ba3002ceae74627d44bb4fb..39c99a2266739d8b48806df0963ff572c418f533 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -4,9 +4,16 @@
#include "ui/gl/gl_surface.h"
+#if defined(OZONE_X11)
+extern "C" {
+#include <X11/Xlib.h>
+}
+#endif
+
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gl/egl_util.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_implementation.h"
@@ -17,6 +24,8 @@
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h"
+using ui::GetLastEGLErrorString;
+
namespace gfx {
namespace {
@@ -56,6 +65,83 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
return image->ScheduleOverlayPlane(
widget_, z_order, transform, bounds_rect, crop_rect);
}
+ virtual bool SupportsPostSubBuffer() override {
+ return NativeViewGLSurfaceEGL::SupportsPostSubBuffer() &&
+ ozone_surface_->SupportsPartialSwap();
+ }
+
+#if defined(OZONE_X11)
spang 2014/11/24 18:56:54 please don't use an #ifdef for this, it is very wr
achaulk 2014/11/24 19:28:39 Well it won't work on non-X builds since XGetWindo
+ EGLConfig GetConfig() override {
+ if (!config_) {
+ // Get a config compatible with the window
+ DCHECK(window_);
+ XWindowAttributes win_attribs;
+ if (!XGetWindowAttributes(reinterpret_cast<Display*>(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(GetDisplay(), config_attribs, &config_, 1,
+ &num_configs)) {
+ LOG(ERROR) << "eglChooseConfig failed with error "
+ << GetLastEGLErrorString();
+ return NULL;
+ }
+
+ if (num_configs) {
+ EGLint config_depth;
+ if (!eglGetConfigAttrib(GetDisplay(), 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(GetDisplay(), 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
private:
using NativeViewGLSurfaceEGL::Initialize;
@@ -138,7 +224,9 @@ class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL {
virtual VSyncProvider* GetVSyncProvider() override {
return vsync_provider_.get();
}
- virtual bool SupportsPostSubBuffer() override { return true; }
+ virtual bool SupportsPostSubBuffer() override {
+ return ozone_surface_->SupportsPartialSwap();
+ }
virtual bool PostSubBuffer(int x, int y, int width, int height) override {
// The actual sub buffer handling is handled at higher layers.
SwapBuffers();

Powered by Google App Engine
This is Rietveld 408576698