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

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: remove new evernt type, add direct route from event -> platform window Created 6 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
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..b8caa72f8c75a00f6adb342f26893d33b28ed417 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -4,9 +4,11 @@
#include "ui/gl/gl_surface.h"
+#include "base/command_line.h"
#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"
@@ -14,9 +16,12 @@
#include "ui/gl/gl_surface_osmesa.h"
#include "ui/gl/gl_surface_stub.h"
#include "ui/gl/scoped_make_current.h"
+#include "ui/ozone/public/ozone_switches.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h"
+using ui::GetLastEGLErrorString;
+
namespace gfx {
namespace {
@@ -56,6 +61,78 @@ 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();
+ }
+
+ EGLConfig GetConfig() override {
+ if (!config_) {
spang 2014/12/06 00:31:23 We may want to delegate this whole config-choosing
achaulk 2014/12/08 16:44:41 It is, but it involves calling egl from within ozo
spang 2014/12/09 19:47:33 We were mostly worried about #incuding chrome's ve
+ // 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,
spang 2014/12/06 00:31:23 I think this was overridden in the old code? Proba
achaulk 2014/12/08 16:44:41 It's not, but GetEGLSurfaceProperties is doing the
+ 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_NONE};
+ const int32* chosen_attribs =
+ ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties(
+ config_attribs, ozone_surface_.get());
+
+ EGLint num_configs;
+ if (!eglChooseConfig(GetDisplay(), chosen_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 == chosen_attribs[kBufferSizeOffset]) {
+ return config_;
+ }
+ }
+
+ // Try without an alpha channel.
+ config_attribs[kAlphaSizeOffset] = 0;
+ chosen_attribs =
+ ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties(
+ config_attribs, ozone_surface_.get());
+ if (!eglChooseConfig(GetDisplay(), chosen_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_;
+ }
private:
using NativeViewGLSurfaceEGL::Initialize;
@@ -138,7 +215,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