| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_video_source_host.h" | 5 #include "content/renderer/pepper/pepper_video_source_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "content/renderer/pepper/ppb_image_data_impl.h" | 10 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Note: We try to reuse the shared memory for the previous frame here. This | 120 // Note: We try to reuse the shared memory for the previous frame here. This |
| 121 // means that the previous frame may be overwritten and is no longer valid | 121 // means that the previous frame may be overwritten and is no longer valid |
| 122 // after calling this function again. | 122 // after calling this function again. |
| 123 base::SharedMemoryHandle image_handle; | 123 base::SharedMemoryHandle image_handle; |
| 124 uint32_t byte_count; | 124 uint32_t byte_count; |
| 125 if (shared_image_.get() && dst_size.width() == shared_image_->width() && | 125 if (shared_image_.get() && dst_size.width() == shared_image_->width() && |
| 126 dst_size.height() == shared_image_->height()) { | 126 dst_size.height() == shared_image_->height()) { |
| 127 // We have already allocated the correct size in shared memory. We need to | 127 // We have already allocated the correct size in shared memory. We need to |
| 128 // duplicate the handle for IPC however, which will close down the | 128 // duplicate the handle for IPC however, which will close down the |
| 129 // duplicated handle when it's done. | 129 // duplicated handle when it's done. |
| 130 base::SharedMemoryHandle local_handle; | 130 base::SharedMemory* local_shm; |
| 131 if (shared_image_->GetSharedMemory(&local_handle, &byte_count) != PP_OK) { | 131 if (shared_image_->GetSharedMemory(&local_shm, &byte_count) != PP_OK) { |
| 132 SendGetFrameErrorReply(PP_ERROR_FAILED); | 132 SendGetFrameErrorReply(PP_ERROR_FAILED); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 ppapi::proxy::HostDispatcher* dispatcher = | 136 ppapi::proxy::HostDispatcher* dispatcher = |
| 137 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 137 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
| 138 if (!dispatcher) { | 138 if (!dispatcher) { |
| 139 SendGetFrameErrorReply(PP_ERROR_FAILED); | 139 SendGetFrameErrorReply(PP_ERROR_FAILED); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 image_handle = dispatcher->ShareSharedMemoryHandleWithRemote(local_handle); | 143 image_handle = |
| 144 dispatcher->ShareSharedMemoryHandleWithRemote(local_shm->handle()); |
| 144 } else { | 145 } else { |
| 145 // We need to allocate new shared memory. | 146 // We need to allocate new shared memory. |
| 146 shared_image_ = NULL; // Release any previous image. | 147 shared_image_ = NULL; // Release any previous image. |
| 147 | 148 |
| 148 ppapi::ScopedPPResource resource( | 149 ppapi::ScopedPPResource resource( |
| 149 ppapi::ScopedPPResource::PassRef(), | 150 ppapi::ScopedPPResource::PassRef(), |
| 150 ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( | 151 ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( |
| 151 pp_instance(), | 152 pp_instance(), |
| 152 ppapi::PPB_ImageData_Shared::SIMPLE, | 153 ppapi::PPB_ImageData_Shared::SIMPLE, |
| 153 PP_IMAGEDATAFORMAT_BGRA_PREMUL, | 154 PP_IMAGEDATAFORMAT_BGRA_PREMUL, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if (source_handler_.get() && !stream_url_.empty()) | 282 if (source_handler_.get() && !stream_url_.empty()) |
| 282 source_handler_->Close(frame_receiver_.get()); | 283 source_handler_->Close(frame_receiver_.get()); |
| 283 | 284 |
| 284 source_handler_.reset(NULL); | 285 source_handler_.reset(NULL); |
| 285 stream_url_.clear(); | 286 stream_url_.clear(); |
| 286 | 287 |
| 287 shared_image_ = NULL; | 288 shared_image_ = NULL; |
| 288 } | 289 } |
| 289 | 290 |
| 290 } // namespace content | 291 } // namespace content |
| OLD | NEW |