OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_DRI_DRI_BUFFER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
6 #define UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "skia/ext/refptr.h" | 9 #include "skia/ext/refptr.h" |
10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
11 #include "ui/ozone/ozone_export.h" | 11 #include "ui/ozone/ozone_export.h" |
12 #include "ui/ozone/platform/dri/scanout_buffer.h" | 12 #include "ui/ozone/platform/dri/scanout_buffer.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 class DriWrapper; | 16 class DrmDevice; |
17 | 17 |
18 // Wrapper for a DRM allocated buffer. Keeps track of the native properties of | 18 // Wrapper for a DRM allocated buffer. Keeps track of the native properties of |
19 // the buffer and wraps the pixel memory into a SkSurface which can be used to | 19 // the buffer and wraps the pixel memory into a SkSurface which can be used to |
20 // draw into using Skia. | 20 // draw into using Skia. |
21 class OZONE_EXPORT DriBuffer : public ScanoutBuffer { | 21 class OZONE_EXPORT DriBuffer : public ScanoutBuffer { |
22 public: | 22 public: |
23 DriBuffer(const scoped_refptr<DriWrapper>& dri); | 23 DriBuffer(const scoped_refptr<DrmDevice>& drm); |
24 | 24 |
25 // Allocates the backing pixels and wraps them in |surface_|. |info| is used | 25 // Allocates the backing pixels and wraps them in |surface_|. |info| is used |
26 // to describe the buffer characteristics (size, color format). | 26 // to describe the buffer characteristics (size, color format). |
27 // |should_register_framebuffer| is used to distinguish the buffers that are | 27 // |should_register_framebuffer| is used to distinguish the buffers that are |
28 // used for modesetting. | 28 // used for modesetting. |
29 bool Initialize(const SkImageInfo& info, bool should_register_framebuffer); | 29 bool Initialize(const SkImageInfo& info, bool should_register_framebuffer); |
30 | 30 |
31 SkCanvas* GetCanvas() const; | 31 SkCanvas* GetCanvas() const; |
32 | 32 |
33 // ScanoutBuffer: | 33 // ScanoutBuffer: |
34 uint32_t GetFramebufferId() const override; | 34 uint32_t GetFramebufferId() const override; |
35 uint32_t GetHandle() const override; | 35 uint32_t GetHandle() const override; |
36 gfx::Size GetSize() const override; | 36 gfx::Size GetSize() const override; |
37 | 37 |
38 protected: | 38 protected: |
39 ~DriBuffer() override; | 39 ~DriBuffer() override; |
40 | 40 |
41 scoped_refptr<DriWrapper> dri_; | 41 scoped_refptr<DrmDevice> drm_; |
42 | 42 |
43 // Wrapper around the native pixel memory. | 43 // Wrapper around the native pixel memory. |
44 skia::RefPtr<SkSurface> surface_; | 44 skia::RefPtr<SkSurface> surface_; |
45 | 45 |
46 // Length of a row of pixels. | 46 // Length of a row of pixels. |
47 uint32_t stride_; | 47 uint32_t stride_; |
48 | 48 |
49 // Buffer handle used by the DRM allocator. | 49 // Buffer handle used by the DRM allocator. |
50 uint32_t handle_; | 50 uint32_t handle_; |
51 | 51 |
52 // Buffer ID used by the DRM modesettings API. This is set when the buffer is | 52 // Buffer ID used by the DRM modesettings API. This is set when the buffer is |
53 // registered with the CRTC. | 53 // registered with the CRTC. |
54 uint32_t framebuffer_; | 54 uint32_t framebuffer_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(DriBuffer); | 56 DISALLOW_COPY_AND_ASSIGN(DriBuffer); |
57 }; | 57 }; |
58 | 58 |
59 class OZONE_EXPORT DriBufferGenerator : public ScanoutBufferGenerator { | 59 class OZONE_EXPORT DriBufferGenerator : public ScanoutBufferGenerator { |
60 public: | 60 public: |
61 DriBufferGenerator(); | 61 DriBufferGenerator(); |
62 ~DriBufferGenerator() override; | 62 ~DriBufferGenerator() override; |
63 | 63 |
64 // ScanoutBufferGenerator: | 64 // ScanoutBufferGenerator: |
65 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DriWrapper>& drm, | 65 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DrmDevice>& drm, |
66 const gfx::Size& size) override; | 66 const gfx::Size& size) override; |
67 | 67 |
68 private: | 68 private: |
69 DISALLOW_COPY_AND_ASSIGN(DriBufferGenerator); | 69 DISALLOW_COPY_AND_ASSIGN(DriBufferGenerator); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace ui | 72 } // namespace ui |
73 | 73 |
74 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ | 74 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
OLD | NEW |