OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 435 |
436 // For hidden video element (with style "display:none"), ensure the texture | 436 // For hidden video element (with style "display:none"), ensure the texture |
437 // size is set. | 437 // size is set. |
438 if (cached_stream_texture_size_.width != natural_size_.width || | 438 if (cached_stream_texture_size_.width != natural_size_.width || |
439 cached_stream_texture_size_.height != natural_size_.height) { | 439 cached_stream_texture_size_.height != natural_size_.height) { |
440 stream_texture_factory_->SetStreamTextureSize( | 440 stream_texture_factory_->SetStreamTextureSize( |
441 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); | 441 stream_id_, gfx::Size(natural_size_.width, natural_size_.height)); |
442 cached_stream_texture_size_ = natural_size_; | 442 cached_stream_texture_size_ = natural_size_; |
443 } | 443 } |
444 | 444 |
| 445 uint32 source_texture = web_graphics_context->createTexture(); |
| 446 // This is strictly not necessary, because we flush when we create the |
| 447 // one and only stream texture. |
| 448 web_graphics_context->waitSyncPoint(texture_mailbox_sync_point_); |
| 449 |
445 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise | 450 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise |
446 // an invalid texture target may be used for copy texture. | 451 // an invalid texture target may be used for copy texture. |
447 web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id_); | 452 web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, source_texture); |
| 453 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, |
| 454 texture_mailbox_.name); |
448 | 455 |
449 // The video is stored in an unmultiplied format, so premultiply if | 456 // The video is stored in an unmultiplied format, so premultiply if |
450 // necessary. | 457 // necessary. |
451 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 458 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
452 premultiply_alpha); | 459 premultiply_alpha); |
453 | 460 |
454 // Application itself needs to take care of setting the right flip_y | 461 // Application itself needs to take care of setting the right flip_y |
455 // value down to get the expected result. | 462 // value down to get the expected result. |
456 // flip_y==true means to reverse the video orientation while | 463 // flip_y==true means to reverse the video orientation while |
457 // flip_y==false means to keep the intrinsic orientation. | 464 // flip_y==false means to keep the intrinsic orientation. |
458 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 465 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
459 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, | 466 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, source_texture, |
460 texture, level, internal_format, | 467 texture, level, internal_format, |
461 type); | 468 type); |
462 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 469 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
463 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 470 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
464 false); | 471 false); |
465 | 472 |
466 web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, 0); | 473 web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, 0); |
| 474 web_graphics_context->deleteTexture(source_texture); |
467 return true; | 475 return true; |
468 } | 476 } |
469 | 477 |
470 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { | 478 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { |
471 if (info_loader_) | 479 if (info_loader_) |
472 return info_loader_->HasSingleOrigin(); | 480 return info_loader_->HasSingleOrigin(); |
473 // The info loader may have failed. | 481 // The info loader may have failed. |
474 if (player_type_ == MEDIA_PLAYER_TYPE_URL) | 482 if (player_type_ == MEDIA_PLAYER_TYPE_URL) |
475 return false; | 483 return false; |
476 return true; | 484 return true; |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 | 1439 |
1432 void WebMediaPlayerAndroid::exitFullscreen() { | 1440 void WebMediaPlayerAndroid::exitFullscreen() { |
1433 manager_->ExitFullscreen(player_id_); | 1441 manager_->ExitFullscreen(player_id_); |
1434 } | 1442 } |
1435 | 1443 |
1436 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1444 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
1437 return manager_->CanEnterFullscreen(frame_); | 1445 return manager_->CanEnterFullscreen(frame_); |
1438 } | 1446 } |
1439 | 1447 |
1440 } // namespace content | 1448 } // namespace content |
OLD | NEW |