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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl.cc

Issue 699073004: content: Add command line flag for native GPU memory buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gpu-memory-buffer-impl-unittests
Patch Set: rebase and use correct texture target Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/common/gpu/client/gpu_memory_buffer_impl.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/gl/gl_bindings.h" 9 #include "ui/gl/gl_bindings.h"
10 10
11 namespace content { 11 namespace content {
12 namespace { 12 namespace {
13 13
14 const struct TypeNamePair {
15 gfx::GpuMemoryBufferType type;
16 const char* name;
17 } kTypeNamePairs[] = {
18 { gfx::SHARED_MEMORY_BUFFER, "shmem" },
19 { gfx::IO_SURFACE_BUFFER, "iosurface" },
20 { gfx::SURFACE_TEXTURE_BUFFER, "surfacetexture" },
21 { gfx::OZONE_NATIVE_BUFFER, "ozone" }
22 };
23
14 gfx::GpuMemoryBufferType g_preferred_type = gfx::EMPTY_BUFFER; 24 gfx::GpuMemoryBufferType g_preferred_type = gfx::EMPTY_BUFFER;
15 25
16 struct DefaultPreferredType { 26 struct DefaultPreferredType {
17 DefaultPreferredType() : value(gfx::EMPTY_BUFFER) { 27 DefaultPreferredType() : value(gfx::EMPTY_BUFFER) {
18 std::vector<gfx::GpuMemoryBufferType> supported_types; 28 std::vector<gfx::GpuMemoryBufferType> supported_types;
19 GpuMemoryBufferImpl::GetSupportedTypes(&supported_types); 29 GpuMemoryBufferImpl::GetSupportedTypes(&supported_types);
20 DCHECK(!supported_types.empty()); 30 DCHECK(!supported_types.empty());
21 value = supported_types[0]; 31 value = supported_types[0];
22 } 32 }
23 gfx::GpuMemoryBufferType value; 33 gfx::GpuMemoryBufferType value;
(...skipping 13 matching lines...) Expand all
37 callback_(callback), 47 callback_(callback),
38 mapped_(false), 48 mapped_(false),
39 destruction_sync_point_(0) { 49 destruction_sync_point_(0) {
40 } 50 }
41 51
42 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { 52 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {
43 callback_.Run(destruction_sync_point_); 53 callback_.Run(destruction_sync_point_);
44 } 54 }
45 55
46 // static 56 // static
57 gfx::GpuMemoryBufferType GpuMemoryBufferImpl::GetNamedType(
58 const std::string& name) {
59 for (size_t i = 0; i < arraysize(kTypeNamePairs); ++i) {
piman 2014/11/19 02:39:40 nit: range for?
60 if (name == kTypeNamePairs[i].name)
61 return kTypeNamePairs[i].type;
62 }
63
64 return gfx::EMPTY_BUFFER;
65 }
66
67 // static
68 const char* GpuMemoryBufferImpl::GetTypeName(gfx::GpuMemoryBufferType type) {
69 for (size_t i = 0; i < arraysize(kTypeNamePairs); ++i) {
piman 2014/11/19 02:39:40 nit: range for?
70 if (type == kTypeNamePairs[i].type)
71 return kTypeNamePairs[i].name;
72 }
73
74 return "unknown";
75 }
76
77 // static
47 void GpuMemoryBufferImpl::SetPreferredType(gfx::GpuMemoryBufferType type) { 78 void GpuMemoryBufferImpl::SetPreferredType(gfx::GpuMemoryBufferType type) {
48 // EMPTY_BUFFER is a reserved value and not a valid preferred type. 79 // EMPTY_BUFFER is a reserved value and not a valid preferred type.
49 DCHECK_NE(gfx::EMPTY_BUFFER, type); 80 DCHECK_NE(gfx::EMPTY_BUFFER, type);
50 81
51 // Make sure this function is only called once before the first call 82 // Make sure this function is only called once before the first call
52 // to GetPreferredType(). 83 // to GetPreferredType().
53 DCHECK_EQ(gfx::EMPTY_BUFFER, g_preferred_type); 84 DCHECK_EQ(gfx::EMPTY_BUFFER, g_preferred_type);
54 85
55 g_preferred_type = type; 86 g_preferred_type = type;
56 } 87 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 119
89 bool GpuMemoryBufferImpl::IsMapped() const { 120 bool GpuMemoryBufferImpl::IsMapped() const {
90 return mapped_; 121 return mapped_;
91 } 122 }
92 123
93 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { 124 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() {
94 return reinterpret_cast<ClientBuffer>(this); 125 return reinterpret_cast<ClientBuffer>(this);
95 } 126 }
96 127
97 } // namespace content 128 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698