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_DRM_GPU_DRM_CONSOLE_BUFFER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_CONSOLE_BUFFER_H_ |
6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_CONSOLE_BUFFER_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_CONSOLE_BUFFER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "skia/ext/refptr.h" | 10 #include "third_party/skia/include/core/SkRefCnt.h" |
11 #include "third_party/skia/include/core/SkSurface.h" | 11 #include "third_party/skia/include/core/SkSurface.h" |
12 | 12 |
13 class SkCanvas; | 13 class SkCanvas; |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 class DrmDevice; | 17 class DrmDevice; |
18 | 18 |
19 // Wrapper for the console buffer. This is the buffer that is allocated by | 19 // Wrapper for the console buffer. This is the buffer that is allocated by |
20 // default by the system and is used when no application is controlling the | 20 // default by the system and is used when no application is controlling the |
21 // CRTC. Keeps track of the native properties of the buffer and wraps the pixel | 21 // CRTC. Keeps track of the native properties of the buffer and wraps the pixel |
22 // memory into a SkSurface which can be used to draw into using Skia. | 22 // memory into a SkSurface which can be used to draw into using Skia. |
23 class DrmConsoleBuffer { | 23 class DrmConsoleBuffer { |
24 public: | 24 public: |
25 DrmConsoleBuffer(const scoped_refptr<DrmDevice>& drm, uint32_t framebuffer); | 25 DrmConsoleBuffer(const scoped_refptr<DrmDevice>& drm, uint32_t framebuffer); |
26 ~DrmConsoleBuffer(); | 26 ~DrmConsoleBuffer(); |
27 | 27 |
28 SkCanvas* canvas() { return surface_->getCanvas(); } | 28 SkCanvas* canvas() { return surface_->getCanvas(); } |
29 skia::RefPtr<SkImage> image() { | 29 sk_sp<SkImage> image() { return surface_->makeImageSnapshot(); } |
30 return skia::AdoptRef(surface_->newImageSnapshot()); | |
31 } | |
32 | 30 |
33 // Memory map the backing pixels and wrap them in |surface_|. | 31 // Memory map the backing pixels and wrap them in |surface_|. |
34 bool Initialize(); | 32 bool Initialize(); |
35 | 33 |
36 protected: | 34 protected: |
37 scoped_refptr<DrmDevice> drm_; | 35 scoped_refptr<DrmDevice> drm_; |
38 | 36 |
39 // Wrapper around the native pixel memory. | 37 // Wrapper around the native pixel memory. |
40 skia::RefPtr<SkSurface> surface_; | 38 sk_sp<SkSurface> surface_; |
41 | 39 |
42 // Length of a row of pixels. | 40 // Length of a row of pixels. |
43 uint32_t stride_ = 0; | 41 uint32_t stride_ = 0; |
44 | 42 |
45 // Buffer handle used by the DRM allocator. | 43 // Buffer handle used by the DRM allocator. |
46 uint32_t handle_ = 0; | 44 uint32_t handle_ = 0; |
47 | 45 |
48 // Buffer ID used by the DRM modesettings API. | 46 // Buffer ID used by the DRM modesettings API. |
49 uint32_t framebuffer_ = 0; | 47 uint32_t framebuffer_ = 0; |
50 | 48 |
51 // Memory map base address. | 49 // Memory map base address. |
52 void* mmap_base_ = nullptr; | 50 void* mmap_base_ = nullptr; |
53 | 51 |
54 // Memory map size. | 52 // Memory map size. |
55 size_t mmap_size_ = 0; | 53 size_t mmap_size_ = 0; |
56 | 54 |
57 DISALLOW_COPY_AND_ASSIGN(DrmConsoleBuffer); | 55 DISALLOW_COPY_AND_ASSIGN(DrmConsoleBuffer); |
58 }; | 56 }; |
59 | 57 |
60 } // namespace ui | 58 } // namespace ui |
61 | 59 |
62 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_CONSOLE_BUFFER_H_ | 60 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_CONSOLE_BUFFER_H_ |
OLD | NEW |