Bug 144129 - [iOS] Add a wrapper around the hosted AVPlayerLayer to intercept -setBounds:
Summary: [iOS] Add a wrapper around the hosted AVPlayerLayer to intercept -setBounds:
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-23 15:24 PDT by Jer Noble
Modified: 2022-11-25 19:30 PST (History)
2 users (show)

See Also:


Attachments
Patch (7.92 KB, patch)
2015-04-23 15:48 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (8.91 KB, patch)
2015-04-23 15:57 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (9.37 KB, patch)
2015-04-23 15:59 PDT, Jer Noble
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2015-04-23 15:24:36 PDT
[iOS] Add a wrapper around the hosted AVPlayerLayer to intercept -setBounds:
Comment 1 Jer Noble 2015-04-23 15:48:29 PDT
Created attachment 251502 [details]
Patch
Comment 2 Jer Noble 2015-04-23 15:49:29 PDT
<rdar://problem/18683624>
Comment 3 Jer Noble 2015-04-23 15:57:15 PDT
Created attachment 251505 [details]
Patch
Comment 4 Jer Noble 2015-04-23 15:59:31 PDT
Created attachment 251506 [details]
Patch
Comment 5 Simon Fraser (smfr) 2015-04-23 16:07:26 PDT
Comment on attachment 251506 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251506&action=review

> Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm:592
> +    [super setBounds:bounds];
> +

This should probably early-return when the bounds aren't changing.

> Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm:612
> +    FloatRect videoFrame = self.model->videoLayerFrame();
> +    FloatRect targetFrame;
> +    switch (self.model->videoLayerGravity()) {
> +    case WebCore::WebVideoFullscreenModel::VideoGravityResize:
> +        targetFrame = bounds;
> +        break;
> +    case WebCore::WebVideoFullscreenModel::VideoGravityResizeAspect:
> +        targetFrame = largestRectWithAspectRatioInsideRect(videoFrame.size().aspectRatio(), bounds);
> +        break;
> +    case WebCore::WebVideoFullscreenModel::VideoGravityResizeAspectFill:
> +        targetFrame = smallestRectWithAspectRatioAroundRect(videoFrame.size().aspectRatio(), bounds);
> +        break;
> +    }
> +    CATransform3D transform = CATransform3DMakeScale(targetFrame.width() / videoFrame.width(), targetFrame.height() / videoFrame.height(), 1);
> +    [_videoSublayer setSublayerTransform:transform];

Doing all this inside -setBounds makes me slightly nervous, but it's probably OK.

> Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm:615
> +    [self performSelector:@selector(resolveBounds) withObject:nil afterDelay:[CATransaction animationDuration] + 0.1];

Add a comment to explain the magic + 0.1?
Comment 6 Jer Noble 2015-04-23 16:44:33 PDT
Committed r183229: <http://trac.webkit.org/changeset/183229>