Title: [173678] trunk/Source/WebCore
Revision
173678
Author
[email protected]
Date
2014-09-16 16:27:22 -0700 (Tue, 16 Sep 2014)

Log Message

[Mac] MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput doesn't work with rotated movies
https://bugs.webkit.org/show_bug.cgi?id=136872

Patch by Eric Carlson <[email protected]> on 2014-09-16
Reviewed by Tim Horton.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator): Add logging.
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): Apply the video track
    preferred transform.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173677 => 173678)


--- trunk/Source/WebCore/ChangeLog	2014-09-16 23:12:12 UTC (rev 173677)
+++ trunk/Source/WebCore/ChangeLog	2014-09-16 23:27:22 UTC (rev 173678)
@@ -1,3 +1,15 @@
+2014-09-16  Eric Carlson  <[email protected]>
+
+        [Mac] MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput doesn't work with rotated movies
+        https://bugs.webkit.org/show_bug.cgi?id=136872
+
+        Reviewed by Tim Horton.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator): Add logging.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): Apply the video track
+            preferred transform.
+
 2014-09-16  Enrica Casucci  <[email protected]>
 
         Move HTMLConverter from editing/cocoa to platform/cocoa.

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2014-09-16 23:12:12 UTC (rev 173677)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2014-09-16 23:27:22 UTC (rev 173678)
@@ -1410,6 +1410,8 @@
 
 void MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator(GraphicsContext* context, const IntRect& rect)
 {
+    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator(%p)", this);
+
     RetainPtr<CGImageRef> image = createImageForTimeInRect(currentTime(), rect);
     if (image) {
         GraphicsContextStateSaver stateSaver(*context);
@@ -2020,18 +2022,28 @@
 {
     updateLastImage();
 
-    if (m_lastImage) {
-        GraphicsContextStateSaver stateSaver(*context);
+    if (!m_lastImage)
+        return;
 
-        IntRect imageRect(0, 0, CGImageGetWidth(m_lastImage.get()), CGImageGetHeight(m_lastImage.get()));
+    AVAssetTrack* firstEnabledVideoTrack = firstEnabledTrack([m_avAsset.get() tracksWithMediaCharacteristic:AVMediaCharacteristicVisual]);
+    if (!firstEnabledVideoTrack)
+        return;
 
-        context->drawNativeImage(m_lastImage.get(), imageRect.size(), ColorSpaceDeviceRGB, outputRect, imageRect);
+    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(%p)", this);
 
-        // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available
-        // video frame, destroy it now that it is no longer needed.
-        if (m_imageGenerator)
-            destroyImageGenerator();
-    }
+    GraphicsContextStateSaver stateSaver(*context);
+    FloatRect imageRect(0, 0, CGImageGetWidth(m_lastImage.get()), CGImageGetHeight(m_lastImage.get()));
+    AffineTransform videoTransform = [firstEnabledVideoTrack preferredTransform];
+    FloatRect transformedOutputRect = videoTransform.inverse().mapRect(outputRect);
+
+    context->concatCTM(videoTransform);
+    context->drawNativeImage(m_lastImage.get(), imageRect.size(), ColorSpaceDeviceRGB, transformedOutputRect, imageRect);
+
+    // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available
+    // video frame, destroy it now that it is no longer needed.
+    if (m_imageGenerator)
+        destroyImageGenerator();
+
 }
 
 PassNativeImagePtr MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to