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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "gpu/command_buffer/common/mailbox.h" | 10 #include "gpu/command_buffer/common/mailbox.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 return decoder_last_error_; | 142 return decoder_last_error_; |
143 if (flush_callback_ || reset_callback_) | 143 if (flush_callback_ || reset_callback_) |
144 return PP_ERROR_FAILED; | 144 return PP_ERROR_FAILED; |
145 if (decode_callback_) | 145 if (decode_callback_) |
146 return PP_ERROR_INPROGRESS; | 146 return PP_ERROR_INPROGRESS; |
147 if (size > kMaximumBitstreamBufferSize) | 147 if (size > kMaximumBitstreamBufferSize) |
148 return PP_ERROR_NOMEMORY; | 148 return PP_ERROR_NOMEMORY; |
149 | 149 |
150 // If we allow the plugin to call Decode again, we must have somewhere to | 150 // If we allow the plugin to call Decode again, we must have somewhere to |
151 // copy their buffer. | 151 // copy their buffer. |
152 DCHECK(!available_shm_buffers_.empty() || | 152 DCHECK(!available_shm_buffers_.empty() || |
igorc
2014/07/14 23:16:42
Perhaps we could change this to be a runtime check
bbudge
2014/07/15 15:58:08
It's a DCHECK to catch programming errors in the p
| |
153 shm_buffers_.size() < kMaximumPendingDecodes); | 153 shm_buffers_.size() < kMaximumPendingDecodes); |
154 | 154 |
155 // Count up, wrapping back to 0 before overflowing. | 155 // Count up, wrapping back to 0 before overflowing. |
156 int32_t uid = ++num_decodes_; | 156 int32_t uid = ++num_decodes_; |
157 if (uid == std::numeric_limits<int32_t>::max()) | 157 if (uid == std::numeric_limits<int32_t>::max()) |
158 num_decodes_ = 0; | 158 num_decodes_ = 0; |
159 | 159 |
160 // Save decode_id in a ring buffer. The ring buffer is sized to store | 160 // Save decode_id in a ring buffer. The ring buffer is sized to store |
161 // decode_id for the maximum picture delay. | 161 // decode_id for the maximum picture delay. |
162 decode_ids_[uid % kMaximumPictureDelay] = decode_id; | 162 decode_ids_[uid % kMaximumPictureDelay] = decode_id; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 } | 253 } |
254 | 254 |
255 get_picture_callback_ = callback; | 255 get_picture_callback_ = callback; |
256 get_picture_ = picture; | 256 get_picture_ = picture; |
257 return PP_OK_COMPLETIONPENDING; | 257 return PP_OK_COMPLETIONPENDING; |
258 } | 258 } |
259 | 259 |
260 void VideoDecoderResource::RecyclePicture(const PP_VideoPicture* picture) { | 260 void VideoDecoderResource::RecyclePicture(const PP_VideoPicture* picture) { |
261 if (decoder_last_error_) | 261 if (decoder_last_error_) |
262 return; | 262 return; |
263 if (reset_callback_) | 263 if (reset_callback_) |
igorc
2014/07/14 23:07:07
Should we now allow recycle during reset?
bbudge
2014/07/15 15:58:08
Done.
| |
264 return; | 264 return; |
265 | 265 |
266 Post(RENDERER, PpapiHostMsg_VideoDecoder_RecyclePicture(picture->texture_id)); | 266 Post(RENDERER, PpapiHostMsg_VideoDecoder_RecyclePicture(picture->texture_id)); |
267 } | 267 } |
268 | 268 |
269 int32_t VideoDecoderResource::Flush(scoped_refptr<TrackedCallback> callback) { | 269 int32_t VideoDecoderResource::Flush(scoped_refptr<TrackedCallback> callback) { |
270 if (decoder_last_error_) | 270 if (decoder_last_error_) |
271 return decoder_last_error_; | 271 return decoder_last_error_; |
272 if (reset_callback_) | 272 if (reset_callback_) |
273 return PP_ERROR_FAILED; | 273 return PP_ERROR_FAILED; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 scoped_refptr<TrackedCallback> callback; | 465 scoped_refptr<TrackedCallback> callback; |
466 callback.swap(flush_callback_); | 466 callback.swap(flush_callback_); |
467 callback->Run(params.result()); | 467 callback->Run(params.result()); |
468 } | 468 } |
469 | 469 |
470 void VideoDecoderResource::OnPluginMsgResetComplete( | 470 void VideoDecoderResource::OnPluginMsgResetComplete( |
471 const ResourceMessageReplyParams& params) { | 471 const ResourceMessageReplyParams& params) { |
472 // All shm buffers should have been made available by now. | 472 // All shm buffers should have been made available by now. |
473 DCHECK_EQ(shm_buffers_.size(), available_shm_buffers_.size()); | 473 DCHECK_EQ(shm_buffers_.size(), available_shm_buffers_.size()); |
474 // Received pictures are no longer valid. | 474 // Received pictures are no longer valid. |
475 while (!received_pictures_.empty()) | 475 while (!received_pictures_.empty()) { |
476 Post(RENDERER, PpapiHostMsg_VideoDecoder_RecyclePicture( | |
477 received_pictures_.front().texture_id)); | |
igorc
2014/07/14 23:07:07
nit: 4 space alignment
bbudge
2014/07/15 15:58:08
Done.
| |
476 received_pictures_.pop(); | 478 received_pictures_.pop(); |
479 } | |
477 | 480 |
478 scoped_refptr<TrackedCallback> callback; | 481 scoped_refptr<TrackedCallback> callback; |
479 callback.swap(reset_callback_); | 482 callback.swap(reset_callback_); |
480 callback->Run(params.result()); | 483 callback->Run(params.result()); |
481 } | 484 } |
482 | 485 |
483 void VideoDecoderResource::RunCallbackWithError( | 486 void VideoDecoderResource::RunCallbackWithError( |
484 scoped_refptr<TrackedCallback>* callback) { | 487 scoped_refptr<TrackedCallback>* callback) { |
485 if (TrackedCallback::IsPending(*callback)) { | 488 if (TrackedCallback::IsPending(*callback)) { |
486 scoped_refptr<TrackedCallback> temp; | 489 scoped_refptr<TrackedCallback> temp; |
(...skipping 21 matching lines...) Expand all Loading... | |
508 pp_picture->texture_target = it->second.texture_target; | 511 pp_picture->texture_target = it->second.texture_target; |
509 pp_picture->texture_size = it->second.size; | 512 pp_picture->texture_size = it->second.size; |
510 } else { | 513 } else { |
511 NOTREACHED(); | 514 NOTREACHED(); |
512 } | 515 } |
513 received_pictures_.pop(); | 516 received_pictures_.pop(); |
514 } | 517 } |
515 | 518 |
516 } // namespace proxy | 519 } // namespace proxy |
517 } // namespace ppapi | 520 } // namespace ppapi |
OLD | NEW |