| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "ash/common/shell_window_ids.h" | 5 #include "ash/common/shell_window_ids.h" |
| 6 #include "components/exo/buffer.h" | 6 #include "components/exo/buffer.h" |
| 7 #include "components/exo/display.h" | 7 #include "components/exo/display.h" |
| 8 #include "components/exo/shared_memory.h" | 8 #include "components/exo/shared_memory.h" |
| 9 #include "components/exo/shell_surface.h" | 9 #include "components/exo/shell_surface.h" |
| 10 #include "components/exo/sub_surface.h" | 10 #include "components/exo/sub_surface.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 std::unique_ptr<Display> display(new Display); | 62 std::unique_ptr<Display> display(new Display); |
| 63 // Creating a prime buffer from a native pixmap handle should succeed. | 63 // Creating a prime buffer from a native pixmap handle should succeed. |
| 64 scoped_refptr<ui::NativePixmap> pixmap = | 64 scoped_refptr<ui::NativePixmap> pixmap = |
| 65 ui::OzonePlatform::GetInstance() | 65 ui::OzonePlatform::GetInstance() |
| 66 ->GetSurfaceFactoryOzone() | 66 ->GetSurfaceFactoryOzone() |
| 67 ->CreateNativePixmap(gfx::kNullAcceleratedWidget, buffer_size, | 67 ->CreateNativePixmap(gfx::kNullAcceleratedWidget, buffer_size, |
| 68 gfx::BufferFormat::RGBA_8888, | 68 gfx::BufferFormat::RGBA_8888, |
| 69 gfx::BufferUsage::GPU_READ); | 69 gfx::BufferUsage::GPU_READ); |
| 70 gfx::NativePixmapHandle native_pixmap_handle = pixmap->ExportHandle(); | 70 gfx::NativePixmapHandle native_pixmap_handle = pixmap->ExportHandle(); |
| 71 std::vector<gfx::NativePixmapPlane> planes; | 71 std::vector<int> strides; |
| 72 std::vector<int> offsets; |
| 72 std::vector<base::ScopedFD> fds; | 73 std::vector<base::ScopedFD> fds; |
| 73 planes.push_back(native_pixmap_handle.planes[0]); | 74 strides.push_back(native_pixmap_handle.strides_and_offsets[0].first); |
| 75 offsets.push_back(native_pixmap_handle.strides_and_offsets[0].second); |
| 74 fds.push_back(base::ScopedFD(native_pixmap_handle.fds[0].fd)); | 76 fds.push_back(base::ScopedFD(native_pixmap_handle.fds[0].fd)); |
| 75 | 77 |
| 76 std::unique_ptr<Buffer> buffer1 = display->CreateLinuxDMABufBuffer( | 78 std::unique_ptr<Buffer> buffer1 = display->CreateLinuxDMABufBuffer( |
| 77 buffer_size, gfx::BufferFormat::RGBA_8888, planes, std::move(fds)); | 79 buffer_size, gfx::BufferFormat::RGBA_8888, strides, offsets, |
| 80 std::move(fds)); |
| 78 EXPECT_TRUE(buffer1); | 81 EXPECT_TRUE(buffer1); |
| 79 | 82 |
| 80 std::vector<base::ScopedFD> invalid_fds; | 83 std::vector<base::ScopedFD> invalid_fds; |
| 81 invalid_fds.push_back(base::ScopedFD()); | 84 invalid_fds.push_back(base::ScopedFD()); |
| 82 // Creating a prime buffer using an invalid fd should fail. | 85 // Creating a prime buffer using an invalid fd should fail. |
| 83 std::unique_ptr<Buffer> buffer2 = display->CreateLinuxDMABufBuffer( | 86 std::unique_ptr<Buffer> buffer2 = display->CreateLinuxDMABufBuffer( |
| 84 buffer_size, gfx::BufferFormat::RGBA_8888, planes, | 87 buffer_size, gfx::BufferFormat::RGBA_8888, strides, offsets, |
| 85 std::move(invalid_fds)); | 88 std::move(invalid_fds)); |
| 86 EXPECT_FALSE(buffer2); | 89 EXPECT_FALSE(buffer2); |
| 87 } | 90 } |
| 88 | 91 |
| 89 // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer | 92 // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer |
| 90 // via Ozone. crbug.com/618516 | 93 // via Ozone. crbug.com/618516 |
| 91 | 94 |
| 92 #endif | 95 #endif |
| 93 | 96 |
| 94 TEST_F(DisplayTest, CreateShellSurface) { | 97 TEST_F(DisplayTest, CreateShellSurface) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // Attempting to create a sub surface for parent with grandchild as its parent | 220 // Attempting to create a sub surface for parent with grandchild as its parent |
| 218 // should fail. | 221 // should fail. |
| 219 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get())); | 222 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get())); |
| 220 | 223 |
| 221 // Create a sub surface for parent. | 224 // Create a sub surface for parent. |
| 222 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get())); | 225 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get())); |
| 223 } | 226 } |
| 224 | 227 |
| 225 } // namespace | 228 } // namespace |
| 226 } // namespace exo | 229 } // namespace exo |
| OLD | NEW |