| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/gl/gl_image_ref_counted_memory.h" | 9 #include "ui/gl/gl_image_ref_counted_memory.h" |
| 10 #include "ui/gl/gl_utils.h" |
| 10 #include "ui/gl/test/gl_image_test_template.h" | 11 #include "ui/gl/test/gl_image_test_template.h" |
| 11 | 12 |
| 12 namespace gl { | 13 namespace gl { |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 template <gfx::BufferFormat format> | 16 template <gfx::BufferFormat format> |
| 16 class GLImageRefCountedMemoryTestDelegate { | 17 class GLImageRefCountedMemoryTestDelegate { |
| 17 public: | 18 public: |
| 18 scoped_refptr<gl::GLImage> CreateSolidColorImage( | 19 scoped_refptr<gl::GLImage> CreateSolidColorImage( |
| 19 const gfx::Size& size, | 20 const gfx::Size& size, |
| 20 const uint8_t color[4]) const { | 21 const uint8_t color[4]) const { |
| 21 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); | 22 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); |
| 22 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format)); | 23 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format)); |
| 23 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); | 24 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); |
| 24 GLImageTestSupport::SetBufferDataToColor( | 25 GLImageTestSupport::SetBufferDataToColor( |
| 25 size.width(), size.height(), | 26 size.width(), size.height(), |
| 26 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), | 27 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), |
| 27 format, color, &bytes->data().front()); | 28 format, color, &bytes->data().front()); |
| 28 scoped_refptr<GLImageRefCountedMemory> image(new GLImageRefCountedMemory( | 29 scoped_refptr<GLImageRefCountedMemory> image( |
| 29 size, gl::GLImageMemory::GetInternalFormatForTesting(format))); | 30 new GLImageRefCountedMemory(size, gl::GetTextureFormatFrom(format))); |
| 30 bool rv = image->Initialize(bytes.get(), format); | 31 bool rv = image->Initialize(bytes.get(), format); |
| 31 EXPECT_TRUE(rv); | 32 EXPECT_TRUE(rv); |
| 32 return image; | 33 return image; |
| 33 } | 34 } |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 using GLImageTestTypes = testing::Types< | 37 using GLImageTestTypes = testing::Types< |
| 37 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::RGBX_8888>, | 38 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::RGBX_8888>, |
| 38 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::RGBA_8888>, | 39 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::RGBA_8888>, |
| 39 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::BGRX_8888>, | 40 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::BGRX_8888>, |
| 40 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::BGRA_8888>>; | 41 GLImageRefCountedMemoryTestDelegate<gfx::BufferFormat::BGRA_8888>>; |
| 41 | 42 |
| 42 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, | 43 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, |
| 43 GLImageTest, | 44 GLImageTest, |
| 44 GLImageTestTypes); | 45 GLImageTestTypes); |
| 45 | 46 |
| 46 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, | 47 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, |
| 47 GLImageCopyTest, | 48 GLImageCopyTest, |
| 48 GLImageTestTypes); | 49 GLImageTestTypes); |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 } // namespace gl | 52 } // namespace gl |
| OLD | NEW |