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 "ui/ozone/public/client_native_pixmap_factory.h" | |
7 #include "ui/ozone/public/surface_factory_ozone.h" | 8 #include "ui/ozone/public/surface_factory_ozone.h" |
8 | 9 |
9 namespace content { | 10 namespace content { |
10 | 11 |
11 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap( | 12 GpuMemoryBufferImplOzoneNativePixmap::GpuMemoryBufferImplOzoneNativePixmap( |
12 gfx::GpuMemoryBufferId id, | 13 gfx::GpuMemoryBufferId id, |
13 const gfx::Size& size, | 14 const gfx::Size& size, |
14 gfx::BufferFormat format, | 15 gfx::BufferFormat format, |
15 const DestructionCallback& callback) | 16 const DestructionCallback& callback, |
16 : GpuMemoryBufferImpl(id, size, format, callback) {} | 17 scoped_ptr<ui::ClientNativePixmap> pixmap) |
18 : GpuMemoryBufferImpl(id, size, format, callback), pixmap_(pixmap.Pass()) {} | |
17 | 19 |
18 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} | 20 GpuMemoryBufferImplOzoneNativePixmap::~GpuMemoryBufferImplOzoneNativePixmap() {} |
19 | 21 |
20 // static | 22 // static |
21 scoped_ptr<GpuMemoryBufferImpl> | 23 scoped_ptr<GpuMemoryBufferImpl> |
22 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( | 24 GpuMemoryBufferImplOzoneNativePixmap::CreateFromHandle( |
23 const gfx::GpuMemoryBufferHandle& handle, | 25 const gfx::GpuMemoryBufferHandle& handle, |
24 const gfx::Size& size, | 26 const gfx::Size& size, |
25 gfx::BufferFormat format, | 27 gfx::BufferFormat format, |
26 gfx::BufferUsage usage, | 28 gfx::BufferUsage usage, |
27 const DestructionCallback& callback) { | 29 const DestructionCallback& callback) { |
30 scoped_ptr<ui::ClientNativePixmap> native_pixmap = | |
31 ui::ClientNativePixmapFactory::GetInstance()->ImportFromHandle( | |
no sievers
2015/08/11 21:16:33
Can this fail?
Below we are accessing |pixmap_| w
spang
2015/08/11 22:03:31
Done. However since cc does not check for allocati
reveman
2015/08/12 08:20:29
cc handles GMB allocation failure properly as it c
dshwang
2015/08/12 08:28:09
I think null check is not needed, as well as nullp
dshwang
2015/08/12 08:41:43
I understand that ClientNativePixmapGbm is always
| |
32 handle.native_pixmap_handle, size, format, usage); | |
28 return make_scoped_ptr<GpuMemoryBufferImpl>( | 33 return make_scoped_ptr<GpuMemoryBufferImpl>( |
29 new GpuMemoryBufferImplOzoneNativePixmap(handle.id, size, format, | 34 new GpuMemoryBufferImplOzoneNativePixmap(handle.id, size, format, |
30 callback)); | 35 callback, native_pixmap.Pass())); |
31 } | 36 } |
32 | 37 |
33 bool GpuMemoryBufferImplOzoneNativePixmap::Map(void** data) { | 38 bool GpuMemoryBufferImplOzoneNativePixmap::Map(void** data) { |
34 NOTREACHED(); | 39 return pixmap_->Map(data); |
35 return false; | |
36 } | 40 } |
37 | 41 |
38 void GpuMemoryBufferImplOzoneNativePixmap::Unmap() { | 42 void GpuMemoryBufferImplOzoneNativePixmap::Unmap() { |
39 NOTREACHED(); | 43 pixmap_->Unmap(); |
40 } | 44 } |
41 | 45 |
42 void GpuMemoryBufferImplOzoneNativePixmap::GetStride(int* stride) const { | 46 void GpuMemoryBufferImplOzoneNativePixmap::GetStride(int* stride) const { |
43 NOTREACHED(); | 47 pixmap_->GetStride(stride); |
44 } | 48 } |
45 | 49 |
46 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() | 50 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativePixmap::GetHandle() |
47 const { | 51 const { |
48 gfx::GpuMemoryBufferHandle handle; | 52 gfx::GpuMemoryBufferHandle handle; |
49 handle.type = gfx::OZONE_NATIVE_PIXMAP; | 53 handle.type = gfx::OZONE_NATIVE_PIXMAP; |
50 handle.id = id_; | 54 handle.id = id_; |
51 return handle; | 55 return handle; |
52 } | 56 } |
53 | 57 |
54 } // namespace content | 58 } // namespace content |
OLD | NEW |