OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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_GFX_LINUX_NATIVE_PIXMAP_DMABUF_H_ | |
6 #define UI_GFX_LINUX_NATIVE_PIXMAP_DMABUF_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <memory> | |
11 | |
12 #include "base/files/scoped_file.h" | |
13 #include "base/macros.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "ui/gfx/client_native_pixmap.h" | |
16 #include "ui/gfx/geometry/size.h" | |
17 #include "ui/gfx/native_pixmap.h" | |
18 | |
19 namespace gfx { | |
20 | |
21 class GFX_EXPORT NativePixmapDmabufHelper | |
reveman
2017/06/07 21:02:37
why a helper instead of NativePixmapDmabufBase tha
Julien Isorce
2017/06/07 21:29:53
I did something like that in Patch Set 13. I will
| |
22 : public base::RefCountedThreadSafe<NativePixmapDmabufHelper> { | |
reveman
2017/06/07 21:02:37
why does this need to be thread-safe refcounted?
Julien Isorce
2017/06/07 21:29:53
By symmetry with scoped_refptr<GbmBuffer> in GbmPi
| |
23 public: | |
24 explicit NativePixmapDmabufHelper(const gfx::NativePixmapHandle& handle); | |
25 NativePixmapDmabufHelper(std::vector<base::ScopedFD>&& fds, | |
26 const std::vector<gfx::NativePixmapPlane>&& planes); | |
27 | |
28 bool AreFdsValid() const; | |
29 size_t GetFdCount() const; | |
30 int GetFd(size_t plane) const; | |
31 int GetStride(size_t plane) const; | |
32 int GetOffset(size_t plane) const; | |
33 size_t GetSize(size_t plane) const; | |
34 uint64_t GetFormatModifier(size_t plane) const; | |
35 | |
36 private: | |
37 friend class base::RefCountedThreadSafe<NativePixmapDmabufHelper>; | |
38 | |
39 ~NativePixmapDmabufHelper(); | |
40 | |
41 std::vector<base::ScopedFD> fds_; | |
42 std::vector<gfx::NativePixmapPlane> planes_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(NativePixmapDmabufHelper); | |
45 }; | |
46 | |
47 class GFX_EXPORT NativePixmapDmaBuf : public gfx::NativePixmap { | |
48 public: | |
49 NativePixmapDmaBuf(const gfx::Size& size, | |
50 gfx::BufferFormat format, | |
51 const scoped_refptr<NativePixmapDmabufHelper>& helper); | |
52 | |
53 // NativePixmap: | |
54 void* GetEGLClientBuffer() const override; | |
55 bool AreDmaBufFdsValid() const override; | |
56 size_t GetDmaBufFdCount() const override; | |
57 int GetDmaBufFd(size_t plane) const override; | |
58 int GetDmaBufPitch(size_t plane) const override; | |
59 int GetDmaBufOffset(size_t plane) const override; | |
60 uint64_t GetDmaBufModifier(size_t plane) const override; | |
61 gfx::BufferFormat GetBufferFormat() const override; | |
62 gfx::Size GetBufferSize() const override; | |
63 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | |
64 int plane_z_order, | |
65 gfx::OverlayTransform plane_transform, | |
66 const gfx::Rect& display_bounds, | |
67 const gfx::RectF& crop_rect) override; | |
68 void SetProcessingCallback( | |
69 const ProcessingCallback& processing_callback) override; | |
70 gfx::NativePixmapHandle ExportHandle() override; | |
71 | |
72 protected: | |
73 ~NativePixmapDmaBuf() override; | |
74 | |
75 private: | |
76 gfx::Size size_; | |
77 gfx::BufferFormat format_; | |
78 | |
79 scoped_refptr<gfx::NativePixmapDmabufHelper> helper_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(NativePixmapDmaBuf); | |
82 }; | |
83 | |
84 } // namespace gfx | |
85 | |
86 #endif // UI_GFX_LINUX_NATIVE_PIXMAP_DMABUF_H_ | |
OLD | NEW |