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 "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
11 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
12 #include "ppapi/c/ppb_opengles2.h" | 13 #include "ppapi/c/ppb_opengles2.h" |
13 #include "ppapi/proxy/plugin_dispatcher.h" | 14 #include "ppapi/proxy/plugin_dispatcher.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 15 #include "ppapi/proxy/ppapi_messages.h" |
15 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" | 16 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
16 #include "ppapi/proxy/serialized_handle.h" | 17 #include "ppapi/proxy/serialized_handle.h" |
17 #include "ppapi/proxy/video_decoder_constants.h" | 18 #include "ppapi/proxy/video_decoder_constants.h" |
18 #include "ppapi/shared_impl/ppapi_globals.h" | 19 #include "ppapi/shared_impl/ppapi_globals.h" |
19 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 20 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // create textures on a proxy thread, and would interfere with the plugin. | 106 // create textures on a proxy thread, and would interfere with the plugin. |
106 thunk::EnterResourceCreationNoLock enter_create(pp_instance()); | 107 thunk::EnterResourceCreationNoLock enter_create(pp_instance()); |
107 if (enter_create.failed()) | 108 if (enter_create.failed()) |
108 return PP_ERROR_FAILED; | 109 return PP_ERROR_FAILED; |
109 int32_t attrib_list[] = {PP_GRAPHICS3DATTRIB_NONE}; | 110 int32_t attrib_list[] = {PP_GRAPHICS3DATTRIB_NONE}; |
110 graphics3d_ = | 111 graphics3d_ = |
111 ScopedPPResource(ScopedPPResource::PassRef(), | 112 ScopedPPResource(ScopedPPResource::PassRef(), |
112 enter_create.functions()->CreateGraphics3D( | 113 enter_create.functions()->CreateGraphics3D( |
113 pp_instance(), graphics_context, attrib_list)); | 114 pp_instance(), graphics_context, attrib_list)); |
114 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics(graphics3d_.get(), | 115 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics(graphics3d_.get(), |
115 true); | 116 false); |
116 if (enter_graphics.failed()) | 117 if (enter_graphics.failed()) |
117 return PP_ERROR_BADRESOURCE; | 118 return PP_ERROR_BADRESOURCE; |
118 | 119 |
119 PPB_Graphics3D_Shared* ppb_graphics3d_shared = | 120 PPB_Graphics3D_Shared* ppb_graphics3d_shared = |
120 static_cast<PPB_Graphics3D_Shared*>(enter_graphics.object()); | 121 static_cast<PPB_Graphics3D_Shared*>(enter_graphics.object()); |
121 gles2_impl_ = ppb_graphics3d_shared->gles2_impl(); | 122 gles2_impl_ = ppb_graphics3d_shared->gles2_impl(); |
122 host_resource = ppb_graphics3d_shared->host_resource(); | 123 host_resource = ppb_graphics3d_shared->host_resource(); |
123 } | 124 } |
124 | 125 |
125 initialize_callback_ = callback; | 126 initialize_callback_ = callback; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 326 } |
326 | 327 |
327 void VideoDecoderResource::SetForTest() { | 328 void VideoDecoderResource::SetForTest() { |
328 testing_ = true; | 329 testing_ = true; |
329 } | 330 } |
330 | 331 |
331 void VideoDecoderResource::OnPluginMsgRequestTextures( | 332 void VideoDecoderResource::OnPluginMsgRequestTextures( |
332 const ResourceMessageReplyParams& params, | 333 const ResourceMessageReplyParams& params, |
333 uint32_t num_textures, | 334 uint32_t num_textures, |
334 const PP_Size& size, | 335 const PP_Size& size, |
335 uint32_t texture_target) { | 336 uint32_t texture_target, |
| 337 const std::vector<gpu::Mailbox>& mailboxes) { |
336 DCHECK(num_textures); | 338 DCHECK(num_textures); |
| 339 DCHECK(mailboxes.empty() || mailboxes.size() == num_textures); |
337 std::vector<uint32_t> texture_ids(num_textures); | 340 std::vector<uint32_t> texture_ids(num_textures); |
338 if (gles2_impl_) { | 341 if (gles2_impl_) { |
339 gles2_impl_->GenTextures(num_textures, &texture_ids.front()); | 342 gles2_impl_->GenTextures(num_textures, &texture_ids.front()); |
340 for (uint32_t i = 0; i < num_textures; ++i) { | 343 for (uint32_t i = 0; i < num_textures; ++i) { |
341 gles2_impl_->ActiveTexture(GL_TEXTURE0); | 344 gles2_impl_->ActiveTexture(GL_TEXTURE0); |
342 gles2_impl_->BindTexture(texture_target, texture_ids[i]); | 345 gles2_impl_->BindTexture(texture_target, texture_ids[i]); |
343 gles2_impl_->TexParameteri( | 346 gles2_impl_->TexParameteri( |
344 texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 347 texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
345 gles2_impl_->TexParameteri( | 348 gles2_impl_->TexParameteri( |
346 texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 349 texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
347 gles2_impl_->TexParameterf( | 350 gles2_impl_->TexParameterf( |
348 texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 351 texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
349 gles2_impl_->TexParameterf( | 352 gles2_impl_->TexParameterf( |
350 texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 353 texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
351 | 354 |
352 if (texture_target == GL_TEXTURE_2D) { | 355 if (texture_target == GL_TEXTURE_2D) { |
353 gles2_impl_->TexImage2D(texture_target, | 356 gles2_impl_->TexImage2D(texture_target, |
354 0, | 357 0, |
355 GL_RGBA, | 358 GL_RGBA, |
356 size.width, | 359 size.width, |
357 size.height, | 360 size.height, |
358 0, | 361 0, |
359 GL_RGBA, | 362 GL_RGBA, |
360 GL_UNSIGNED_BYTE, | 363 GL_UNSIGNED_BYTE, |
361 NULL); | 364 NULL); |
362 } | 365 } |
| 366 if (!mailboxes.empty()) { |
| 367 gles2_impl_->ProduceTextureCHROMIUM( |
| 368 GL_TEXTURE_2D, reinterpret_cast<const GLbyte*>(mailboxes[i].name)); |
| 369 } |
363 | 370 |
364 textures_.insert( | 371 textures_.insert( |
365 std::make_pair(texture_ids[i], Texture(texture_target, size))); | 372 std::make_pair(texture_ids[i], Texture(texture_target, size))); |
366 } | 373 } |
367 gles2_impl_->Flush(); | 374 gles2_impl_->Flush(); |
368 } else { | 375 } else { |
369 DCHECK(testing_); | 376 DCHECK(testing_); |
370 // Create some fake texture ids so we can test picture handling. | 377 // Create some fake texture ids so we can test picture handling. |
371 for (uint32_t i = 0; i < num_textures; ++i) { | 378 for (uint32_t i = 0; i < num_textures; ++i) { |
372 texture_ids[i] = i + 1; | 379 texture_ids[i] = i + 1; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 pp_picture->texture_target = it->second.texture_target; | 504 pp_picture->texture_target = it->second.texture_target; |
498 pp_picture->texture_size = it->second.size; | 505 pp_picture->texture_size = it->second.size; |
499 } else { | 506 } else { |
500 NOTREACHED(); | 507 NOTREACHED(); |
501 } | 508 } |
502 received_pictures_.pop(); | 509 received_pictures_.pop(); |
503 } | 510 } |
504 | 511 |
505 } // namespace proxy | 512 } // namespace proxy |
506 } // namespace ppapi | 513 } // namespace ppapi |
OLD | NEW |