Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / ozone / platform / drm / gpu / drm_buffer.h
blob84556ad746fe3d254c1fac15684c0eaecaee568b
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.
5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_BUFFER_H_
6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_BUFFER_H_
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"
14 namespace ui {
16 class DrmDevice;
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);
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);
31 SkCanvas* GetCanvas() const;
33 // ScanoutBuffer:
34 uint32_t GetFramebufferId() const override;
35 uint32_t GetHandle() const override;
36 gfx::Size GetSize() const override;
38 protected:
39 ~DrmBuffer() override;
41 scoped_refptr<DrmDevice> drm_;
43 // Length of a row of pixels.
44 uint32_t stride_ = 0;
46 // Buffer handle used by the DRM allocator.
47 uint32_t handle_ = 0;
49 // Base address for memory mapping.
50 void* mmap_base_ = 0;
52 // Size for memory mapping.
53 size_t mmap_size_ = 0;
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;
59 // Wrapper around the native pixel memory.
60 skia::RefPtr<SkSurface> surface_;
62 DISALLOW_COPY_AND_ASSIGN(DrmBuffer);
65 class OZONE_EXPORT DrmBufferGenerator : public ScanoutBufferGenerator {
66 public:
67 DrmBufferGenerator();
68 ~DrmBufferGenerator() override;
70 // ScanoutBufferGenerator:
71 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DrmDevice>& drm,
72 const gfx::Size& size) override;
74 private:
75 DISALLOW_COPY_AND_ASSIGN(DrmBufferGenerator);
78 } // namespace ui
80 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_BUFFER_H_