OLD | NEW |
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/video_decoder_resource.h" | 5 #include "ppapi/proxy/video_decoder_resource.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 10 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &shm_handle)) | 231 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &shm_handle)) |
232 return PP_ERROR_NOMEMORY; | 232 return PP_ERROR_NOMEMORY; |
233 std::unique_ptr<base::SharedMemory> shm( | 233 std::unique_ptr<base::SharedMemory> shm( |
234 new base::SharedMemory(shm_handle, false /* read_only */)); | 234 new base::SharedMemory(shm_handle, false /* read_only */)); |
235 std::unique_ptr<ShmBuffer> shm_buffer( | 235 std::unique_ptr<ShmBuffer> shm_buffer( |
236 new ShmBuffer(std::move(shm), shm_size, shm_id)); | 236 new ShmBuffer(std::move(shm), shm_size, shm_id)); |
237 if (!shm_buffer->addr) | 237 if (!shm_buffer->addr) |
238 return PP_ERROR_NOMEMORY; | 238 return PP_ERROR_NOMEMORY; |
239 | 239 |
240 available_shm_buffers_.push_back(shm_buffer.get()); | 240 available_shm_buffers_.push_back(shm_buffer.get()); |
241 if (shm_buffers_.size() < kMaximumPendingDecodes) { | 241 if (shm_buffers_.size() < kMaximumPendingDecodes) |
242 shm_buffers_.push_back(shm_buffer.release()); | 242 shm_buffers_.push_back(std::move(shm_buffer)); |
243 } else { | 243 else |
244 // Delete manually since ScopedVector won't delete the existing element if | 244 shm_buffers_[shm_id] = std::move(shm_buffer); |
245 // we just assign it. | |
246 delete shm_buffers_[shm_id]; | |
247 shm_buffers_[shm_id] = shm_buffer.release(); | |
248 } | |
249 } | 245 } |
250 | 246 |
251 // At this point we should have shared memory to hold the plugin's buffer. | 247 // At this point we should have shared memory to hold the plugin's buffer. |
252 DCHECK(!available_shm_buffers_.empty() && | 248 DCHECK(!available_shm_buffers_.empty() && |
253 available_shm_buffers_.back()->shm->mapped_size() >= size); | 249 available_shm_buffers_.back()->shm->mapped_size() >= size); |
254 | 250 |
255 ShmBuffer* shm_buffer = available_shm_buffers_.back(); | 251 ShmBuffer* shm_buffer = available_shm_buffers_.back(); |
256 available_shm_buffers_.pop_back(); | 252 available_shm_buffers_.pop_back(); |
257 memcpy(shm_buffer->addr, buffer, size); | 253 memcpy(shm_buffer->addr, buffer, size); |
258 | 254 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 475 } |
480 | 476 |
481 void VideoDecoderResource::OnPluginMsgDecodeComplete( | 477 void VideoDecoderResource::OnPluginMsgDecodeComplete( |
482 const ResourceMessageReplyParams& params, | 478 const ResourceMessageReplyParams& params, |
483 uint32_t shm_id) { | 479 uint32_t shm_id) { |
484 if (shm_id >= shm_buffers_.size()) { | 480 if (shm_id >= shm_buffers_.size()) { |
485 NOTREACHED(); | 481 NOTREACHED(); |
486 return; | 482 return; |
487 } | 483 } |
488 // Make the shm buffer available. | 484 // Make the shm buffer available. |
489 available_shm_buffers_.push_back(shm_buffers_[shm_id]); | 485 available_shm_buffers_.push_back(shm_buffers_[shm_id].get()); |
490 // If the plugin is waiting, let it call Decode again. | 486 // If the plugin is waiting, let it call Decode again. |
491 if (decode_callback_.get()) { | 487 if (decode_callback_.get()) { |
492 scoped_refptr<TrackedCallback> callback; | 488 scoped_refptr<TrackedCallback> callback; |
493 callback.swap(decode_callback_); | 489 callback.swap(decode_callback_); |
494 callback->Run(PP_OK); | 490 callback->Run(PP_OK); |
495 } | 491 } |
496 } | 492 } |
497 | 493 |
498 void VideoDecoderResource::OnPluginMsgFlushComplete( | 494 void VideoDecoderResource::OnPluginMsgFlushComplete( |
499 const ResourceMessageReplyParams& params) { | 495 const ResourceMessageReplyParams& params) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 get_picture_0_1_->texture_target = texture_target; | 572 get_picture_0_1_->texture_target = texture_target; |
577 get_picture_0_1_->texture_size = texture_size; | 573 get_picture_0_1_->texture_size = texture_size; |
578 get_picture_0_1_ = NULL; | 574 get_picture_0_1_ = NULL; |
579 } | 575 } |
580 | 576 |
581 received_pictures_.pop(); | 577 received_pictures_.pop(); |
582 } | 578 } |
583 | 579 |
584 } // namespace proxy | 580 } // namespace proxy |
585 } // namespace ppapi | 581 } // namespace ppapi |
OLD | NEW |