| 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 bitmap.setInfo(info); | 489 bitmap.setInfo(info); |
| 490 bitmap.setPixelRef(pixelRef)->unref(); | 490 bitmap.setPixelRef(pixelRef)->unref(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 return true; | 493 return true; |
| 494 } | 494 } |
| 495 | 495 |
| 496 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, | 496 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
| 497 const blink::WebRect& rect, | 497 const blink::WebRect& rect, |
| 498 unsigned char alpha) { | 498 unsigned char alpha) { |
| 499 paint(canvas, rect, alpha, SkXfermode::kSrcOver_Mode); |
| 500 } |
| 501 |
| 502 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
| 503 const blink::WebRect& rect, |
| 504 unsigned char alpha, |
| 505 SkXfermode::Mode mode) { |
| 499 scoped_ptr<blink::WebGraphicsContext3DProvider> provider = | 506 scoped_ptr<blink::WebGraphicsContext3DProvider> provider = |
| 500 scoped_ptr<blink::WebGraphicsContext3DProvider>(blink::Platform::current( | 507 scoped_ptr<blink::WebGraphicsContext3DProvider>(blink::Platform::current( |
| 501 )->createSharedOffscreenGraphicsContext3DProvider()); | 508 )->createSharedOffscreenGraphicsContext3DProvider()); |
| 502 if (!provider) | 509 if (!provider) |
| 503 return; | 510 return; |
| 504 blink::WebGraphicsContext3D* context3D = provider->context3d(); | 511 blink::WebGraphicsContext3D* context3D = provider->context3d(); |
| 505 if (!context3D || !context3D->makeContextCurrent()) | 512 if (!context3D || !context3D->makeContextCurrent()) |
| 506 return; | 513 return; |
| 507 | 514 |
| 508 // Copy video texture into a RGBA texture based bitmap first as video texture | 515 // Copy video texture into a RGBA texture based bitmap first as video texture |
| (...skipping 15 matching lines...) Expand all Loading... |
| 524 } | 531 } |
| 525 | 532 |
| 526 // Draw the texture based bitmap onto the Canvas. If the canvas is | 533 // Draw the texture based bitmap onto the Canvas. If the canvas is |
| 527 // hardware based, this will do a GPU-GPU texture copy. | 534 // hardware based, this will do a GPU-GPU texture copy. |
| 528 // If the canvas is software based, the texture based bitmap will be | 535 // If the canvas is software based, the texture based bitmap will be |
| 529 // readbacked to system memory then draw onto the canvas. | 536 // readbacked to system memory then draw onto the canvas. |
| 530 SkRect dest; | 537 SkRect dest; |
| 531 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); | 538 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); |
| 532 SkPaint paint; | 539 SkPaint paint; |
| 533 paint.setAlpha(alpha); | 540 paint.setAlpha(alpha); |
| 541 paint.setXfermodeMode(mode); |
| 534 // It is not necessary to pass the dest into the drawBitmap call since all | 542 // It is not necessary to pass the dest into the drawBitmap call since all |
| 535 // the context have been set up before calling paintCurrentFrameInContext. | 543 // the context have been set up before calling paintCurrentFrameInContext. |
| 536 canvas->drawBitmapRect(bitmap_, 0, dest, &paint); | 544 canvas->drawBitmapRect(bitmap_, 0, dest, &paint); |
| 537 } | 545 } |
| 538 | 546 |
| 539 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( | 547 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( |
| 540 blink::WebGraphicsContext3D* web_graphics_context, | 548 blink::WebGraphicsContext3D* web_graphics_context, |
| 541 unsigned int texture, | 549 unsigned int texture, |
| 542 unsigned int level, | 550 unsigned int level, |
| 543 unsigned int internal_format, | 551 unsigned int internal_format, |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 player_manager_->EnterFullscreen(player_id_, frame_); | 1610 player_manager_->EnterFullscreen(player_id_, frame_); |
| 1603 SetNeedsEstablishPeer(false); | 1611 SetNeedsEstablishPeer(false); |
| 1604 } | 1612 } |
| 1605 } | 1613 } |
| 1606 | 1614 |
| 1607 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1615 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1608 return player_manager_->CanEnterFullscreen(frame_); | 1616 return player_manager_->CanEnterFullscreen(frame_); |
| 1609 } | 1617 } |
| 1610 | 1618 |
| 1611 } // namespace content | 1619 } // namespace content |
| OLD | NEW |