Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_io_surface.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( | 12 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( |
| 13 const gfx::Size& size, | 13 const gfx::Size& size, |
| 14 unsigned internalformat) | 14 const DestructionCallback& callback) |
| 15 : GpuMemoryBufferImpl(size, internalformat) {} | 15 : GpuMemoryBufferImpl(size, internalformat), callback_(callback) { |
| 16 } | |
| 16 | 17 |
| 17 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {} | 18 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() { |
| 19 if (!io_surface_) | |
| 20 return; | |
| 21 | |
| 22 // Call destruction callback if instance was successfully initialized. | |
| 23 callback_.Run(); | |
|
piman
2014/09/24 03:19:10
I think it would be nice if the callback_ was mana
reveman
2014/09/24 06:03:38
Yes, that's much better. Thanks for the suggestion
| |
| 24 } | |
| 18 | 25 |
| 19 // static | 26 // static |
| 20 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) { | 27 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) { |
| 21 switch (internalformat) { | 28 switch (internalformat) { |
| 22 case GL_BGRA8_EXT: | 29 case GL_BGRA8_EXT: |
| 23 return true; | 30 return true; |
| 24 default: | 31 default: |
| 25 return false; | 32 return false; |
| 26 } | 33 } |
| 27 } | 34 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 91 } |
| 85 | 92 |
| 86 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 93 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
| 87 gfx::GpuMemoryBufferHandle handle; | 94 gfx::GpuMemoryBufferHandle handle; |
| 88 handle.type = gfx::IO_SURFACE_BUFFER; | 95 handle.type = gfx::IO_SURFACE_BUFFER; |
| 89 handle.io_surface_id = IOSurfaceGetID(io_surface_); | 96 handle.io_surface_id = IOSurfaceGetID(io_surface_); |
| 90 return handle; | 97 return handle; |
| 91 } | 98 } |
| 92 | 99 |
| 93 } // namespace content | 100 } // namespace content |
| OLD | NEW |