OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef MEDIA_GPU_SHARED_MEMORY_REGION_H_ | 5 #ifndef MEDIA_GPU_SHARED_MEMORY_REGION_H_ |
6 #define MEDIA_GPU_SHARED_MEMORY_REGION_H_ | 6 #define MEDIA_GPU_SHARED_MEMORY_REGION_H_ |
7 | 7 |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "media/base/bitstream_buffer.h" | 9 #include "media/base/bitstream_buffer.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 // shared memory and the length is |size|. It will take the ownership of | 22 // shared memory and the length is |size|. It will take the ownership of |
23 // the |handle| and release the resource when being destroyed. Different | 23 // the |handle| and release the resource when being destroyed. Different |
24 // from SharedMemory, the |offset| needs not to be aligned to the value of | 24 // from SharedMemory, the |offset| needs not to be aligned to the value of |
25 // |SysInfo::VMAllocationGranularity()|. | 25 // |SysInfo::VMAllocationGranularity()|. |
26 SharedMemoryRegion(const base::SharedMemoryHandle& handle, | 26 SharedMemoryRegion(const base::SharedMemoryHandle& handle, |
27 off_t offset, | 27 off_t offset, |
28 size_t size, | 28 size_t size, |
29 bool read_only); | 29 bool read_only); |
30 | 30 |
31 // Creates a SharedMemoryRegion from the given |bistream_buffer|. | 31 // Creates a SharedMemoryRegion from the given |bistream_buffer|. |
32 SharedMemoryRegion(const media::BitstreamBuffer& bitstream_buffer, | 32 SharedMemoryRegion(const BitstreamBuffer& bitstream_buffer, bool read_only); |
33 bool read_only); | |
34 | 33 |
35 // Maps the shared memory into the caller's address space. | 34 // Maps the shared memory into the caller's address space. |
36 // Return true on success, false otherwise. | 35 // Return true on success, false otherwise. |
37 bool Map(); | 36 bool Map(); |
38 | 37 |
39 // Gets a pointer to the mapped region if it has been mapped via Map(). | 38 // Gets a pointer to the mapped region if it has been mapped via Map(). |
40 // Returns |nullptr| if it is not mapped. The returned pointer points | 39 // Returns |nullptr| if it is not mapped. The returned pointer points |
41 // to the memory at the offset previously passed to the constructor. | 40 // to the memory at the offset previously passed to the constructor. |
42 void* memory(); | 41 void* memory(); |
43 | 42 |
44 size_t size() const { return size_; } | 43 size_t size() const { return size_; } |
45 | 44 |
46 private: | 45 private: |
47 base::SharedMemory shm_; | 46 base::SharedMemory shm_; |
48 off_t offset_; | 47 off_t offset_; |
49 size_t size_; | 48 size_t size_; |
50 size_t alignment_size_; | 49 size_t alignment_size_; |
51 | 50 |
52 DISALLOW_COPY_AND_ASSIGN(SharedMemoryRegion); | 51 DISALLOW_COPY_AND_ASSIGN(SharedMemoryRegion); |
53 }; | 52 }; |
54 | 53 |
55 } // namespace media | 54 } // namespace media |
56 | 55 |
57 #endif // MEDIA_GPU_SHARED_MEMORY_REGION_H_ | 56 #endif // MEDIA_GPU_SHARED_MEMORY_REGION_H_ |
OLD | NEW |