Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: ppapi/proxy/video_decoder_resource.cc

Issue 390213002: Pepper: Change PPB_VideoDecoder::Reset behavior so plugin always manages textures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/video_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
OLDNEW
« no previous file with comments | « ppapi/cpp/video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698