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