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_DRI_DRI_BUFFER_H_
6 #define UI_OZONE_PLATFORM_DRI_DRI_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/platform/dri/scanout_buffer.h"
17 // Wrapper for a DRM allocated buffer. Keeps track of the native properties of
18 // the buffer and wraps the pixel memory into a SkSurface which can be used to
19 // draw into using Skia.
20 class DriBuffer : public ScanoutBuffer {
22 DriBuffer(DriWrapper* dri);
24 // Allocates the backing pixels and wraps them in |surface_|. |info| is used
25 // to describe the buffer characteristics (size, color format).
26 bool Initialize(const SkImageInfo& info);
28 SkCanvas* GetCanvas() const;
31 uint32_t GetFramebufferId() const override;
32 uint32_t GetHandle() const override;
33 gfx::Size GetSize() const override;
36 ~DriBuffer() override;
38 DriWrapper* dri_; // Not owned.
40 // Wrapper around the native pixel memory.
41 skia::RefPtr<SkSurface> surface_;
43 // Length of a row of pixels.
46 // Buffer handle used by the DRM allocator.
49 // Buffer ID used by the DRM modesettings API. This is set when the buffer is
50 // registered with the CRTC.
51 uint32_t framebuffer_;
53 DISALLOW_COPY_AND_ASSIGN(DriBuffer);
56 class DriBufferGenerator : public ScanoutBufferGenerator {
58 DriBufferGenerator(DriWrapper* dri);
59 ~DriBufferGenerator() override;
61 // ScanoutBufferGenerator:
62 scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) override;
65 DriWrapper* dri_; // Not owned.
67 DISALLOW_COPY_AND_ASSIGN(DriBufferGenerator);
72 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_