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 "ui/ozone/platform/drm/client_native_pixmap_factory_gbm.h" | 5 #include "ui/ozone/platform/drm/client_native_pixmap_factory_gbm.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
10 #include "ui/gfx/native_pixmap_handle_ozone.h" | 11 #include "ui/gfx/native_pixmap_handle_ozone.h" |
11 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" | 12 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" |
12 #include "ui/ozone/public/client_native_pixmap_factory.h" | 13 #include "ui/ozone/public/client_native_pixmap_factory.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 class ClientNativePixmapGbm : public ClientNativePixmap { | 19 class ClientNativePixmapGbm : public ClientNativePixmap { |
19 public: | 20 public: |
(...skipping 30 matching lines...) Expand all Loading... |
50 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
51 return format == gfx::BufferFormat::BGRA_8888; | 52 return format == gfx::BufferFormat::BGRA_8888; |
52 #else | 53 #else |
53 return false; | 54 return false; |
54 #endif | 55 #endif |
55 } | 56 } |
56 } | 57 } |
57 NOTREACHED(); | 58 NOTREACHED(); |
58 return false; | 59 return false; |
59 } | 60 } |
60 scoped_ptr<ClientNativePixmap> ImportFromHandle( | 61 std::unique_ptr<ClientNativePixmap> ImportFromHandle( |
61 const gfx::NativePixmapHandle& handle, | 62 const gfx::NativePixmapHandle& handle, |
62 const gfx::Size& size, | 63 const gfx::Size& size, |
63 gfx::BufferUsage usage) override { | 64 gfx::BufferUsage usage) override { |
64 base::ScopedFD scoped_fd(handle.fd.fd); | 65 base::ScopedFD scoped_fd(handle.fd.fd); |
65 | 66 |
66 switch (usage) { | 67 switch (usage) { |
67 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 68 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
68 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 69 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
69 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
70 return ClientNativePixmapDmaBuf::ImportFromDmabuf(scoped_fd.release(), | 71 return ClientNativePixmapDmaBuf::ImportFromDmabuf(scoped_fd.release(), |
71 size, handle.stride); | 72 size, handle.stride); |
72 #else | 73 #else |
73 NOTREACHED(); | 74 NOTREACHED(); |
74 return nullptr; | 75 return nullptr; |
75 #endif | 76 #endif |
76 case gfx::BufferUsage::GPU_READ: | 77 case gfx::BufferUsage::GPU_READ: |
77 case gfx::BufferUsage::SCANOUT: | 78 case gfx::BufferUsage::SCANOUT: |
78 return make_scoped_ptr<ClientNativePixmapGbm>( | 79 return base::WrapUnique<ClientNativePixmapGbm>( |
79 new ClientNativePixmapGbm); | 80 new ClientNativePixmapGbm); |
80 } | 81 } |
81 NOTREACHED(); | 82 NOTREACHED(); |
82 return nullptr; | 83 return nullptr; |
83 } | 84 } |
84 | 85 |
85 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); | 86 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); |
86 }; | 87 }; |
87 | 88 |
88 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { | 89 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { |
89 return new ClientNativePixmapFactoryGbm(); | 90 return new ClientNativePixmapFactoryGbm(); |
90 } | 91 } |
91 | 92 |
92 } // namespace ui | 93 } // namespace ui |
OLD | NEW |