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

Side by Side Diff: ppapi/proxy/ppb_buffer_proxy.cc

Issue 10790063: PPAPI/NaCl: Make ImageData for NaCl just use shared memory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make PPB_ImageData_API base non-exported Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_buffer_proxy.h ('k') | ppapi/proxy/ppb_image_data_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ppapi/proxy/ppb_buffer_proxy.h" 5 #include "ppapi/proxy/ppb_buffer_proxy.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 11 matching lines...) Expand all
22 22
23 namespace ppapi { 23 namespace ppapi {
24 namespace proxy { 24 namespace proxy {
25 25
26 Buffer::Buffer(const HostResource& resource, 26 Buffer::Buffer(const HostResource& resource,
27 const base::SharedMemoryHandle& shm_handle, 27 const base::SharedMemoryHandle& shm_handle,
28 uint32_t size) 28 uint32_t size)
29 : Resource(OBJECT_IS_PROXY, resource), 29 : Resource(OBJECT_IS_PROXY, resource),
30 shm_(shm_handle, false), 30 shm_(shm_handle, false),
31 size_(size), 31 size_(size),
32 mapped_data_(NULL),
33 map_count_(0) { 32 map_count_(0) {
34 } 33 }
35 34
36 Buffer::~Buffer() { 35 Buffer::~Buffer() {
37 Unmap(); 36 Unmap();
38 } 37 }
39 38
40 thunk::PPB_Buffer_API* Buffer::AsPPB_Buffer_API() { 39 thunk::PPB_Buffer_API* Buffer::AsPPB_Buffer_API() {
41 return this; 40 return this;
42 } 41 }
43 42
44 PP_Bool Buffer::Describe(uint32_t* size_in_bytes) { 43 PP_Bool Buffer::Describe(uint32_t* size_in_bytes) {
45 *size_in_bytes = size_; 44 *size_in_bytes = size_;
46 return PP_TRUE; 45 return PP_TRUE;
47 } 46 }
48 47
49 PP_Bool Buffer::IsMapped() { 48 PP_Bool Buffer::IsMapped() {
50 return PP_FromBool(!!mapped_data_); 49 return PP_FromBool(map_count_ > 0);
51 } 50 }
52 51
53 void* Buffer::Map() { 52 void* Buffer::Map() {
54 if (map_count_++ == 0) 53 if (map_count_++ == 0)
55 shm_.Map(size_); 54 shm_.Map(size_);
56 return shm_.memory(); 55 return shm_.memory();
57 } 56 }
58 57
59 void Buffer::Unmap() { 58 void Buffer::Unmap() {
60 if (--map_count_ == 0) 59 if (--map_count_ == 0)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #elif defined(OS_POSIX) 140 #elif defined(OS_POSIX)
142 local_fd; 141 local_fd;
143 #else 142 #else
144 #error Not implemented. 143 #error Not implemented.
145 #endif 144 #endif
146 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); 145 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false);
147 } 146 }
148 147
149 } // namespace proxy 148 } // namespace proxy
150 } // namespace ppapi 149 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_buffer_proxy.h ('k') | ppapi/proxy/ppb_image_data_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698