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

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

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 #include "base/sys_info.h"
6 #include "content/common/gpu/media/shared_memory_region.h"
7
8 namespace content {
9
10 SharedMemoryRegion::SharedMemoryRegion(const base::SharedMemoryHandle& handle,
11 off_t offset,
12 size_t size,
13 bool read_only)
14 : shm_(handle, read_only),
15 offset_(offset),
16 size_(size),
17 extra_size_(offset % base::SysInfo::VMAllocationGranularity()) {
18 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.
19 }
20
21 SharedMemoryRegion::SharedMemoryRegion(
22 const media::BitstreamBuffer& bitstream_buffer,
23 bool read_only)
24 : SharedMemoryRegion(bitstream_buffer.handle(),
25 bitstream_buffer.offset(),
26 bitstream_buffer.size(),
27 read_only) {}
28
29 bool SharedMemoryRegion::Map() {
30 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.
31 }
32
33 void* SharedMemoryRegion::memory() {
34 int8_t* addr = reinterpret_cast<int8_t*>(shm_.memory());
35 return addr ? addr + extra_size_ : nullptr;
36 }
37
38 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698