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