diff options
author | wonsik@chromium.org <wonsik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 08:23:57 +0000 |
---|---|---|
committer | wonsik@chromium.org <wonsik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 08:23:57 +0000 |
commit | a3be04bdaab865ad66f45c3f8a1c433ec596fefc (patch) | |
tree | 4ba66a772fbd9b432766f13c05a9e0e0bff5f461 /content | |
parent | 85bbf09119661731bdc0138a67a97a3b9c1b2706 (diff) | |
download | chromium_src-a3be04bdaab865ad66f45c3f8a1c433ec596fefc.zip chromium_src-a3be04bdaab865ad66f45c3f8a1c433ec596fefc.tar.gz chromium_src-a3be04bdaab865ad66f45c3f8a1c433ec596fefc.tar.bz2 |
Notify geometry when requesting for external surface
The browser process may not be aware of geometry of the requesting
media player, so notify the browser processs when requesting for an
external surface.
BUG=236363
R=qinmin@chromium.org,scherkus@chromium.org
Review URL: https://chromiumcodereview.appspot.com/14650003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
11 files changed, 44 insertions, 70 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index 41487dde..505b590 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -16,6 +16,7 @@ #include "cc/layers/layer.h" #include "content/browser/android/interstitial_page_delegate_android.h" #include "content/browser/android/load_url_params.h" +#include "content/browser/android/media_player_manager_impl.h" #include "content/browser/android/sync_input_event_filter.h" #include "content/browser/android/touch_point.h" #include "content/browser/renderer_host/compositor_impl_android.h" @@ -588,32 +589,23 @@ void ContentViewCoreImpl::ShowDisambiguationPopup( java_bitmap.obj()); } -void ContentViewCoreImpl::RequestExternalVideoSurface(int player_id) { +void ContentViewCoreImpl::NotifyExternalSurface( + int player_id, bool is_request, const gfx::RectF& rect) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); if (obj.is_null()) return; - Java_ContentViewCore_requestExternalVideoSurface( - env, obj.obj(), static_cast<jint>(player_id)); -} - -void ContentViewCoreImpl::NotifyGeometryChange(int player_id, - const gfx::RectF& rect) { - JNIEnv* env = AttachCurrentThread(); - - ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); - if (obj.is_null()) - return; - - Java_ContentViewCore_notifyGeometryChange(env, - obj.obj(), - static_cast<jint>(player_id), - static_cast<jfloat>(rect.x()), - static_cast<jfloat>(rect.y()), - static_cast<jfloat>(rect.width()), - static_cast<jfloat>(rect.height())); + Java_ContentViewCore_notifyExternalSurface( + env, + obj.obj(), + static_cast<jint>(player_id), + static_cast<jboolean>(is_request), + static_cast<jfloat>(rect.x()), + static_cast<jfloat>(rect.y()), + static_cast<jfloat>(rect.width()), + static_cast<jfloat>(rect.height())); } gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 414f5cc..6f2acf1 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -269,8 +269,10 @@ class ContentViewCoreImpl : public ContentViewCore, void ShowDisambiguationPopup( const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap); - void RequestExternalVideoSurface(int player_id); - void NotifyGeometryChange(int player_id, const gfx::RectF& rect); + // Notifies the java object about the external surface, requesting for one if + // necessary. + void NotifyExternalSurface( + int player_id, bool is_request, const gfx::RectF& rect); // -------------------------------------------------------------------------- // Methods called from native code diff --git a/content/browser/android/media_player_manager_impl.cc b/content/browser/android/media_player_manager_impl.cc index ba799a6..30f11a4 100644 --- a/content/browser/android/media_player_manager_impl.cc +++ b/content/browser/android/media_player_manager_impl.cc @@ -46,10 +46,8 @@ bool MediaPlayerManagerImpl::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, DestroyAllMediaPlayers) #if defined(GOOGLE_TV) - IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_RequestExternalSurface, - OnRequestExternalSurface) - IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyGeometryChange, - OnNotifyGeometryChange) + IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface, + OnNotifyExternalSurface) IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DemuxerReady, OnDemuxerReady) IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_ReadFromDemuxerAck, @@ -234,25 +232,15 @@ void MediaPlayerManagerImpl::DetachExternalVideoSurface(int player_id) { player->SetVideoSurface(NULL); } -void MediaPlayerManagerImpl::OnRequestExternalSurface(int player_id) { +void MediaPlayerManagerImpl::OnNotifyExternalSurface( + int player_id, bool is_request, const gfx::RectF& rect) { if (!web_contents_) return; WebContentsViewAndroid* view = static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); if (view) - view->RequestExternalVideoSurface(player_id); -} - -void MediaPlayerManagerImpl::OnNotifyGeometryChange(int player_id, - const gfx::RectF& rect) { - if (!web_contents_) - return; - - WebContentsViewAndroid* view = - static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); - if (view) - view->NotifyGeometryChange(player_id, rect); + view->NotifyExternalSurface(player_id, is_request, rect); } void MediaPlayerManagerImpl::OnDemuxerReady( diff --git a/content/browser/android/media_player_manager_impl.h b/content/browser/android/media_player_manager_impl.h index 34905df..2cba3f6 100644 --- a/content/browser/android/media_player_manager_impl.h +++ b/content/browser/android/media_player_manager_impl.h @@ -97,8 +97,8 @@ class MediaPlayerManagerImpl void OnReleaseResources(int player_id); void OnDestroyPlayer(int player_id); #if defined(GOOGLE_TV) - void OnRequestExternalSurface(int player_id); - void OnNotifyGeometryChange(int player_id, const gfx::RectF& rect); + void OnNotifyExternalSurface( + int player_id, bool is_request, const gfx::RectF& rect); void OnDemuxerReady( int player_id, const media::MediaPlayerHostMsg_DemuxerReady_Params& params); diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index 1540d95..bd60290 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc @@ -55,15 +55,10 @@ void WebContentsViewAndroid::SetContentViewCore( } #if defined(GOOGLE_TV) -void WebContentsViewAndroid::RequestExternalVideoSurface(int player_id) { +void WebContentsViewAndroid::NotifyExternalSurface( + int player_id, bool is_request, const gfx::RectF& rect) { if (content_view_core_) - content_view_core_->RequestExternalVideoSurface(player_id); -} - -void WebContentsViewAndroid::NotifyGeometryChange(int player_id, - const gfx::RectF& rect) { - if (content_view_core_) - content_view_core_->NotifyGeometryChange(player_id, rect); + content_view_core_->NotifyExternalSurface(player_id, is_request, rect); } #endif diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index dcfaf39..58eb05a 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h @@ -30,8 +30,9 @@ class WebContentsViewAndroid : public WebContentsViewPort, void SetContentViewCore(ContentViewCoreImpl* content_view_core); #if defined(GOOGLE_TV) - void RequestExternalVideoSurface(int player_id); - void NotifyGeometryChange(int player_id, const gfx::RectF& rect); + void NotifyExternalSurface(int player_id, + bool is_request, + const gfx::RectF& rect); #endif // WebContentsView implementation -------------------------------------------- diff --git a/content/common/media/media_player_messages.h b/content/common/media/media_player_messages.h index 156e1eb..20a7db2 100644 --- a/content/common/media/media_player_messages.h +++ b/content/common/media/media_player_messages.h @@ -173,13 +173,10 @@ IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen, int /* player_id */) #if defined(GOOGLE_TV) -// Request the player to use external surface for rendering. -IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestExternalSurface, - int /* player_id */) - -// Request the player to use external surface for rendering. -IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_NotifyGeometryChange, +// Notify the player about the external surface, requesting it if necessary. +IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface, int /* player_id */, + bool /* is_request */, gfx::RectF /* rect */) // Inform the media source player that the demuxer is ready. diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java index 3176ecc..a9ff266 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java @@ -167,6 +167,6 @@ public class ContentViewClient { public void onExternalVideoSurfaceRequested(int playerId) { } - public void onGeometryChanged(int playerId, float x, float y, float height, float width) { + public void onGeometryChanged(int playerId, float x, float y, float width, float height) { } } diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index 20b30d8..88375d7 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java @@ -2750,17 +2750,14 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { } @CalledByNative - private void requestExternalVideoSurface(int playerId) { - getContentViewClient().onExternalVideoSurfaceRequested(playerId); - } - - @CalledByNative - private void notifyGeometryChange(int playerId, float x, float y, float width, float height) { + private void notifyExternalSurface( + int playerId, boolean isRequest, float x, float y, float width, float height) { RenderCoordinates.NormalizedPoint topLeft = mRenderCoordinates.createNormalizedPoint(); RenderCoordinates.NormalizedPoint bottomRight = mRenderCoordinates.createNormalizedPoint(); topLeft.setLocalDip(x * getScale(), y * getScale()); bottomRight.setLocalDip((x + width) * getScale(), (y + height) * getScale()); + if (isRequest) getContentViewClient().onExternalVideoSurfaceRequested(playerId); getContentViewClient().onGeometryChanged( playerId, topLeft.getXPix(), diff --git a/content/renderer/media/webmediaplayer_proxy_impl_android.cc b/content/renderer/media/webmediaplayer_proxy_impl_android.cc index 652964a..c129995 100644 --- a/content/renderer/media/webmediaplayer_proxy_impl_android.cc +++ b/content/renderer/media/webmediaplayer_proxy_impl_android.cc @@ -175,8 +175,10 @@ void WebMediaPlayerProxyImplAndroid::ExitFullscreen(int player_id) { } #if defined(GOOGLE_TV) -void WebMediaPlayerProxyImplAndroid::RequestExternalSurface(int player_id) { - Send(new MediaPlayerHostMsg_RequestExternalSurface(routing_id(), player_id)); +void WebMediaPlayerProxyImplAndroid::RequestExternalSurface( + int player_id, const gfx::RectF& geometry) { + Send(new MediaPlayerHostMsg_NotifyExternalSurface( + routing_id(), player_id, true, geometry)); } void WebMediaPlayerProxyImplAndroid::DidCommitCompositorFrame() { @@ -185,9 +187,8 @@ void WebMediaPlayerProxyImplAndroid::DidCommitCompositorFrame() { for (std::map<int, gfx::RectF>::iterator it = geometry_change.begin(); it != geometry_change.end(); ++it) { - Send(new MediaPlayerHostMsg_NotifyGeometryChange(routing_id(), - it->first, - it->second)); + Send(new MediaPlayerHostMsg_NotifyExternalSurface( + routing_id(), it->first, false, it->second)); } } diff --git a/content/renderer/media/webmediaplayer_proxy_impl_android.h b/content/renderer/media/webmediaplayer_proxy_impl_android.h index a990459..d999adf 100644 --- a/content/renderer/media/webmediaplayer_proxy_impl_android.h +++ b/content/renderer/media/webmediaplayer_proxy_impl_android.h @@ -46,7 +46,8 @@ class WebMediaPlayerProxyImplAndroid virtual void EnterFullscreen(int player_id) OVERRIDE; virtual void ExitFullscreen(int player_id) OVERRIDE; #if defined(GOOGLE_TV) - virtual void RequestExternalSurface(int player_id) OVERRIDE; + virtual void RequestExternalSurface( + int player_id, const gfx::RectF& geometry) OVERRIDE; virtual void DemuxerReady( int player_id, const media::MediaPlayerHostMsg_DemuxerReady_Params& params) OVERRIDE; |