OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GL_GL_SURFACE_GLX_H_ | 5 #ifndef UI_GL_GL_SURFACE_GLX_H_ |
6 #define UI_GL_GL_SURFACE_GLX_H_ | 6 #define UI_GL_GL_SURFACE_GLX_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "ui/events/platform/platform_event_dispatcher.h" | |
15 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/vsync_provider.h" | 16 #include "ui/gfx/vsync_provider.h" |
18 #include "ui/gfx/x/x11_types.h" | 17 #include "ui/gfx/x/x11_types.h" |
19 #include "ui/gl/gl_export.h" | 18 #include "ui/gl/gl_export.h" |
20 #include "ui/gl/gl_surface.h" | 19 #include "ui/gl/gl_surface.h" |
21 | 20 |
22 namespace gfx { | 21 namespace gfx { |
23 | 22 |
24 // Base class for GLX surfaces. | 23 // Base class for GLX surfaces. |
(...skipping 20 matching lines...) Expand all Loading... | |
45 void* GetConfig() override = 0; | 44 void* GetConfig() override = 0; |
46 | 45 |
47 protected: | 46 protected: |
48 ~GLSurfaceGLX() override; | 47 ~GLSurfaceGLX() override; |
49 | 48 |
50 private: | 49 private: |
51 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); | 50 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); |
52 }; | 51 }; |
53 | 52 |
54 // A surface used to render to a view. | 53 // A surface used to render to a view. |
55 class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX, | 54 class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { |
56 public ui::PlatformEventDispatcher { | |
57 public: | 55 public: |
58 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); | 56 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); |
59 | 57 |
60 // Implement GLSurfaceGLX. | 58 // Implement GLSurfaceGLX. |
61 bool Initialize(GLSurface::Format format) override; | 59 bool Initialize(GLSurface::Format format) override; |
62 void Destroy() override; | 60 void Destroy() override; |
63 bool Resize(const gfx::Size& size, | 61 bool Resize(const gfx::Size& size, |
64 float scale_factor, | 62 float scale_factor, |
65 bool has_alpha) override; | 63 bool has_alpha) override; |
66 bool IsOffscreen() override; | 64 bool IsOffscreen() override; |
67 gfx::SwapResult SwapBuffers() override; | 65 gfx::SwapResult SwapBuffers() override; |
68 gfx::Size GetSize() override; | 66 gfx::Size GetSize() override; |
69 void* GetHandle() override; | 67 void* GetHandle() override; |
70 bool SupportsPostSubBuffer() override; | 68 bool SupportsPostSubBuffer() override; |
71 void* GetConfig() override; | 69 void* GetConfig() override; |
72 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 70 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
73 VSyncProvider* GetVSyncProvider() override; | 71 VSyncProvider* GetVSyncProvider() override; |
74 | 72 |
75 protected: | 73 protected: |
76 ~NativeViewGLSurfaceGLX() override; | 74 ~NativeViewGLSurfaceGLX() override; |
77 | 75 |
76 // Handle registering and unregistering for Expose events. | |
rjkroege
2016/04/27 19:08:12
This seems unfortunate. Can you handle this at a l
kylechar
2016/04/27 19:36:32
Not totally sure I understand this part. This abst
| |
77 virtual void RegisterEvents() = 0; | |
78 virtual void UnregisterEvents() = 0; | |
79 | |
80 // Forwards Expose event to child window. | |
81 void ForwardExposeEvent(XEvent* xevent); | |
82 | |
83 // Checks if event is Expose for child window. | |
84 bool CanHandleEvent(XEvent* xevent); | |
85 | |
86 gfx::AcceleratedWidget window() const { return window_; } | |
87 | |
78 private: | 88 private: |
79 // The handle for the drawable to make current or swap. | 89 // The handle for the drawable to make current or swap. |
80 GLXDrawable GetDrawableHandle() const; | 90 GLXDrawable GetDrawableHandle() const; |
81 | 91 |
82 // PlatformEventDispatcher implementation | |
83 bool CanDispatchEvent(const ui::PlatformEvent& event) override; | |
84 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; | |
85 | |
86 // Window passed in at creation. Always valid. | 92 // Window passed in at creation. Always valid. |
87 gfx::AcceleratedWidget parent_window_; | 93 gfx::AcceleratedWidget parent_window_; |
88 | 94 |
89 // Child window, used to control resizes so that they're in-order with GL. | 95 // Child window, used to control resizes so that they're in-order with GL. |
90 gfx::AcceleratedWidget window_; | 96 gfx::AcceleratedWidget window_; |
91 | 97 |
92 // GLXDrawable for the window. | 98 // GLXDrawable for the window. |
93 GLXWindow glx_window_; | 99 GLXWindow glx_window_; |
94 | 100 |
95 GLXFBConfig config_; | 101 GLXFBConfig config_; |
(...skipping 29 matching lines...) Expand all Loading... | |
125 | 131 |
126 // GLXDrawable for the window. | 132 // GLXDrawable for the window. |
127 GLXWindow glx_window_; | 133 GLXWindow glx_window_; |
128 | 134 |
129 DISALLOW_COPY_AND_ASSIGN(UnmappedNativeViewGLSurfaceGLX); | 135 DISALLOW_COPY_AND_ASSIGN(UnmappedNativeViewGLSurfaceGLX); |
130 }; | 136 }; |
131 | 137 |
132 } // namespace gfx | 138 } // namespace gfx |
133 | 139 |
134 #endif // UI_GL_GL_SURFACE_GLX_H_ | 140 #endif // UI_GL_GL_SURFACE_GLX_H_ |
OLD | NEW |