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

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

Issue 703753002: Pepper: Expose visible_rect to PPB_VideoDecoder.GetPicture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_video_decoder.h" 10 #include "ppapi/c/ppb_video_decoder.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return result; 209 return result;
210 } 210 }
211 211
212 void SendDecodeReply(const ResourceMessageCallParams& params, 212 void SendDecodeReply(const ResourceMessageCallParams& params,
213 uint32_t shm_id) { 213 uint32_t shm_id) {
214 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_DecodeReply(shm_id)); 214 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_DecodeReply(shm_id));
215 } 215 }
216 216
217 void SendPictureReady(const ResourceMessageCallParams& params, 217 void SendPictureReady(const ResourceMessageCallParams& params,
218 uint32_t decode_count, 218 uint32_t decode_count,
219 uint32_t texture_id) { 219 uint32_t texture_id,
220 SendReply( 220 PP_Rect* visible_rect) {
221 params, 221 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_PictureReady(
222 PP_OK, 222 decode_count, texture_id, *visible_rect));
223 PpapiPluginMsg_VideoDecoder_PictureReady(decode_count, texture_id));
224 } 223 }
225 224
226 void SendFlushReply(const ResourceMessageCallParams& params) { 225 void SendFlushReply(const ResourceMessageCallParams& params) {
227 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_FlushReply()); 226 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_FlushReply());
228 } 227 }
229 228
230 void SendResetReply(const ResourceMessageCallParams& params) { 229 void SendResetReply(const ResourceMessageCallParams& params) {
231 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_ResetReply()); 230 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_ResetReply());
232 } 231 }
233 232
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 ASSERT_FALSE(uncalled_cb.called()); 423 ASSERT_FALSE(uncalled_cb.called());
425 // Free up the first decode buffer. 424 // Free up the first decode buffer.
426 SendDecodeReply(params, 0U); 425 SendDecodeReply(params, 0U);
427 // The decoder should run the pending callback. 426 // The decoder should run the pending callback.
428 ASSERT_TRUE(decode_cb.called()); 427 ASSERT_TRUE(decode_cb.called());
429 ASSERT_EQ(PP_OK, decode_cb.result()); 428 ASSERT_EQ(PP_OK, decode_cb.result());
430 decode_cb.Reset(); 429 decode_cb.Reset();
431 430
432 // Now try to get a picture. No picture ready message has been received yet. 431 // Now try to get a picture. No picture ready message has been received yet.
433 PP_VideoPicture picture; 432 PP_VideoPicture picture;
433 PP_Rect visible_rect;
434 ASSERT_EQ(PP_OK_COMPLETIONPENDING, 434 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
435 CallGetPicture(decoder.get(), &picture, &get_picture_cb)); 435 CallGetPicture(decoder.get(), &picture, &get_picture_cb));
436 ASSERT_FALSE(get_picture_cb.called()); 436 ASSERT_FALSE(get_picture_cb.called());
437 // Calling GetPicture when another GetPicture is pending should fail. 437 // Calling GetPicture when another GetPicture is pending should fail.
438 ASSERT_EQ(PP_ERROR_INPROGRESS, 438 ASSERT_EQ(PP_ERROR_INPROGRESS,
439 CallGetPicture(decoder.get(), &picture, &uncalled_cb)); 439 CallGetPicture(decoder.get(), &picture, &uncalled_cb));
440 ASSERT_FALSE(uncalled_cb.called()); 440 ASSERT_FALSE(uncalled_cb.called());
441 // Send 'request textures' message to initialize textures. 441 // Send 'request textures' message to initialize textures.
442 SendRequestTextures(params); 442 SendRequestTextures(params);
443 // Send a picture ready message for Decode call 1. The GetPicture callback 443 // Send a picture ready message for Decode call 1. The GetPicture callback
444 // should complete. 444 // should complete.
445 SendPictureReady(params, 1U, kTextureId1); 445 SendPictureReady(params, 1U, kTextureId1, &visible_rect);
446 ASSERT_TRUE(get_picture_cb.called()); 446 ASSERT_TRUE(get_picture_cb.called());
447 ASSERT_EQ(PP_OK, get_picture_cb.result()); 447 ASSERT_EQ(PP_OK, get_picture_cb.result());
448 ASSERT_EQ(kDecodeId, picture.decode_id); 448 ASSERT_EQ(kDecodeId, picture.decode_id);
449 get_picture_cb.Reset(); 449 get_picture_cb.Reset();
450 450
451 // Send a picture ready message for Decode call 2. Since there is no pending 451 // Send a picture ready message for Decode call 2. Since there is no pending
452 // GetPicture call, the picture should be queued. 452 // GetPicture call, the picture should be queued.
453 SendPictureReady(params, 2U, kTextureId2); 453 SendPictureReady(params, 2U, kTextureId2, &visible_rect);
454 // The next GetPicture should return synchronously. 454 // The next GetPicture should return synchronously.
455 ASSERT_EQ(PP_OK, CallGetPicture(decoder.get(), &picture, &uncalled_cb)); 455 ASSERT_EQ(PP_OK, CallGetPicture(decoder.get(), &picture, &uncalled_cb));
456 ASSERT_FALSE(uncalled_cb.called()); 456 ASSERT_FALSE(uncalled_cb.called());
457 ASSERT_EQ(kDecodeId, picture.decode_id); 457 ASSERT_EQ(kDecodeId, picture.decode_id);
458 } 458 }
459 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 459 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
460 460
461 // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply 461 // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply
462 // message for GetShm isn't received, causing Decode to fail. 462 // message for GetShm isn't received, causing Decode to fail.
463 // http://crbug.com/379260 463 // http://crbug.com/379260
464 #if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 464 #if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
465 TEST_F(VideoDecoderResourceTest, RecyclePicture) { 465 TEST_F(VideoDecoderResourceTest, RecyclePicture) {
466 LockingResourceReleaser decoder(CreateAndInitializeDecoder()); 466 LockingResourceReleaser decoder(CreateAndInitializeDecoder());
467 ResourceMessageCallParams params; 467 ResourceMessageCallParams params;
468 MockCompletionCallback decode_cb, get_picture_cb, uncalled_cb; 468 MockCompletionCallback decode_cb, get_picture_cb, uncalled_cb;
469 469
470 // Get to a state where we have a picture to recycle. 470 // Get to a state where we have a picture to recycle.
471 PpapiHostMsg_VideoDecoder_GetShm shm_msg(0U, kDecodeBufferSize); 471 PpapiHostMsg_VideoDecoder_GetShm shm_msg(0U, kDecodeBufferSize);
472 ASSERT_EQ(PP_OK, CallDecode(decoder.get(), &decode_cb, &shm_msg)); 472 ASSERT_EQ(PP_OK, CallDecode(decoder.get(), &decode_cb, &shm_msg));
473 uint32_t shm_id; 473 uint32_t shm_id;
474 uint32_t decode_size; 474 uint32_t decode_size;
475 int32_t decode_id; 475 int32_t decode_id;
476 CheckDecodeMsg(&params, &shm_id, &decode_size, &decode_id); 476 CheckDecodeMsg(&params, &shm_id, &decode_size, &decode_id);
477 SendDecodeReply(params, 0U); 477 SendDecodeReply(params, 0U);
478 // Send 'request textures' message to initialize textures. 478 // Send 'request textures' message to initialize textures.
479 SendRequestTextures(params); 479 SendRequestTextures(params);
480 // Call GetPicture and send 'picture ready' message to get a picture to 480 // Call GetPicture and send 'picture ready' message to get a picture to
481 // recycle. 481 // recycle.
482 PP_VideoPicture picture; 482 PP_VideoPicture picture;
483 PP_Rect visible_rect;
483 ASSERT_EQ(PP_OK_COMPLETIONPENDING, 484 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
484 CallGetPicture(decoder.get(), &picture, &get_picture_cb)); 485 CallGetPicture(decoder.get(), &picture, &get_picture_cb));
485 SendPictureReady(params, 0U, kTextureId1); 486 SendPictureReady(params, 0U, kTextureId1, &visible_rect);
486 ASSERT_EQ(kTextureId1, picture.texture_id); 487 ASSERT_EQ(kTextureId1, picture.texture_id);
487 488
488 CallRecyclePicture(decoder.get(), picture); 489 CallRecyclePicture(decoder.get(), picture);
489 uint32_t texture_id; 490 uint32_t texture_id;
490 ASSERT_TRUE(CheckRecyclePictureMsg(&params, &texture_id)); 491 ASSERT_TRUE(CheckRecyclePictureMsg(&params, &texture_id));
491 ASSERT_EQ(kTextureId1, texture_id); 492 ASSERT_EQ(kTextureId1, texture_id);
492 493
493 ClearCallbacks(decoder.get()); 494 ClearCallbacks(decoder.get());
494 } 495 }
495 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 496 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 ASSERT_FALSE(uncalled_cb.called()); 574 ASSERT_FALSE(uncalled_cb.called());
574 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); 575 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb));
575 ASSERT_FALSE(uncalled_cb.called()); 576 ASSERT_FALSE(uncalled_cb.called());
576 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); 577 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb));
577 ASSERT_FALSE(uncalled_cb.called()); 578 ASSERT_FALSE(uncalled_cb.called());
578 } 579 }
579 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 580 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
580 581
581 } // namespace proxy 582 } // namespace proxy
582 } // namespace ppapi 583 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698