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

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

Issue 1419733005: gpu: Add YCbCr 420v extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually enable/disable capabilities. Typo. Created 5 years 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_ref_counted_memory_unittest.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 "base/sys_info.h" 6 #include "base/sys_info.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gl/gl_image_shared_memory.h" 8 #include "ui/gl/gl_image_shared_memory.h"
9 #include "ui/gl/test/gl_image_test_template.h" 9 #include "ui/gl/test/gl_image_test_template.h"
10 10
11 namespace gl { 11 namespace gl {
12 namespace { 12 namespace {
13 13
14 template <gfx::BufferFormat format> 14 template <gfx::BufferFormat format>
15 class GLImageSharedMemoryTestDelegate { 15 class GLImageSharedMemoryTestDelegate {
16 public: 16 public:
17 scoped_refptr<gl::GLImage> CreateSolidColorImage( 17 scoped_refptr<gl::GLImage> CreateSolidColorImage(
18 const gfx::Size& size, 18 const gfx::Size& size,
19 const uint8_t color[4]) const { 19 const uint8_t color[4]) const {
20 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); 20 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
21 base::SharedMemory shared_memory; 21 base::SharedMemory shared_memory;
22 bool rv = shared_memory.CreateAndMapAnonymous( 22 bool rv = shared_memory.CreateAndMapAnonymous(
23 gfx::BufferSizeForBufferFormat(size, format)); 23 gfx::BufferSizeForBufferFormat(size, format));
24 DCHECK(rv); 24 DCHECK(rv);
25 GLImageTestSupport::SetBufferDataToColor( 25 GLImageTestSupport::SetBufferDataToColor(
26 size.width(), size.height(), 26 size.width(), size.height(),
27 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), 27 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), 0,
28 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); 28 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory()));
29 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( 29 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory(
30 size, gl::GLImageMemory::GetInternalFormatForTesting(format))); 30 size, gl::GLImageMemory::GetInternalFormatForTesting(format)));
31 rv = image->Initialize( 31 rv = image->Initialize(
32 base::SharedMemory::DuplicateHandle(shared_memory.handle()), 32 base::SharedMemory::DuplicateHandle(shared_memory.handle()),
33 gfx::GenericSharedMemoryId(0), format, 0, 33 gfx::GenericSharedMemoryId(0), format, 0,
34 gfx::RowSizeForBufferFormat(size.width(), format, 0)); 34 gfx::RowSizeForBufferFormat(size.width(), format, 0));
35 EXPECT_TRUE(rv); 35 EXPECT_TRUE(rv);
36 return image; 36 return image;
37 } 37 }
(...skipping 26 matching lines...) Expand all
64 size_t pool_size = 64 size_t pool_size =
65 stride * size.height() + base::SysInfo::VMAllocationGranularity() * 3; 65 stride * size.height() + base::SysInfo::VMAllocationGranularity() * 3;
66 base::SharedMemory shared_memory; 66 base::SharedMemory shared_memory;
67 bool rv = shared_memory.CreateAndMapAnonymous(pool_size); 67 bool rv = shared_memory.CreateAndMapAnonymous(pool_size);
68 DCHECK(rv); 68 DCHECK(rv);
69 // Initialize memory to a value that is easy to recognize if test fails. 69 // Initialize memory to a value that is easy to recognize if test fails.
70 memset(shared_memory.memory(), 0x55, pool_size); 70 memset(shared_memory.memory(), 0x55, pool_size);
71 // Place buffer at a non-zero non-page-aligned offset in shared memory. 71 // Place buffer at a non-zero non-page-aligned offset in shared memory.
72 size_t buffer_offset = 3 * base::SysInfo::VMAllocationGranularity() / 2; 72 size_t buffer_offset = 3 * base::SysInfo::VMAllocationGranularity() / 2;
73 GLImageTestSupport::SetBufferDataToColor( 73 GLImageTestSupport::SetBufferDataToColor(
74 size.width(), size.height(), static_cast<int>(stride), 74 size.width(), size.height(), static_cast<int>(stride), 0,
75 gfx::BufferFormat::RGBA_8888, color, 75 gfx::BufferFormat::RGBA_8888, color,
76 reinterpret_cast<uint8_t*>(shared_memory.memory()) + buffer_offset); 76 reinterpret_cast<uint8_t*>(shared_memory.memory()) + buffer_offset);
77 scoped_refptr<gl::GLImageSharedMemory> image( 77 scoped_refptr<gl::GLImageSharedMemory> image(
78 new gl::GLImageSharedMemory(size, GL_RGBA)); 78 new gl::GLImageSharedMemory(size, GL_RGBA));
79 rv = image->Initialize( 79 rv = image->Initialize(
80 base::SharedMemory::DuplicateHandle(shared_memory.handle()), 80 base::SharedMemory::DuplicateHandle(shared_memory.handle()),
81 gfx::GenericSharedMemoryId(0), gfx::BufferFormat::RGBA_8888, 81 gfx::GenericSharedMemoryId(0), gfx::BufferFormat::RGBA_8888,
82 buffer_offset, stride); 82 buffer_offset, stride);
83 EXPECT_TRUE(rv); 83 EXPECT_TRUE(rv);
84 return image; 84 return image;
85 } 85 }
86 }; 86 };
87 87
88 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemoryPool, 88 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemoryPool,
89 GLImageCopyTest, 89 GLImageCopyTest,
90 GLImageSharedMemoryPoolTestDelegate); 90 GLImageSharedMemoryPoolTestDelegate);
91 91
92 } // namespace 92 } // namespace
93 } // namespace gl 93 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ref_counted_memory_unittest.cc ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698