OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/pepper/pepper_compositor_host.h" | 5 #include "content/renderer/pepper/pepper_compositor_host.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 return PP_ERROR_BADARGUMENT; | 109 return PP_ERROR_BADARGUMENT; |
110 } | 110 } |
111 | 111 |
112 // Make sure the source rect is not beyond the dimensions of the | 112 // Make sure the source rect is not beyond the dimensions of the |
113 // image. | 113 // image. |
114 if (!CheckPPFloatRect(new_layer->image->source_rect, | 114 if (!CheckPPFloatRect(new_layer->image->source_rect, |
115 desc.size.width, desc.size.height)) { | 115 desc.size.width, desc.size.height)) { |
116 return PP_ERROR_BADARGUMENT; | 116 return PP_ERROR_BADARGUMENT; |
117 } | 117 } |
118 | 118 |
119 int handle; | 119 base::SharedMemoryHandle handle; |
120 uint32_t byte_count; | 120 uint32_t byte_count; |
121 if (enter.object()->GetSharedMemory(&handle, &byte_count) != PP_OK) | 121 if (enter.object()->GetSharedMemory(&handle, &byte_count) != PP_OK) |
122 return PP_ERROR_FAILED; | 122 return PP_ERROR_FAILED; |
123 | 123 |
124 #if defined(OS_WIN) | 124 #if defined(OS_WIN) |
125 base::SharedMemoryHandle shm_handle; | 125 base::SharedMemoryHandle shm_handle; |
126 if (!::DuplicateHandle(::GetCurrentProcess(), | 126 if (!::DuplicateHandle(::GetCurrentProcess(), |
127 reinterpret_cast<base::SharedMemoryHandle>(handle), | 127 reinterpret_cast<base::SharedMemoryHandle>(handle), |
128 ::GetCurrentProcess(), | 128 ::GetCurrentProcess(), |
129 &shm_handle, | 129 &shm_handle, |
130 0, | 130 0, |
131 FALSE, | 131 FALSE, |
132 DUPLICATE_SAME_ACCESS)) { | 132 DUPLICATE_SAME_ACCESS)) { |
133 return PP_ERROR_FAILED; | 133 return PP_ERROR_FAILED; |
134 } | 134 } |
135 #else | 135 #else |
136 base::SharedMemoryHandle shm_handle(dup(handle), false); | 136 base::SharedMemoryHandle shm_handle = |
137 base::SharedMemory::DeepCopyHandle(handle, false); | |
piman
2015/06/01 22:16:08
Can you do this in both OS_WIN and !OS_WIN paths?
erikchen
2015/06/01 23:48:53
Yes. I will do so in a follow up CL. DeepCopyHandl
| |
137 #endif | 138 #endif |
138 image_shm->reset(new base::SharedMemory(shm_handle, true)); | 139 image_shm->reset(new base::SharedMemory(shm_handle, true)); |
139 if (!(*image_shm)->Map(desc.stride * desc.size.height)) { | 140 if (!(*image_shm)->Map(desc.stride * desc.size.height)) { |
140 image_shm->reset(); | 141 image_shm->reset(); |
141 return PP_ERROR_NOMEMORY; | 142 return PP_ERROR_NOMEMORY; |
142 } | 143 } |
143 return PP_OK; | 144 return PP_OK; |
144 } | 145 } |
145 | 146 |
146 return PP_ERROR_BADARGUMENT; | 147 return PP_ERROR_BADARGUMENT; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 415 |
415 // If the host is not bound to the instance, return PP_OK immediately. | 416 // If the host is not bound to the instance, return PP_OK immediately. |
416 if (!bound_instance_) | 417 if (!bound_instance_) |
417 return PP_OK; | 418 return PP_OK; |
418 | 419 |
419 commit_layers_reply_context_ = context->MakeReplyMessageContext(); | 420 commit_layers_reply_context_ = context->MakeReplyMessageContext(); |
420 return PP_OK_COMPLETIONPENDING; | 421 return PP_OK_COMPLETIONPENDING; |
421 } | 422 } |
422 | 423 |
423 } // namespace content | 424 } // namespace content |
OLD | NEW |