[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jer.noble at apple.com jer.noble at apple.com
Wed Dec 22 14:50:12 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit ab7a35f08342dd023834df01c599cb4d8b3103ac
Author: jer.noble at apple.com <jer.noble at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 21 18:19:04 2010 +0000

    2010-10-20  Jer Noble  <jer.noble at apple.com>
    
            Reviewed by Eric Carlson.
    
            Video -> Canvas doesn't work on Windows
            https://bugs.webkit.org/show_bug.cgi?id=47996
            rdar://problem/7884690
    
            * WebCore.vcproj/QTMovieWin.vcproj: Added QTDecompressionSession.{cpp,h}
            * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
            (WebCore::MediaPlayerPrivateQuickTimeVisualContext::paint): Create a
                QTDecompressionSession if necessary and convert the QTPixelBuffer
                into a CG-compatible one.
            * platform/graphics/win/QTDecompressionSession.cpp: Added.
            * platform/graphics/win/QTDecompressionSession.h: Added.
            * platform/graphics/win/QTPixelBuffer.cpp:
            (SetNumberValue): Moved from QTMovieVisualContext.
            (QTPixelBuffer::createPixelBufferAttributesDictionary): Moved from inside
                QTMovieVisualContext::createPixelBufferOptionsDictionary().
            * platform/graphics/win/QTPixelBuffer.h: Moved the Type enum
                from QTMovieVisualContext.h.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70252 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 33a74d8..c4654c7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-10-20  Jer Noble  <jer.noble at apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Video -> Canvas doesn't work on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=47996
+        rdar://problem/7884690
+
+        * WebCore.vcproj/QTMovieWin.vcproj: Added QTDecompressionSession.{cpp,h}
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::paint): Create a 
+            QTDecompressionSession if necessary and convert the QTPixelBuffer
+            into a CG-compatible one.
+        * platform/graphics/win/QTDecompressionSession.cpp: Added.
+        * platform/graphics/win/QTDecompressionSession.h: Added.
+        * platform/graphics/win/QTPixelBuffer.cpp:
+        (SetNumberValue): Moved from QTMovieVisualContext.
+        (QTPixelBuffer::createPixelBufferAttributesDictionary): Moved from inside
+            QTMovieVisualContext::createPixelBufferOptionsDictionary().
+        * platform/graphics/win/QTPixelBuffer.h: Moved the Type enum 
+            from QTMovieVisualContext.h.
+
 2010-10-21  Carlos Garcia Campos  <cgarcia at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebCore/WebCore.vcproj/QTMovieWin.vcproj b/WebCore/WebCore.vcproj/QTMovieWin.vcproj
index adda5e0..73e287e 100644
--- a/WebCore/WebCore.vcproj/QTMovieWin.vcproj
+++ b/WebCore/WebCore.vcproj/QTMovieWin.vcproj
@@ -318,6 +318,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\platform\graphics\win\QTDecompressionSession.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\platform\graphics\win\QTMovie.cpp"
 				>
 			</File>
@@ -356,6 +360,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\platform\graphics\win\QTDecompressionSession.h"
+				>
+			</File>
+			<File
 				RelativePath="..\platform\graphics\win\QTMovie.h"
 				>
 			</File>
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
index 1b4f1d9..92263b6 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
@@ -36,6 +36,7 @@
 #include "KURL.h"
 #include "MediaPlayerPrivateTaskTimer.h"
 #include "QTCFDictionary.h"
+#include "QTDecompressionSession.h"
 #include "QTMovie.h"
 #include "QTMovieTask.h"
 #include "QTMovieVisualContext.h"
@@ -728,12 +729,25 @@ void MediaPlayerPrivateQuickTimeVisualContext::paint(GraphicsContext* p, const I
     if (currentMode == MediaRenderingSoftwareRenderer && !m_visualContext)
         return;
 
-#if USE(ACCELERATED_COMPOSITING)
-    if (m_qtVideoLayer)
-        return;
-#endif
     QTPixelBuffer buffer = m_visualContext->imageForTime(0);
     if (buffer.pixelBufferRef()) {
+#if USE(ACCELERATED_COMPOSITING)
+        if (m_qtVideoLayer) {
+            // We are probably being asked to render the video into a canvas, but 
+            // there's a good chance the QTPixelBuffer is not ARGB and thus can't be
+            // drawn using CG.  If so, fire up an ICMDecompressionSession and convert 
+            // the current frame into something which can be rendered by CG.
+            if (!buffer.pixelFormatIs32ARGB() && !buffer.pixelFormatIs32BGRA()) {
+                // The decompression session will only decompress a specific pixelFormat 
+                // at a specific width and height; if these differ, the session must be
+                // recreated with the new parameters.
+                if (!m_decompressionSession || !m_decompressionSession->canDecompress(buffer))
+                    m_decompressionSession = QTDecompressionSession::create(buffer.pixelFormatType(), buffer.width(), buffer.height());
+            }
+
+            buffer = m_decompressionSession->decompress(buffer);
+        }
+#endif
         CGImageRef image = CreateCGImageFromPixelBuffer(buffer);
         
         CGContextRef context = p->platformContext();
@@ -1089,7 +1103,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpVideoRendering()
         m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player);
 #endif
 
-    QTMovieVisualContext::Type contextType = requiredDllsAvailable() && preferredMode == MediaRenderingMovieLayer ? QTMovieVisualContext::ConfigureForCAImageQueue : QTMovieVisualContext::ConfigureForCGImage;
+    QTPixelBuffer::Type contextType = requiredDllsAvailable() && preferredMode == MediaRenderingMovieLayer ? QTPixelBuffer::ConfigureForCAImageQueue : QTPixelBuffer::ConfigureForCGImage;
     m_visualContext = QTMovieVisualContext::create(m_visualContextClient.get(), contextType);
     m_visualContext->setMovie(m_movie.get());
 }
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
index 4c62558..109fd0b 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
@@ -42,6 +42,7 @@
 typedef struct CGImage *CGImageRef;
 class QTMovie;
 class QTMovieVisualContext;
+class QTDecompressionSession;
 
 namespace WebCore {
 
@@ -178,6 +179,7 @@ private:
     RefPtr<WKCACFLayer> m_qtVideoLayer;
     OwnPtr<GraphicsLayer> m_transformLayer;
     OwnPtr<WKCAImageQueue> m_imageQueue;
+    OwnPtr<QTDecompressionSession> m_decompressionSession;
     CGAffineTransform m_movieTransform; 
 #endif
     RefPtr<QTMovieVisualContext> m_visualContext;
diff --git a/WebCore/platform/graphics/win/QTDecompressionSession.cpp b/WebCore/platform/graphics/win/QTDecompressionSession.cpp
new file mode 100644
index 0000000..eeb3ca7
--- /dev/null
+++ b/WebCore/platform/graphics/win/QTDecompressionSession.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 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. 
+ */
+#include "config.h"
+
+#include "QTDecompressionSession.h"
+
+#include <ImageCompression.h>
+#include <algorithm>
+
+class QTDecompressionSessionClient {
+public:
+    static void trackingCallback(void *decompressionTrackingRefCon, OSStatus, 
+        ICMDecompressionTrackingFlags decompressionTrackingFlags, CVPixelBufferRef pixelBuffer, 
+        TimeValue64, TimeValue64, ICMValidTimeFlags, void *, void *)
+    {
+        QTDecompressionSession* session = static_cast<QTDecompressionSession*>(decompressionTrackingRefCon);
+        ASSERT(session);
+
+        if (decompressionTrackingFlags & kICMDecompressionTracking_FrameDecoded)
+            session->m_latestFrame = QTPixelBuffer(pixelBuffer);
+    }
+};
+
+PassOwnPtr<QTDecompressionSession> QTDecompressionSession::create(unsigned long pixelFormat, size_t width, size_t height)
+{
+    return adoptPtr(new QTDecompressionSession(pixelFormat, width, height));
+}
+
+QTDecompressionSession::QTDecompressionSession(unsigned long pixelFormat, size_t width, size_t height)
+    : m_session(0)
+    , m_pixelFormat(pixelFormat)
+    , m_width(width)
+    , m_height(height)
+{
+    initializeSession();
+}
+
+QTDecompressionSession::~QTDecompressionSession()
+{
+    if (m_session)
+        ICMDecompressionSessionRelease(m_session);
+}
+
+void QTDecompressionSession::initializeSession()
+{
+    if (m_session)
+        return;
+
+    ICMPixelFormatInfo pixelFormatInfo = {sizeof(ICMPixelFormatInfo), 0};
+    if (ICMGetPixelFormatInfo(m_pixelFormat, &pixelFormatInfo) != noErr) {
+        // The ICM does not know anything about the pixelFormat contained in
+        // the pixel buffer, so it won't be able to convert it to RGBA.  
+        return;
+    }
+
+    // The depth and cType fields of the ImageDescriptionHandle are filled 
+    // out according to the instructions in Technical Q&A QA1183: 
+    // http://developer.apple.com/library/mac/#qa/qa2001/qa1183.html
+    bool isIndexed = pixelFormatInfo.formatFlags & kICMPixelFormatIsIndexed;
+    bool isQD = pixelFormatInfo.formatFlags & kICMPixelFormatIsSupportedByQD;
+    bool isMonochrome = pixelFormatInfo.formatFlags & kICMPixelFormatIsMonochrome;
+    bool hasAlpha = pixelFormatInfo.formatFlags & kICMPixelFormatHasAlphaChannel;
+
+    unsigned int depth = 24; // The default depth is 24.
+    if (hasAlpha)
+        depth = 32; // Any pixel format with alpha gets a depth of 32.
+    else if (isMonochrome) {
+        // Grayscale pixel formats get depths 33 through 40, depending
+        // on their bits per pixel. Yes, this means that 16-bit grayscale
+        // and 8-bit grayscale have the same pixel depth.
+        depth = 32 + std::min<unsigned int>(8, pixelFormatInfo.bitsPerPixel[0]);
+    } else if (isIndexed) {
+        // Indexed pixel formats get a depth of 1 through 8, depending on
+        // the their bits per pixel.
+        depth = pixelFormatInfo.bitsPerPixel[0]; 
+    }
+
+    // If QuickDraw supports the given pixel format, the cType should be kRawCodecType.
+    // Otherwise, use the pixel format code for the cType.  We are assuming the pixel 
+    // buffer is uncompressed.
+    unsigned long cType = isQD ? kRawCodecType : m_pixelFormat;
+
+    ImageDescriptionHandle description = (ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription));
+    (**description).idSize = sizeof(ImageDescription);
+    (**description).cType = cType;
+    (**description).version = 2;
+    (**description).spatialQuality = codecLosslessQuality;
+    (**description).width = m_width;
+    (**description).height = m_height;
+    (**description).hRes = 72 << 16; // 72 DPI as a fixed-point number
+    (**description).vRes = 72 << 16; // 72 DPI as a fixed-point number
+    (**description).frameCount = 1;
+    (**description).depth =  depth;
+    (**description).clutID = -1;
+
+    // Create the mandatory ICMDecompressionSessionOptions, but leave
+    // all the default values.
+    ICMDecompressionSessionOptionsRef options = 0;
+    ICMDecompressionSessionOptionsCreate(kCFAllocatorDefault, &options);
+
+    CFDictionaryRef pixelBufferAttributes = QTPixelBuffer::createPixelBufferAttributesDictionary(QTPixelBuffer::ConfigureForCGImage);
+
+    ICMDecompressionTrackingCallbackRecord callback = {
+        QTDecompressionSessionClient::trackingCallback,
+        this,
+    };
+
+    ICMDecompressionSessionCreate(kCFAllocatorDefault,
+        description,
+        options,
+        pixelBufferAttributes,
+        &callback,
+        &m_session);
+
+    if (pixelBufferAttributes)
+        CFRelease(pixelBufferAttributes);
+
+    ICMDecompressionSessionOptionsRelease(options);
+    DisposeHandle((Handle)description);
+}
+
+bool QTDecompressionSession::canDecompress(QTPixelBuffer inBuffer)
+{
+    return m_session 
+        && inBuffer.pixelFormatType() == m_pixelFormat 
+        && inBuffer.width() == m_width
+        && inBuffer.height() == m_height;
+}
+
+QTPixelBuffer QTDecompressionSession::decompress(QTPixelBuffer inBuffer)
+{
+    if (!canDecompress(inBuffer))
+        return QTPixelBuffer();
+    
+    inBuffer.lockBaseAddress();
+    ICMDecompressionSessionDecodeFrame(m_session,
+        static_cast<UInt8*>(inBuffer.baseAddress()),
+        inBuffer.dataSize(),
+        0, // frameOptions
+        0, // frameTime
+        0); // sourceFrameRefCon
+
+    // Because we passed in 0 for frameTime, the above function
+    // is synchronous, and the client callback will have been
+    // called before the function returns, and m_latestFrame
+    // will contain the newly decompressed frame.
+    return m_latestFrame;
+}
diff --git a/WebCore/platform/graphics/win/QTDecompressionSession.h b/WebCore/platform/graphics/win/QTDecompressionSession.h
new file mode 100644
index 0000000..67b6635
--- /dev/null
+++ b/WebCore/platform/graphics/win/QTDecompressionSession.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 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 QTDecompressionSession_h
+#define QTDecompressionSession_h
+
+#ifdef QTMOVIEWIN_EXPORTS
+#define QTMOVIEWIN_API __declspec(dllexport)
+#else
+#define QTMOVIEWIN_API __declspec(dllimport)
+#endif
+
+#include "QTPixelBuffer.h"
+
+#include <WTF/PassOwnPtr.h>
+
+class QTDecompressionSessionClient;
+typedef struct OpaqueICMDecompressionSession*  ICMDecompressionSessionRef;
+
+class QTMOVIEWIN_API QTDecompressionSession {
+public:
+    static PassOwnPtr<QTDecompressionSession> create(unsigned long pixelFormat, size_t width, size_t height);
+    ~QTDecompressionSession();
+
+    bool canDecompress(QTPixelBuffer);
+
+    // The resulting QTPixelBuffer will be a CG compatable ARGB pixel buffer.
+    QTPixelBuffer decompress(QTPixelBuffer);
+
+private:
+    friend class QTDecompressionSessionClient;
+    QTDecompressionSession(unsigned long pixelFormat, size_t width, size_t height);
+    void initializeSession();
+
+    unsigned long m_pixelFormat;
+    size_t m_width;
+    size_t m_height;
+    QTPixelBuffer m_latestFrame;
+    ICMDecompressionSessionRef m_session;
+};
+
+#endif
diff --git a/WebCore/platform/graphics/win/QTMovieVisualContext.cpp b/WebCore/platform/graphics/win/QTMovieVisualContext.cpp
index 0232d3b..0fcc7e2 100644
--- a/WebCore/platform/graphics/win/QTMovieVisualContext.cpp
+++ b/WebCore/platform/graphics/win/QTMovieVisualContext.cpp
@@ -39,7 +39,7 @@ struct QTCVTimeStamp {
 
 class QTMovieVisualContextPriv {
 public:
-    QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTMovieVisualContext::Type contextType);
+    QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType);
     ~QTMovieVisualContextPriv();
 
     bool isImageAvailableForTime(const QTCVTimeStamp*) const;
@@ -61,61 +61,28 @@ private:
 
 };
 
-static OSStatus SetNumberValue(CFMutableDictionaryRef inDict, CFStringRef inKey, SInt32 inValue)
+static CFDictionaryRef createPixelBufferOptionsDictionary(QTPixelBuffer::Type contextType)
 {
-    CFNumberRef number;
- 
-    number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
-    if (!number) 
-        return coreFoundationUnknownErr;
- 
-    CFDictionarySetValue(inDict, inKey, number);
-    CFRelease(number);
-
-    return noErr;
-}
-
-static CFDictionaryRef createPixelBufferOptionsDictionary(QTMovieVisualContext::Type contextType)
-{
-    static const CFStringRef kDirect3DCompatibilityKey = CFSTR("Direct3DCompatibility");
-
-    CFMutableDictionaryRef pixelBufferOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-
-    CFMutableDictionaryRef pixelBufferAttributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-    if (contextType == QTMovieVisualContext::ConfigureForCAImageQueue) {
-        // Ask for D3D compatible pixel buffers so no further work is needed.
-        CFDictionarySetValue(pixelBufferAttributes, kDirect3DCompatibilityKey, kCFBooleanTrue);
-    } else {
-        // Use the k32BGRAPixelFormat, as QuartzCore will be able to use the pixels directly,
-        // without needing an additional copy or rendering pass.
-        SetNumberValue(pixelBufferAttributes, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat);
-            
-        // Set kCVPixelBufferBytesPerRowAlignmentKey to 16 to ensure that each row of pixels 
-        // starts at a 16 byte aligned address for most efficient data reading.
-        SetNumberValue(pixelBufferAttributes, kCVPixelBufferBytesPerRowAlignmentKey, 16);
-        CFDictionarySetValue(pixelBufferAttributes, kCVPixelBufferCGImageCompatibilityKey, kCFBooleanTrue);
-    }
- 
-    CFDictionarySetValue(pixelBufferOptions, kQTVisualContextPixelBufferAttributesKey, pixelBufferAttributes);
-
-    CFRelease(pixelBufferAttributes);
-
+    const void* key = kQTVisualContextPixelBufferAttributesKey;
+    const void* value = QTPixelBuffer::createPixelBufferAttributesDictionary(contextType);
+    CFDictionaryRef pixelBufferOptions = CFDictionaryCreate(kCFAllocatorDefault, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFRelease(value);
     return pixelBufferOptions;
 }
 
-static CFDictionaryRef pixelBufferCreationOptions(QTMovieVisualContext::Type contextType)
+static CFDictionaryRef pixelBufferCreationOptions(QTPixelBuffer::Type contextType)
 {
-    if (contextType == QTMovieVisualContext::ConfigureForCAImageQueue) {
+    if (contextType == QTPixelBuffer::ConfigureForCAImageQueue) {
         static CFDictionaryRef imageQueueOptions = createPixelBufferOptionsDictionary(contextType);
         return imageQueueOptions;
     } 
 
-    ASSERT(contextType == QTMovieVisualContext::ConfigureForCGImage);
+    ASSERT(contextType == QTPixelBuffer::ConfigureForCGImage);
     static CFDictionaryRef cgImageOptions = createPixelBufferOptionsDictionary(contextType);
     return cgImageOptions;
 }
 
-QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTMovieVisualContext::Type contextType) 
+QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType) 
         : m_parent(parent)
         , m_client(client)
         , m_visualContext(0)
@@ -206,12 +173,12 @@ void QTMovieVisualContextPriv::imageAvailableCallback(QTVisualContextRef visualC
     vc->m_client->imageAvailableForTime(reinterpret_cast<const QTCVTimeStamp*>(timeStamp));
 }
 
-PassRefPtr<QTMovieVisualContext> QTMovieVisualContext::create(QTMovieVisualContextClient* client, Type contextType)
+PassRefPtr<QTMovieVisualContext> QTMovieVisualContext::create(QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
 {
     return adoptRef(new QTMovieVisualContext(client, contextType));
 }
 
-QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, Type contextType) 
+QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType) 
     : m_private(new QTMovieVisualContextPriv(this, client, contextType))
 {
 }
diff --git a/WebCore/platform/graphics/win/QTMovieVisualContext.h b/WebCore/platform/graphics/win/QTMovieVisualContext.h
index 057031e..8410208 100644
--- a/WebCore/platform/graphics/win/QTMovieVisualContext.h
+++ b/WebCore/platform/graphics/win/QTMovieVisualContext.h
@@ -54,9 +54,7 @@ public:
 
 class QTMOVIEWIN_API QTMovieVisualContext : public RefCounted<QTMovieVisualContext> {
 public:
-    enum Type { ConfigureForCGImage, ConfigureForCAImageQueue };
-
-    static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, Type);
+    static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, QTPixelBuffer::Type);
     ~QTMovieVisualContext();
 
     bool isImageAvailableForTime(const QTCVTimeStamp*) const;
@@ -71,7 +69,7 @@ public:
     static double currentHostTime();
 
 protected:
-    QTMovieVisualContext(QTMovieVisualContextClient*, Type);
+    QTMovieVisualContext(QTMovieVisualContextClient*, QTPixelBuffer::Type);
     void setupVisualContext();
 
     friend class QTMovieVisualContextPriv;
diff --git a/WebCore/platform/graphics/win/QTPixelBuffer.cpp b/WebCore/platform/graphics/win/QTPixelBuffer.cpp
index 657b68e..44a1b0e 100644
--- a/WebCore/platform/graphics/win/QTPixelBuffer.cpp
+++ b/WebCore/platform/graphics/win/QTPixelBuffer.cpp
@@ -26,6 +26,7 @@
 
 #include "QTPixelBuffer.h"
 
+#include <CFNumber.h>
 #include <CFString.h>
 #include <CGColorSpace.h>
 #include <CGImage.h>
@@ -33,6 +34,41 @@
 #include <QuickDraw.h>
 #include <memory.h>
 
+static OSStatus SetNumberValue(CFMutableDictionaryRef inDict, CFStringRef inKey, SInt32 inValue)
+{
+    CFNumberRef number;
+ 
+    number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
+    if (!number) 
+        return coreFoundationUnknownErr;
+ 
+    CFDictionarySetValue(inDict, inKey, number);
+    CFRelease(number);
+
+    return noErr;
+}
+
+CFDictionaryRef QTPixelBuffer::createPixelBufferAttributesDictionary(QTPixelBuffer::Type contextType)
+{
+    static const CFStringRef kDirect3DCompatibilityKey = CFSTR("Direct3DCompatibility");
+
+    CFMutableDictionaryRef pixelBufferAttributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (contextType == QTPixelBuffer::ConfigureForCAImageQueue) {
+        // Ask for D3D compatible pixel buffers so no further work is needed.
+        CFDictionarySetValue(pixelBufferAttributes, kDirect3DCompatibilityKey, kCFBooleanTrue);
+    } else {
+        // Use the k32BGRAPixelFormat, as QuartzCore will be able to use the pixels directly,
+        // without needing an additional copy or rendering pass.
+        SetNumberValue(pixelBufferAttributes, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat);
+            
+        // Set kCVPixelBufferBytesPerRowAlignmentKey to 16 to ensure that each row of pixels 
+        // starts at a 16 byte aligned address for most efficient data reading.
+        SetNumberValue(pixelBufferAttributes, kCVPixelBufferBytesPerRowAlignmentKey, 16);
+        CFDictionarySetValue(pixelBufferAttributes, kCVPixelBufferCGImageCompatibilityKey, kCFBooleanTrue);
+    }
+    return pixelBufferAttributes;
+}
+
 QTPixelBuffer::QTPixelBuffer() 
     : m_pixelBuffer(0) 
 {
diff --git a/WebCore/platform/graphics/win/QTPixelBuffer.h b/WebCore/platform/graphics/win/QTPixelBuffer.h
index 22f8ba4..13630da 100644
--- a/WebCore/platform/graphics/win/QTPixelBuffer.h
+++ b/WebCore/platform/graphics/win/QTPixelBuffer.h
@@ -44,6 +44,9 @@ typedef const struct __CFDictionary * CFDictionaryRef;
 // safe to call within WebKit.
 class QTMOVIEWIN_API QTPixelBuffer {
 public:
+    enum Type { ConfigureForCGImage, ConfigureForCAImageQueue };
+    static CFDictionaryRef createPixelBufferAttributesDictionary(Type);
+
     QTPixelBuffer();
     QTPixelBuffer(const QTPixelBuffer&);
     QTPixelBuffer(CVPixelBufferRef);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list