Title: [179784] trunk/Source/WebCore
Revision
179784
Author
[email protected]
Date
2015-02-07 14:48:36 -0800 (Sat, 07 Feb 2015)

Log Message

[Mac] Set -contentsScale on AVPlayerLayer to allow AVPlayer to select the appropriate HLS variant.
https://bugs.webkit.org/show_bug.cgi?id=141354
rdar://problem/19717591

Reviewed by Darin Adler.

AVPlayer will try to determine the correct HLS variant based on the bounds of an AVPlayerLayer.
When not in a layer tree, AVFoundation is not able to determine the correct mapping from logical
units to pixel values. To provide AVPlayer with that scaling value, set -contentsScale based on
both the current device scale and the current page scale.

Since this needs to be set at initialization time, before the AVPlayer is has any AVPlayerItems,
add some plumbing up from MediaPlayer to as the HTMLMediaElement for the appropriate contents
scale.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerContentsScale):
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerContentsScale):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::updateContentsScale):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (179783 => 179784)


--- trunk/Source/WebCore/ChangeLog	2015-02-07 20:21:24 UTC (rev 179783)
+++ trunk/Source/WebCore/ChangeLog	2015-02-07 22:48:36 UTC (rev 179784)
@@ -1,3 +1,30 @@
+2015-02-07  Jer Noble  <[email protected]>
+
+        [Mac] Set -contentsScale on AVPlayerLayer to allow AVPlayer to select the appropriate HLS variant.
+        https://bugs.webkit.org/show_bug.cgi?id=141354
+        rdar://problem/19717591
+
+        Reviewed by Darin Adler.
+
+        AVPlayer will try to determine the correct HLS variant based on the bounds of an AVPlayerLayer.
+        When not in a layer tree, AVFoundation is not able to determine the correct mapping from logical
+        units to pixel values. To provide AVPlayer with that scaling value, set -contentsScale based on
+        both the current device scale and the current page scale.
+
+        Since this needs to be set at initialization time, before the AVPlayer is has any AVPlayerItems,
+        add some plumbing up from MediaPlayer to as the HTMLMediaElement for the appropriate contents
+        scale.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerContentsScale):
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerContentsScale):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::updateContentsScale):
+
 2015-02-07  Alexey Proskuryakov  <[email protected]>
 
         ASan complains about plugins/snapshotting/snapshot-plugin-not-quite-blocked-by-image.html

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (179783 => 179784)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2015-02-07 20:21:24 UTC (rev 179783)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2015-02-07 22:48:36 UTC (rev 179784)
@@ -5701,6 +5701,13 @@
     return LayoutRect();
 }
 
+float HTMLMediaElement::mediaPlayerContentsScale() const
+{
+    if (auto page = document().page())
+        return page->pageScaleFactor() * page->deviceScaleFactor();
+    return 1;
+}
+
 void HTMLMediaElement::mediaPlayerSetSize(const IntSize& size)
 {
     setIntegralAttribute(widthAttr, size.width());

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (179783 => 179784)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2015-02-07 20:21:24 UTC (rev 179783)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2015-02-07 22:48:36 UTC (rev 179784)
@@ -587,6 +587,7 @@
     virtual bool mediaPlayerIsFullscreenPermitted() const override;
     virtual bool mediaPlayerIsVideo() const override;
     virtual LayoutRect mediaPlayerContentBoxRect() const override;
+    virtual float mediaPlayerContentsScale() const override;
     virtual void mediaPlayerSetSize(const IntSize&) override;
     virtual void mediaPlayerPause() override;
     virtual void mediaPlayerPlay() override;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (179783 => 179784)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2015-02-07 20:21:24 UTC (rev 179783)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2015-02-07 22:48:36 UTC (rev 179784)
@@ -228,6 +228,7 @@
     virtual bool mediaPlayerIsFullscreenPermitted() const { return false; }
     virtual bool mediaPlayerIsVideo() const { return false; }
     virtual LayoutRect mediaPlayerContentBoxRect() const { return LayoutRect(); }
+    virtual float mediaPlayerContentsScale() const { return 1; }
     virtual void mediaPlayerSetSize(const IntSize&) { }
     virtual void mediaPlayerPause() { }
     virtual void mediaPlayerPlay() { }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (179783 => 179784)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2015-02-07 20:21:24 UTC (rev 179783)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2015-02-07 22:48:36 UTC (rev 179784)
@@ -620,6 +620,7 @@
 #endif
     [m_videoLayer addObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextAVPlayerLayer];
     updateVideoLayerGravity();
+    [m_videoLayer setContentsScale:player()->client().mediaPlayerContentsScale()];
     IntSize defaultSize = player()->client().mediaPlayerContentBoxRect().pixelSnappedSize();
     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p", this, m_videoLayer.get());
 

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (179783 => 179784)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2015-02-07 20:21:24 UTC (rev 179783)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2015-02-07 22:48:36 UTC (rev 179784)
@@ -2990,6 +2990,9 @@
 
     m_layer->setContentsScale(contentsScale);
 
+    if (m_contentsLayer && m_contentsLayerPurpose == ContentsLayerForMedia)
+        m_contentsLayer->setContentsScale(contentsScale);
+
     if (tiledBacking()) {
         // Scale change may swap in a different set of tiles changing the custom child layers.
         if (m_isPageTiledBackingLayer)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to