Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: ui/gl/gl_image_shared_memory_unittest.cc

Issue 1415723006: ui: Add RGBX_8888 buffer format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gles but no conversion needed case Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_shared_memory.cc ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class GLImageSharedMemoryTestDelegate { 14 class GLImageSharedMemoryTestDelegate {
14 public: 15 public:
15 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size, 16 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size,
16 unsigned internalformat,
17 BufferFormat format,
18 const uint8_t color[4]) const { 17 const uint8_t color[4]) const {
19 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); 18 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
20 base::SharedMemory shared_memory; 19 base::SharedMemory shared_memory;
21 bool rv = shared_memory.CreateAndMapAnonymous( 20 bool rv = shared_memory.CreateAndMapAnonymous(
22 BufferSizeForBufferFormat(size, format)); 21 BufferSizeForBufferFormat(size, format));
23 DCHECK(rv); 22 DCHECK(rv);
24 GLImageTestSupport::SetBufferDataToColor( 23 GLImageTestSupport::SetBufferDataToColor(
25 size.width(), size.height(), 24 size.width(), size.height(),
26 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), 25 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)),
27 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); 26 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory()));
28 scoped_refptr<GLImageSharedMemory> image( 27 scoped_refptr<GLImageSharedMemory> image(new GLImageSharedMemory(
29 new GLImageSharedMemory(size, internalformat)); 28 size, GLImageMemory::GetInternalFormatForTesting(format)));
30 rv = image->Initialize( 29 rv = image->Initialize(
31 base::SharedMemory::DuplicateHandle(shared_memory.handle()), 30 base::SharedMemory::DuplicateHandle(shared_memory.handle()),
32 GenericSharedMemoryId(0), format); 31 GenericSharedMemoryId(0), format);
33 EXPECT_TRUE(rv); 32 EXPECT_TRUE(rv);
34 return image; 33 return image;
35 } 34 }
36 }; 35 };
37 36
37 using GLImageTestTypes =
38 testing::Types<GLImageSharedMemoryTestDelegate<BufferFormat::RGBX_8888>,
39 GLImageSharedMemoryTestDelegate<BufferFormat::RGBA_8888>,
40 GLImageSharedMemoryTestDelegate<BufferFormat::BGRX_8888>,
41 GLImageSharedMemoryTestDelegate<BufferFormat::BGRA_8888>>;
42
38 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, 43 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory,
39 GLImageTest, 44 GLImageTest,
40 GLImageSharedMemoryTestDelegate); 45 GLImageTestTypes);
41 46
42 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory, 47 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemory,
43 GLImageCopyTest, 48 GLImageCopyTest,
44 GLImageSharedMemoryTestDelegate); 49 GLImageTestTypes);
45 50
46 } // namespace 51 } // namespace
47 } // namespace gfx 52 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_shared_memory.cc ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698