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.
5 #include "mojo/services/gles2/mojo_buffer_backing.h"
7 #include "base/logging.h"
12 MojoBufferBacking::MojoBufferBacking(mojo::ScopedSharedBufferHandle handle
,
15 : handle_(handle
.Pass()), memory_(memory
), size_(size
) {}
17 MojoBufferBacking::~MojoBufferBacking() { mojo::UnmapBuffer(memory_
); }
20 scoped_ptr
<gpu::BufferBacking
> MojoBufferBacking::Create(
21 mojo::ScopedSharedBufferHandle handle
,
24 MojoResult result
= mojo::MapBuffer(
25 handle
.get(), 0, size
, &memory
, MOJO_MAP_BUFFER_FLAG_NONE
);
26 if (result
!= MOJO_RESULT_OK
)
27 return scoped_ptr
<BufferBacking
>();
29 return scoped_ptr
<BufferBacking
>(
30 new MojoBufferBacking(handle
.Pass(), memory
, size
));
32 void* MojoBufferBacking::GetMemory() const { return memory_
; }
33 size_t MojoBufferBacking::GetSize() const { return size_
; }