Changeset 180839 in webkit


Ignore:
Timestamp:
Feb 28, 2015 12:58:51 PM (9 years ago)
Author:
Simon Fraser
Message:

Fullscreen video layers are off by one sometimes
https://bugs.webkit.org/show_bug.cgi?id=142122
rdar://problem/19878821

Reviewed by Eric Carlson.

Convert MediaPlayer::naturalSize() to return a FloatSize, since the natural size
isn't always integral (because of preserving pixel aspect ratio etc). Fix all the media
backends to use FloatSizes for natural size. Convert the video image drawing code
paths to FloatSize, since naturalSize is used on the destination rect computation,
and painting should be floating point anyway.

Give the layer created by SourceBufferPrivateAVFObjC a name in debug builds.

  • html/HTMLVideoElement.cpp:

(WebCore::HTMLVideoElement::videoWidth):
(WebCore::HTMLVideoElement::videoHeight):
(WebCore::HTMLVideoElement::paintCurrentFrameInContext):

  • html/HTMLVideoElement.h:
  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::size):
(WebCore::CanvasRenderingContext2D::drawImage):

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::videoFrameToImage):

  • platform/graphics/MediaPlayer.cpp:

(WebCore::NullMediaPlayerPrivate::naturalSize):
(WebCore::MediaPlayer::naturalSize):
(WebCore::MediaPlayer::paint):
(WebCore::MediaPlayer::paintCurrentFrameInContext):
(WebCore::NullMediaPlayerPrivate::paint): Deleted.

  • platform/graphics/MediaPlayer.h:
  • platform/graphics/MediaPlayerPrivate.h:

(WebCore::MediaPlayerPrivateInterface::paintCurrentFrameInContext):

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::naturalSize):
(WebCore::MediaPlayerPrivateAVFoundation::setNaturalSize):

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext):
(WebCore::MediaPlayerPrivateAVFoundationObjC::paint):
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged):
(WebCore::MediaPlayerPrivateAVFoundationObjC::sizeChanged):
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::naturalSize):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paint):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext):

  • platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:

(WebCore::MediaSourcePrivateAVFObjC::naturalSize):

  • platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
  • platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:

(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::naturalSize):

  • platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h:
  • platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm:

(WebCore::VideoTrackPrivateMediaSourceAVFObjC::naturalSize):

  • platform/graphics/mac/MediaPlayerPrivateQTKit.h:
  • platform/graphics/mac/MediaPlayerPrivateQTKit.mm:

(WebCore::MediaPlayerPrivateQTKit::naturalSize):
(WebCore::MediaPlayerPrivateQTKit::paintCurrentFrameInContext):
(WebCore::MediaPlayerPrivateQTKit::paint):

  • platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:

(WebCore::MockMediaPlayerMediaSource::naturalSize):
(WebCore::MockMediaPlayerMediaSource::paint):

  • platform/mock/mediasource/MockMediaPlayerMediaSource.h:
  • rendering/RenderVideo.cpp:

(WebCore::RenderVideo::calculateIntrinsicSize):
(WebCore::RenderVideo::paintReplaced):

Location:
trunk/Source/WebCore
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180817 r180839  
     12015-02-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fullscreen video layers are off by one sometimes
     4        https://bugs.webkit.org/show_bug.cgi?id=142122
     5        rdar://problem/19878821
     6
     7        Reviewed by Eric Carlson.
     8
     9        Convert MediaPlayer::naturalSize() to return a FloatSize, since the natural size
     10        isn't always integral (because of preserving pixel aspect ratio etc). Fix all the media
     11        backends to use FloatSizes for natural size. Convert the video image drawing code
     12        paths to FloatSize, since naturalSize is used on the destination rect computation,
     13        and painting should be floating point anyway.
     14       
     15        Give the layer created by SourceBufferPrivateAVFObjC a name in debug builds.
     16
     17        * html/HTMLVideoElement.cpp:
     18        (WebCore::HTMLVideoElement::videoWidth):
     19        (WebCore::HTMLVideoElement::videoHeight):
     20        (WebCore::HTMLVideoElement::paintCurrentFrameInContext):
     21        * html/HTMLVideoElement.h:
     22        * html/canvas/CanvasRenderingContext2D.cpp:
     23        (WebCore::size):
     24        (WebCore::CanvasRenderingContext2D::drawImage):
     25        * html/canvas/WebGLRenderingContextBase.cpp:
     26        (WebCore::WebGLRenderingContextBase::videoFrameToImage):
     27        * platform/graphics/MediaPlayer.cpp:
     28        (WebCore::NullMediaPlayerPrivate::naturalSize):
     29        (WebCore::MediaPlayer::naturalSize):
     30        (WebCore::MediaPlayer::paint):
     31        (WebCore::MediaPlayer::paintCurrentFrameInContext):
     32        (WebCore::NullMediaPlayerPrivate::paint): Deleted.
     33        * platform/graphics/MediaPlayer.h:
     34        * platform/graphics/MediaPlayerPrivate.h:
     35        (WebCore::MediaPlayerPrivateInterface::paintCurrentFrameInContext):
     36        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     37        (WebCore::MediaPlayerPrivateAVFoundation::naturalSize):
     38        (WebCore::MediaPlayerPrivateAVFoundation::setNaturalSize):
     39        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
     40        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     41        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     42        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext):
     43        (WebCore::MediaPlayerPrivateAVFoundationObjC::paint):
     44        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator):
     45        (WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
     46        (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged):
     47        (WebCore::MediaPlayerPrivateAVFoundationObjC::sizeChanged):
     48        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):
     49        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     50        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     51        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::naturalSize):
     52        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paint):
     53        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext):
     54        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
     55        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
     56        (WebCore::MediaSourcePrivateAVFObjC::naturalSize):
     57        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
     58        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
     59        (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
     60        (WebCore::SourceBufferPrivateAVFObjC::naturalSize):
     61        * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h:
     62        * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm:
     63        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::naturalSize):
     64        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
     65        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
     66        (WebCore::MediaPlayerPrivateQTKit::naturalSize):
     67        (WebCore::MediaPlayerPrivateQTKit::paintCurrentFrameInContext):
     68        (WebCore::MediaPlayerPrivateQTKit::paint):
     69        * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
     70        (WebCore::MockMediaPlayerMediaSource::naturalSize):
     71        (WebCore::MockMediaPlayerMediaSource::paint):
     72        * platform/mock/mediasource/MockMediaPlayerMediaSource.h:
     73        * rendering/RenderVideo.cpp:
     74        (WebCore::RenderVideo::calculateIntrinsicSize):
     75        (WebCore::RenderVideo::paintReplaced):
     76
    1772015-02-27  Hunseop Jeong  <hs85.jeong@samsung.com>
    278
  • trunk/Source/WebCore/html/HTMLVideoElement.cpp

    r180416 r180839  
    172172    if (!player())
    173173        return 0;
    174     return player()->naturalSize().width();
     174    return clampToUnsigned(player()->naturalSize().width());
    175175}
    176176
     
    179179    if (!player())
    180180        return 0;
    181     return player()->naturalSize().height();
     181    return clampToUnsigned(player()->naturalSize().height());
    182182}
    183183
     
    236236}
    237237
    238 void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& destRect)
     238void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const FloatRect& destRect)
    239239{
    240240    MediaPlayer* player = HTMLMediaElement::player();
  • trunk/Source/WebCore/html/HTMLVideoElement.h

    r180416 r180839  
    6666
    6767    // Used by canvas to gain raw pixel access
    68     void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
     68    void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&);
    6969
    7070    PassNativeImagePtr nativeImageForCurrentTime();
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r180268 r180839  
    12891289
    12901290#if ENABLE(VIDEO)
    1291 static IntSize size(HTMLVideoElement* video)
     1291static FloatSize size(HTMLVideoElement* video)
    12921292{
    12931293    if (MediaPlayer* player = video->player())
    12941294        return player->naturalSize();
    1295     return IntSize();
     1295    return FloatSize();
    12961296}
    12971297#endif
     
    14861486        return;
    14871487    }
    1488     IntSize s = size(video);
    1489     drawImage(video, x, y, s.width(), s.height(), ec);
     1488    FloatSize videoSize = size(video);
     1489    drawImage(video, x, y, videoSize.width(), videoSize.height(), ec);
    14901490}
    14911491
     
    14971497        return;
    14981498    }
    1499     IntSize s = size(video);
    1500     drawImage(video, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
     1499    FloatSize videoSize = size(video);
     1500    drawImage(video, FloatRect(0, 0, videoSize.width(), videoSize.height()), FloatRect(x, y, width, height), ec);
    15011501}
    15021502
     
    15551555    c->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
    15561556    c->translate(-srcRect.x(), -srcRect.y());
    1557     video->paintCurrentFrameInContext(c, IntRect(IntPoint(), size(video)));
     1557    video->paintCurrentFrameInContext(c, FloatRect(FloatPoint(), size(video)));
    15581558    stateSaver.restore();
    15591559    didDraw(dstRect);
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r180801 r180839  
    32473247        return nullptr;
    32483248    }
    3249     IntRect destRect(0, 0, size.width(), size.height());
     3249    FloatRect destRect(0, 0, size.width(), size.height());
    32503250    // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
    32513251    video->paintCurrentFrameInContext(buf->context(), destRect);
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r180532 r180839  
    9595    virtual PlatformLayer* platformLayer() const { return 0; }
    9696
    97     virtual IntSize naturalSize() const { return IntSize(0, 0); }
     97    virtual FloatSize naturalSize() const { return FloatSize(); }
    9898
    9999    virtual bool hasVideo() const { return false; }
     
    132132    virtual void setSize(const IntSize&) { }
    133133
    134     virtual void paint(GraphicsContext*, const IntRect&) { }
     134    virtual void paint(GraphicsContext*, const FloatRect&) override { }
    135135
    136136    virtual bool canLoadPoster() const { return false; }
     
    545545}
    546546
    547 IntSize MediaPlayer::naturalSize()
     547FloatSize MediaPlayer::naturalSize()
    548548{
    549549    return m_private->naturalSize();
     
    734734}
    735735
    736 void MediaPlayer::paint(GraphicsContext* p, const IntRect& r)
     736void MediaPlayer::paint(GraphicsContext* p, const FloatRect& r)
    737737{
    738738    m_private->paint(p, r);
    739739}
    740740
    741 void MediaPlayer::paintCurrentFrameInContext(GraphicsContext* p, const IntRect& r)
     741void MediaPlayer::paintCurrentFrameInContext(GraphicsContext* p, const FloatRect& r)
    742742{
    743743    m_private->paintCurrentFrameInContext(p, r);
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r180416 r180839  
    312312#endif
    313313
    314     IntSize naturalSize();
     314    FloatSize naturalSize();
    315315    bool hasVideo() const;
    316316    bool hasAudio() const;
     
    392392    void setAutoplay(bool);
    393393
    394     void paint(GraphicsContext*, const IntRect&);
    395     void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
     394    void paint(GraphicsContext*, const FloatRect&);
     395    void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&);
    396396
    397397    // copyVideoTextureToPlatformTexture() is used to do the GPU-GPU textures copy without a readback to system memory.
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r180532 r180839  
    7575    virtual bool canSaveMediaData() const { return false; }
    7676
    77     virtual IntSize naturalSize() const = 0;
     77    virtual FloatSize naturalSize() const = 0;
    7878
    7979    virtual bool hasVideo() const = 0;
     
    138138    virtual void setSize(const IntSize&) = 0;
    139139
    140     virtual void paint(GraphicsContext*, const IntRect&) = 0;
    141 
    142     virtual void paintCurrentFrameInContext(GraphicsContext* c, const IntRect& r) { paint(c, r); }
     140    virtual void paint(GraphicsContext*, const FloatRect&) = 0;
     141
     142    virtual void paintCurrentFrameInContext(GraphicsContext* c, const FloatRect& r) { paint(c, r); }
    143143    virtual bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject, GC3Dint, GC3Denum, GC3Denum, bool, bool) { return false; }
    144144    virtual PassNativeImagePtr nativeImageForCurrentTime() { return nullptr; }
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r180532 r180839  
    308308}
    309309
    310 IntSize MediaPlayerPrivateAVFoundation::naturalSize() const
     310FloatSize MediaPlayerPrivateAVFoundation::naturalSize() const
    311311{
    312312    if (!metaDataAvailable())
     
    323323}
    324324
    325 void MediaPlayerPrivateAVFoundation::setNaturalSize(IntSize size)
    326 {
    327     LOG(Media, "MediaPlayerPrivateAVFoundation:setNaturalSize(%p) - size = %d x %d", this, size.width(), size.height());
    328 
    329     IntSize oldSize = m_cachedNaturalSize;
     325void MediaPlayerPrivateAVFoundation::setNaturalSize(FloatSize size)
     326{
     327    LOG(Media, "MediaPlayerPrivateAVFoundation:setNaturalSize(%p) - size = %f x %f", this, size.width(), size.height());
     328
     329    FloatSize oldSize = m_cachedNaturalSize;
    330330    m_cachedNaturalSize = size;
    331331    if (oldSize != m_cachedNaturalSize)
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r180416 r180839  
    162162    virtual void pause() override;
    163163
    164     virtual IntSize naturalSize() const override;
     164    virtual FloatSize naturalSize() const override;
    165165    virtual bool hasVideo() const override { return m_cachedHasVideo; }
    166166    virtual bool hasAudio() const override { return m_cachedHasAudio; }
     
    182182    virtual bool didLoadingProgress() const override;
    183183    virtual void setSize(const IntSize&) override;
    184     virtual void paint(GraphicsContext*, const IntRect&) = 0;
    185     virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&) = 0;
     184    virtual void paint(GraphicsContext*, const FloatRect&) = 0;
     185    virtual void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&) = 0;
    186186    virtual void setPreload(MediaPlayer::Preload) override;
    187187    virtual PlatformLayer* platformLayer() const { return 0; }
     
    266266    void setDelayCallbacks(bool) const;
    267267    void setIgnoreLoadStateChanges(bool delay) { m_ignoreLoadStateChanges = delay; }
    268     void setNaturalSize(IntSize);
     268    void setNaturalSize(FloatSize);
    269269    bool isLiveStream() const { return std::isinf(duration()); }
    270270
     
    321321    MediaPlayer::Preload m_preload;
    322322
    323     IntSize m_cachedNaturalSize;
     323    FloatSize m_cachedNaturalSize;
    324324    mutable MediaTime m_cachedMaxTimeLoaded;
    325325    mutable MediaTime m_cachedMaxTimeSeekable;
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r180532 r180839  
    107107    void createImageGenerator();
    108108    void destroyImageGenerator();
    109     RetainPtr<CGImageRef> createImageForTimeInRect(const MediaTime&, const IntRect&);
     109    RetainPtr<CGImageRef> createImageForTimeInRect(const MediaTime&, const FloatRect&);
    110110
    111111    void createAssetForURL(const String& url, bool inheritURI);
     
    832832}
    833833
    834 void MediaPlayerPrivateAVFoundationCF::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect)
     834void MediaPlayerPrivateAVFoundationCF::paintCurrentFrameInContext(GraphicsContext* context, const FloatRect& rect)
    835835{
    836836    ASSERT(isMainThread());
     
    847847}
    848848
    849 void MediaPlayerPrivateAVFoundationCF::paint(GraphicsContext* context, const IntRect& rect)
     849void MediaPlayerPrivateAVFoundationCF::paint(GraphicsContext* context, const FloatRect& rect)
    850850{
    851851    ASSERT(isMainThread());
     
    862862        context->scale(FloatSize(1.0f, -1.0f));
    863863        context->setImageInterpolationQuality(InterpolationLow);
    864         IntRect paintRect(IntPoint(0, 0), IntSize(rect.width(), rect.height()));
     864        FloatRect paintRect(FloatPoint(), rect.size());
    865865        CGContextDrawImage(context->platformContext(), CGRectMake(0, 0, paintRect.width(), paintRect.height()), image.get());
    866866        context->restore();
     
    20012001}
    20022002
    2003 RetainPtr<CGImageRef> AVFWrapper::createImageForTimeInRect(const MediaTime& time, const IntRect& rect)
     2003RetainPtr<CGImageRef> AVFWrapper::createImageForTimeInRect(const MediaTime& time, const FloatRect& rect)
    20042004{
    20052005    if (!m_imageGenerator)
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h

    r180406 r180839  
    7676    virtual void setVolume(float);
    7777    virtual void setClosedCaptionsVisible(bool);
    78     virtual void paint(GraphicsContext*, const IntRect&);
    79     virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
     78    virtual void paint(GraphicsContext*, const FloatRect&);
     79    virtual void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&);
    8080    virtual PlatformLayer* platformLayer() const;
    8181    virtual bool supportsAcceleratedRendering() const { return true; }
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r180416 r180839  
    151151    virtual void setVolume(float);
    152152    virtual void setClosedCaptionsVisible(bool);
    153     virtual void paint(GraphicsContext*, const IntRect&);
    154     virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
     153    virtual void paint(GraphicsContext*, const FloatRect&);
     154    virtual void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&);
    155155    virtual PlatformLayer* platformLayer() const;
    156156#if PLATFORM(IOS)
     
    218218    void createImageGenerator();
    219219    void destroyImageGenerator();
    220     RetainPtr<CGImageRef> createImageForTimeInRect(float, const IntRect&);
    221     void paintWithImageGenerator(GraphicsContext*, const IntRect&);
     220    RetainPtr<CGImageRef> createImageForTimeInRect(float, const FloatRect&);
     221    void paintWithImageGenerator(GraphicsContext*, const FloatRect&);
    222222
    223223#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     
    227227    void updateLastImage();
    228228    bool videoOutputHasAvailableFrame();
    229     void paintWithVideoOutput(GraphicsContext*, const IntRect&);
     229    void paintWithVideoOutput(GraphicsContext*, const FloatRect&);
    230230    virtual PassNativeImagePtr nativeImageForCurrentTime() override;
    231231    void waitForVideoOutputMediaDataWillChange();
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r180532 r180839  
    14671467}
    14681468
    1469 void MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect)
     1469void MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext(GraphicsContext* context, const FloatRect& rect)
    14701470{
    14711471    if (!metaDataAvailable() || context->paintingDisabled())
     
    14881488}
    14891489
    1490 void MediaPlayerPrivateAVFoundationObjC::paint(GraphicsContext* context, const IntRect& rect)
     1490void MediaPlayerPrivateAVFoundationObjC::paint(GraphicsContext* context, const FloatRect& rect)
    14911491{
    14921492    if (!metaDataAvailable() || context->paintingDisabled())
     
    15041504}
    15051505
    1506 void MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator(GraphicsContext* context, const IntRect& rect)
     1506void MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator(GraphicsContext* context, const FloatRect& rect)
    15071507{
    15081508    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator(%p)", this);
     
    15361536}
    15371537
    1538 RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect(float time, const IntRect& rect)
     1538RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect(float time, const FloatRect& rect)
    15391539{
    15401540    if (!m_imageGenerator)
     
    18281828#endif
    18291829
    1830         presentationSizeDidChange(firstEnabledVideoTrack ? IntSize(CGSizeApplyAffineTransform([firstEnabledVideoTrack naturalSize], [firstEnabledVideoTrack preferredTransform])) : IntSize());
     1830        presentationSizeDidChange(firstEnabledVideoTrack ? FloatSize(CGSizeApplyAffineTransform([firstEnabledVideoTrack naturalSize], [firstEnabledVideoTrack preferredTransform])) : FloatSize());
    18311831    } else {
    18321832        bool hasVideo = false;
     
    21222122        return;
    21232123
    2124     setNaturalSize(roundedIntSize(m_cachedPresentationSize));
     2124    setNaturalSize(m_cachedPresentationSize);
    21252125}
    21262126   
     
    22742274}
    22752275
    2276 void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext* context, const IntRect& outputRect)
     2276void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext* context, const FloatRect& outputRect)
    22772277{
    22782278    if (m_videoOutput && !m_lastImage && !videoOutputHasAvailableFrame())
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r180406 r180839  
    116116    virtual bool supportsScanning() const override;
    117117
    118     virtual IntSize naturalSize() const override;
     118    virtual FloatSize naturalSize() const override;
    119119
    120120    virtual bool hasVideo() const override;
     
    141141    virtual void setSize(const IntSize&) override;
    142142
    143     virtual void paint(GraphicsContext*, const IntRect&) override;
    144     virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&) override;
     143    virtual void paint(GraphicsContext*, const FloatRect&) override;
     144    virtual void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&) override;
    145145
    146146    virtual bool hasAvailableVideoFrame() const override;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r180532 r180839  
    346346}
    347347
    348 IntSize MediaPlayerPrivateMediaSourceAVFObjC::naturalSize() const
     348FloatSize MediaPlayerPrivateMediaSourceAVFObjC::naturalSize() const
    349349{
    350350    if (!m_mediaSourcePrivate)
    351         return IntSize();
     351        return FloatSize();
    352352
    353353    return m_mediaSourcePrivate->naturalSize();
     
    513513}
    514514
    515 void MediaPlayerPrivateMediaSourceAVFObjC::paint(GraphicsContext*, const IntRect&)
     515void MediaPlayerPrivateMediaSourceAVFObjC::paint(GraphicsContext*, const FloatRect&)
    516516{
    517517    // FIXME(125157): Implement painting.
    518518}
    519519
    520 void MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext(GraphicsContext*, const IntRect&)
     520void MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext(GraphicsContext*, const FloatRect&)
    521521{
    522522    // FIXME(125157): Implement painting.
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h

    r173197 r180839  
    7676    void seekToTime(const MediaTime&);
    7777    MediaTime fastSeekTimeForMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold);
    78     IntSize naturalSize() const;
     78    FloatSize naturalSize() const;
    7979
    8080private:
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm

    r173318 r180839  
    199199}
    200200
    201 IntSize MediaSourcePrivateAVFObjC::naturalSize() const
    202 {
    203     IntSize result;
     201FloatSize MediaSourcePrivateAVFObjC::naturalSize() const
     202{
     203    FloatSize result;
    204204
    205205    for (auto* sourceBuffer : m_activeSourceBuffers)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h

    r175000 r180839  
    9494    void seekToTime(MediaTime);
    9595    MediaTime fastSeekTimeForMediaTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
    96     IntSize naturalSize();
     96    FloatSize naturalSize();
    9797
    9898    int protectedTrackID() const { return m_protectedTrackID; }
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm

    r180065 r180839  
    891891        if (!m_displayLayer) {
    892892            m_displayLayer = adoptNS([allocAVSampleBufferDisplayLayerInstance() init]);
     893#ifndef NDEBUG
     894            [m_displayLayer setName:@"SourceBufferPrivateAVFObjC AVSampleBufferDisplayLayer"];
     895#endif
    893896            [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
    894897                didBecomeReadyForMoreSamples(trackID);
     
    10771080}
    10781081
    1079 IntSize SourceBufferPrivateAVFObjC::naturalSize()
    1080 {
    1081     return roundedIntSize(m_cachedSize);
     1082FloatSize SourceBufferPrivateAVFObjC::naturalSize()
     1083{
     1084    return m_cachedSize;
    10821085}
    10831086
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h

    r165676 r180839  
    5656    int trackID() { return m_trackID; }
    5757
    58     IntSize naturalSize() const;
     58    FloatSize naturalSize() const;
    5959
    6060private:
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm

    r174823 r180839  
    8181}
    8282
    83 IntSize VideoTrackPrivateMediaSourceAVFObjC::naturalSize() const
     83FloatSize VideoTrackPrivateMediaSourceAVFObjC::naturalSize() const
    8484{
    85     return IntSize([assetTrack() naturalSize]);
     85    return FloatSize([assetTrack() naturalSize]);
    8686}
    8787
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r179985 r180839  
    130130
    131131// Returns the size of the video
    132 IntSize MediaPlayerPrivateGStreamerBase::naturalSize() const
     132FloatSize MediaPlayerPrivateGStreamerBase::naturalSize() const
    133133{
    134134    if (!hasVideo())
    135         return IntSize();
     135        return FloatSize();
    136136
    137137    if (!m_videoSize.isEmpty())
     
    140140    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
    141141    if (!m_sample)
    142         return IntSize();
     142        return FloatSize();
    143143
    144144    GstCaps* caps = gst_sample_get_caps(m_sample);
    145145    if (!caps)
    146         return IntSize();
     146        return FloatSize();
    147147
    148148
     
    158158    GstVideoFormat format;
    159159    if (!getVideoSizeAndFormatFromCaps(caps, originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
    160         return IntSize();
     160        return FloatSize();
    161161
    162162    LOG_MEDIA_MESSAGE("Original video size: %dx%d", originalSize.width(), originalSize.height());
     
    189189
    190190    LOG_MEDIA_MESSAGE("Natural size: %" G_GUINT64_FORMAT "x%" G_GUINT64_FORMAT, width, height);
    191     m_videoSize = IntSize(static_cast<int>(width), static_cast<int>(height));
     191    m_videoSize = FloatSize(static_cast<int>(width), static_cast<int>(height));
    192192    return m_videoSize;
    193193}
     
    352352}
    353353
    354 void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const IntRect& rect)
     354void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const FloatRect& rect)
    355355{
    356356#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r175370 r180839  
    5858    virtual ~MediaPlayerPrivateGStreamerBase();
    5959
    60     IntSize naturalSize() const;
     60    FloatSize naturalSize() const;
    6161
    6262    void setVolume(float);
     
    7979
    8080    void triggerRepaint(GstSample*);
    81     void paint(GraphicsContext*, const IntRect&);
     81    void paint(GraphicsContext*, const FloatRect&);
    8282
    8383    virtual bool hasSingleSecurityOrigin() const { return true; }
     
    130130    unsigned long m_volumeSignalHandler;
    131131    unsigned long m_muteSignalHandler;
    132     mutable IntSize m_videoSize;
     132    mutable FloatSize m_videoSize;
    133133#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
    134134    PassRefPtr<BitmapTexture> updateTexture(TextureMapper*);
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h

    r180406 r180839  
    7777    PlatformLayer* platformLayer() const;
    7878
    79     IntSize naturalSize() const;
     79    FloatSize naturalSize() const override;
    8080    bool hasVideo() const;
    8181    bool hasAudio() const;
     
    125125    virtual bool hasAvailableVideoFrame() const;
    126126
    127     void paint(GraphicsContext*, const IntRect&);
    128     void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
     127    void paint(GraphicsContext*, const FloatRect&);
     128    void paintCurrentFrameInContext(GraphicsContext*, const FloatRect&);
    129129    virtual void prepareForRendering();
    130130
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

    r180532 r180839  
    710710}
    711711
    712 IntSize MediaPlayerPrivateQTKit::naturalSize() const
     712FloatSize MediaPlayerPrivateQTKit::naturalSize() const
    713713{
    714714    if (!metaDataAvailable())
    715         return IntSize();
     715        return FloatSize();
    716716
    717717    // In spite of the name of this method, return QTMovieNaturalSizeAttribute transformed by the
     
    733733        m_cachedNaturalSize = naturalSize;
    734734    }
    735        
    736     return IntSize(naturalSize.width() * m_scaleFactor.width(), naturalSize.height() * m_scaleFactor.height());
     735   
     736    naturalSize.scale(m_scaleFactor.width(), m_scaleFactor.height());
     737    return naturalSize;
    737738}
    738739
     
    11821183}
    11831184
    1184 void MediaPlayerPrivateQTKit::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& r)
     1185void MediaPlayerPrivateQTKit::paintCurrentFrameInContext(GraphicsContext* context, const FloatRect& r)
    11851186{
    11861187    id qtVideoRenderer = m_qtVideoRenderer.get();
     
    11961197}
    11971198
    1198 void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
     1199void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const FloatRect& r)
    11991200{
    12001201    if (context->paintingDisabled() || m_hasUnsupportedTracks)
     
    12081209    NSGraphicsContext* newContext;
    12091210    FloatSize scaleFactor(1.0f, -1.0f);
    1210     IntRect paintRect(IntPoint(0, 0), IntSize(r.width(), r.height()));
     1211    FloatRect paintRect(FloatPoint(), r.size());
    12111212
    12121213    GraphicsContextStateSaver stateSaver(*context);
  • trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp

    r180641 r180839  
    144144}
    145145
    146 IntSize MediaPlayerPrivateMediaFoundation::naturalSize() const
     146FloatSize MediaPlayerPrivateMediaFoundation::naturalSize() const
    147147{
    148148    return m_size;
     
    222222}
    223223
    224 void MediaPlayerPrivateMediaFoundation::paint(GraphicsContext* context, const IntRect& rect)
     224void MediaPlayerPrivateMediaFoundation::paint(GraphicsContext* context, const FloatRect& rect)
    225225{
    226226    if (context->paintingDisabled()
  • trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h

    r180406 r180839  
    5050    virtual void pause();
    5151
    52     virtual IntSize naturalSize() const;
     52    virtual FloatSize naturalSize() const;
    5353
    5454    virtual bool hasVideo() const;
     
    7070    virtual void setSize(const IntSize&);
    7171
    72     virtual void paint(GraphicsContext*, const IntRect&);
     72    virtual void paint(GraphicsContext*, const FloatRect&);
    7373
    7474private:
     
    8282    HWND m_hwndVideo;
    8383    MediaPlayer::ReadyState m_readyState;
    84     IntRect m_lastPaintRect;
     84    FloatRect m_lastPaintRect;
    8585
    8686    COMPtr<IMFMediaSession> m_mediaSession;
  • trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp

    r180532 r180839  
    119119}
    120120
    121 IntSize MockMediaPlayerMediaSource::naturalSize() const
    122 {
    123     return IntSize();
     121FloatSize MockMediaPlayerMediaSource::naturalSize() const
     122{
     123    return FloatSize();
    124124}
    125125
     
    180180}
    181181
    182 void MockMediaPlayerMediaSource::paint(GraphicsContext*, const IntRect&)
     182void MockMediaPlayerMediaSource::paint(GraphicsContext*, const FloatRect&)
    183183{
    184184}
  • trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h

    r180406 r180839  
    6464    virtual void play() override;
    6565    virtual void pause() override;
    66     virtual IntSize naturalSize() const override;
     66    virtual FloatSize naturalSize() const override;
    6767    virtual bool hasVideo() const override;
    6868    virtual bool hasAudio() const override;
     
    7575    virtual bool didLoadingProgress() const override;
    7676    virtual void setSize(const IntSize&) override;
    77     virtual void paint(GraphicsContext*, const IntRect&) override;
     77    virtual void paint(GraphicsContext*, const FloatRect&) override;
    7878    virtual MediaTime currentMediaTime() const override;
    7979    virtual MediaTime durationMediaTime() const override;
  • trunk/Source/WebCore/rendering/RenderVideo.cpp

    r177259 r180839  
    107107    MediaPlayer* player = videoElement().player();
    108108    if (player && videoElement().readyState() >= HTMLVideoElement::HAVE_METADATA) {
    109         LayoutSize size = player->naturalSize();
     109        LayoutSize size(player->naturalSize());
    110110        if (!size.isEmpty())
    111111            return size;
     
    190190        paintIntoRect(context, rect);
    191191    else if (view().frameView().paintBehavior() & PaintBehaviorFlattenCompositingLayers)
    192         mediaPlayer->paintCurrentFrameInContext(context, snappedIntRect(rect));
     192        mediaPlayer->paintCurrentFrameInContext(context, rect);
    193193    else
    194         mediaPlayer->paint(context, snappedIntRect(rect));
     194        mediaPlayer->paint(context, rect);
    195195}
    196196
Note: See TracChangeset for help on using the changeset viewer.