OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/memory/shared_memory.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 #include "ui/gl/gl_image_shared_memory.h" | |
8 #include "ui/gl/test/gl_image_test_template.h" | |
9 | |
10 namespace gfx { | |
11 namespace { | |
12 | |
13 class GLImageSharedMemoryTestDelegate { | |
14 public: | |
15 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size, | |
16 unsigned internalformat, | |
17 BufferFormat format, | |
18 const uint8_t color[4]) const { | |
19 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); | |
20 base::SharedMemory shared_memory; | |
21 bool rv = shared_memory.CreateAndMapAnonymous( | |
22 BufferSizeForBufferFormat(size, format)); | |
23 DCHECK(rv); | |
24 GLImageTestSupport::SetBufferDataToColor( | |
25 size.width(), size.height(), | |
26 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), | |
27 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); | |
28 scoped_refptr<GLImageSharedMemory> image( | |
29 new GLImageSharedMemory(size, internalformat)); | |
30 rv = image->Initialize( | |
31 base::SharedMemory::DuplicateHandle(shared_memory.handle()), | |
32 GenericSharedMemoryId(0), format); | |
33 EXPECT_TRUE(rv); | |
34 return image; | |
35 } | |
36 }; | |
37 | |
38 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, | |
39 GLImageTest, | |
40 GLImageSharedMemoryTestDelegate); | |
41 | |
42 } // namespace | |
43 } // namespace gfx | |
OLD | NEW |