| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "ui/gl/gl_image_shared_memory.h" | 7 #include "ui/gl/gl_image_shared_memory.h" |
| 8 #include "ui/gl/test/gl_image_test_template.h" | 8 #include "ui/gl/test/gl_image_test_template.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 template <BufferFormat format> | 13 template <BufferFormat format> |
| 14 class GLImageSharedMemoryTestDelegate { | 14 class GLImageSharedMemoryTestDelegate { |
| 15 public: | 15 public: |
| 16 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size, | 16 scoped_refptr<gl::GLImage> CreateSolidColorImage( |
| 17 const uint8_t color[4]) const { | 17 const Size& size, |
| 18 const uint8_t color[4]) const { |
| 18 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); | 19 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); |
| 19 base::SharedMemory shared_memory; | 20 base::SharedMemory shared_memory; |
| 20 bool rv = shared_memory.CreateAndMapAnonymous( | 21 bool rv = shared_memory.CreateAndMapAnonymous( |
| 21 BufferSizeForBufferFormat(size, format)); | 22 BufferSizeForBufferFormat(size, format)); |
| 22 DCHECK(rv); | 23 DCHECK(rv); |
| 23 GLImageTestSupport::SetBufferDataToColor( | 24 GLImageTestSupport::SetBufferDataToColor( |
| 24 size.width(), size.height(), | 25 size.width(), size.height(), |
| 25 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), | 26 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), |
| 26 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); | 27 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); |
| 27 scoped_refptr<GLImageSharedMemory> image(new GLImageSharedMemory( | 28 scoped_refptr<GLImageSharedMemory> image(new GLImageSharedMemory( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 43 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, | 44 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, |
| 44 GLImageTest, | 45 GLImageTest, |
| 45 GLImageTestTypes); | 46 GLImageTestTypes); |
| 46 | 47 |
| 47 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, | 48 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, |
| 48 GLImageCopyTest, | 49 GLImageCopyTest, |
| 49 GLImageTestTypes); | 50 GLImageTestTypes); |
| 50 | 51 |
| 51 } // namespace | 52 } // namespace |
| 52 } // namespace gfx | 53 } // namespace gfx |
| OLD | NEW |