Index: content/common/gpu/media/shared_memory_region.cc |
diff --git a/content/common/gpu/media/shared_memory_region.cc b/content/common/gpu/media/shared_memory_region.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..972c4eee2d15dcf0d599185a50b715b8e36e1f21 |
--- /dev/null |
+++ b/content/common/gpu/media/shared_memory_region.cc |
@@ -0,0 +1,38 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/sys_info.h" |
+#include "content/common/gpu/media/shared_memory_region.h" |
+ |
+namespace content { |
+ |
+SharedMemoryRegion::SharedMemoryRegion(const base::SharedMemoryHandle& handle, |
+ off_t offset, |
+ size_t size, |
+ bool read_only) |
+ : shm_(handle, read_only), |
+ offset_(offset), |
+ size_(size), |
+ extra_size_(offset % base::SysInfo::VMAllocationGranularity()) { |
+ DCHECK_LT(offset_, 0) << "Invalid offset: " << offset_; |
Pawel Osciak
2016/01/05 06:22:51
DCHECK_GE ?
Owen Lin
2016/01/06 03:45:46
Done.
|
+} |
+ |
+SharedMemoryRegion::SharedMemoryRegion( |
+ const media::BitstreamBuffer& bitstream_buffer, |
+ bool read_only) |
+ : SharedMemoryRegion(bitstream_buffer.handle(), |
+ bitstream_buffer.offset(), |
+ bitstream_buffer.size(), |
+ read_only) {} |
+ |
+bool SharedMemoryRegion::Map() { |
+ return shm_.MapAt(offset_ - extra_size_, size_ + extra_size_); |
Pawel Osciak
2016/01/05 06:22:51
I'm wondering, if offset is < 0, then extra_size_
Owen Lin
2016/01/06 03:45:46
Done.
|
+} |
+ |
+void* SharedMemoryRegion::memory() { |
+ int8_t* addr = reinterpret_cast<int8_t*>(shm_.memory()); |
+ return addr ? addr + extra_size_ : nullptr; |
+} |
+ |
+} // namespace content |