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/test/gl_image_test_template.h" | 10 #include "ui/gl/test/gl_image_test_template.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 namespace { | 13 namespace { |
14 | 14 |
15 template <BufferFormat format> | 15 template <BufferFormat format> |
16 class GLImageRefCountedMemoryTestDelegate { | 16 class GLImageRefCountedMemoryTestDelegate { |
17 public: | 17 public: |
18 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size, | 18 scoped_refptr<gl::GLImage> CreateSolidColorImage( |
19 const uint8_t color[4]) const { | 19 const Size& size, |
| 20 const uint8_t color[4]) const { |
20 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); | 21 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); |
21 std::vector<uint8_t> data(BufferSizeForBufferFormat(size, format)); | 22 std::vector<uint8_t> data(BufferSizeForBufferFormat(size, format)); |
22 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); | 23 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); |
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, &bytes->data().front()); | 27 format, color, &bytes->data().front()); |
27 scoped_refptr<GLImageRefCountedMemory> image(new GLImageRefCountedMemory( | 28 scoped_refptr<GLImageRefCountedMemory> image(new GLImageRefCountedMemory( |
28 size, GLImageMemory::GetInternalFormatForTesting(format))); | 29 size, GLImageMemory::GetInternalFormatForTesting(format))); |
29 bool rv = image->Initialize(bytes.get(), format); | 30 bool rv = image->Initialize(bytes.get(), format); |
(...skipping 11 matching lines...) Expand all Loading... |
41 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, | 42 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, |
42 GLImageTest, | 43 GLImageTest, |
43 GLImageTestTypes); | 44 GLImageTestTypes); |
44 | 45 |
45 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, | 46 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, |
46 GLImageCopyTest, | 47 GLImageCopyTest, |
47 GLImageTestTypes); | 48 GLImageTestTypes); |
48 | 49 |
49 } // namespace | 50 } // namespace |
50 } // namespace gfx | 51 } // namespace gfx |
OLD | NEW |