| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "media/gpu/android_video_decode_accelerator.h" | 5 #include "media/gpu/android_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 auto gles_decoder = get_gles2_decoder_cb_.Run(); | 470 auto gles_decoder = get_gles2_decoder_cb_.Run(); |
| 471 if (!gles_decoder) { | 471 if (!gles_decoder) { |
| 472 LOG(ERROR) << "Failed to get gles2 decoder instance."; | 472 LOG(ERROR) << "Failed to get gles2 decoder instance."; |
| 473 return false; | 473 return false; |
| 474 } | 474 } |
| 475 | 475 |
| 476 const gpu::GpuPreferences& gpu_preferences = | 476 const gpu::GpuPreferences& gpu_preferences = |
| 477 gles_decoder->GetContextGroup()->gpu_preferences(); | 477 gles_decoder->GetContextGroup()->gpu_preferences(); |
| 478 | 478 |
| 479 if (UseDeferredRenderingStrategy(gpu_preferences)) { | 479 if (UseDeferredRenderingStrategy(gpu_preferences)) { |
| 480 // TODO(liberato, watk): Figure out what we want to do about zero copy for | |
| 481 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. | |
| 482 DCHECK(!gles_decoder->GetContextGroup()->mailbox_manager()->UsesSync()); | |
| 483 DVLOG(1) << __FUNCTION__ << ", using deferred rendering strategy."; | 480 DVLOG(1) << __FUNCTION__ << ", using deferred rendering strategy."; |
| 484 strategy_.reset(new AndroidDeferredRenderingBackingStrategy(this)); | 481 strategy_.reset(new AndroidDeferredRenderingBackingStrategy(this)); |
| 485 } else { | 482 } else { |
| 486 DVLOG(1) << __FUNCTION__ << ", using copy back strategy."; | 483 DVLOG(1) << __FUNCTION__ << ", using copy back strategy."; |
| 487 strategy_.reset(new AndroidCopyingBackingStrategy(this)); | 484 strategy_.reset(new AndroidCopyingBackingStrategy(this)); |
| 488 } | 485 } |
| 489 | 486 |
| 490 if (!make_context_current_cb_.Run()) { | 487 if (!make_context_current_cb_.Run()) { |
| 491 LOG(ERROR) << "Failed to make this decoder's GL context current."; | 488 LOG(ERROR) << "Failed to make this decoder's GL context current."; |
| 492 return false; | 489 return false; |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 | 1568 |
| 1572 if (should_be_running) | 1569 if (should_be_running) |
| 1573 g_avda_timer.Pointer()->StartTimer(this); | 1570 g_avda_timer.Pointer()->StartTimer(this); |
| 1574 else | 1571 else |
| 1575 g_avda_timer.Pointer()->StopTimer(this); | 1572 g_avda_timer.Pointer()->StopTimer(this); |
| 1576 } | 1573 } |
| 1577 | 1574 |
| 1578 // static | 1575 // static |
| 1579 bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy( | 1576 bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy( |
| 1580 const gpu::GpuPreferences& gpu_preferences) { | 1577 const gpu::GpuPreferences& gpu_preferences) { |
| 1581 // TODO(liberato, watk): Figure out what we want to do about zero copy for | 1578 return true; |
| 1582 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. | |
| 1583 return !gpu_preferences.enable_threaded_texture_mailboxes; | |
| 1584 } | 1579 } |
| 1585 | 1580 |
| 1586 // static | 1581 // static |
| 1582 bool AndroidVideoDecodeAccelerator::RequiresTextureCopy( |
| 1583 const gpu::GpuPreferences& gpu_preferences) { |
| 1584 // http://crbug.com/582170 |
| 1585 return gpu_preferences.enable_threaded_texture_mailboxes; |
| 1586 } |
| 1587 |
| 1588 // static |
| 1587 media::VideoDecodeAccelerator::Capabilities | 1589 media::VideoDecodeAccelerator::Capabilities |
| 1588 AndroidVideoDecodeAccelerator::GetCapabilities( | 1590 AndroidVideoDecodeAccelerator::GetCapabilities( |
| 1589 const gpu::GpuPreferences& gpu_preferences) { | 1591 const gpu::GpuPreferences& gpu_preferences) { |
| 1590 Capabilities capabilities; | 1592 Capabilities capabilities; |
| 1591 SupportedProfiles& profiles = capabilities.supported_profiles; | 1593 SupportedProfiles& profiles = capabilities.supported_profiles; |
| 1592 | 1594 |
| 1593 // Only support VP8 on Android versions where we don't have to synchronously | 1595 // Only support VP8 on Android versions where we don't have to synchronously |
| 1594 // tear down the MediaCodec on surface destruction because VP8 requires | 1596 // tear down the MediaCodec on surface destruction because VP8 requires |
| 1595 // us to completely drain the decoder before releasing it, which is difficult | 1597 // us to completely drain the decoder before releasing it, which is difficult |
| 1596 // and time consuming to do while the surface is being destroyed. | 1598 // and time consuming to do while the surface is being destroyed. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 // software fallback for H264 on Android anyway. | 1642 // software fallback for H264 on Android anyway. |
| 1641 profile.max_resolution.SetSize(3840, 2160); | 1643 profile.max_resolution.SetSize(3840, 2160); |
| 1642 profiles.push_back(profile); | 1644 profiles.push_back(profile); |
| 1643 } | 1645 } |
| 1644 | 1646 |
| 1645 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: | 1647 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: |
| 1646 SUPPORTS_DEFERRED_INITIALIZATION; | 1648 SUPPORTS_DEFERRED_INITIALIZATION; |
| 1647 if (UseDeferredRenderingStrategy(gpu_preferences)) { | 1649 if (UseDeferredRenderingStrategy(gpu_preferences)) { |
| 1648 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1650 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
| 1649 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; | 1651 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; |
| 1652 if (RequiresTextureCopy(gpu_preferences)) { |
| 1653 capabilities.flags |= |
| 1654 media::VideoDecodeAccelerator::Capabilities::REQUIRES_TEXTURE_COPY; |
| 1655 } |
| 1650 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1656 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
| 1651 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1657 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
| 1652 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1658 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
| 1653 } | 1659 } |
| 1654 } | 1660 } |
| 1655 | 1661 |
| 1656 return capabilities; | 1662 return capabilities; |
| 1657 } | 1663 } |
| 1658 | 1664 |
| 1659 } // namespace media | 1665 } // namespace media |
| OLD | NEW |