2011-05-25 Alexis Menard <alexis.menard@openbossa.org>
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 May 2011 19:22:25 +0000 (19:22 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 May 2011 19:22:25 +0000 (19:22 +0000)
        Reviewed by Eric Carlson.

        [Qt] Enable usage of QuickTime mediaplayer for the Qt port on Mac.
        https://bugs.webkit.org/show_bug.cgi?id=61279

        Enable the QuickTime backend for the Qt port on Mac. The patch adds the bits in WebCore
        to enable the QTKit backend of the Mac port. It can be enabled by passing DEFINES+=USE_QTKIT=1
        when calling build-webkit.

        * WebCore.pri:
        * WebCore.pro:
        * features.pri:
        * platform/KURL.h:
        * platform/SharedBuffer.h:
        * platform/cf/KURLCFNet.cpp:
        * platform/cf/SharedBufferCF.cpp:
        * platform/graphics/FloatSize.h:
        * platform/graphics/IntRect.h:
        * platform/graphics/IntSize.h:
        * platform/graphics/MediaPlayer.cpp:
        * platform/graphics/cg/FloatSizeCG.cpp:
        * platform/graphics/cg/IntRectCG.cpp:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivateQTKit::createQTMovieView):
        (WebCore::MediaPlayerPrivateQTKit::createQTVideoRenderer):
        (WebCore::MediaPlayerPrivateQTKit::createQTMovieLayer):
        (WebCore::MediaPlayerPrivateQTKit::preferredRenderingMode):
        (WebCore::MediaPlayerPrivateQTKit::paint):
        (-[WebCoreMovieObserver layerHostChanged:]):
        * platform/mac/KURLMac.mm:
        * platform/mac/SharedBufferMac.mm:
        (+[WebCoreSharedBufferData initialize]):
        * platform/mac/WebCoreObjCExtras.mm:
        * platform/qt/WebCoreSystemInterface.h: Added.
        * platform/qt/WebCoreSystemInterface.mm: Added.
2011-05-25  Alexis Menard  <alexis.menard@openbossa.org>

        Reviewed by Eric Carlson.

        [Qt] Enable usage of QuickTime mediaplayer for the Qt port on Mac.
        https://bugs.webkit.org/show_bug.cgi?id=61279

        Enable the usage of QuickTime backend for the Qt port. It can be enabled by
        passing DEFINES+=USE_QTKIT=1 when calling build-webkit.

        * Api/qwebpage.cpp:
        (QWebPagePrivate::QWebPagePrivate):
        * QtWebKit.pro:
        * WebCoreSupport/FullScreenVideoQt.cpp:
        (WebCore::FullScreenVideoQt::enterFullScreenForNode):
        (WebCore::FullScreenVideoQt::requiresFullScreenForVideoPlayback):
        (WebCore::FullScreenVideoQt::isValid):
        * WebCoreSupport/WebSystemInterface.h: Added.
        * WebCoreSupport/WebSystemInterface.mm: Added.
        (InitWebCoreSystemInterface):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87312 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.pri
Source/WebCore/WebCore.pro
Source/WebCore/features.pri
Source/WebCore/platform/KURL.h
Source/WebCore/platform/SharedBuffer.h
Source/WebCore/platform/cf/KURLCFNet.cpp
Source/WebCore/platform/cf/SharedBufferCF.cpp
Source/WebCore/platform/graphics/FloatSize.h
Source/WebCore/platform/graphics/IntRect.h
Source/WebCore/platform/graphics/IntSize.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp
Source/WebCore/platform/graphics/cg/IntRectCG.cpp
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
Source/WebCore/platform/mac/KURLMac.mm
Source/WebCore/platform/mac/SharedBufferMac.mm
Source/WebCore/platform/mac/WebCoreObjCExtras.mm
Source/WebCore/platform/qt/WebCoreSystemInterface.h [new file with mode: 0644]
Source/WebCore/platform/qt/WebCoreSystemInterface.mm [new file with mode: 0644]
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/QtWebKit.pro
Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp
Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h [new file with mode: 0644]
Source/WebKit/qt/WebCoreSupport/WebSystemInterface.mm [new file with mode: 0644]

index c6900e1..1be8961 100644 (file)
@@ -1,3 +1,42 @@
+2011-05-25  Alexis Menard  <alexis.menard@openbossa.org>
+
+        Reviewed by Eric Carlson.
+
+        [Qt] Enable usage of QuickTime mediaplayer for the Qt port on Mac.
+        https://bugs.webkit.org/show_bug.cgi?id=61279
+
+        Enable the QuickTime backend for the Qt port on Mac. The patch adds the bits in WebCore
+        to enable the QTKit backend of the Mac port. It can be enabled by passing DEFINES+=USE_QTKIT=1
+        when calling build-webkit.
+
+        * WebCore.pri:
+        * WebCore.pro:
+        * features.pri:
+        * platform/KURL.h:
+        * platform/SharedBuffer.h:
+        * platform/cf/KURLCFNet.cpp:
+        * platform/cf/SharedBufferCF.cpp:
+        * platform/graphics/FloatSize.h:
+        * platform/graphics/IntRect.h:
+        * platform/graphics/IntSize.h:
+        * platform/graphics/MediaPlayer.cpp:
+        * platform/graphics/cg/FloatSizeCG.cpp:
+        * platform/graphics/cg/IntRectCG.cpp:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivateQTKit::createQTMovieView):
+        (WebCore::MediaPlayerPrivateQTKit::createQTVideoRenderer):
+        (WebCore::MediaPlayerPrivateQTKit::createQTMovieLayer):
+        (WebCore::MediaPlayerPrivateQTKit::preferredRenderingMode):
+        (WebCore::MediaPlayerPrivateQTKit::paint):
+        (-[WebCoreMovieObserver layerHostChanged:]):
+        * platform/mac/KURLMac.mm:
+        * platform/mac/SharedBufferMac.mm:
+        (+[WebCoreSharedBufferData initialize]):
+        * platform/mac/WebCoreObjCExtras.mm:
+        * platform/qt/WebCoreSystemInterface.h: Added.
+        * platform/qt/WebCoreSystemInterface.mm: Added.
+
 2011-05-25  Rob Buis  <rbuis@rim.com>
 
         Reviewed by Eric Seidel.
index 9954ed2..fd13353 100644 (file)
@@ -243,7 +243,16 @@ contains(DEFINES, WTF_USE_QT_BEARER=1) {
 }
 
 contains(DEFINES, ENABLE_VIDEO=1) {
-    contains(DEFINES, USE_GSTREAMER=1) {
+    contains(DEFINES, USE_QTKIT=1) {
+        DEFINES += WTF_USE_QTKIT=1
+
+        INCLUDEPATH += $$PWD/platform/graphics/mac
+
+        LIBS += -framework AppKit -framework AudioUnit \
+                -framework AudioToolbox -framework CoreAudio \
+                -framework QuartzCore -framework QTKit
+
+    } else:contains(DEFINES, USE_GSTREAMER=1) {
         DEFINES += WTF_USE_GSTREAMER=1
         DEFINES += ENABLE_GLIB_SUPPORT=1
 
index 50977bf..30dd6c5 100644 (file)
@@ -2960,7 +2960,31 @@ contains(DEFINES, ENABLE_VIDEO=1) {
             bindings/js/JSAudioConstructor.cpp
     }
 
-    contains(DEFINES, USE_GSTREAMER=1) {
+    contains(DEFINES, USE_QTKIT=1) {
+        HEADERS += \
+            platform/graphics/mac/MediaPlayerPrivateQTKit.h \
+            platform/mac/WebCoreObjCExtras.h \
+            platform/qt/WebCoreSystemInterface.h \
+            platform/mac/BlockExceptions.h \
+            platform/mac/WebCoreObjCExtras.h
+        SOURCES += \
+            platform/graphics/mac/MediaPlayerPrivateQTKit.mm \
+            platform/mac/SharedBufferMac.mm \
+            platform/mac/KURLMac.mm \
+            platform/text/mac/StringMac.mm \
+            platform/graphics/mac/FloatSizeMac.mm \
+            platform/graphics/mac/IntRectMac.mm \
+            platform/graphics/cg/IntRectCG.cpp \
+            platform/graphics/cg/FloatSizeCG.cpp \
+            platform/cf/SharedBufferCF.cpp \
+            platform/cf/KURLCFNet.cpp \
+            platform/qt/WebCoreSystemInterface.mm \
+            platform/mac/BlockExceptions.mm \
+            platform/mac/WebCoreObjCExtras.mm
+
+        DEFINES+=NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+    } else: contains(DEFINES, USE_GSTREAMER=1) {
         HEADERS += \
             platform/graphics/gstreamer/GOwnPtrGStreamer.h \
             platform/graphics/gstreamer/GRefPtrGStreamer.h \
index 89074d6..9ffbb1c 100644 (file)
@@ -164,7 +164,12 @@ symbian|maemo5|maemo6 {
     DEFINES -= ENABLE_VIDEO=1
     DEFINES += ENABLE_VIDEO=0
 
-    contains(DEFINES, USE_GSTREAMER=1) {
+    contains(DEFINES, USE_QTKIT=1) {
+        DEFINES -= ENABLE_VIDEO=0
+        DEFINES += ENABLE_VIDEO=1
+        DEFINES -= WTF_USE_QT_MULTIMEDIA=1
+        DEFINES += WTF_USE_QT_MULTIMEDIA=0
+    } else: contains(DEFINES, USE_GSTREAMER=1) {
         DEFINES -= ENABLE_VIDEO=0
         DEFINES += ENABLE_VIDEO=1
         DEFINES -= WTF_USE_QT_MULTIMEDIA=1
index 94dcba8..fd2af60 100644 (file)
@@ -34,7 +34,7 @@
 typedef const struct __CFURL* CFURLRef;
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
 #ifdef __OBJC__
 @class NSURL;
 #else
@@ -202,7 +202,7 @@ public:
     CFURLRef createCFURL() const;
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
     KURL(NSURL*);
     operator NSURL*() const;
 #endif
index 967ed96..4f1d629 100644 (file)
@@ -36,7 +36,7 @@
 #include <wtf/RetainPtr.h>
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
 #ifdef __OBJC__
 @class NSData;
 #else
@@ -65,7 +65,7 @@ public:
     
     ~SharedBuffer();
     
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
     NSData *createNSData();
     static PassRefPtr<SharedBuffer> wrapNSData(NSData *data);
 #endif
index f060b28..bc84909 100644 (file)
@@ -78,6 +78,7 @@ CFURLRef KURL::createCFURL() const
     return result;
 }
 
+#if !(PLATFORM(QT) && USE(QTKIT))
 String KURL::fileSystemPath() const
 {
     RetainPtr<CFURLRef> cfURL(AdoptCF, createCFURL());
@@ -91,5 +92,5 @@ String KURL::fileSystemPath() const
 #endif
     return RetainPtr<CFStringRef>(AdoptCF, CFURLCopyFileSystemPath(cfURL.get(), pathStyle)).get();
 }
-
+#endif
 }
index 319f484..3e1b03d 100644 (file)
@@ -40,7 +40,7 @@ SharedBuffer::SharedBuffer(CFDataRef cfData)
 
 // Mac is a CF platform but has an even more efficient version of this method,
 // so only use this version for non-Mac
-#if !PLATFORM(MAC)
+#if !PLATFORM(MAC) && !(PLATFORM(QT) && USE(QTKIT))
 CFDataRef SharedBuffer::createCFData()
 {
     if (m_cfData) {
index afcd2d3..ce9efc5 100644 (file)
@@ -35,7 +35,7 @@
 typedef struct CGSize CGSize;
 #endif
 
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGSize NSSize;
 #else
@@ -97,7 +97,7 @@ public:
 #endif
 
 #if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)) \
-        || (PLATFORM(CHROMIUM) && OS(DARWIN))
+        || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
     explicit FloatSize(const NSSize &); // don't do this implicitly since it's lossy
     operator NSSize() const;
 #endif
index 80363c3..360b856 100644 (file)
@@ -33,7 +33,7 @@
 typedef struct CGRect CGRect;
 #endif
 
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGRect NSRect;
 #else
@@ -203,7 +203,7 @@ public:
 #endif
 
 #if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)) \
-        || (PLATFORM(CHROMIUM) && OS(DARWIN))
+        || (PLATFORM(CHROMIUM) && OS(DARWIN))  || (PLATFORM(QT) && USE(QTKIT))
     operator NSRect() const;
 #endif
 
@@ -243,7 +243,7 @@ IntRect enclosingIntRect(const CGRect&);
 #endif
 
 #if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)) \
-        || (PLATFORM(CHROMIUM) && OS(DARWIN))
+        || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
 IntRect enclosingIntRect(const NSRect&);
 #endif
 
index 8cfabf5..db4e54c 100644 (file)
@@ -30,7 +30,7 @@
 typedef struct CGSize CGSize;
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGSize NSSize;
 #else
@@ -114,7 +114,7 @@ public:
     operator CGSize() const;
 #endif
 
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+#if (PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
     explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
     operator NSSize() const;
 #endif
index 9dbe34a..4781a39 100644 (file)
@@ -46,7 +46,7 @@
 #include "MediaPlayerPrivateGStreamer.h"
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
 #include "MediaPlayerPrivateQTKit.h"
 #if USE(AVFOUNDATION)
 #include "MediaPlayerPrivateAVFoundationObjC.h"
@@ -62,7 +62,7 @@
 #if USE(QT_MULTIMEDIA) && !USE(GSTREAMER)
 #include "MediaPlayerPrivateQt.h"
 #define PlatformMediaEngineClassName MediaPlayerPrivateQt
-#elif !USE(GSTREAMER)
+#elif !USE(GSTREAMER) && !USE(QTKIT)
 #include "MediaPlayerPrivatePhonon.h"
 #define PlatformMediaEngineClassName MediaPlayerPrivatePhonon
 #endif
index a035c7a..475ebc0 100644 (file)
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "FloatSize.h"
 
-#if USE(CG) || USE(SKIA_ON_MAC_CHROME)
+#if USE(CG) || USE(SKIA_ON_MAC_CHROME) || (PLATFORM(QT) && USE(QTKIT))
 
 #include <ApplicationServices/ApplicationServices.h>
 
index 18edeb0..ebd9655 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "IntRect.h"
 
-#if USE(CG) || USE(SKIA_ON_MAC_CHROME)
+#if USE(CG) || USE(SKIA_ON_MAC_CHROME) || (PLATFORM(QT) && USE(QTKIT))
 
 #include <ApplicationServices/ApplicationServices.h>
 
index b679f64..a41946a 100644 (file)
@@ -41,6 +41,8 @@
 @class QTVideoRendererWebKitOnly;
 @class WebCoreMovieObserver;
 #else
+class NSDictionary;
+class NSMutableDictionary;
 class QTMovie;
 class QTMovieView;
 class QTTime;
@@ -85,7 +87,7 @@ private:
     static bool isAvailable();
 
     PlatformMedia platformMedia() const;
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
     PlatformLayer* platformLayer() const;
 #endif
 
@@ -137,7 +139,7 @@ private:
     virtual void prepareForRendering();
 
 
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
     bool supportsAcceleratedRendering() const;
     void acceleratedRenderingStateChanged();
 #endif
index 3f55cb4..97a4902 100644 (file)
@@ -38,6 +38,7 @@
 #import "DocumentLoader.h"
 #import "Frame.h"
 #import "FrameView.h"
+#import "HostWindow.h"
 #import "GraphicsContext.h"
 #import "KURL.h"
 #import "MIMETypeRegistry.h"
@@ -59,7 +60,6 @@
 #import "RenderStyle.h"
 #endif
 
-
 SOFT_LINK_FRAMEWORK(QTKit)
 
 SOFT_LINK(QTKit, QTMakeTime, QTTime, (long long timeValue, long timeScale), (timeValue, timeScale))
@@ -455,8 +455,11 @@ void MediaPlayerPrivateQTKit::createQTMovieView()
 
     m_qtMovieView.adoptNS([[QTMovieView alloc] init]);
     setSize(m_player->size());
-    NSView* parentView = m_player->frameView()->documentView();
+    NSView* parentView = 0;
+#if PLATFORM(MAC)
+    parentView = m_player->frameView()->documentView();
     [parentView addSubview:m_qtMovieView.get()];
+#endif
     [m_qtMovieView.get() setDelegate:m_objcObserver.get()];
     [m_objcObserver.get() setView:m_qtMovieView.get()];
     [m_qtMovieView.get() setMovie:m_qtMovie.get()];
@@ -493,7 +496,7 @@ void MediaPlayerPrivateQTKit::createQTVideoRenderer(QTVideoRendererMode renderer
         return;
     
     // associate our movie with our instance of QTVideoRendererWebKitOnly
-    [(id<WebKitVideoRenderingDetails>)m_qtVideoRenderer.get() setMovie:m_qtMovie.get()];    
+    [(id<WebKitVideoRenderingDetails>)m_qtVideoRenderer.get() setMovie:m_qtMovie.get()];
 
     if (rendererMode == QTVideoRendererModeListensForNewImages) {
         // listen to QTVideoRendererWebKitOnly's QTVideoRendererWebKitOnlyNewImageDidBecomeAvailableNotification
@@ -522,7 +525,7 @@ void MediaPlayerPrivateQTKit::destroyQTVideoRenderer()
 
 void MediaPlayerPrivateQTKit::createQTMovieLayer()
 {
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
     if (!m_qtMovie)
         return;
 
@@ -573,7 +576,7 @@ MediaPlayerPrivateQTKit::MediaRenderingMode MediaPlayerPrivateQTKit::preferredRe
     if (!m_player->frameView() || !m_qtMovie)
         return MediaRenderingNone;
 
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
     if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
         return MediaRenderingMovieLayer;
 #endif
@@ -699,7 +702,7 @@ PlatformMedia MediaPlayerPrivateQTKit::platformMedia() const
     return pm;
 }
 
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
 PlatformLayer* MediaPlayerPrivateQTKit::platformLayer() const
 {
     return m_qtVideoLayer.get();
@@ -1212,7 +1215,7 @@ void MediaPlayerPrivateQTKit::didEnd()
     m_player->timeChanged();
 }
 
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
 #if defined(BUILDING_ON_SNOW_LEOPARD)
 static bool layerIsDescendentOf(PlatformLayer* child, PlatformLayer* descendent)
 {
@@ -1327,14 +1330,28 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
 
     [m_objcObserver.get() setDelayCallbacks:YES];
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    NSGraphicsContext* newContext;
+    FloatSize scaleFactor(1.0f, -1.0f);
+    IntRect paintRect(IntPoint(0, 0), IntSize(r.width(), r.height()));
+
+#if PLATFORM(QT) && USE(QTKIT)
+    // In Qt, GraphicsContext is a QPainter so every transformations applied on it won't matter because here
+    // the video is rendered by QuickTime not by Qt.
+    CGContextRef cgContext = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+    CGContextSaveGState(cgContext);
+    CGContextSetInterpolationQuality(cgContext, kCGInterpolationLow);
+    CGContextTranslateCTM(cgContext, r.x(), r.y() + r.height());
+    CGContextScaleCTM(cgContext, scaleFactor.width(), scaleFactor.height());
+
+    newContext = [NSGraphicsContext currentContext];
+#else
     GraphicsContextStateSaver stateSaver(*context);
     context->translate(r.x(), r.y() + r.height());
-    context->scale(FloatSize(1.0f, -1.0f));
+    context->scale(scaleFactor);
     context->setImageInterpolationQuality(InterpolationLow);
-    IntRect paintRect(IntPoint(0, 0), IntSize(r.width(), r.height()));
-    
-    NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context->platformContext() flipped:NO];
 
+    newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context->platformContext() flipped:NO];
+#endif
     // draw the current video frame
     if (qtVideoRenderer) {
         [NSGraphicsContext saveGraphicsState];
@@ -1388,7 +1405,9 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
         }
     }
 #endif
-
+#if PLATFORM(QT) && USE(QTKIT)
+    CGContextRestoreGState(cgContext);
+#endif
     END_BLOCK_OBJC_EXCEPTIONS;
     [m_objcObserver.get() setDelayCallbacks:NO];
 }
@@ -1593,7 +1612,7 @@ void MediaPlayerPrivateQTKit::sawUnsupportedTracks()
     m_player->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks(m_player);
 }
 
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
 bool MediaPlayerPrivateQTKit::supportsAcceleratedRendering() const
 {
     return isReadyForVideoSetup() && getQTMovieLayerClass() != Nil;
@@ -1744,7 +1763,7 @@ void MediaPlayerPrivateQTKit::setPrivateBrowsingMode(bool privateBrowsing)
 
 - (void)layerHostChanged:(NSNotification *)notification
 {
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
     CALayer* rootLayer = static_cast<CALayer*>([notification object]);
     m_callback->layerHostChanged(rootLayer);
 #else
index c913ab4..e6feec1 100644 (file)
@@ -27,6 +27,7 @@
 #import "KURL.h"
 
 #import "FoundationExtras.h"
+#import <CoreFoundation/CFURL.h>
 
 namespace WebCore {
 
index 70eca27..eb5cf2c 100644 (file)
@@ -47,7 +47,11 @@ using namespace WebCore;
 + (void)initialize
 {
     JSC::initializeThreading();
+#if PLATFORM(QT) && USE(QTKIT)
+    WTF::initializeMainThread();
+#else
     WTF::initializeMainThreadToProcessMainThread();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
@@ -107,7 +111,7 @@ CFDataRef SharedBuffer::createCFData()
     
     return (CFDataRef)RetainPtr<WebCoreSharedBufferData>(AdoptNS, [[WebCoreSharedBufferData alloc] initWithSharedBuffer:this]).releaseRef();
 }
-
+#if !(PLATFORM(QT) && USE(QTKIT))
 PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath)
 {
     NSData *resourceData = [NSData dataWithContentsOfFile:filePath];
@@ -115,6 +119,6 @@ PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& fi
         return SharedBuffer::wrapNSData(resourceData);
     return 0;
 }
-
+#endif
 }
 
index 82afbf0..41b5ec5 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <objc/objc-auto.h>
 #include <objc/objc-runtime.h>
+#include <utility>
 #include <wtf/Assertions.h>
 #include <wtf/MainThread.h>
 #include <wtf/Threading.h>
diff --git a/Source/WebCore/platform/qt/WebCoreSystemInterface.h b/Source/WebCore/platform/qt/WebCoreSystemInterface.h
new file mode 100644 (file)
index 0000000..3669ca3
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef WebCoreSystemInterface_h
+#define WebCoreSystemInterface_h
+
+#include <objc/objc.h>
+
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+typedef struct CGPoint NSPoint;
+typedef struct CGRect NSRect;
+#else
+typedef struct _NSPoint NSPoint;
+typedef struct _NSRect NSRect;
+#endif
+
+#ifdef __OBJC__
+@class NSArray;
+@class NSString;
+@class QTMovie;
+@class QTMovieView;
+#else
+class NSArray;
+class NSString;
+class QTMovie;
+class QTMovieView;
+#endif
+
+extern "C" {
+
+// In alphabetical order.
+extern unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
+extern int (*wkQTMovieDataRate)(QTMovie*);
+extern void (*wkQTMovieDisableComponent)(uint32_t[5]);
+extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
+extern NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
+extern float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
+extern int (*wkQTMovieGetType)(QTMovie*);
+extern BOOL (*wkQTMovieHasClosedCaptions)(QTMovie*);
+extern void (*wkQTMovieSetShowClosedCaptions)(QTMovie*, BOOL);
+extern void (*wkQTMovieSelectPreferredAlternates)(QTMovie*);
+extern void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
+extern NSArray *(*wkQTGetSitesInMediaDownloadCache)();
+extern void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
+extern void (*wkQTClearMediaDownloadCache)();
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/qt/WebCoreSystemInterface.mm b/Source/WebCore/platform/qt/WebCoreSystemInterface.mm
new file mode 100644 (file)
index 0000000..0b4e2ef
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "WebCoreSystemInterface.h"
+#import <Foundation/Foundation.h>
+
+unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
+int (*wkQTMovieDataRate)(QTMovie*);
+void (*wkQTMovieDisableComponent)(uint32_t[5]);
+float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
+NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
+float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
+int (*wkQTMovieGetType)(QTMovie*);
+BOOL (*wkQTMovieHasClosedCaptions)(QTMovie*);
+void (*wkQTMovieSetShowClosedCaptions)(QTMovie*, BOOL);
+void (*wkQTMovieSelectPreferredAlternates)(QTMovie*);
+void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
+NSArray *(*wkQTGetSitesInMediaDownloadCache)();
+void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
+void (*wkQTClearMediaDownloadCache)();
+
index 36652cd..87dd926 100644 (file)
 #endif // Q_OS_WIN32
 #include "TextIterator.h"
 #include "WebPlatformStrategies.h"
+#if USE(QTKIT)
+#include "WebSystemInterface.h"
+#endif
 #include "WindowFeatures.h"
 #include "WorkerThread.h"
 #include "runtime/InitializeThreading.h"
@@ -317,6 +320,10 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
 
     WebPlatformStrategies::initialize();
 
+#if USE(QTKIT)
+    InitWebCoreSystemInterface();
+#endif
+
     Page::PageClients pageClients;
     pageClients.chromeClient = new ChromeClientQt(q);
     pageClients.contextMenuClient = new ContextMenuClientQt();
index e39ff59..3cf10f1 100644 (file)
@@ -1,3 +1,24 @@
+2011-05-25  Alexis Menard  <alexis.menard@openbossa.org>
+
+        Reviewed by Eric Carlson.
+
+        [Qt] Enable usage of QuickTime mediaplayer for the Qt port on Mac.
+        https://bugs.webkit.org/show_bug.cgi?id=61279
+
+        Enable the usage of QuickTime backend for the Qt port. It can be enabled by
+        passing DEFINES+=USE_QTKIT=1 when calling build-webkit.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate):
+        * QtWebKit.pro:
+        * WebCoreSupport/FullScreenVideoQt.cpp:
+        (WebCore::FullScreenVideoQt::enterFullScreenForNode):
+        (WebCore::FullScreenVideoQt::requiresFullScreenForVideoPlayback):
+        (WebCore::FullScreenVideoQt::isValid):
+        * WebCoreSupport/WebSystemInterface.h: Added.
+        * WebCoreSupport/WebSystemInterface.mm: Added.
+        (InitWebCoreSystemInterface):
+
 2011-05-25  Qi Zhang  <qi.2.zhang@nokia.com>
 
         Reviewed by Andreas Kling.
index 2769ab6..1f297f3 100644 (file)
@@ -215,7 +215,7 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
 }
 
 contains(DEFINES, ENABLE_VIDEO=1) {
-    !contains(DEFINES, USE_GSTREAMER=1):contains(MOBILITY_CONFIG, multimedia) {
+    !contains(DEFINES, USE_QTKIT=1):!contains(DEFINES, USE_GSTREAMER=1):contains(MOBILITY_CONFIG, multimedia) {
         HEADERS += $$PWD/WebCoreSupport/FullScreenVideoWidget.h
         SOURCES += $$PWD/WebCoreSupport/FullScreenVideoWidget.cpp
     }
@@ -224,6 +224,24 @@ contains(DEFINES, ENABLE_VIDEO=1) {
         HEADERS += $$PWD/WebCoreSupport/FullScreenVideoQt.h
         SOURCES += $$PWD/WebCoreSupport/FullScreenVideoQt.cpp
     }
+
+    contains(DEFINES, USE_QTKIT=1) {
+        INCLUDEPATH += $$SOURCE_DIR/WebCore/platform/qt/
+        INCLUDEPATH += $$SOURCE_DIR/../WebKitLibraries/
+        DEFINES+=NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+        HEADERS += $$PWD/WebCoreSupport/WebSystemInterface.h
+        SOURCES += $$PWD/WebCoreSupport/WebSystemInterface.mm
+        # We can know the Mac OS version by using the Darwin major version
+        DARWIN_VERSION = $$split(QMAKE_HOST.version, ".")
+        DARWIN_MAJOR_VERSION = $$first(DARWIN_VERSION)
+        equals(DARWIN_MAJOR_VERSION, "10") {
+            LIBS+= $$SOURCE_DIR/../WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a -framework Security
+        } else {
+            equals(DARWIN_MAJOR_VERSION, "9") {
+                LIBS+= $$SOURCE_DIR/../WebKitLibraries/libWebKitSystemInterfaceLeopard.a -framework Security
+            }
+        }
+    }
 }
 
 contains(DEFINES, ENABLE_ICONDATABASE=1) {
index b24d2ee..9cecb50 100644 (file)
@@ -162,11 +162,10 @@ FullScreenVideoQt::~FullScreenVideoQt()
 void FullScreenVideoQt::enterFullScreenForNode(Node* node)
 {
     Q_ASSERT(node);
-    Q_ASSERT(m_FullScreenVideoHandler);
-
     m_videoElement = static_cast<HTMLVideoElement*>(node);
 
 #if USE(QT_MULTIMEDIA)
+    Q_ASSERT(m_FullScreenVideoHandler);
     HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
     PlatformMedia platformMedia = videoElement->platformMedia();
 
@@ -236,6 +235,8 @@ bool FullScreenVideoQt::requiresFullScreenForVideoPlayback()
 #endif
 #if USE(GSTREAMER)
     return false;
+#else
+    return false;
 #endif
 }
 
@@ -246,6 +247,8 @@ bool FullScreenVideoQt::isValid() const
 #endif
 #if USE(GSTREAMER)
     return m_FullScreenVideoHandlerGStreamer;
+#else
+    return 0;
 #endif
 }
 
diff --git a/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h b/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.h
new file mode 100644 (file)
index 0000000..467b5ba
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+
+void InitWebCoreSystemInterface();
diff --git a/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.mm b/Source/WebKit/qt/WebCoreSupport/WebSystemInterface.mm
new file mode 100644 (file)
index 0000000..48b60cc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebSystemInterface.h"
+
+// Needed for builds not using PCH to expose BUILDING_ macros, see bug 32753.
+#include <wtf/Platform.h>
+
+#import <WebCoreSystemInterface.h>
+#import <WebKitSystemInterface.h>
+
+#define INIT(function) wk##function = WK##function
+
+void InitWebCoreSystemInterface(void)
+{
+    static bool didInit;
+    if (didInit)
+        return;
+
+    INIT(QTIncludeOnlyModernMediaFileTypes);
+    INIT(QTMovieDataRate);
+    INIT(QTMovieDisableComponent);
+    INIT(QTMovieMaxTimeLoaded);
+    INIT(QTMovieMaxTimeLoadedChangeNotification);
+    INIT(QTMovieMaxTimeSeekable);
+    INIT(QTMovieGetType);
+    INIT(QTMovieHasClosedCaptions);
+    INIT(QTMovieSetShowClosedCaptions);
+    INIT(QTMovieSelectPreferredAlternates);
+    INIT(QTMovieViewSetDrawSynchronously);
+    INIT(QTGetSitesInMediaDownloadCache);
+    INIT(QTClearMediaDownloadCacheForSite);
+    INIT(QTClearMediaDownloadCache);
+
+    didInit = true;
+}