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_surface_texture.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 uint32 sync_point) { | 21 uint32 sync_point) { |
22 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, | 22 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, |
23 sync_point); | 23 sync_point); |
24 } | 24 } |
25 | 25 |
26 void GpuMemoryBufferCreated( | 26 void GpuMemoryBufferCreated( |
27 const gfx::Size& size, | 27 const gfx::Size& size, |
28 gfx::GpuMemoryBuffer::Format format, | 28 gfx::GpuMemoryBuffer::Format format, |
29 const GpuMemoryBufferImpl::CreationCallback& callback, | 29 const GpuMemoryBufferImpl::CreationCallback& callback, |
30 const gfx::GpuMemoryBufferHandle& handle) { | 30 const gfx::GpuMemoryBufferHandle& handle) { |
| 31 if (handle.is_null()) { |
| 32 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
| 33 return; |
| 34 } |
| 35 |
31 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); | 36 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); |
32 | |
33 callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( | 37 callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
34 handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); | 38 handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); |
35 } | 39 } |
36 | 40 |
37 void GpuMemoryBufferCreatedForChildProcess( | 41 void GpuMemoryBufferCreatedForChildProcess( |
38 const GpuMemoryBufferImpl::AllocationCallback& callback, | 42 const GpuMemoryBufferImpl::AllocationCallback& callback, |
39 const gfx::GpuMemoryBufferHandle& handle) { | 43 const gfx::GpuMemoryBufferHandle& handle) { |
40 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); | 44 DCHECK_IMPLIES(!handle.is_null(), gfx::SURFACE_TEXTURE_BUFFER == handle.type); |
41 | 45 |
42 callback.Run(handle); | 46 callback.Run(handle); |
43 } | 47 } |
44 | 48 |
45 } // namespace | 49 } // namespace |
46 | 50 |
47 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( | 51 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( |
48 const gfx::Size& size, | 52 const gfx::Size& size, |
49 Format format, | 53 Format format, |
50 const DestructionCallback& callback, | 54 const DestructionCallback& callback, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 214 |
211 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 215 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
212 const { | 216 const { |
213 gfx::GpuMemoryBufferHandle handle; | 217 gfx::GpuMemoryBufferHandle handle; |
214 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 218 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
215 handle.global_id = id_; | 219 handle.global_id = id_; |
216 return handle; | 220 return handle; |
217 } | 221 } |
218 | 222 |
219 } // namespace content | 223 } // namespace content |
OLD | NEW |