OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/services/gles2/mojo_buffer_backing.h" |
| 6 |
| 7 namespace mojo { |
| 8 namespace gles2 { |
| 9 |
| 10 MojoBufferBacking::MojoBufferBacking(mojo::ScopedSharedBufferHandle handle, |
| 11 void* memory, |
| 12 size_t size) |
| 13 : handle_(handle.Pass()), memory_(memory), size_(size) {} |
| 14 |
| 15 MojoBufferBacking::~MojoBufferBacking() { mojo::UnmapBuffer(memory_); } |
| 16 |
| 17 // static |
| 18 scoped_ptr<gpu::BufferBacking> MojoBufferBacking::Create( |
| 19 mojo::ScopedSharedBufferHandle handle, |
| 20 size_t size) { |
| 21 void* memory = NULL; |
| 22 MojoResult result = mojo::MapBuffer( |
| 23 handle.get(), 0, size, &memory, MOJO_MAP_BUFFER_FLAG_NONE); |
| 24 if (result != MOJO_RESULT_OK) |
| 25 return scoped_ptr<BufferBacking>(); |
| 26 DCHECK(memory); |
| 27 return scoped_ptr<BufferBacking>( |
| 28 new MojoBufferBacking(handle.Pass(), memory, size)); |
| 29 } |
| 30 void* MojoBufferBacking::GetMemory() const { return memory_; } |
| 31 size_t MojoBufferBacking::GetSize() const { return size_; } |
| 32 |
| 33 } // namespace gles2 |
| 34 } // namespace mojo |
OLD | NEW |