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/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 bitmap.setInfo(info); | 490 bitmap.setInfo(info); |
491 bitmap.setPixelRef(pixelRef)->unref(); | 491 bitmap.setPixelRef(pixelRef)->unref(); |
492 } | 492 } |
493 | 493 |
494 return true; | 494 return true; |
495 } | 495 } |
496 | 496 |
497 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, | 497 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
498 const blink::WebRect& rect, | 498 const blink::WebRect& rect, |
499 unsigned char alpha) { | 499 unsigned char alpha) { |
| 500 paint(canvas, rect, alpha, SkXfermode::kSrcOver_Mode); |
| 501 } |
| 502 |
| 503 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
| 504 const blink::WebRect& rect, |
| 505 unsigned char alpha, |
| 506 SkXfermode::Mode mode) { |
500 scoped_ptr<blink::WebGraphicsContext3DProvider> provider = | 507 scoped_ptr<blink::WebGraphicsContext3DProvider> provider = |
501 scoped_ptr<blink::WebGraphicsContext3DProvider>(blink::Platform::current( | 508 scoped_ptr<blink::WebGraphicsContext3DProvider>(blink::Platform::current( |
502 )->createSharedOffscreenGraphicsContext3DProvider()); | 509 )->createSharedOffscreenGraphicsContext3DProvider()); |
503 if (!provider) | 510 if (!provider) |
504 return; | 511 return; |
505 blink::WebGraphicsContext3D* context3D = provider->context3d(); | 512 blink::WebGraphicsContext3D* context3D = provider->context3d(); |
506 if (!context3D || !context3D->makeContextCurrent()) | 513 if (!context3D || !context3D->makeContextCurrent()) |
507 return; | 514 return; |
508 | 515 |
509 // Copy video texture into a RGBA texture based bitmap first as video texture | 516 // Copy video texture into a RGBA texture based bitmap first as video texture |
(...skipping 15 matching lines...) Expand all Loading... |
525 } | 532 } |
526 | 533 |
527 // Draw the texture based bitmap onto the Canvas. If the canvas is | 534 // Draw the texture based bitmap onto the Canvas. If the canvas is |
528 // hardware based, this will do a GPU-GPU texture copy. | 535 // hardware based, this will do a GPU-GPU texture copy. |
529 // If the canvas is software based, the texture based bitmap will be | 536 // If the canvas is software based, the texture based bitmap will be |
530 // readbacked to system memory then draw onto the canvas. | 537 // readbacked to system memory then draw onto the canvas. |
531 SkRect dest; | 538 SkRect dest; |
532 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); | 539 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); |
533 SkPaint paint; | 540 SkPaint paint; |
534 paint.setAlpha(alpha); | 541 paint.setAlpha(alpha); |
| 542 paint.setXfermodeMode(mode); |
535 // It is not necessary to pass the dest into the drawBitmap call since all | 543 // It is not necessary to pass the dest into the drawBitmap call since all |
536 // the context have been set up before calling paintCurrentFrameInContext. | 544 // the context have been set up before calling paintCurrentFrameInContext. |
537 canvas->drawBitmapRect(bitmap_, 0, dest, &paint); | 545 canvas->drawBitmapRect(bitmap_, 0, dest, &paint); |
538 } | 546 } |
539 | 547 |
540 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( | 548 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( |
541 blink::WebGraphicsContext3D* web_graphics_context, | 549 blink::WebGraphicsContext3D* web_graphics_context, |
542 unsigned int texture, | 550 unsigned int texture, |
543 unsigned int level, | 551 unsigned int level, |
544 unsigned int internal_format, | 552 unsigned int internal_format, |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 player_manager_->EnterFullscreen(player_id_, frame_); | 1628 player_manager_->EnterFullscreen(player_id_, frame_); |
1621 SetNeedsEstablishPeer(false); | 1629 SetNeedsEstablishPeer(false); |
1622 } | 1630 } |
1623 } | 1631 } |
1624 | 1632 |
1625 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1633 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
1626 return player_manager_->CanEnterFullscreen(frame_); | 1634 return player_manager_->CanEnterFullscreen(frame_); |
1627 } | 1635 } |
1628 | 1636 |
1629 } // namespace content | 1637 } // namespace content |
OLD | NEW |