| 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.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
| 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" | 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| 11 #include "ui/gl/gl_image_memory.h" | |
| 12 | 11 |
| 13 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
| 14 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" | 13 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" |
| 15 #endif | 14 #endif |
| 16 | 15 |
| 17 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 18 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" | 17 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
| 19 #endif | 18 #endif |
| 20 | 19 |
| 21 #if defined(USE_OZONE) | 20 #if defined(USE_OZONE) |
| 22 #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.h
" | 21 #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.h
" |
| 23 #endif | 22 #endif |
| 24 | 23 |
| 25 namespace content { | 24 namespace content { |
| 26 | 25 |
| 27 GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, | 26 GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, |
| 28 const gfx::Size& size, | 27 const gfx::Size& size, |
| 29 Format format, | 28 Format format, |
| 30 const DestructionCallback& callback) | 29 const DestructionCallback& callback) |
| 31 : id_(id), | 30 : id_(id), |
| 32 size_(size), | 31 size_(size), |
| 33 format_(format), | 32 format_(format), |
| 34 callback_(callback), | 33 callback_(callback), |
| 35 mapped_(false), | 34 mapped_(false), |
| 36 destruction_sync_point_(0) { | 35 destruction_sync_point_(0) { |
| 37 DCHECK(gfx::GLImageMemory::ValidSize(size, format)); | |
| 38 } | 36 } |
| 39 | 37 |
| 40 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { | 38 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { |
| 41 callback_.Run(destruction_sync_point_); | 39 callback_.Run(destruction_sync_point_); |
| 42 } | 40 } |
| 43 | 41 |
| 44 // static | 42 // static |
| 45 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 43 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
| 46 const gfx::GpuMemoryBufferHandle& handle, | 44 const gfx::GpuMemoryBufferHandle& handle, |
| 47 const gfx::Size& size, | 45 const gfx::Size& size, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 117 |
| 120 bool GpuMemoryBufferImpl::IsMapped() const { | 118 bool GpuMemoryBufferImpl::IsMapped() const { |
| 121 return mapped_; | 119 return mapped_; |
| 122 } | 120 } |
| 123 | 121 |
| 124 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { | 122 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { |
| 125 return reinterpret_cast<ClientBuffer>(this); | 123 return reinterpret_cast<ClientBuffer>(this); |
| 126 } | 124 } |
| 127 | 125 |
| 128 } // namespace content | 126 } // namespace content |
| OLD | NEW |