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 base::SharedMemoryHandle handle; | 119 base::SharedMemory* shm; |
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(&shm, &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(), handle, ::GetCurrentProcess(), | 126 if (!::DuplicateHandle(::GetCurrentProcess(), shm->handle(), |
127 &shm_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { | 127 ::GetCurrentProcess(), &shm_handle, 0, FALSE, |
| 128 DUPLICATE_SAME_ACCESS)) { |
128 return PP_ERROR_FAILED; | 129 return PP_ERROR_FAILED; |
129 } | 130 } |
130 #else | 131 #else |
131 base::SharedMemoryHandle shm_handle = | 132 base::SharedMemoryHandle shm_handle = |
132 base::SharedMemory::DeepCopyHandle(handle, false); | 133 base::SharedMemory::DeepCopyHandle(shm->handle(), false); |
133 #endif | 134 #endif |
134 image_shm->reset(new base::SharedMemory(shm_handle, true)); | 135 image_shm->reset(new base::SharedMemory(shm_handle, true)); |
135 if (!(*image_shm)->Map(desc.stride * desc.size.height)) { | 136 if (!(*image_shm)->Map(desc.stride * desc.size.height)) { |
136 image_shm->reset(); | 137 image_shm->reset(); |
137 return PP_ERROR_NOMEMORY; | 138 return PP_ERROR_NOMEMORY; |
138 } | 139 } |
139 return PP_OK; | 140 return PP_OK; |
140 } | 141 } |
141 | 142 |
142 return PP_ERROR_BADARGUMENT; | 143 return PP_ERROR_BADARGUMENT; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 411 |
411 // If the host is not bound to the instance, return PP_OK immediately. | 412 // If the host is not bound to the instance, return PP_OK immediately. |
412 if (!bound_instance_) | 413 if (!bound_instance_) |
413 return PP_OK; | 414 return PP_OK; |
414 | 415 |
415 commit_layers_reply_context_ = context->MakeReplyMessageContext(); | 416 commit_layers_reply_context_ = context->MakeReplyMessageContext(); |
416 return PP_OK_COMPLETIONPENDING; | 417 return PP_OK_COMPLETIONPENDING; |
417 } | 418 } |
418 | 419 |
419 } // namespace content | 420 } // namespace content |
OLD | NEW |