OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/ozone/platform/x11/x11_surface_factory.h" | |
6 | |
7 #include "third_party/khronos/EGL/egl.h" | |
8 #include "ui/gfx/vsync_provider.h" | |
9 #include "ui/ozone/common/egl_util.h" | |
10 #include "ui/ozone/public/surface_ozone_egl.h" | |
11 #include "ui/platform_window/x11/x11_window.h" | |
12 | |
13 namespace ui { | |
14 | |
15 class X11SurfaceEGL : public SurfaceOzoneEGL { | |
16 public: | |
17 X11SurfaceEGL(gfx::AcceleratedWidget widget) : widget_(widget) {} | |
18 ~X11SurfaceEGL() {} | |
19 | |
20 intptr_t GetNativeWindow() override { return widget_; } | |
21 | |
22 bool OnSwapBuffers() override { return true; } | |
23 | |
24 bool ResizeNativeWindow(const gfx::Size& viewport_size) override { | |
25 NOTIMPLEMENTED(); | |
spang
2014/12/06 00:31:23
This will be noisy, probably just "return true".
achaulk
2014/12/08 16:44:41
Done.
| |
26 return true; | |
27 } | |
28 | |
29 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { | |
30 return scoped_ptr<gfx::VSyncProvider>(); | |
31 } | |
32 | |
33 // There is currently a bug where the EGL property says it supports partial | |
34 // swap, but actually using it causes an error. | |
35 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
| |
36 | |
37 private: | |
38 gfx::AcceleratedWidget widget_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(X11SurfaceEGL); | |
41 }; | |
42 | |
43 X11SurfaceFactory::X11SurfaceFactory( | |
44 scoped_refptr<X11WindowManager> window_manager) | |
45 : window_manager_(window_manager) { | |
46 } | |
47 | |
48 X11SurfaceFactory::~X11SurfaceFactory() { | |
49 } | |
50 | |
51 // SurfaceFactoryOzone: | |
52 scoped_ptr<SurfaceOzoneEGL> X11SurfaceFactory::CreateEGLSurfaceForWidget( | |
53 gfx::AcceleratedWidget widget) { | |
54 return scoped_ptr<SurfaceOzoneEGL>(new X11SurfaceEGL(widget)); | |
55 } | |
56 | |
57 bool X11SurfaceFactory::LoadEGLGLES2Bindings( | |
58 AddGLLibraryCallback add_gl_library, | |
59 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | |
60 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); | |
61 } | |
62 | |
63 intptr_t X11SurfaceFactory::GetNativeDisplay() { | |
64 return reinterpret_cast<intptr_t>(gfx::GetXDisplay()); | |
65 } | |
66 | |
67 const int32* X11SurfaceFactory::GetEGLSurfaceProperties( | |
68 const int32* desired_list, | |
69 SurfaceOzoneEGL* surface) { | |
70 const int kBufferSizeOffset = 1; | |
71 const int kAlphaSizeOffset = 3; | |
72 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
| |
73 -1, | |
74 EGL_ALPHA_SIZE, | |
75 8, | |
76 EGL_BLUE_SIZE, | |
77 8, | |
78 EGL_GREEN_SIZE, | |
79 8, | |
80 EGL_RED_SIZE, | |
81 8, | |
82 EGL_RENDERABLE_TYPE, | |
83 EGL_OPENGL_ES2_BIT, | |
84 EGL_SURFACE_TYPE, | |
85 EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | |
86 EGL_NONE}; | |
87 config_attribs[kBufferSizeOffset] = 32; | |
88 // Copy out properties from the desired list. | |
89 for (size_t i = 0; desired_list[i] != EGL_NONE; i++) { | |
90 switch (desired_list[i]) { | |
91 case EGL_ALPHA_SIZE: | |
92 config_attribs[kAlphaSizeOffset] = desired_list[i + 1]; | |
93 } | |
94 } | |
95 | |
96 if (surface) { | |
97 // Get a config compatible with the window. | |
98 XWindowAttributes win_attribs; | |
99 if (XGetWindowAttributes(gfx::GetXDisplay(), surface->GetNativeWindow(), | |
100 &win_attribs)) { | |
101 config_attribs[kBufferSizeOffset] = win_attribs.depth; | |
102 } | |
103 } | |
104 | |
105 return config_attribs; | |
106 } | |
107 | |
108 X11Window* X11SurfaceFactory::FindWindow(XID id) { | |
109 return window_manager_->FindWindow(id); | |
110 } | |
111 | |
112 } // namespace ui | |
OLD | NEW |