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

Side by Side Diff: ui/gfx/mojo/struct_traits_unittest.cc

Issue 2272153002: Add ClientNativePixmap multi-planar support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-native-pixmap-dmabug-multiple-planes
Patch Set: ifdef USE_OZONE for unused variables. Created 4 years, 2 months 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/gfx/mojo/buffer_types_traits.h ('k') | ui/gfx/native_pixmap_handle.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "mojo/public/cpp/bindings/binding_set.h" 6 #include "mojo/public/cpp/bindings/binding_set.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/mojo/traits_test_service.mojom.h" 8 #include "ui/gfx/mojo/traits_test_service.mojom.h"
9 #include "ui/gfx/native_widget_types.h" 9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/selection_bound.h" 10 #include "ui/gfx/selection_bound.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 137 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
138 gfx::AcceleratedWidget output; 138 gfx::AcceleratedWidget output;
139 proxy->EchoAcceleratedWidget(input, &output); 139 proxy->EchoAcceleratedWidget(input, &output);
140 EXPECT_EQ(input, output); 140 EXPECT_EQ(input, output);
141 } 141 }
142 142
143 TEST_F(StructTraitsTest, GpuMemoryBufferHandle) { 143 TEST_F(StructTraitsTest, GpuMemoryBufferHandle) {
144 const gfx::GpuMemoryBufferId kId(99); 144 const gfx::GpuMemoryBufferId kId(99);
145 const uint32_t kOffset = 126; 145 const uint32_t kOffset = 126;
146 const int32_t kStride = 256; 146 const int32_t kStride = 256;
147 #if defined(USE_OZONE)
148 const uint64_t kSize = kOffset + kStride;
149 const uint64_t kModifier = 2;
150 #endif
147 base::SharedMemory shared_memory; 151 base::SharedMemory shared_memory;
148 ASSERT_TRUE(shared_memory.CreateAnonymous(1024)); 152 ASSERT_TRUE(shared_memory.CreateAnonymous(1024));
149 ASSERT_TRUE(shared_memory.Map(1024)); 153 ASSERT_TRUE(shared_memory.Map(1024));
150 154
151 gfx::GpuMemoryBufferHandle handle; 155 gfx::GpuMemoryBufferHandle handle;
152 handle.type = gfx::SHARED_MEMORY_BUFFER; 156 handle.type = gfx::SHARED_MEMORY_BUFFER;
153 handle.id = kId; 157 handle.id = kId;
154 handle.handle = base::SharedMemory::DuplicateHandle(shared_memory.handle()); 158 handle.handle = base::SharedMemory::DuplicateHandle(shared_memory.handle());
155 handle.offset = kOffset; 159 handle.offset = kOffset;
156 handle.stride = kStride; 160 handle.stride = kStride;
157 161
162 #if defined(USE_OZONE)
163 handle.native_pixmap_handle.planes.emplace_back(kOffset, kStride, kSize,
164 kModifier);
165 #endif
166
158 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 167 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
159 gfx::GpuMemoryBufferHandle output; 168 gfx::GpuMemoryBufferHandle output;
160 proxy->EchoGpuMemoryBufferHandle(handle, &output); 169 proxy->EchoGpuMemoryBufferHandle(handle, &output);
161 EXPECT_EQ(gfx::SHARED_MEMORY_BUFFER, output.type); 170 EXPECT_EQ(gfx::SHARED_MEMORY_BUFFER, output.type);
162 EXPECT_EQ(kId, output.id); 171 EXPECT_EQ(kId, output.id);
163 EXPECT_EQ(kOffset, output.offset); 172 EXPECT_EQ(kOffset, output.offset);
164 EXPECT_EQ(kStride, output.stride); 173 EXPECT_EQ(kStride, output.stride);
174
175 #if defined(USE_OZONE)
176 ASSERT_EQ(1u, output.native_pixmap_handle.planes.size());
177 EXPECT_EQ(kSize, output.native_pixmap_handle.planes.back().size);
178 EXPECT_EQ(kModifier, output.native_pixmap_handle.planes.back().modifier);
179 #endif
180
165 #if !defined(OS_MACOSX) && !defined(OS_IOS) 181 #if !defined(OS_MACOSX) && !defined(OS_IOS)
166 // TODO: Add support for mach_port on mac. 182 // TODO: Add support for mach_port on mac.
167 base::SharedMemory output_memory(output.handle, true); 183 base::SharedMemory output_memory(output.handle, true);
168 EXPECT_TRUE(output_memory.Map(1024)); 184 EXPECT_TRUE(output_memory.Map(1024));
169 #endif 185 #endif
170 } 186 }
171 187
172 } // namespace gfx 188 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/mojo/buffer_types_traits.h ('k') | ui/gfx/native_pixmap_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698