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

Unified Diff: ui/ozone/platform/x11/x11_surface_factory.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/ozone/platform/x11/x11_surface_factory.cc
diff --git a/ui/ozone/platform/x11/x11_surface_factory.cc b/ui/ozone/platform/x11/x11_surface_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aba5bee1c9cef4f3632fb9e764b57569593d983f
--- /dev/null
+++ b/ui/ozone/platform/x11/x11_surface_factory.cc
@@ -0,0 +1,112 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/x11/x11_surface_factory.h"
+
+#include "third_party/khronos/EGL/egl.h"
+#include "ui/gfx/vsync_provider.h"
+#include "ui/ozone/common/egl_util.h"
+#include "ui/ozone/public/surface_ozone_egl.h"
+#include "ui/platform_window/x11/x11_window.h"
+
+namespace ui {
+
+class X11SurfaceEGL : public SurfaceOzoneEGL {
+ public:
+ X11SurfaceEGL(gfx::AcceleratedWidget widget) : widget_(widget) {}
+ ~X11SurfaceEGL() {}
+
+ intptr_t GetNativeWindow() override { return widget_; }
+
+ bool OnSwapBuffers() override { return true; }
+
+ bool ResizeNativeWindow(const gfx::Size& viewport_size) override {
+ NOTIMPLEMENTED();
spang 2014/12/06 00:31:23 This will be noisy, probably just "return true".
achaulk 2014/12/08 16:44:41 Done.
+ return true;
+ }
+
+ scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override {
+ return scoped_ptr<gfx::VSyncProvider>();
+ }
+
+ // There is currently a bug where the EGL property says it supports partial
+ // swap, but actually using it causes an error.
+ bool SupportsPartialSwap() override { return false; }
spang 2014/12/06 00:31:23 Not sure we should do this. Doing it this way brea
achaulk 2014/12/08 16:44:41 I don't know how to determine if it is broken or n
spang 2014/12/09 19:47:33 Fixing this @ https://codereview.chromium.org/7926
+
+ private:
+ gfx::AcceleratedWidget widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(X11SurfaceEGL);
+};
+
+X11SurfaceFactory::X11SurfaceFactory(
+ scoped_refptr<X11WindowManager> window_manager)
+ : window_manager_(window_manager) {
+}
+
+X11SurfaceFactory::~X11SurfaceFactory() {
+}
+
+// SurfaceFactoryOzone:
+scoped_ptr<SurfaceOzoneEGL> X11SurfaceFactory::CreateEGLSurfaceForWidget(
+ gfx::AcceleratedWidget widget) {
+ return scoped_ptr<SurfaceOzoneEGL>(new X11SurfaceEGL(widget));
+}
+
+bool X11SurfaceFactory::LoadEGLGLES2Bindings(
+ AddGLLibraryCallback add_gl_library,
+ SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
+ return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address);
+}
+
+intptr_t X11SurfaceFactory::GetNativeDisplay() {
+ return reinterpret_cast<intptr_t>(gfx::GetXDisplay());
+}
+
+const int32* X11SurfaceFactory::GetEGLSurfaceProperties(
+ const int32* desired_list,
+ SurfaceOzoneEGL* surface) {
+ const int kBufferSizeOffset = 1;
+ const int kAlphaSizeOffset = 3;
+ static int32 config_attribs[] = {EGL_BUFFER_SIZE,
spang 2014/12/06 00:31:23 We should fix this broken interface rather than ma
achaulk 2014/12/08 16:44:41 Sure
+ -1,
+ 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] = 32;
+ // Copy out properties from the desired list.
+ for (size_t i = 0; desired_list[i] != EGL_NONE; i++) {
+ switch (desired_list[i]) {
+ case EGL_ALPHA_SIZE:
+ config_attribs[kAlphaSizeOffset] = desired_list[i + 1];
+ }
+ }
+
+ if (surface) {
+ // Get a config compatible with the window.
+ XWindowAttributes win_attribs;
+ if (XGetWindowAttributes(gfx::GetXDisplay(), surface->GetNativeWindow(),
+ &win_attribs)) {
+ config_attribs[kBufferSizeOffset] = win_attribs.depth;
+ }
+ }
+
+ return config_attribs;
+}
+
+X11Window* X11SurfaceFactory::FindWindow(XID id) {
+ return window_manager_->FindWindow(id);
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698