OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <fcntl.h> | 5 #include <fcntl.h> |
6 #include <libdrm/i915_drm.h> | 6 #include <libdrm/i915_drm.h> |
7 #include <linux/types.h> | 7 #include <linux/types.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 base::ScopedFD drm_fd( | 43 base::ScopedFD drm_fd( |
44 HANDLE_EINTR(open("/dev/dri/card0", O_RDWR | O_CLOEXEC))); | 44 HANDLE_EINTR(open("/dev/dri/card0", O_RDWR | O_CLOEXEC))); |
45 DCHECK(drm_fd.is_valid()) << "Couldn't open '/dev/dri/card0'"; | 45 DCHECK(drm_fd.is_valid()) << "Couldn't open '/dev/dri/card0'"; |
46 | 46 |
47 std::vector<int> pitches{RoundTo64(size.width()), RoundTo64(size.width() / 2), | 47 std::vector<int> pitches{RoundTo64(size.width()), RoundTo64(size.width() / 2), |
48 RoundTo64(size.width() / 2)}; | 48 RoundTo64(size.width() / 2)}; |
49 std::vector<int> offsets{ | 49 std::vector<int> offsets{ |
50 0, pitches[0] * size.height() + pitches[1] * size.height() / 2, | 50 0, pitches[0] * size.height() + pitches[1] * size.height() / 2, |
51 pitches[0] * size.height(), | 51 pitches[0] * size.height(), |
52 }; | 52 }; |
| 53 std::vector<size_t> sizes{pitches[0] * size.height(), |
| 54 pitches[1] * size.height() / 2, |
| 55 pitches[2] * size.height() / 2}; |
| 56 |
53 size_t byte_number = pitches[0] * size.height() + | 57 size_t byte_number = pitches[0] * size.height() + |
54 pitches[1] * size.height() / 2 + | 58 pitches[1] * size.height() / 2 + |
55 pitches[2] * size.height() / 2; | 59 pitches[2] * size.height() / 2; |
56 | 60 |
57 struct drm_i915_gem_create gem_create {}; | 61 struct drm_i915_gem_create gem_create {}; |
58 gem_create.size = byte_number; | 62 gem_create.size = byte_number; |
59 int ret = drmIoctl(drm_fd.get(), DRM_IOCTL_I915_GEM_CREATE, &gem_create); | 63 int ret = drmIoctl(drm_fd.get(), DRM_IOCTL_I915_GEM_CREATE, &gem_create); |
60 DCHECK(!ret) << "Can't create the GEM buffer."; | 64 DCHECK(!ret) << "Can't create the GEM buffer."; |
61 struct drm_i915_gem_set_tiling gem_set_tiling {}; | 65 struct drm_i915_gem_set_tiling gem_set_tiling {}; |
62 do { | 66 do { |
(...skipping 19 matching lines...) Expand all Loading... |
82 struct drm_i915_gem_pwrite gem_pwrite {}; | 86 struct drm_i915_gem_pwrite gem_pwrite {}; |
83 gem_pwrite.handle = gem_create.handle; | 87 gem_pwrite.handle = gem_create.handle; |
84 gem_pwrite.size = byte_number; | 88 gem_pwrite.size = byte_number; |
85 gem_pwrite.data_ptr = reinterpret_cast<uint64_t>(&data[0]); | 89 gem_pwrite.data_ptr = reinterpret_cast<uint64_t>(&data[0]); |
86 ret = drmIoctl(drm_fd.get(), DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite); | 90 ret = drmIoctl(drm_fd.get(), DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite); |
87 DCHECK(!ret) << "Problems with drmIoctl when writing data."; | 91 DCHECK(!ret) << "Problems with drmIoctl when writing data."; |
88 | 92 |
89 gfx::NativePixmapHandle pixmap_handle; | 93 gfx::NativePixmapHandle pixmap_handle; |
90 pixmap_handle.fds.emplace_back(fd, false); | 94 pixmap_handle.fds.emplace_back(fd, false); |
91 for (int i = 0; i < 3; i++) { | 95 for (int i = 0; i < 3; i++) { |
92 pixmap_handle.planes.emplace_back(pitches[i], offsets[i], 0); | 96 pixmap_handle.planes.emplace_back(pitches[i], offsets[i], sizes[i], 0); |
93 } | 97 } |
94 ui::SurfaceFactoryOzone* surface_factory = | 98 ui::SurfaceFactoryOzone* surface_factory = |
95 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); | 99 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); |
96 return surface_factory->CreateNativePixmapFromHandle( | 100 return surface_factory->CreateNativePixmapFromHandle( |
97 gfx::kNullAcceleratedWidget, size, gfx::BufferFormat::YVU_420, | 101 gfx::kNullAcceleratedWidget, size, gfx::BufferFormat::YVU_420, |
98 pixmap_handle); | 102 pixmap_handle); |
99 } | 103 } |
100 | 104 |
101 // Delegate to test EGL images created directly using drm. | 105 // Delegate to test EGL images created directly using drm. |
102 // YVU420 buffers can't be created yet via Ozone, we still | 106 // YVU420 buffers can't be created yet via Ozone, we still |
(...skipping 27 matching lines...) Expand all Loading... |
130 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapDrm, | 134 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapDrm, |
131 GLImageTest, | 135 GLImageTest, |
132 GLImageOzoneNativePixmapDrmTestDelegate); | 136 GLImageOzoneNativePixmapDrmTestDelegate); |
133 | 137 |
134 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapDrm, | 138 INSTANTIATE_TYPED_TEST_CASE_P(DISABLED_GLImageOzoneNativePixmapDrm, |
135 GLImageBindTest, | 139 GLImageBindTest, |
136 GLImageOzoneNativePixmapDrmTestDelegate); | 140 GLImageOzoneNativePixmapDrmTestDelegate); |
137 | 141 |
138 } // namespace | 142 } // namespace |
139 } // namespace gl | 143 } // namespace gl |
OLD | NEW |