summaryrefslogtreecommitdiffstats
path: root/webkit/media
diff options
context:
space:
mode:
authorwonsik@chromium.org <wonsik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 12:57:55 +0000
committerwonsik@chromium.org <wonsik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 12:57:55 +0000
commit480c03471cabfadc3a2ac42021de6a20f8ae2780 (patch)
tree5973a074f5ceed81f55744fc6f2fe127ee047ed2 /webkit/media
parentc39ee69e8fd8a5caaf9e299b929e285e52076e57 (diff)
downloadchromium_src-480c03471cabfadc3a2ac42021de6a20f8ae2780.zip
chromium_src-480c03471cabfadc3a2ac42021de6a20f8ae2780.tar.gz
chromium_src-480c03471cabfadc3a2ac42021de6a20f8ae2780.tar.bz2
Location/size change notification when external rendering is enabled
Extract location/size of the video at renderer process and pass it to browser process where the external surface resides, so that app can readjust the location of external surface when it is changed. BUG=180197 R=scherkus@chromium.org,yfriedman@chromium.org,sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/13688004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r--webkit/media/android/webmediaplayer_android.cc27
-rw-r--r--webkit/media/android/webmediaplayer_android.h16
-rw-r--r--webkit/media/android/webmediaplayer_impl_android.cc2
-rw-r--r--webkit/media/android/webmediaplayer_impl_android.h2
-rw-r--r--webkit/media/android/webmediaplayer_manager_android.cc27
-rw-r--r--webkit/media/android/webmediaplayer_manager_android.h13
-rw-r--r--webkit/media/android/webmediaplayer_proxy_android.h2
7 files changed, 84 insertions, 5 deletions
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index 78461ce..3dfa9f8 100644
--- a/webkit/media/android/webmediaplayer_android.cc
+++ b/webkit/media/android/webmediaplayer_android.cc
@@ -95,10 +95,12 @@ void WebMediaPlayerAndroid::cancelLoad() {
}
void WebMediaPlayerAndroid::play() {
+#if defined(GOOGLE_TV)
if (hasVideo() && needs_external_surface_) {
DCHECK(!needs_establish_peer_);
RequestExternalSurface();
}
+#endif
if (hasVideo() && needs_establish_peer_)
EstablishSurfaceTexturePeer();
@@ -414,6 +416,7 @@ void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
if (natural_size_.width == width && natural_size_.height == height)
return;
+#if defined(GOOGLE_TV)
static bool has_switch = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseExternalVideoSurfaceThresholdInPixels);
static int threshold = 0;
@@ -430,6 +433,7 @@ void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
if (!paused())
RequestExternalSurface();
}
+#endif
natural_size_.width = width;
natural_size_.height = height;
@@ -554,4 +558,27 @@ void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) {
is_playing_ = is_playing;
}
+#if defined(GOOGLE_TV)
+bool WebMediaPlayerAndroid::RetrieveGeometryChange(gfx::RectF* rect) {
+ if (!video_weblayer_)
+ return false;
+
+ // Compute the geometry of video frame layer.
+ cc::Layer* layer = video_weblayer_->layer();
+ rect->set_size(layer->bounds());
+ while (layer) {
+ rect->Offset(layer->position().OffsetFromOrigin());
+ layer = layer->parent();
+ }
+
+ // Return false when the geometry hasn't been changed from the last time.
+ if (last_computed_rect_ == *rect)
+ return false;
+
+ // Store the changed geometry information when it is actually changed.
+ last_computed_rect_ = *rect;
+ return true;
+}
+#endif
+
} // namespace webkit_media
diff --git a/webkit/media/android/webmediaplayer_android.h b/webkit/media/android/webmediaplayer_android.h
index 22c3895..b0371d5 100644
--- a/webkit/media/android/webmediaplayer_android.h
+++ b/webkit/media/android/webmediaplayer_android.h
@@ -17,6 +17,7 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
+#include "ui/gfx/rect_f.h"
#include "webkit/media/android/stream_texture_factory_android.h"
namespace webkit {
@@ -149,6 +150,13 @@ class WebMediaPlayerAndroid
// Detach the player from its manager.
void Detach();
+#if defined(GOOGLE_TV)
+ // Retrieve geometry of the media player (i.e. location and size of the video
+ // frame) if changed. Returns true only if the geometry has been changed since
+ // the last call.
+ bool RetrieveGeometryChange(gfx::RectF* rect);
+#endif
+
protected:
// Construct a WebMediaPlayerAndroid object with reference to the
// client, manager and stream texture factory.
@@ -199,8 +207,10 @@ class WebMediaPlayerAndroid
WebMediaPlayerManagerAndroid* manager() const { return manager_; }
+#if defined(GOOGLE_TV)
// Request external surface for out-of-band composition.
virtual void RequestExternalSurface() = 0;
+#endif
private:
void ReallocateVideoFrame();
@@ -275,6 +285,12 @@ class WebMediaPlayerAndroid
scoped_ptr<webkit::WebLayerImpl> video_weblayer_;
+#if defined(GOOGLE_TV)
+ // A rectangle represents the geometry of video frame, when computed last
+ // time.
+ gfx::RectF last_computed_rect_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid);
};
diff --git a/webkit/media/android/webmediaplayer_impl_android.cc b/webkit/media/android/webmediaplayer_impl_android.cc
index 083edd7..4011885 100644
--- a/webkit/media/android/webmediaplayer_impl_android.cc
+++ b/webkit/media/android/webmediaplayer_impl_android.cc
@@ -129,10 +129,12 @@ void WebMediaPlayerImplAndroid::Destroy() {
proxy_ = NULL;
}
+#if defined(GOOGLE_TV)
void WebMediaPlayerImplAndroid::RequestExternalSurface() {
if (proxy_)
proxy_->RequestExternalSurface(player_id());
}
+#endif
void WebMediaPlayerImplAndroid::SetVideoSurface(jobject j_surface) {}
diff --git a/webkit/media/android/webmediaplayer_impl_android.h b/webkit/media/android/webmediaplayer_impl_android.h
index aef6db4..ba2ef4d 100644
--- a/webkit/media/android/webmediaplayer_impl_android.h
+++ b/webkit/media/android/webmediaplayer_impl_android.h
@@ -68,7 +68,9 @@ class WebMediaPlayerImplAndroid : public WebMediaPlayerAndroid {
virtual double GetCurrentTimeInternal() const OVERRIDE;
virtual void ReleaseResourcesInternal() OVERRIDE;
virtual void Destroy() OVERRIDE;
+#if defined(GOOGLE_TV)
virtual void RequestExternalSurface() OVERRIDE;
+#endif
WebKit::WebFrame* const frame_;
diff --git a/webkit/media/android/webmediaplayer_manager_android.cc b/webkit/media/android/webmediaplayer_manager_android.cc
index c64de25..80296d9 100644
--- a/webkit/media/android/webmediaplayer_manager_android.cc
+++ b/webkit/media/android/webmediaplayer_manager_android.cc
@@ -4,6 +4,7 @@
#include "webkit/media/android/webmediaplayer_manager_android.h"
+#include "ui/gfx/rect_f.h"
#include "webkit/media/android/webmediaplayer_android.h"
namespace webkit_media {
@@ -14,7 +15,7 @@ WebMediaPlayerManagerAndroid::WebMediaPlayerManagerAndroid()
}
WebMediaPlayerManagerAndroid::~WebMediaPlayerManagerAndroid() {
- std::map<int32, WebMediaPlayerAndroid*>::iterator player_it;
+ std::map<int, WebMediaPlayerAndroid*>::iterator player_it;
for (player_it = media_players_.begin();
player_it != media_players_.end(); ++player_it) {
WebMediaPlayerAndroid* player = player_it->second;
@@ -33,7 +34,7 @@ void WebMediaPlayerManagerAndroid::UnregisterMediaPlayer(int player_id) {
}
void WebMediaPlayerManagerAndroid::ReleaseMediaResources() {
- std::map<int32, WebMediaPlayerAndroid*>::iterator player_it;
+ std::map<int, WebMediaPlayerAndroid*>::iterator player_it;
for (player_it = media_players_.begin();
player_it != media_players_.end(); ++player_it) {
WebMediaPlayerAndroid* player = player_it->second;
@@ -46,7 +47,7 @@ void WebMediaPlayerManagerAndroid::ReleaseMediaResources() {
WebMediaPlayerAndroid* WebMediaPlayerManagerAndroid::GetMediaPlayer(
int player_id) {
- std::map<int32, WebMediaPlayerAndroid*>::iterator iter =
+ std::map<int, WebMediaPlayerAndroid*>::iterator iter =
media_players_.find(player_id);
if (iter != media_players_.end())
return iter->second;
@@ -69,4 +70,24 @@ bool WebMediaPlayerManagerAndroid::IsInFullscreen(WebKit::WebFrame* frame) {
return fullscreen_frame_ == frame;
}
+#if defined(GOOGLE_TV)
+void WebMediaPlayerManagerAndroid::RetrieveGeometryChanges(
+ std::map<int, gfx::RectF>* changes) {
+ DCHECK(changes->empty());
+ for (std::map<int, WebMediaPlayerAndroid*>::iterator player_it =
+ media_players_.begin();
+ player_it != media_players_.end();
+ ++player_it) {
+ WebMediaPlayerAndroid* player = player_it->second;
+
+ if (player && player->hasVideo()) {
+ gfx::RectF rect;
+ if (player->RetrieveGeometryChange(&rect)) {
+ (*changes)[player_it->first] = rect;
+ }
+ }
+ }
+}
+#endif
+
} // namespace webkit_media
diff --git a/webkit/media/android/webmediaplayer_manager_android.h b/webkit/media/android/webmediaplayer_manager_android.h
index ce345b7..30de485 100644
--- a/webkit/media/android/webmediaplayer_manager_android.h
+++ b/webkit/media/android/webmediaplayer_manager_android.h
@@ -13,6 +13,10 @@ namespace WebKit {
class WebFrame;
}
+namespace gfx {
+class RectF;
+}
+
namespace webkit_media {
class WebMediaPlayerAndroid;
@@ -45,12 +49,17 @@ class WebMediaPlayerManagerAndroid {
// Get the pointer to WebMediaPlayerAndroid given the |player_id|.
WebMediaPlayerAndroid* GetMediaPlayer(int player_id);
+#if defined(GOOGLE_TV)
+ // Get the list of media players with video geometry changes.
+ void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes);
+#endif
+
private:
// Info for all available WebMediaPlayerAndroid on a page; kept so that
// we can enumerate them to send updates about tab focus and visibily.
- std::map<int32, WebMediaPlayerAndroid*> media_players_;
+ std::map<int, WebMediaPlayerAndroid*> media_players_;
- int32 next_media_player_id_;
+ int next_media_player_id_;
// WebFrame of the fullscreen video.
WebKit::WebFrame* fullscreen_frame_;
diff --git a/webkit/media/android/webmediaplayer_proxy_android.h b/webkit/media/android/webmediaplayer_proxy_android.h
index 9d7c9ad..2961c2f 100644
--- a/webkit/media/android/webmediaplayer_proxy_android.h
+++ b/webkit/media/android/webmediaplayer_proxy_android.h
@@ -45,8 +45,10 @@ class WebMediaPlayerProxyAndroid {
// Request the player to exit fullscreen.
virtual void ExitFullscreen(int player_id) = 0;
+#if defined(GOOGLE_TV)
// Request an external surface for out-of-band compositing.
virtual void RequestExternalSurface(int player_id) = 0;
+#endif
};
} // namespace webkit_media