Changeset 179784 in webkit


Ignore:
Timestamp:
Feb 7, 2015 2:48:36 PM (9 years ago)
Author:
jer.noble@apple.com
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):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r179783 r179784  
     12015-02-07  Jer Noble  <jer.noble@apple.com>
     2
     3        [Mac] Set -contentsScale on AVPlayerLayer to allow AVPlayer to select the appropriate HLS variant.
     4        https://bugs.webkit.org/show_bug.cgi?id=141354
     5        rdar://problem/19717591
     6
     7        Reviewed by Darin Adler.
     8
     9        AVPlayer will try to determine the correct HLS variant based on the bounds of an AVPlayerLayer.
     10        When not in a layer tree, AVFoundation is not able to determine the correct mapping from logical
     11        units to pixel values. To provide AVPlayer with that scaling value, set -contentsScale based on
     12        both the current device scale and the current page scale.
     13
     14        Since this needs to be set at initialization time, before the AVPlayer is has any AVPlayerItems,
     15        add some plumbing up from MediaPlayer to as the HTMLMediaElement for the appropriate contents
     16        scale.
     17
     18        * html/HTMLMediaElement.cpp:
     19        (WebCore::HTMLMediaElement::mediaPlayerContentsScale):
     20        * html/HTMLMediaElement.h:
     21        * platform/graphics/MediaPlayer.h:
     22        (WebCore::MediaPlayerClient::mediaPlayerContentsScale):
     23        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     24        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
     25        * platform/graphics/ca/GraphicsLayerCA.cpp:
     26        (WebCore::GraphicsLayerCA::updateContentsScale):
     27
    1282015-02-07  Alexey Proskuryakov  <ap@apple.com>
    229
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r179641 r179784  
    57025702}
    57035703
     5704float HTMLMediaElement::mediaPlayerContentsScale() const
     5705{
     5706    if (auto page = document().page())
     5707        return page->pageScaleFactor() * page->deviceScaleFactor();
     5708    return 1;
     5709}
     5710
    57045711void HTMLMediaElement::mediaPlayerSetSize(const IntSize& size)
    57055712{
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r179641 r179784  
    588588    virtual bool mediaPlayerIsVideo() const override;
    589589    virtual LayoutRect mediaPlayerContentBoxRect() const override;
     590    virtual float mediaPlayerContentsScale() const override;
    590591    virtual void mediaPlayerSetSize(const IntSize&) override;
    591592    virtual void mediaPlayerPause() override;
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r179641 r179784  
    229229    virtual bool mediaPlayerIsVideo() const { return false; }
    230230    virtual LayoutRect mediaPlayerContentBoxRect() const { return LayoutRect(); }
     231    virtual float mediaPlayerContentsScale() const { return 1; }
    231232    virtual void mediaPlayerSetSize(const IntSize&) { }
    232233    virtual void mediaPlayerPause() { }
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r179641 r179784  
    621621    [m_videoLayer addObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextAVPlayerLayer];
    622622    updateVideoLayerGravity();
     623    [m_videoLayer setContentsScale:player()->client().mediaPlayerContentsScale()];
    623624    IntSize defaultSize = player()->client().mediaPlayerContentBoxRect().pixelSnappedSize();
    624625    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p", this, m_videoLayer.get());
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r179604 r179784  
    29912991    m_layer->setContentsScale(contentsScale);
    29922992
     2993    if (m_contentsLayer && m_contentsLayerPurpose == ContentsLayerForMedia)
     2994        m_contentsLayer->setContentsScale(contentsScale);
     2995
    29932996    if (tiledBacking()) {
    29942997        // Scale change may swap in a different set of tiles changing the custom child layers.
Note: See TracChangeset for help on using the changeset viewer.