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 "ui/gfx/client_native_pixmap.h" |
| 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "ui/gfx/native_pixmap.h" |
| 17 |
| 18 namespace gfx { |
| 19 |
| 20 class GFX_EXPORT NativePixmapDmabufHelper { |
| 21 public: |
| 22 explicit NativePixmapDmabufHelper(const gfx::NativePixmapHandle& handle); |
| 23 NativePixmapDmabufHelper(std::vector<base::ScopedFD>&& fds, |
| 24 const std::vector<gfx::NativePixmapPlane>&& planes); |
| 25 |
| 26 virtual ~NativePixmapDmabufHelper(); |
| 27 |
| 28 virtual bool AreFdsValid() const; |
| 29 virtual size_t GetFdCount() const; |
| 30 virtual int GetFd(size_t plane) const; |
| 31 virtual int GetStride(size_t plane) const; |
| 32 virtual int GetOffset(size_t plane) const; |
| 33 virtual size_t GetSize(size_t plane) const; |
| 34 virtual uint64_t GetFormatModifier(size_t plane) const; |
| 35 |
| 36 private: |
| 37 std::vector<base::ScopedFD> fds_; |
| 38 std::vector<gfx::NativePixmapPlane> planes_; |
| 39 }; |
| 40 |
| 41 class GFX_EXPORT NativePixmapDmaBuf : public gfx::NativePixmap { |
| 42 public: |
| 43 NativePixmapDmaBuf(const gfx::Size& size, |
| 44 gfx::BufferFormat format, |
| 45 const gfx::NativePixmapHandle& handle); |
| 46 |
| 47 NativePixmapDmaBuf(const gfx::Size& size, |
| 48 gfx::BufferFormat format, |
| 49 const NativePixmapDmabufHelper& helper); |
| 50 |
| 51 // NativePixmap: |
| 52 void* GetEGLClientBuffer() const override; |
| 53 bool AreDmaBufFdsValid() const override; |
| 54 size_t GetDmaBufFdCount() const override; |
| 55 int GetDmaBufFd(size_t plane) const override; |
| 56 int GetDmaBufPitch(size_t plane) const override; |
| 57 int GetDmaBufOffset(size_t plane) const override; |
| 58 uint64_t GetDmaBufModifier(size_t plane) const override; |
| 59 gfx::BufferFormat GetBufferFormat() const override; |
| 60 gfx::Size GetBufferSize() const override; |
| 61 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 62 int plane_z_order, |
| 63 gfx::OverlayTransform plane_transform, |
| 64 const gfx::Rect& display_bounds, |
| 65 const gfx::RectF& crop_rect) override; |
| 66 void SetProcessingCallback( |
| 67 const ProcessingCallback& processing_callback) override; |
| 68 gfx::NativePixmapHandle ExportHandle() override; |
| 69 |
| 70 protected: |
| 71 ~NativePixmapDmaBuf() override; |
| 72 |
| 73 private: |
| 74 gfx::Size size_; |
| 75 gfx::BufferFormat format_; |
| 76 |
| 77 std::unique_ptr<NativePixmapDmabufHelper> holder_; |
| 78 |
| 79 const 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 |