OLD | NEW |
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/pp_rect.h" |
10 #include "ppapi/c/ppb_video_decoder.h" | 11 #include "ppapi/c/ppb_video_decoder.h" |
11 #include "ppapi/proxy/locking_resource_releaser.h" | 12 #include "ppapi/proxy/locking_resource_releaser.h" |
12 #include "ppapi/proxy/plugin_message_filter.h" | 13 #include "ppapi/proxy/plugin_message_filter.h" |
13 #include "ppapi/proxy/ppapi_message_utils.h" | 14 #include "ppapi/proxy/ppapi_message_utils.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 15 #include "ppapi/proxy/ppapi_messages.h" |
15 #include "ppapi/proxy/ppapi_proxy_test.h" | 16 #include "ppapi/proxy/ppapi_proxy_test.h" |
16 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" | 17 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
17 #include "ppapi/proxy/video_decoder_constants.h" | 18 #include "ppapi/proxy/video_decoder_constants.h" |
18 #include "ppapi/proxy/video_decoder_resource.h" | 19 #include "ppapi/proxy/video_decoder_resource.h" |
19 #include "ppapi/shared_impl/proxy_lock.h" | 20 #include "ppapi/shared_impl/proxy_lock.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 52 } |
52 | 53 |
53 private: | 54 private: |
54 bool called_; | 55 bool called_; |
55 int32_t result_; | 56 int32_t result_; |
56 }; | 57 }; |
57 | 58 |
58 class VideoDecoderResourceTest : public PluginProxyTest { | 59 class VideoDecoderResourceTest : public PluginProxyTest { |
59 public: | 60 public: |
60 VideoDecoderResourceTest() | 61 VideoDecoderResourceTest() |
61 : decoder_iface_(thunk::GetPPB_VideoDecoder_0_2_Thunk()) {} | 62 : decoder_iface_(thunk::GetPPB_VideoDecoder_1_0_Thunk()) {} |
62 | 63 |
63 const PPB_VideoDecoder_0_2* decoder_iface() const { return decoder_iface_; } | 64 const PPB_VideoDecoder_1_0* decoder_iface() const { return decoder_iface_; } |
64 | 65 |
65 void SendReply(const ResourceMessageCallParams& params, | 66 void SendReply(const ResourceMessageCallParams& params, |
66 int32_t result, | 67 int32_t result, |
67 const IPC::Message& nested_message) { | 68 const IPC::Message& nested_message) { |
68 ResourceMessageReplyParams reply_params(params.pp_resource(), | 69 ResourceMessageReplyParams reply_params(params.pp_resource(), |
69 params.sequence()); | 70 params.sequence()); |
70 reply_params.set_result(result); | 71 reply_params.set_result(result); |
71 PluginMessageFilter::DispatchResourceReplyForTest(reply_params, | 72 PluginMessageFilter::DispatchResourceReplyForTest(reply_params, |
72 nested_message); | 73 nested_message); |
73 } | 74 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 211 } |
211 | 212 |
212 void SendDecodeReply(const ResourceMessageCallParams& params, | 213 void SendDecodeReply(const ResourceMessageCallParams& params, |
213 uint32_t shm_id) { | 214 uint32_t shm_id) { |
214 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_DecodeReply(shm_id)); | 215 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_DecodeReply(shm_id)); |
215 } | 216 } |
216 | 217 |
217 void SendPictureReady(const ResourceMessageCallParams& params, | 218 void SendPictureReady(const ResourceMessageCallParams& params, |
218 uint32_t decode_count, | 219 uint32_t decode_count, |
219 uint32_t texture_id) { | 220 uint32_t texture_id) { |
220 SendReply( | 221 PP_Rect visible_rect = PP_MakeRectFromXYWH(0, 0, 640, 480); |
221 params, | 222 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_PictureReady( |
222 PP_OK, | 223 decode_count, texture_id, visible_rect)); |
223 PpapiPluginMsg_VideoDecoder_PictureReady(decode_count, texture_id)); | |
224 } | 224 } |
225 | 225 |
226 void SendFlushReply(const ResourceMessageCallParams& params) { | 226 void SendFlushReply(const ResourceMessageCallParams& params) { |
227 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_FlushReply()); | 227 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_FlushReply()); |
228 } | 228 } |
229 | 229 |
230 void SendResetReply(const ResourceMessageCallParams& params) { | 230 void SendResetReply(const ResourceMessageCallParams& params) { |
231 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_ResetReply()); | 231 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_ResetReply()); |
232 } | 232 } |
233 | 233 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 private: | 292 private: |
293 bool CheckMsg(ResourceMessageCallParams* params, int id) { | 293 bool CheckMsg(ResourceMessageCallParams* params, int id) { |
294 IPC::Message msg; | 294 IPC::Message msg; |
295 if (!sink().GetFirstResourceCallMatching(id, params, &msg)) | 295 if (!sink().GetFirstResourceCallMatching(id, params, &msg)) |
296 return false; | 296 return false; |
297 sink().ClearMessages(); | 297 sink().ClearMessages(); |
298 return true; | 298 return true; |
299 } | 299 } |
300 | 300 |
301 const PPB_VideoDecoder_0_2* decoder_iface_; | 301 const PPB_VideoDecoder_1_0* decoder_iface_; |
302 | 302 |
303 char decode_buffer_[kDecodeBufferSize]; | 303 char decode_buffer_[kDecodeBufferSize]; |
304 }; | 304 }; |
305 | 305 |
306 } // namespace | 306 } // namespace |
307 | 307 |
308 TEST_F(VideoDecoderResourceTest, Initialize) { | 308 TEST_F(VideoDecoderResourceTest, Initialize) { |
309 // Initialize with 0 graphics3d_context should fail. | 309 // Initialize with 0 graphics3d_context should fail. |
310 { | 310 { |
311 LockingResourceReleaser decoder(CreateDecoder()); | 311 LockingResourceReleaser decoder(CreateDecoder()); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 ASSERT_FALSE(uncalled_cb.called()); | 573 ASSERT_FALSE(uncalled_cb.called()); |
574 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); | 574 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); |
575 ASSERT_FALSE(uncalled_cb.called()); | 575 ASSERT_FALSE(uncalled_cb.called()); |
576 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); | 576 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); |
577 ASSERT_FALSE(uncalled_cb.called()); | 577 ASSERT_FALSE(uncalled_cb.called()); |
578 } | 578 } |
579 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) | 579 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) |
580 | 580 |
581 } // namespace proxy | 581 } // namespace proxy |
582 } // namespace ppapi | 582 } // namespace ppapi |
OLD | NEW |