OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h
" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h
" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h" | 9 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h" |
8 #include "ui/gfx/buffer_format_util.h" | 10 #include "ui/gfx/buffer_format_util.h" |
9 #include "ui/ozone/public/client_native_pixmap_factory.h" | 11 #include "ui/ozone/public/client_native_pixmap_factory.h" |
10 #include "ui/ozone/public/native_pixmap.h" | 12 #include "ui/ozone/public/native_pixmap.h" |
11 #include "ui/ozone/public/ozone_platform.h" | 13 #include "ui/ozone/public/ozone_platform.h" |
12 #include "ui/ozone/public/surface_factory_ozone.h" | 14 #include "ui/ozone/public/surface_factory_ozone.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 namespace { | 17 namespace { |
16 | 18 |
17 void FreeNativePixmapForTesting(scoped_refptr<ui::NativePixmap> native_pixmap) { | 19 void FreeNativePixmapForTesting(scoped_refptr<ui::NativePixmap> native_pixmap) { |
18 // Nothing to do here. |native_pixmap| will be freed when this function | 20 // Nothing to do here. |native_pixmap| will be freed when this function |
19 // returns and reference count drops to 0. | 21 // returns and reference count drops to 0. |
20 } | 22 } |
21 | 23 |
22 } // namespace | 24 } // namespace |
23 | 25 |
24 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap( | 26 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap( |
25 gfx::GpuMemoryBufferId id, | 27 gfx::GpuMemoryBufferId id, |
26 const gfx::Size& size, | 28 const gfx::Size& size, |
27 gfx::BufferFormat format, | 29 gfx::BufferFormat format, |
28 const DestructionCallback& callback, | 30 const DestructionCallback& callback, |
29 scoped_ptr<ui::ClientNativePixmap> pixmap) | 31 scoped_ptr<ui::ClientNativePixmap> pixmap) |
30 : GpuMemoryBufferImpl(id, size, format, callback), pixmap_(pixmap.Pass()) {} | 32 : GpuMemoryBufferImpl(id, size, format, callback), |
| 33 pixmap_(std::move(pixmap)) {} |
31 | 34 |
32 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} | 35 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} |
33 | 36 |
34 // static | 37 // static |
35 scoped_ptr<GpuMemoryBufferImplOzoneNativePixmap> | 38 scoped_ptr<GpuMemoryBufferImplOzoneNativePixmap> |
36 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( | 39 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( |
37 const gfx::GpuMemoryBufferHandle& handle, | 40 const gfx::GpuMemoryBufferHandle& handle, |
38 const gfx::Size& size, | 41 const gfx::Size& size, |
39 gfx::BufferFormat format, | 42 gfx::BufferFormat format, |
40 gfx::BufferUsage usage, | 43 gfx::BufferUsage usage, |
41 const DestructionCallback& callback) { | 44 const DestructionCallback& callback) { |
42 scoped_ptr<ui::ClientNativePixmap> native_pixmap = | 45 scoped_ptr<ui::ClientNativePixmap> native_pixmap = |
43 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle( | 46 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle( |
44 handle.native_pixmap_handle, size, usage); | 47 handle.native_pixmap_handle, size, usage); |
45 DCHECK(native_pixmap); | 48 DCHECK(native_pixmap); |
46 return make_scoped_ptr(new GpuMemoryBufferImplOzoneNativePixmap( | 49 return make_scoped_ptr(new GpuMemoryBufferImplOzoneNativePixmap( |
47 handle.id, size, format, callback, native_pixmap.Pass())); | 50 handle.id, size, format, callback, std::move(native_pixmap))); |
48 } | 51 } |
49 | 52 |
50 // static | 53 // static |
51 bool GpuMemoryBufferImplOzoneNativePixmap::IsConfigurationSupported( | 54 bool GpuMemoryBufferImplOzoneNativePixmap::IsConfigurationSupported( |
52 gfx::BufferFormat format, | 55 gfx::BufferFormat format, |
53 gfx::BufferUsage usage) { | 56 gfx::BufferUsage usage) { |
54 return GpuMemoryBufferFactoryOzoneNativePixmap:: | 57 return GpuMemoryBufferFactoryOzoneNativePixmap:: |
55 IsGpuMemoryBufferConfigurationSupported(format, usage); | 58 IsGpuMemoryBufferConfigurationSupported(format, usage); |
56 } | 59 } |
57 | 60 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 103 |
101 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() | 104 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() |
102 const { | 105 const { |
103 gfx::GpuMemoryBufferHandle handle; | 106 gfx::GpuMemoryBufferHandle handle; |
104 handle.type = gfx::OZONE_NATIVE_PIXMAP; | 107 handle.type = gfx::OZONE_NATIVE_PIXMAP; |
105 handle.id = id_; | 108 handle.id = id_; |
106 return handle; | 109 return handle; |
107 } | 110 } |
108 | 111 |
109 } // namespace content | 112 } // namespace content |
OLD | NEW |