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

Side by Side Diff: components/view_manager/gles2/mojo_gpu_memory_buffer.cc

Issue 1245683004: Mandoline: Merge Surfaces and Views apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bot issues (I hope) Created 5 years, 4 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 "components/view_manager/gles2/mojo_gpu_memory_buffer.h" 5 #include "components/view_manager/gles2/mojo_gpu_memory_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return nullptr; 106 return nullptr;
107 return make_scoped_ptr<gfx::GpuMemoryBuffer>( 107 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
108 new MojoGpuMemoryBufferImpl(size, format, shared_memory.Pass())); 108 new MojoGpuMemoryBufferImpl(size, format, shared_memory.Pass()));
109 } 109 }
110 110
111 MojoGpuMemoryBufferImpl* MojoGpuMemoryBufferImpl::FromClientBuffer( 111 MojoGpuMemoryBufferImpl* MojoGpuMemoryBufferImpl::FromClientBuffer(
112 ClientBuffer buffer) { 112 ClientBuffer buffer) {
113 return reinterpret_cast<MojoGpuMemoryBufferImpl*>(buffer); 113 return reinterpret_cast<MojoGpuMemoryBufferImpl*>(buffer);
114 } 114 }
115 115
116 const unsigned char* MojoGpuMemoryBufferImpl::GetMemory() const {
117 return static_cast<const unsigned char*>(shared_memory_->memory());
118 }
119
116 bool MojoGpuMemoryBufferImpl::Map(void** data) { 120 bool MojoGpuMemoryBufferImpl::Map(void** data) {
117 DCHECK(!mapped_); 121 DCHECK(!mapped_);
118 if (!shared_memory_->Map(BufferSizeInBytes(size_, format_))) 122 if (!shared_memory_->Map(BufferSizeInBytes(size_, format_)))
119 return false; 123 return false;
120 mapped_ = true; 124 mapped_ = true;
121 size_t offset = 0; 125 size_t offset = 0;
122 int num_planes = static_cast<int>( 126 int num_planes = static_cast<int>(
123 gfx::NumberOfPlanesForBufferFormat(format_)); 127 gfx::NumberOfPlanesForBufferFormat(format_));
124 for (int i = 0; i < num_planes; ++i) { 128 for (int i = 0; i < num_planes; ++i) {
125 data[i] = reinterpret_cast<uint8*>(shared_memory_->memory()) + offset; 129 data[i] = reinterpret_cast<uint8*>(shared_memory_->memory()) + offset;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 handle.type = gfx::SHARED_MEMORY_BUFFER; 164 handle.type = gfx::SHARED_MEMORY_BUFFER;
161 handle.handle = shared_memory_->handle(); 165 handle.handle = shared_memory_->handle();
162 return handle; 166 return handle;
163 } 167 }
164 168
165 ClientBuffer MojoGpuMemoryBufferImpl::AsClientBuffer() { 169 ClientBuffer MojoGpuMemoryBufferImpl::AsClientBuffer() {
166 return reinterpret_cast<ClientBuffer>(this); 170 return reinterpret_cast<ClientBuffer>(this);
167 } 171 }
168 172
169 } // namespace gles2 173 } // namespace gles2
OLDNEW
« no previous file with comments | « components/view_manager/gles2/mojo_gpu_memory_buffer.h ('k') | components/view_manager/native_viewport/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698