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

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

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/gl_utils.h"
9 #include "ui/gl/test/gl_image_test_template.h" 10 #include "ui/gl/test/gl_image_test_template.h"
10 11
11 namespace gl { 12 namespace gl {
12 namespace { 13 namespace {
13 14
14 template <gfx::BufferFormat format> 15 template <gfx::BufferFormat format>
15 class GLImageSharedMemoryTestDelegate { 16 class GLImageSharedMemoryTestDelegate {
16 public: 17 public:
17 scoped_refptr<gl::GLImage> CreateSolidColorImage( 18 scoped_refptr<gl::GLImage> CreateSolidColorImage(
18 const gfx::Size& size, 19 const gfx::Size& size,
19 const uint8_t color[4]) const { 20 const uint8_t color[4]) const {
20 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); 21 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
21 base::SharedMemory shared_memory; 22 base::SharedMemory shared_memory;
22 bool rv = shared_memory.CreateAndMapAnonymous( 23 bool rv = shared_memory.CreateAndMapAnonymous(
23 gfx::BufferSizeForBufferFormat(size, format)); 24 gfx::BufferSizeForBufferFormat(size, format));
24 DCHECK(rv); 25 DCHECK(rv);
25 GLImageTestSupport::SetBufferDataToColor( 26 GLImageTestSupport::SetBufferDataToColor(
26 size.width(), size.height(), 27 size.width(), size.height(),
27 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), 28 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)),
28 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory())); 29 format, color, reinterpret_cast<uint8_t*>(shared_memory.memory()));
29 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( 30 scoped_refptr<gl::GLImageSharedMemory> image(
30 size, gl::GLImageMemory::GetInternalFormatForTesting(format))); 31 new gl::GLImageSharedMemory(size, gl::GetTextureFormatFrom(format)));
31 rv = image->Initialize( 32 rv = image->Initialize(
32 base::SharedMemory::DuplicateHandle(shared_memory.handle()), 33 base::SharedMemory::DuplicateHandle(shared_memory.handle()),
33 gfx::GenericSharedMemoryId(0), format, 0, 34 gfx::GenericSharedMemoryId(0), format, 0,
34 gfx::RowSizeForBufferFormat(size.width(), format, 0)); 35 gfx::RowSizeForBufferFormat(size.width(), format, 0));
35 EXPECT_TRUE(rv); 36 EXPECT_TRUE(rv);
36 return image; 37 return image;
37 } 38 }
38 }; 39 };
39 40
40 using GLImageTestTypes = testing::Types< 41 using GLImageTestTypes = testing::Types<
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return image; 85 return image;
85 } 86 }
86 }; 87 };
87 88
88 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemoryPool, 89 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSharedMemoryPool,
89 GLImageCopyTest, 90 GLImageCopyTest,
90 GLImageSharedMemoryPoolTestDelegate); 91 GLImageSharedMemoryPoolTestDelegate);
91 92
92 } // namespace 93 } // namespace
93 } // namespace gl 94 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698