• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 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 // Note: ported from Chromium commit head: a9d98e6
5 
6 #ifndef NATIVE_PIXMAP_HANDLE_H_
7 #define NATIVE_PIXMAP_HANDLE_H_
8 
9 #include <vector>
10 
11 #include "base/file_descriptor_posix.h"
12 
13 namespace media {
14 
15 // NativePixmapPlane is used to carry the plane related information for GBM
16 // buffer. More fields can be added if they are plane specific.
17 struct NativePixmapPlane {
18   // This is the same value as DRM_FORMAT_MOD_INVALID, which is not a valid
19   // modifier. We use this to indicate that layout information
20   // (tiling/compression) if any will be communicated out of band.
21   static constexpr uint64_t kNoModifier = 0x00ffffffffffffffULL;
22 
23   NativePixmapPlane();
24   NativePixmapPlane(int stride,
25                     int offset,
26                     uint64_t size,
27                     uint64_t modifier = kNoModifier);
28   NativePixmapPlane(const NativePixmapPlane& other);
29   ~NativePixmapPlane();
30 
31   // The strides and offsets in bytes to be used when accessing the buffers via
32   // a memory mapping. One per plane per entry.
33   int stride;
34   int offset;
35   // Size in bytes of the plane.
36   // This is necessary to map the buffers.
37   uint64_t size;
38   // The modifier is retrieved from GBM library and passed to EGL driver.
39   // Generally it's platform specific, and we don't need to modify it in
40   // Chromium code. Also one per plane per entry.
41   uint64_t modifier;
42 };
43 
44 struct NativePixmapHandle {
45   NativePixmapHandle();
46   NativePixmapHandle(const NativePixmapHandle& other);
47 
48   ~NativePixmapHandle();
49 
50   // File descriptors for the underlying memory objects (usually dmabufs).
51   std::vector<base::FileDescriptor> fds;
52   std::vector<NativePixmapPlane> planes;
53 };
54 
55 }  // namespace media
56 
57 #endif  // NATIVE_PIXMAP_HANDLE_H_
58