Changeset 70252 in webkit


Ignore:
Timestamp:
Oct 21, 2010 11:19:04 AM (13 years ago)
Author:
jer.noble@apple.com
Message:

2010-10-20 Jer Noble <jer.noble@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.

Location:
trunk/WebCore
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70251 r70252  
     12010-10-20  Jer Noble  <jer.noble@apple.com>
     2
     3        Reviewed by Eric Carlson.
     4
     5        Video -> Canvas doesn't work on Windows
     6        https://bugs.webkit.org/show_bug.cgi?id=47996
     7        rdar://problem/7884690
     8
     9        * WebCore.vcproj/QTMovieWin.vcproj: Added QTDecompressionSession.{cpp,h}
     10        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
     11        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::paint): Create a
     12            QTDecompressionSession if necessary and convert the QTPixelBuffer
     13            into a CG-compatible one.
     14        * platform/graphics/win/QTDecompressionSession.cpp: Added.
     15        * platform/graphics/win/QTDecompressionSession.h: Added.
     16        * platform/graphics/win/QTPixelBuffer.cpp:
     17        (SetNumberValue): Moved from QTMovieVisualContext.
     18        (QTPixelBuffer::createPixelBufferAttributesDictionary): Moved from inside
     19            QTMovieVisualContext::createPixelBufferOptionsDictionary().
     20        * platform/graphics/win/QTPixelBuffer.h: Moved the Type enum
     21            from QTMovieVisualContext.h.
     22
    1232010-10-21  Carlos Garcia Campos  <cgarcia@igalia.com>
    224
  • trunk/WebCore/WebCore.vcproj/QTMovieWin.vcproj

    r67285 r70252  
    319319                        </File>
    320320                        <File
     321                                RelativePath="..\platform\graphics\win\QTDecompressionSession.cpp"
     322                                >
     323                        </File>
     324                        <File
    321325                                RelativePath="..\platform\graphics\win\QTMovie.cpp"
    322326                                >
     
    357361                        </File>
    358362                        <File
     363                                RelativePath="..\platform\graphics\win\QTDecompressionSession.h"
     364                                >
     365                        </File>
     366                        <File
    359367                                RelativePath="..\platform\graphics\win\QTMovie.h"
    360368                                >
  • trunk/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp

    r70084 r70252  
    3737#include "MediaPlayerPrivateTaskTimer.h"
    3838#include "QTCFDictionary.h"
     39#include "QTDecompressionSession.h"
    3940#include "QTMovie.h"
    4041#include "QTMovieTask.h"
     
    729730        return;
    730731
    731 #if USE(ACCELERATED_COMPOSITING)
    732     if (m_qtVideoLayer)
    733         return;
    734 #endif
    735732    QTPixelBuffer buffer = m_visualContext->imageForTime(0);
    736733    if (buffer.pixelBufferRef()) {
     734#if USE(ACCELERATED_COMPOSITING)
     735        if (m_qtVideoLayer) {
     736            // We are probably being asked to render the video into a canvas, but
     737            // there's a good chance the QTPixelBuffer is not ARGB and thus can't be
     738            // drawn using CG.  If so, fire up an ICMDecompressionSession and convert
     739            // the current frame into something which can be rendered by CG.
     740            if (!buffer.pixelFormatIs32ARGB() && !buffer.pixelFormatIs32BGRA()) {
     741                // The decompression session will only decompress a specific pixelFormat
     742                // at a specific width and height; if these differ, the session must be
     743                // recreated with the new parameters.
     744                if (!m_decompressionSession || !m_decompressionSession->canDecompress(buffer))
     745                    m_decompressionSession = QTDecompressionSession::create(buffer.pixelFormatType(), buffer.width(), buffer.height());
     746            }
     747
     748            buffer = m_decompressionSession->decompress(buffer);
     749        }
     750#endif
    737751        CGImageRef image = CreateCGImageFromPixelBuffer(buffer);
    738752       
     
    10901104#endif
    10911105
    1092     QTMovieVisualContext::Type contextType = requiredDllsAvailable() && preferredMode == MediaRenderingMovieLayer ? QTMovieVisualContext::ConfigureForCAImageQueue : QTMovieVisualContext::ConfigureForCGImage;
     1106    QTPixelBuffer::Type contextType = requiredDllsAvailable() && preferredMode == MediaRenderingMovieLayer ? QTPixelBuffer::ConfigureForCAImageQueue : QTPixelBuffer::ConfigureForCGImage;
    10931107    m_visualContext = QTMovieVisualContext::create(m_visualContextClient.get(), contextType);
    10941108    m_visualContext->setMovie(m_movie.get());
  • trunk/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h

    r70084 r70252  
    4343class QTMovie;
    4444class QTMovieVisualContext;
     45class QTDecompressionSession;
    4546
    4647namespace WebCore {
     
    179180    OwnPtr<GraphicsLayer> m_transformLayer;
    180181    OwnPtr<WKCAImageQueue> m_imageQueue;
     182    OwnPtr<QTDecompressionSession> m_decompressionSession;
    181183    CGAffineTransform m_movieTransform;
    182184#endif
  • trunk/WebCore/platform/graphics/win/QTMovieVisualContext.cpp

    r60317 r70252  
    4040class QTMovieVisualContextPriv {
    4141public:
    42     QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTMovieVisualContext::Type contextType);
     42    QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType);
    4343    ~QTMovieVisualContextPriv();
    4444
     
    6262};
    6363
    64 static OSStatus SetNumberValue(CFMutableDictionaryRef inDict, CFStringRef inKey, SInt32 inValue)
    65 {
    66     CFNumberRef number;
    67  
    68     number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
    69     if (!number)
    70         return coreFoundationUnknownErr;
    71  
    72     CFDictionarySetValue(inDict, inKey, number);
    73     CFRelease(number);
    74 
    75     return noErr;
    76 }
    77 
    78 static CFDictionaryRef createPixelBufferOptionsDictionary(QTMovieVisualContext::Type contextType)
    79 {
    80     static const CFStringRef kDirect3DCompatibilityKey = CFSTR("Direct3DCompatibility");
    81 
    82     CFMutableDictionaryRef pixelBufferOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    83 
    84     CFMutableDictionaryRef pixelBufferAttributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    85     if (contextType == QTMovieVisualContext::ConfigureForCAImageQueue) {
    86         // Ask for D3D compatible pixel buffers so no further work is needed.
    87         CFDictionarySetValue(pixelBufferAttributes, kDirect3DCompatibilityKey, kCFBooleanTrue);
    88     } else {
    89         // Use the k32BGRAPixelFormat, as QuartzCore will be able to use the pixels directly,
    90         // without needing an additional copy or rendering pass.
    91         SetNumberValue(pixelBufferAttributes, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat);
    92            
    93         // Set kCVPixelBufferBytesPerRowAlignmentKey to 16 to ensure that each row of pixels
    94         // starts at a 16 byte aligned address for most efficient data reading.
    95         SetNumberValue(pixelBufferAttributes, kCVPixelBufferBytesPerRowAlignmentKey, 16);
    96         CFDictionarySetValue(pixelBufferAttributes, kCVPixelBufferCGImageCompatibilityKey, kCFBooleanTrue);
    97     }
    98  
    99     CFDictionarySetValue(pixelBufferOptions, kQTVisualContextPixelBufferAttributesKey, pixelBufferAttributes);
    100 
    101     CFRelease(pixelBufferAttributes);
    102 
     64static CFDictionaryRef createPixelBufferOptionsDictionary(QTPixelBuffer::Type contextType)
     65{
     66    const void* key = kQTVisualContextPixelBufferAttributesKey;
     67    const void* value = QTPixelBuffer::createPixelBufferAttributesDictionary(contextType);
     68    CFDictionaryRef pixelBufferOptions = CFDictionaryCreate(kCFAllocatorDefault, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
     69    CFRelease(value);
    10370    return pixelBufferOptions;
    10471}
    10572
    106 static CFDictionaryRef pixelBufferCreationOptions(QTMovieVisualContext::Type contextType)
    107 {
    108     if (contextType == QTMovieVisualContext::ConfigureForCAImageQueue) {
     73static CFDictionaryRef pixelBufferCreationOptions(QTPixelBuffer::Type contextType)
     74{
     75    if (contextType == QTPixelBuffer::ConfigureForCAImageQueue) {
    10976        static CFDictionaryRef imageQueueOptions = createPixelBufferOptionsDictionary(contextType);
    11077        return imageQueueOptions;
    11178    }
    11279
    113     ASSERT(contextType == QTMovieVisualContext::ConfigureForCGImage);
     80    ASSERT(contextType == QTPixelBuffer::ConfigureForCGImage);
    11481    static CFDictionaryRef cgImageOptions = createPixelBufferOptionsDictionary(contextType);
    11582    return cgImageOptions;
    11683}
    11784
    118 QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTMovieVisualContext::Type contextType)
     85QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
    11986        : m_parent(parent)
    12087        , m_client(client)
     
    207174}
    208175
    209 PassRefPtr<QTMovieVisualContext> QTMovieVisualContext::create(QTMovieVisualContextClient* client, Type contextType)
     176PassRefPtr<QTMovieVisualContext> QTMovieVisualContext::create(QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
    210177{
    211178    return adoptRef(new QTMovieVisualContext(client, contextType));
    212179}
    213180
    214 QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, Type contextType)
     181QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
    215182    : m_private(new QTMovieVisualContextPriv(this, client, contextType))
    216183{
  • trunk/WebCore/platform/graphics/win/QTMovieVisualContext.h

    r60317 r70252  
    5555class QTMOVIEWIN_API QTMovieVisualContext : public RefCounted<QTMovieVisualContext> {
    5656public:
    57     enum Type { ConfigureForCGImage, ConfigureForCAImageQueue };
    58 
    59     static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, Type);
     57    static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, QTPixelBuffer::Type);
    6058    ~QTMovieVisualContext();
    6159
     
    7270
    7371protected:
    74     QTMovieVisualContext(QTMovieVisualContextClient*, Type);
     72    QTMovieVisualContext(QTMovieVisualContextClient*, QTPixelBuffer::Type);
    7573    void setupVisualContext();
    7674
  • trunk/WebCore/platform/graphics/win/QTPixelBuffer.cpp

    r60110 r70252  
    2727#include "QTPixelBuffer.h"
    2828
     29#include <CFNumber.h>
    2930#include <CFString.h>
    3031#include <CGColorSpace.h>
     
    3435#include <memory.h>
    3536
     37static OSStatus SetNumberValue(CFMutableDictionaryRef inDict, CFStringRef inKey, SInt32 inValue)
     38{
     39    CFNumberRef number;
     40 
     41    number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
     42    if (!number)
     43        return coreFoundationUnknownErr;
     44 
     45    CFDictionarySetValue(inDict, inKey, number);
     46    CFRelease(number);
     47
     48    return noErr;
     49}
     50
     51CFDictionaryRef QTPixelBuffer::createPixelBufferAttributesDictionary(QTPixelBuffer::Type contextType)
     52{
     53    static const CFStringRef kDirect3DCompatibilityKey = CFSTR("Direct3DCompatibility");
     54
     55    CFMutableDictionaryRef pixelBufferAttributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
     56    if (contextType == QTPixelBuffer::ConfigureForCAImageQueue) {
     57        // Ask for D3D compatible pixel buffers so no further work is needed.
     58        CFDictionarySetValue(pixelBufferAttributes, kDirect3DCompatibilityKey, kCFBooleanTrue);
     59    } else {
     60        // Use the k32BGRAPixelFormat, as QuartzCore will be able to use the pixels directly,
     61        // without needing an additional copy or rendering pass.
     62        SetNumberValue(pixelBufferAttributes, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat);
     63           
     64        // Set kCVPixelBufferBytesPerRowAlignmentKey to 16 to ensure that each row of pixels
     65        // starts at a 16 byte aligned address for most efficient data reading.
     66        SetNumberValue(pixelBufferAttributes, kCVPixelBufferBytesPerRowAlignmentKey, 16);
     67        CFDictionarySetValue(pixelBufferAttributes, kCVPixelBufferCGImageCompatibilityKey, kCFBooleanTrue);
     68    }
     69    return pixelBufferAttributes;
     70}
     71
    3672QTPixelBuffer::QTPixelBuffer()
    3773    : m_pixelBuffer(0)
  • trunk/WebCore/platform/graphics/win/QTPixelBuffer.h

    r60110 r70252  
    4545class QTMOVIEWIN_API QTPixelBuffer {
    4646public:
     47    enum Type { ConfigureForCGImage, ConfigureForCAImageQueue };
     48    static CFDictionaryRef createPixelBufferAttributesDictionary(Type);
     49
    4750    QTPixelBuffer();
    4851    QTPixelBuffer(const QTPixelBuffer&);
Note: See TracChangeset for help on using the changeset viewer.