| 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 "cc/test/test_image_factory.h" | 5 #include "cc/test/test_image_factory.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "ui/gl/gl_image_shared_memory.h" | 10 #include "ui/gl/gl_image_shared_memory.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 TestImageFactory::TestImageFactory() { | 14 TestImageFactory::TestImageFactory() { |
| 15 } | 15 } |
| 16 | 16 |
| 17 TestImageFactory::~TestImageFactory() { | 17 TestImageFactory::~TestImageFactory() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 scoped_refptr<gl::GLImage> TestImageFactory::CreateImageForGpuMemoryBuffer( | 20 scoped_refptr<gl::GLImage> TestImageFactory::CreateImageForGpuMemoryBuffer( |
| 21 const gfx::GpuMemoryBufferHandle& handle, | 21 const gfx::GpuMemoryBufferHandle& handle, |
| 22 const gfx::Size& size, | 22 const gfx::Size& size, |
| 23 gfx::BufferFormat format, | 23 gfx::BufferFormat format, |
| 24 unsigned internalformat, | 24 unsigned internalformat, |
| 25 int client_id) { | 25 int client_id, |
| 26 gpu::SurfaceHandle surface_handle) { |
| 26 DCHECK_EQ(handle.type, gfx::SHARED_MEMORY_BUFFER); | 27 DCHECK_EQ(handle.type, gfx::SHARED_MEMORY_BUFFER); |
| 27 | 28 |
| 28 scoped_refptr<gl::GLImageSharedMemory> image( | 29 scoped_refptr<gl::GLImageSharedMemory> image( |
| 29 new gl::GLImageSharedMemory(size, internalformat)); | 30 new gl::GLImageSharedMemory(size, internalformat)); |
| 30 if (!image->Initialize(handle.handle, handle.id, format, handle.offset, | 31 if (!image->Initialize(handle.handle, handle.id, format, handle.offset, |
| 31 base::checked_cast<size_t>(handle.stride))) | 32 base::checked_cast<size_t>(handle.stride))) |
| 32 return nullptr; | 33 return nullptr; |
| 33 | 34 |
| 34 return image; | 35 return image; |
| 35 } | 36 } |
| 36 | 37 |
| 37 } // namespace cc | 38 } // namespace cc |
| OLD | NEW |