OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_H_ |
6 #define UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
13 #include "ui/gl/gl_image.h" | 13 #include "ui/gl/gl_image.h" |
14 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 14 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 class DrmWindowProxy; | 18 class DrmWindowProxy; |
19 class GbmSurfaceFactory; | 19 class GbmSurfaceFactory; |
20 | 20 |
21 // A GLSurface for GBM Ozone platform provides surface-like semantics | 21 // A GLSurface for GBM Ozone platform provides surface-like semantics |
22 // implemented through surfaceless. A framebuffer is bound automatically. | 22 // implemented through surfaceless. A framebuffer is bound automatically. |
23 class GbmSurface : public GbmSurfaceless { | 23 class GbmSurface : public GbmSurfaceless { |
24 public: | 24 public: |
25 GbmSurface(GbmSurfaceFactory* surface_factory, | 25 GbmSurface(GbmSurfaceFactory* surface_factory, |
26 std::unique_ptr<DrmWindowProxy> window, | 26 std::unique_ptr<DrmWindowProxy> window, |
27 gfx::AcceleratedWidget widget); | 27 gfx::AcceleratedWidget widget); |
28 | 28 |
29 // gl::GLSurface: | 29 // gl::GLSurface: |
30 unsigned int GetBackingFrameBufferObject() override; | 30 unsigned int GetBackingFramebufferObject() override; |
31 bool OnMakeCurrent(gl::GLContext* context) override; | 31 bool OnMakeCurrent(gl::GLContext* context) override; |
32 bool Resize(const gfx::Size& size, | 32 bool Resize(const gfx::Size& size, |
33 float scale_factor, | 33 float scale_factor, |
34 bool has_alpha) override; | 34 bool has_alpha) override; |
35 bool SupportsPostSubBuffer() override; | 35 bool SupportsPostSubBuffer() override; |
36 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 36 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
37 void Destroy() override; | 37 void Destroy() override; |
38 bool IsSurfaceless() const override; | 38 bool IsSurfaceless() const override; |
39 | 39 |
40 private: | 40 private: |
41 ~GbmSurface() override; | 41 ~GbmSurface() override; |
42 | 42 |
43 void BindFramebuffer(); | 43 void BindFramebuffer(); |
44 bool CreatePixmaps(); | 44 bool CreatePixmaps(); |
45 | 45 |
46 scoped_refptr<gl::GLContext> context_; | 46 scoped_refptr<gl::GLContext> context_; |
47 GLuint fbo_ = 0; | 47 GLuint fbo_ = 0; |
48 GLuint textures_[2]; | 48 GLuint textures_[2]; |
49 scoped_refptr<gl::GLImage> images_[2]; | 49 scoped_refptr<gl::GLImage> images_[2]; |
50 int current_surface_ = 0; | 50 int current_surface_ = 0; |
51 | 51 |
52 DISALLOW_COPY_AND_ASSIGN(GbmSurface); | 52 DISALLOW_COPY_AND_ASSIGN(GbmSurface); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace ui | 55 } // namespace ui |
56 | 56 |
57 #endif // UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_H_ | 57 #endif // UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACE_H_ |
OLD | NEW |