| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "base/android/build_info.h" | 11 #include "base/android/build_info.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "cc/blink/web_layer_impl.h" | 22 #include "cc/blink/web_layer_impl.h" |
| 23 #include "cc/layers/video_layer.h" | 23 #include "cc/layers/video_layer.h" |
| 24 #include "cc/paint/paint_flags.h" |
| 24 #include "content/public/common/content_client.h" | 25 #include "content/public/common/content_client.h" |
| 25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/renderer_preferences.h" | 27 #include "content/public/common/renderer_preferences.h" |
| 27 #include "content/public/renderer/render_frame.h" | 28 #include "content/public/renderer/render_frame.h" |
| 28 #include "content/renderer/media/android/renderer_media_player_manager.h" | 29 #include "content/renderer/media/android/renderer_media_player_manager.h" |
| 29 #include "content/renderer/render_frame_impl.h" | 30 #include "content/renderer/render_frame_impl.h" |
| 30 #include "content/renderer/render_thread_impl.h" | 31 #include "content/renderer/render_thread_impl.h" |
| 31 #include "content/renderer/render_view_impl.h" | 32 #include "content/renderer/render_view_impl.h" |
| 32 #include "gpu/GLES2/gl2extchromium.h" | 33 #include "gpu/GLES2/gl2extchromium.h" |
| 33 #include "gpu/command_buffer/client/gles2_interface.h" | 34 #include "gpu/command_buffer/client/gles2_interface.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" | 58 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.
h" |
| 58 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 59 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
| 59 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 60 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 60 #include "third_party/WebKit/public/platform/WebString.h" | 61 #include "third_party/WebKit/public/platform/WebString.h" |
| 61 #include "third_party/WebKit/public/platform/WebURL.h" | 62 #include "third_party/WebKit/public/platform/WebURL.h" |
| 62 #include "third_party/WebKit/public/web/WebDocument.h" | 63 #include "third_party/WebKit/public/web/WebDocument.h" |
| 63 #include "third_party/WebKit/public/web/WebFrame.h" | 64 #include "third_party/WebKit/public/web/WebFrame.h" |
| 64 #include "third_party/WebKit/public/web/WebView.h" | 65 #include "third_party/WebKit/public/web/WebView.h" |
| 65 #include "third_party/skia/include/core/SkCanvas.h" | 66 #include "third_party/skia/include/core/SkCanvas.h" |
| 66 #include "third_party/skia/include/core/SkImage.h" | 67 #include "third_party/skia/include/core/SkImage.h" |
| 67 #include "third_party/skia/include/core/SkPaint.h" | |
| 68 #include "third_party/skia/include/core/SkTypeface.h" | 68 #include "third_party/skia/include/core/SkTypeface.h" |
| 69 #include "ui/gfx/image/image.h" | 69 #include "ui/gfx/image/image.h" |
| 70 #include "url/gurl.h" | 70 #include "url/gurl.h" |
| 71 #include "url/origin.h" | 71 #include "url/origin.h" |
| 72 | 72 |
| 73 static const uint32_t kGLTextureExternalOES = 0x8D65; | 73 static const uint32_t kGLTextureExternalOES = 0x8D65; |
| 74 static const int kSDKVersionToSupportSecurityOriginCheck = 20; | 74 static const int kSDKVersionToSupportSecurityOriginCheck = 20; |
| 75 | 75 |
| 76 using blink::WebMediaPlayer; | 76 using blink::WebMediaPlayer; |
| 77 using blink::WebSize; | 77 using blink::WebSize; |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 500 } |
| 501 | 501 |
| 502 bool WebMediaPlayerAndroid::didLoadingProgress() { | 502 bool WebMediaPlayerAndroid::didLoadingProgress() { |
| 503 bool ret = did_loading_progress_; | 503 bool ret = did_loading_progress_; |
| 504 did_loading_progress_ = false; | 504 did_loading_progress_ = false; |
| 505 return ret; | 505 return ret; |
| 506 } | 506 } |
| 507 | 507 |
| 508 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, | 508 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas, |
| 509 const blink::WebRect& rect, | 509 const blink::WebRect& rect, |
| 510 SkPaint& paint) { | 510 cc::PaintFlags& paint) { |
| 511 DCHECK(main_thread_checker_.CalledOnValidThread()); | 511 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 512 std::unique_ptr<blink::WebGraphicsContext3DProvider> provider( | 512 std::unique_ptr<blink::WebGraphicsContext3DProvider> provider( |
| 513 blink::Platform::current() | 513 blink::Platform::current() |
| 514 ->createSharedOffscreenGraphicsContext3DProvider()); | 514 ->createSharedOffscreenGraphicsContext3DProvider()); |
| 515 if (!provider) | 515 if (!provider) |
| 516 return; | 516 return; |
| 517 gpu::gles2::GLES2Interface* gl = provider->contextGL(); | 517 gpu::gles2::GLES2Interface* gl = provider->contextGL(); |
| 518 | 518 |
| 519 scoped_refptr<VideoFrame> video_frame; | 519 scoped_refptr<VideoFrame> video_frame; |
| 520 { | 520 { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 548 kOpaque_SkAlphaType)); | 548 kOpaque_SkAlphaType)); |
| 549 if (!image) | 549 if (!image) |
| 550 return; | 550 return; |
| 551 | 551 |
| 552 // Draw the texture based image onto the Canvas. If the canvas is | 552 // Draw the texture based image onto the Canvas. If the canvas is |
| 553 // hardware based, this will do a GPU-GPU texture copy. | 553 // hardware based, this will do a GPU-GPU texture copy. |
| 554 // If the canvas is software based, the texture based bitmap will be | 554 // If the canvas is software based, the texture based bitmap will be |
| 555 // readbacked to system memory then draw onto the canvas. | 555 // readbacked to system memory then draw onto the canvas. |
| 556 SkRect dest; | 556 SkRect dest; |
| 557 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); | 557 dest.set(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); |
| 558 SkPaint video_paint; | 558 cc::PaintFlags video_paint; |
| 559 video_paint.setAlpha(paint.getAlpha()); | 559 video_paint.setAlpha(paint.getAlpha()); |
| 560 video_paint.setBlendMode(paint.getBlendMode()); | 560 video_paint.setBlendMode(paint.getBlendMode()); |
| 561 // It is not necessary to pass the dest into the drawBitmap call since all | 561 // It is not necessary to pass the dest into the drawBitmap call since all |
| 562 // the context have been set up before calling paintCurrentFrameInContext. | 562 // the context have been set up before calling paintCurrentFrameInContext. |
| 563 canvas->drawImageRect(image, dest, &video_paint); | 563 canvas->drawImageRect(image, dest, &video_paint); |
| 564 | 564 |
| 565 // Ensure the Skia draw of the GL texture is flushed to GL, delete the | 565 // Ensure the Skia draw of the GL texture is flushed to GL, delete the |
| 566 // mailboxed texture from this context, and then signal that we're done with | 566 // mailboxed texture from this context, and then signal that we're done with |
| 567 // the video frame. | 567 // the video frame. |
| 568 canvas->flush(); | 568 canvas->flush(); |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 switches::kDisableMediaSuspend)) { | 1331 switches::kDisableMediaSuspend)) { |
| 1332 return false; | 1332 return false; |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && | 1335 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && |
| 1336 hasAudio() && !isRemote() && delegate_ && delegate_->IsFrameHidden() && | 1336 hasAudio() && !isRemote() && delegate_ && delegate_->IsFrameHidden() && |
| 1337 !delegate_->IsFrameClosed(); | 1337 !delegate_->IsFrameClosed(); |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 } // namespace content | 1340 } // namespace content |
| OLD | NEW |