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