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

Side by Side Diff: content/common/gpu/media/shared_memory_region.h

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address posciak's comments Created 4 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
6 #define CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
7
8 #include "base/memory/shared_memory.h"
9 #include "media/base/bitstream_buffer.h"
10
11 namespace content {
12
13 // Helper class to access a region of a SharedMemory.
14 class SharedMemoryRegion {
15 public:
16 // Creates a SharedMemoryRegion.
17 // The mapped memory region begins at |offset| bytes from the start of the
18 // shared memory and the length is |size|. SharedMemoryRegion will take the
19 // ownership of the |handle| and release the resource when it was destroyed.
20 // Please make sure |handle| is not |auto_close|.
Pawel Osciak 2016/01/05 06:22:51 Could we instead call SharedMemory::DuplicateHandl
Owen Lin 2016/01/06 03:45:46 Oops, I was confused by the document. https://cod
21 SharedMemoryRegion(const base::SharedMemoryHandle& handle,
22 off_t offset,
23 size_t size,
24 bool read_only);
25
26 // Creates a SharedMemoryRegion from the given |bistream_buffer|.
27 SharedMemoryRegion(const media::BitstreamBuffer& bitstream_buffer,
28 bool read_only);
29
30 // Maps the shared memory into the caller's address space.
31 // Return true on success, false otherwise.
32 bool Map();
33
34 // Gets a pointer to the mapped region if it has been mapped via Map().
35 // Returns |nullptr| if it is not mapped. The mapped region begins at
36 // |offset| bytes from the start of the whole shared memory.
Pawel Osciak 2016/01/05 06:22:51 The returned pointer points to the memory at the o
Owen Lin 2016/01/06 03:45:46 Done.
37 void* memory();
38
39 size_t size() const { return size_; }
40
41 private:
42 base::SharedMemory shm_;
43 off_t offset_;
44 size_t size_;
45 size_t extra_size_;
Pawel Osciak 2016/01/05 06:22:51 Nit: s/extra_size_/aligned_size_/
Owen Lin 2016/01/06 03:45:46 Done.
46
47 DISALLOW_COPY_AND_ASSIGN(SharedMemoryRegion);
48 };
49
50 } // namespace content
51
52 #endif // CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698