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

Side by Side Diff: ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.cc

Issue 1389133002: content: Use type-parameterized tests for GpuMemoryBuffer implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h" 5 #include "ui/ozone/platform/drm/common/client_native_pixmap_factory_gbm.h"
6 6
7 #include "ui/gfx/native_pixmap_handle_ozone.h" 7 #include "ui/gfx/native_pixmap_handle_ozone.h"
8 #include "ui/ozone/public/client_native_pixmap_factory.h" 8 #include "ui/ozone/public/client_native_pixmap_factory.h"
9 9
10 #if defined(USE_VGEM_MAP) 10 #if defined(USE_VGEM_MAP)
(...skipping 26 matching lines...) Expand all
37 37
38 // ClientNativePixmapFactory: 38 // ClientNativePixmapFactory:
39 void Initialize(base::ScopedFD device_fd) override { 39 void Initialize(base::ScopedFD device_fd) override {
40 #if defined(USE_VGEM_MAP) 40 #if defined(USE_VGEM_MAP)
41 // It's called in IO thread. We rely on clients for thread-safety. 41 // It's called in IO thread. We rely on clients for thread-safety.
42 // Switching to an IPC message filter ensures thread-safety. 42 // Switching to an IPC message filter ensures thread-safety.
43 DCHECK_LT(vgem_fd_.get(), 0); 43 DCHECK_LT(vgem_fd_.get(), 0);
44 vgem_fd_ = device_fd.Pass(); 44 vgem_fd_ = device_fd.Pass();
45 #endif 45 #endif
46 } 46 }
47 std::vector<Configuration> GetSupportedConfigurations() const override { 47 bool IsConfigurationSupported(gfx::BufferFormat format,
48 const Configuration kConfigurations[] = { 48 gfx::BufferUsage usage) const override {
49 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, 49 switch (usage) {
50 {gfx::BufferFormat::BGRX_8888, gfx::BufferUsage::SCANOUT}}; 50 case gfx::BufferUsage::SCANOUT: {
51 std::vector<Configuration> configurations( 51 const gfx::BufferFormat kSupportedFormats[] = {
52 kConfigurations, kConfigurations + arraysize(kConfigurations)); 52 gfx::BufferFormat::BGRA_8888, gfx::BufferFormat::BGRX_8888};
53 for (auto& supported_format : kSupportedFormats) {
54 if (supported_format == format)
55 return true;
56 }
57 return false;
piman 2015/10/07 01:20:17 nit: return format == gfx::BufferFormat::BGRA_8888
reveman 2015/10/07 09:05:01 Done here and in places where I had a similar patt
58 }
59 case gfx::BufferUsage::MAP:
60 case gfx::BufferUsage::PERSISTENT_MAP: {
53 #if defined(USE_VGEM_MAP) 61 #if defined(USE_VGEM_MAP)
54 if (vgem_fd_.is_valid()) { 62 if (vgem_fd_.is_valid()) {
55 configurations.push_back( 63 const gfx::BufferFormat kSupportedFormat =
56 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}); 64 gfx::BufferFormat::BGRA_8888;
57 configurations.push_back( 65 if (format == kSupportedFormat)
58 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::PERSISTENT_MAP}); 66 return true;
67 }
68 #endif
69 return false;
70 }
59 } 71 }
60 #endif 72 NOTREACHED();
61 return configurations; 73 return false;
62 } 74 }
63 scoped_ptr<ClientNativePixmap> ImportFromHandle( 75 scoped_ptr<ClientNativePixmap> ImportFromHandle(
64 const gfx::NativePixmapHandle& handle, 76 const gfx::NativePixmapHandle& handle,
65 const gfx::Size& size, 77 const gfx::Size& size,
66 gfx::BufferUsage usage) override { 78 gfx::BufferUsage usage) override {
67 base::ScopedFD scoped_fd(handle.fd.fd); 79 base::ScopedFD scoped_fd(handle.fd.fd);
68 80
69 switch (usage) { 81 switch (usage) {
70 case gfx::BufferUsage::MAP: 82 case gfx::BufferUsage::MAP:
71 case gfx::BufferUsage::PERSISTENT_MAP: 83 case gfx::BufferUsage::PERSISTENT_MAP:
(...skipping 20 matching lines...) Expand all
92 #endif 104 #endif
93 105
94 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 106 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
95 }; 107 };
96 108
97 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 109 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
98 return new ClientNativePixmapFactoryGbm(); 110 return new ClientNativePixmapFactoryGbm();
99 } 111 }
100 112
101 } // namespace ui 113 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698