summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/win
diff options
context:
space:
mode:
authorLeon Clarke <leonclarke@google.com>2010-06-03 14:33:32 +0100
committerLeon Clarke <leonclarke@google.com>2010-06-08 12:24:51 +0100
commit5af96e2c7b73ebc627c6894727826a7576d31758 (patch)
treef9d5e6f6175ccd7e3d14de9b290f08937a0d17ba /WebCore/platform/graphics/win
parent8cc4fcf4f6adcbc0e0aebfc24fbad9a4cddf2cfb (diff)
downloadexternal_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.zip
external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.gz
external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.bz2
Merge webkit.org at r60469 : Initial merge by git.
Change-Id: I66a0047aa2af802f66bb0c7f2a8b02247a596234
Diffstat (limited to 'WebCore/platform/graphics/win')
-rw-r--r--WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp182
-rw-r--r--WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h82
-rw-r--r--WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp145
-rw-r--r--WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h6
-rw-r--r--WebCore/platform/graphics/win/QTMovieVisualContext.cpp123
-rw-r--r--WebCore/platform/graphics/win/QTMovieVisualContext.h6
-rw-r--r--WebCore/platform/graphics/win/QTPixelBuffer.cpp5
-rw-r--r--WebCore/platform/graphics/win/QTPixelBuffer.h2
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayer.cpp48
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayer.h28
-rw-r--r--WebCore/platform/graphics/win/WKCAImageQueue.cpp104
-rw-r--r--WebCore/platform/graphics/win/WKCAImageQueue.h92
-rwxr-xr-xWebCore/platform/graphics/win/WebTiledLayer.cpp9
-rwxr-xr-xWebCore/platform/graphics/win/WebTiledLayer.h1
14 files changed, 738 insertions, 95 deletions
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
new file mode 100644
index 0000000..c6be087
--- /dev/null
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
@@ -0,0 +1,182 @@
+/*
+ * 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 INC. 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 INC. 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 "config.h"
+#include "MediaPlayerPrivateFullscreenWindow.h"
+
+#include "IntRect.h"
+#include "WebCoreInstanceHandle.h"
+#include <CoreGraphics/CGColor.h>
+#include <windows.h>
+
+namespace WebCore {
+
+MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlayerPrivateFullscreenClient* client)
+ : m_client(client)
+ , m_hwnd(0)
+#if USE(ACCELERATED_COMPOSITING)
+ , m_layerRenderer(WKCACFLayerRenderer::create(0))
+#endif
+{
+}
+
+MediaPlayerPrivateFullscreenWindow::~MediaPlayerPrivateFullscreenWindow()
+{
+ if (m_hwnd)
+ close();
+}
+
+void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd)
+{
+ static ATOM windowAtom;
+ static LPCWSTR windowClassName = L"MediaPlayerPrivateFullscreenWindowClass";
+ if (!windowAtom) {
+ WNDCLASSEX wcex = {0};
+ wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = staticWndProc;
+ wcex.hInstance = instanceHandle();
+ wcex.lpszClassName = windowClassName;
+ windowAtom = ::RegisterClassEx(&wcex);
+ }
+
+ if (m_hwnd)
+ close();
+
+ MONITORINFO mi = {0};
+ mi.cbSize = sizeof(MONITORINFO);
+ if (!GetMonitorInfo(MonitorFromWindow(parentHwnd, MONITOR_DEFAULTTONEAREST), &mi))
+ return;
+
+ IntRect monitorRect = mi.rcMonitor;
+
+ ::CreateWindowExW(WS_EX_TOOLWINDOW, windowClassName, L"", WS_POPUP | WS_VISIBLE,
+ monitorRect.x(), monitorRect.y(), monitorRect.width(), monitorRect.height(),
+ parentHwnd, 0, WebCore::instanceHandle(), this);
+ ASSERT(IsWindow(m_hwnd));
+
+ ::SetFocus(m_hwnd);
+}
+
+void MediaPlayerPrivateFullscreenWindow::close()
+{
+ ::DestroyWindow(m_hwnd);
+ ASSERT(!m_hwnd);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLayer> rootChild)
+{
+ if (m_rootChild == rootChild)
+ return;
+
+ if (m_rootChild)
+ m_rootChild->removeFromSuperlayer();
+
+ m_rootChild = rootChild;
+
+ if (!m_rootChild)
+ return;
+
+ m_layerRenderer->setRootChildLayer(m_rootChild.get());
+ WKCACFLayer* rootLayer = m_rootChild->rootLayer();
+ CGRect rootBounds = m_rootChild->rootLayer()->bounds();
+ m_rootChild->setFrame(rootBounds);
+ m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size));
+ m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
+#ifndef NDEBUG
+ RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1));
+ rootLayer->setBackgroundColor(redColor.get());
+#else
+ rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
+#endif
+}
+#endif
+
+LRESULT MediaPlayerPrivateFullscreenWindow::staticWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LONG_PTR longPtr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
+
+ if (!longPtr && message == WM_CREATE) {
+ LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
+ longPtr = reinterpret_cast<LONG_PTR>(lpcs->lpCreateParams);
+ ::SetWindowLongPtr(hWnd, GWLP_USERDATA, longPtr);
+ }
+
+ if (MediaPlayerPrivateFullscreenWindow* window = reinterpret_cast<MediaPlayerPrivateFullscreenWindow*>(longPtr))
+ return window->wndProc(hWnd, message, wParam, lParam);
+
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT lResult = 0;
+ switch (message) {
+ case WM_CREATE:
+ m_hwnd = hWnd;
+#if USE(ACCELERATED_COMPOSITING)
+ m_layerRenderer->setHostWindow(m_hwnd);
+ m_layerRenderer->createRenderer();
+ if (m_rootChild)
+ m_layerRenderer->setNeedsDisplay();
+#endif
+ break;
+ case WM_DESTROY:
+ m_hwnd = 0;
+#if USE(ACCELERATED_COMPOSITING)
+ m_layerRenderer->destroyRenderer();
+ m_layerRenderer->setHostWindow(0);
+#endif
+ break;
+ case WM_WINDOWPOSCHANGED:
+ {
+ LPWINDOWPOS wp = reinterpret_cast<LPWINDOWPOS>(lParam);
+ if (wp->flags & SWP_NOSIZE)
+ break;
+#if USE(ACCELERATED_COMPOSITING)
+ m_layerRenderer->resize();
+ WKCACFLayer* rootLayer = m_rootChild->rootLayer();
+ CGRect rootBounds = m_rootChild->rootLayer()->bounds();
+ m_rootChild->setFrame(rootBounds);
+ m_rootChild->setNeedsLayout();
+ m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size));
+#endif
+ }
+ break;
+ case WM_PAINT:
+#if USE(ACCELERATED_COMPOSITING)
+ m_layerRenderer->renderSoon();
+#endif
+ break;
+ }
+
+ if (m_client)
+ lResult = m_client->fullscreenClientWndProc(hWnd, message, wParam, lParam);
+
+ return lResult;
+}
+
+}
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
new file mode 100644
index 0000000..d42f7f3
--- /dev/null
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
@@ -0,0 +1,82 @@
+/*
+ * 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 INC. 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 INC. 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.
+ */
+
+#ifndef MediaPlayerPrivateFullscreenWindow_h
+#define MediaPlayerPrivateFullscreenWindow_h
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "WKCACFLayer.h"
+#include "WKCACFLayerRenderer.h"
+#endif
+#include <wtf/OwnPtr.h>
+
+typedef unsigned WPARAM;
+typedef long LPARAM;
+typedef struct HWND__* HWND;
+typedef _W64 long LONG_PTR;
+typedef LONG_PTR LRESULT;
+typedef unsigned int UINT;
+
+namespace WebCore {
+
+class MediaPlayerPrivateFullscreenClient {
+public:
+ virtual LRESULT fullscreenClientWndProc(HWND, UINT message, WPARAM, LPARAM) = 0;
+protected:
+ virtual ~MediaPlayerPrivateFullscreenClient() {}
+};
+
+class MediaPlayerPrivateFullscreenWindow {
+public:
+ MediaPlayerPrivateFullscreenWindow(MediaPlayerPrivateFullscreenClient*);
+ ~MediaPlayerPrivateFullscreenWindow();
+
+ void createWindow(HWND ownerWindow);
+ void close();
+
+ HWND hwnd() const { return m_hwnd; }
+
+#if USE(ACCELERATED_COMPOSITING)
+ WKCACFLayerRenderer* layerRenderer() const { return m_layerRenderer.get(); }
+
+ WKCACFLayer* rootChildLayer() const { return m_rootChild.get(); }
+ void setRootChildLayer(PassRefPtr<WKCACFLayer>);
+#endif
+
+private:
+ static LRESULT __stdcall staticWndProc(HWND, UINT message, WPARAM, LPARAM);
+ LRESULT wndProc(HWND, UINT message, WPARAM, LPARAM);
+
+ MediaPlayerPrivateFullscreenClient* m_client;
+#if USE(ACCELERATED_COMPOSITING)
+ OwnPtr<WKCACFLayerRenderer> m_layerRenderer;
+ RefPtr<WKCACFLayer> m_rootChild;
+#endif
+ HWND m_hwnd;
+};
+
+}
+
+#endif
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
index e1d457f..aa7bdd4 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
@@ -40,6 +40,7 @@
#include "QTMovieTask.h"
#include "QTMovieVisualContext.h"
#include "ScrollView.h"
+#include "Settings.h"
#include "SoftLinking.h"
#include "StringBuilder.h"
#include "StringHash.h"
@@ -56,16 +57,15 @@
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsLayerCACF.h"
#include "WKCACFLayer.h"
+#include "WKCAImageQueue.h"
#endif
using namespace std;
-const CFStringRef kMinQuartzCoreVersion = CFSTR("1.0.43.0");
-const CFStringRef kMinCoreVideoVersion = CFSTR("1.0.0.2");
-
namespace WebCore {
static CGImageRef CreateCGImageFromPixelBuffer(QTPixelBuffer buffer);
+static bool requiredDllsAvailable();
SOFT_LINK_LIBRARY(Wininet)
SOFT_LINK(Wininet, InternetSetCookieExW, DWORD, WINAPI, (LPCWSTR lpszUrl, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData, DWORD dwFlags, DWORD_PTR dwReserved), (lpszUrl, lpszCookieName, lpszCookieData, dwFlags, dwReserved))
@@ -144,12 +144,16 @@ MediaPlayerPrivateQuickTimeVisualContext::MediaPlayerPrivateQuickTimeVisualConte
MediaPlayerPrivateQuickTimeVisualContext::~MediaPlayerPrivateQuickTimeVisualContext()
{
tearDownVideoRendering();
- m_visualContext->setMovie(0);
cancelCallOnMainThread(&VisualContextClient::retrieveCurrentImageProc, this);
}
bool MediaPlayerPrivateQuickTimeVisualContext::supportsFullscreen() const
{
+#if USE(ACCELERATED_COMPOSITING)
+ Document* document = m_player->mediaPlayerClient()->mediaPlayerOwningDocument();
+ if (document && document->settings())
+ return document->settings()->acceleratedCompositingEnabled();
+#endif
return false;
}
@@ -285,10 +289,6 @@ void MediaPlayerPrivateQuickTimeVisualContext::load(const String& url)
m_movie = adoptRef(new QTMovie(m_movieClient.get()));
m_movie->load(url.characters(), url.length(), m_player->preservesPitch());
m_movie->setVolume(m_player->volume());
-
- CFDictionaryRef options = QTMovieVisualContext::getCGImageOptions();
- m_visualContext = adoptRef(new QTMovieVisualContext(m_visualContextClient.get(), options));
- m_visualContext->setMovie(m_movie.get());
}
void MediaPlayerPrivateQuickTimeVisualContext::play()
@@ -630,6 +630,14 @@ void MediaPlayerPrivateQuickTimeVisualContext::setVisible(bool visible)
void MediaPlayerPrivateQuickTimeVisualContext::paint(GraphicsContext* p, const IntRect& r)
{
+ MediaRenderingMode currentMode = currentRenderingMode();
+
+ if (currentMode == MediaRenderingNone)
+ return;
+
+ if (currentMode == MediaRenderingSoftwareRenderer && !m_visualContext)
+ return;
+
#if USE(ACCELERATED_COMPOSITING)
if (m_qtVideoLayer)
return;
@@ -756,16 +764,40 @@ void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage()
WKCACFLayer* layer = static_cast<WKCACFLayer*>(m_qtVideoLayer->platformLayer());
- if (!buffer.lockBaseAddress()) {
- CFTimeInterval imageTime = QTMovieVisualContext::currentHostTime();
+ if (!buffer.lockBaseAddress()) {
+ if (requiredDllsAvailable()) {
+ if (!m_imageQueue) {
+ m_imageQueue = new WKCAImageQueue(buffer.width(), buffer.height(), 30);
+ m_imageQueue->setFlags(WKCAImageQueue::Fill, WKCAImageQueue::Fill);
+ layer->setContents(m_imageQueue->get());
+ }
+
+ // Debug QuickTime links against a non-Debug version of CoreFoundation, so the
+ // CFDictionary attached to the CVPixelBuffer cannot be directly passed on into the
+ // CAImageQueue without being converted to a non-Debug CFDictionary. Additionally,
+ // old versions of QuickTime used a non-AAS CoreFoundation, so the types are not
+ // interchangable even in the release case.
+ RetainPtr<CFDictionaryRef> attachments(AdoptCF, QTCFDictionaryCreateCopyWithDataCallback(kCFAllocatorDefault, buffer.attachments(), &QTCFDictionaryCreateWithDataCallback));
+ CFTimeInterval imageTime = QTMovieVisualContext::currentHostTime();
+
+ m_imageQueue->collect();
+ uint64_t imageId = m_imageQueue->registerPixelBuffer(buffer.baseAddress(), buffer.dataSize(), buffer.bytesPerRow(), buffer.width(), buffer.height(), buffer.pixelFormatType(), attachments.get(), 0);
+
+ if (m_imageQueue->insertImage(imageTime, WKCAImageQueue::Buffer, imageId, WKCAImageQueue::Opaque | WKCAImageQueue::Flush, &QTPixelBuffer::imageQueueReleaseCallback, buffer.pixelBufferRef())) {
+ // Retain the buffer one extra time so it doesn't dissappear before CAImageQueue decides to release it:
+ QTPixelBuffer::retainCallback(buffer.pixelBufferRef());
+ }
+
+ } else {
CGImageRef image = CreateCGImageFromPixelBuffer(buffer);
layer->setContents(image);
CGImageRelease(image);
-
- buffer.unlockBaseAddress();
- layer->rootLayer()->setNeedsRender();
}
+
+ buffer.unlockBaseAddress();
+ layer->rootLayer()->setNeedsRender();
+ }
} else
#endif
m_player->repaint();
@@ -794,6 +826,69 @@ static HashSet<String> mimeTypeCache()
return typeCache;
}
+static CFStringRef createVersionStringFromModuleName(LPCWSTR moduleName)
+{
+ HMODULE module = GetModuleHandleW(moduleName);
+ if (!module)
+ return 0;
+
+ wchar_t filePath[MAX_PATH] = {0};
+ if (!GetModuleFileNameW(module, filePath, MAX_PATH))
+ return 0;
+
+ DWORD versionInfoSize = GetFileVersionInfoSizeW(filePath, 0);
+ if (!versionInfoSize)
+ return 0;
+
+ CFStringRef versionString = 0;
+ void* versionInfo = calloc(versionInfoSize, sizeof(char));
+ if (GetFileVersionInfo(filePath, 0, versionInfoSize, versionInfo)) {
+ VS_FIXEDFILEINFO* fileInfo = 0;
+ UINT fileInfoLength = 0;
+
+ if (VerQueryValueW(versionInfo, L"\\", reinterpret_cast<LPVOID*>(&fileInfo), &fileInfoLength)) {
+ versionString = CFStringCreateWithFormat(kCFAllocatorDefault, 0, CFSTR("%d.%d.%d.%d"),
+ HIWORD(fileInfo->dwFileVersionMS), LOWORD(fileInfo->dwFileVersionMS),
+ HIWORD(fileInfo->dwFileVersionLS), LOWORD(fileInfo->dwFileVersionLS));
+ }
+ }
+ free(versionInfo);
+
+ return versionString;
+}
+
+static bool requiredDllsAvailable()
+{
+ static bool s_prerequisitesChecked = false;
+ static bool s_prerequisitesSatisfied;
+ static const CFStringRef kMinQuartzCoreVersion = CFSTR("1.0.42.0");
+ static const CFStringRef kMinCoreVideoVersion = CFSTR("1.0.1.0");
+
+ if (s_prerequisitesChecked)
+ return s_prerequisitesSatisfied;
+ s_prerequisitesChecked = true;
+ s_prerequisitesSatisfied = false;
+
+ CFStringRef quartzCoreString = createVersionStringFromModuleName(L"QuartzCore");
+ if (!quartzCoreString)
+ quartzCoreString = createVersionStringFromModuleName(L"QuartzCore_debug");
+
+ CFStringRef coreVideoString = createVersionStringFromModuleName(L"CoreVideo");
+ if (!coreVideoString)
+ coreVideoString = createVersionStringFromModuleName(L"CoreVideo_debug");
+
+ s_prerequisitesSatisfied = (quartzCoreString && coreVideoString
+ && CFStringCompare(quartzCoreString, kMinQuartzCoreVersion, kCFCompareNumerically) != kCFCompareLessThan
+ && CFStringCompare(coreVideoString, kMinCoreVideoVersion, kCFCompareNumerically) != kCFCompareLessThan);
+
+ if (quartzCoreString)
+ CFRelease(quartzCoreString);
+ if (coreVideoString)
+ CFRelease(coreVideoString);
+
+ return s_prerequisitesSatisfied;
+}
+
void MediaPlayerPrivateQuickTimeVisualContext::getSupportedTypes(HashSet<String>& types)
{
types = mimeTypeCache();
@@ -858,7 +953,7 @@ MediaPlayerPrivateQuickTimeVisualContext::MediaRenderingMode MediaPlayerPrivateQ
return MediaRenderingMovieLayer;
#endif
- return MediaRenderingSoftwareRenderer;
+ return m_visualContext ? MediaRenderingSoftwareRenderer : MediaRenderingNone;
}
MediaPlayerPrivateQuickTimeVisualContext::MediaRenderingMode MediaPlayerPrivateQuickTimeVisualContext::preferredRenderingMode() const
@@ -896,6 +991,10 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpVideoRendering()
if (currentMode == MediaRenderingMovieLayer || preferredMode == MediaRenderingMovieLayer)
m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player);
#endif
+
+ QTMovieVisualContext::Type contextType = requiredDllsAvailable() && preferredMode == MediaRenderingMovieLayer ? QTMovieVisualContext::ConfigureForCAImageQueue : QTMovieVisualContext::ConfigureForCGImage;
+ m_visualContext = QTMovieVisualContext::create(m_visualContextClient.get(), contextType);
+ m_visualContext->setMovie(m_movie.get());
}
void MediaPlayerPrivateQuickTimeVisualContext::tearDownVideoRendering()
@@ -904,12 +1003,14 @@ void MediaPlayerPrivateQuickTimeVisualContext::tearDownVideoRendering()
if (m_qtVideoLayer)
destroyLayerForMovie();
#endif
+
+ m_visualContext = 0;
}
bool MediaPlayerPrivateQuickTimeVisualContext::hasSetUpVideoRendering() const
{
#if USE(ACCELERATED_COMPOSITING)
- return m_qtVideoLayer || currentRenderingMode() != MediaRenderingMovieLayer;
+ return m_qtVideoLayer || (currentRenderingMode() != MediaRenderingMovieLayer && m_visualContext);
#else
return true;
#endif
@@ -939,14 +1040,22 @@ void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie()
#endif
// The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration().
#endif
+
+ // Fill the newly created layer with image data, so we're not looking at
+ // an empty layer until the next time a new image is available, which could
+ // be a long time if we're paused.
+ if (m_visualContext)
+ retrieveCurrentImage();
}
void MediaPlayerPrivateQuickTimeVisualContext::destroyLayerForMovie()
{
#if USE(ACCELERATED_COMPOSITING)
- if (!m_qtVideoLayer)
- return;
- m_qtVideoLayer = 0;
+ if (m_qtVideoLayer)
+ m_qtVideoLayer = 0;
+
+ if (m_imageQueue)
+ m_imageQueue = 0;
#endif
}
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
index 12166a3..7bf796c 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
@@ -41,7 +41,6 @@
typedef struct CGImage *CGImageRef;
class QTMovie;
class QTMovieVisualContext;
-class WKCAImageQueue;
namespace WebCore {
@@ -50,6 +49,10 @@ class IntSize;
class IntRect;
class String;
+#if USE(ACCELERATED_COMPOSITING)
+class WKCAImageQueue;
+#endif
+
class MediaPlayerPrivateQuickTimeVisualContext : public MediaPlayerPrivateInterface {
public:
static void registerMediaEngine(MediaEngineRegistrar);
@@ -161,6 +164,7 @@ private:
RefPtr<QTMovie> m_movie;
#if USE(ACCELERATED_COMPOSITING)
OwnPtr<GraphicsLayer> m_qtVideoLayer;
+ OwnPtr<WKCAImageQueue> m_imageQueue;
#endif
RefPtr<QTMovieVisualContext> m_visualContext;
float m_seekTo;
diff --git a/WebCore/platform/graphics/win/QTMovieVisualContext.cpp b/WebCore/platform/graphics/win/QTMovieVisualContext.cpp
index 9c08cd9..0232d3b 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, CFDictionaryRef options);
+ QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTMovieVisualContext::Type contextType);
~QTMovieVisualContextPriv();
bool isImageAvailableForTime(const QTCVTimeStamp*) const;
@@ -61,7 +61,61 @@ private:
};
-QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, CFDictionaryRef options)
+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;
+}
+
+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);
+
+ return pixelBufferOptions;
+}
+
+static CFDictionaryRef pixelBufferCreationOptions(QTMovieVisualContext::Type contextType)
+{
+ if (contextType == QTMovieVisualContext::ConfigureForCAImageQueue) {
+ static CFDictionaryRef imageQueueOptions = createPixelBufferOptionsDictionary(contextType);
+ return imageQueueOptions;
+ }
+
+ ASSERT(contextType == QTMovieVisualContext::ConfigureForCGImage);
+ static CFDictionaryRef cgImageOptions = createPixelBufferOptionsDictionary(contextType);
+ return cgImageOptions;
+}
+
+QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTMovieVisualContext::Type contextType)
: m_parent(parent)
, m_client(client)
, m_visualContext(0)
@@ -77,13 +131,15 @@ QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent,
return;
}
- OSStatus status = pPixelBufferContextCreate(kCFAllocatorDefault, options, &m_visualContext);
+ OSStatus status = pPixelBufferContextCreate(kCFAllocatorDefault, pixelBufferCreationOptions(contextType), &m_visualContext);
if (status == noErr && m_visualContext)
QTVisualContextSetImageAvailableCallback(m_visualContext, &QTMovieVisualContextPriv::imageAvailableCallback, static_cast<void*>(this));
}
QTMovieVisualContextPriv::~QTMovieVisualContextPriv()
{
+ if (m_visualContext)
+ QTVisualContextSetImageAvailableCallback(m_visualContext, 0, 0);
}
bool QTMovieVisualContextPriv::isImageAvailableForTime(const QTCVTimeStamp* timeStamp) const
@@ -150,66 +206,13 @@ void QTMovieVisualContextPriv::imageAvailableCallback(QTVisualContextRef visualC
vc->m_client->imageAvailableForTime(reinterpret_cast<const QTCVTimeStamp*>(timeStamp));
}
-static OSStatus SetNumberValue(CFMutableDictionaryRef inDict, CFStringRef inKey, SInt32 inValue)
+PassRefPtr<QTMovieVisualContext> QTMovieVisualContext::create(QTMovieVisualContextClient* client, Type contextType)
{
- CFNumberRef number;
-
- number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
- if (!number)
- return coreFoundationUnknownErr;
-
- CFDictionarySetValue(inDict, inKey, number);
-
- CFRelease(number);
-
- return noErr;
-}
-
-CFDictionaryRef QTMovieVisualContext::getCGImageOptions()
-{
- static CFDictionaryRef options = 0;
-
- if (!options) {
- CFMutableDictionaryRef pixelBufferOptions = 0;
- CFMutableDictionaryRef visualContextOptions = 0;
- OSStatus status = noErr;
-
- // Pixel Buffer attributes
- pixelBufferOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
-
- // Use the k32BGRAPixelFormat, as QuartzCore will be able to use the pixels directly,
- // without needing an aditional copy or rendering pass:s
- SetNumberValue(pixelBufferOptions, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat);
-
- // alignment
- SetNumberValue(pixelBufferOptions, kCVPixelBufferBytesPerRowAlignmentKey, 16);
-
- // compatability
- SetNumberValue(pixelBufferOptions, kCVPixelBufferCGImageCompatibilityKey, 1);
-
- // QT Visual Context attributes
- visualContextOptions = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
-
- // set the pixel buffer attributes for the visual context
- CFDictionarySetValue(visualContextOptions,
- kQTVisualContextPixelBufferAttributesKey,
- pixelBufferOptions);
-
- if (pixelBufferOptions)
- CFRelease(pixelBufferOptions);
-
- options = visualContextOptions;
- }
-
- return options;
+ return adoptRef(new QTMovieVisualContext(client, contextType));
}
-QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, CFDictionaryRef options)
- : m_private(new QTMovieVisualContextPriv(this, client, options))
+QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, 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 8846416..057031e 100644
--- a/WebCore/platform/graphics/win/QTMovieVisualContext.h
+++ b/WebCore/platform/graphics/win/QTMovieVisualContext.h
@@ -54,7 +54,9 @@ public:
class QTMOVIEWIN_API QTMovieVisualContext : public RefCounted<QTMovieVisualContext> {
public:
- QTMovieVisualContext(QTMovieVisualContextClient*, CFDictionaryRef options = 0);
+ enum Type { ConfigureForCGImage, ConfigureForCAImageQueue };
+
+ static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, Type);
~QTMovieVisualContext();
bool isImageAvailableForTime(const QTCVTimeStamp*) const;
@@ -66,10 +68,10 @@ public:
void setMovie(PassRefPtr<QTMovie>);
QTMovie* movie() const;
- static CFDictionaryRef getCGImageOptions();
static double currentHostTime();
protected:
+ QTMovieVisualContext(QTMovieVisualContextClient*, Type);
void setupVisualContext();
friend class QTMovieVisualContextPriv;
diff --git a/WebCore/platform/graphics/win/QTPixelBuffer.cpp b/WebCore/platform/graphics/win/QTPixelBuffer.cpp
index f874287..657b68e 100644
--- a/WebCore/platform/graphics/win/QTPixelBuffer.cpp
+++ b/WebCore/platform/graphics/win/QTPixelBuffer.cpp
@@ -172,6 +172,11 @@ void QTPixelBuffer::getExtendedPixels(size_t* left, size_t* right, size_t* top,
return CVPixelBufferGetExtendedPixels(m_pixelBuffer, left, right, top, bottom);
}
+CFDictionaryRef QTPixelBuffer::attachments() const
+{
+ return CVBufferGetAttachments(m_pixelBuffer, kCVAttachmentMode_ShouldPropagate);
+}
+
void QTPixelBuffer::retainCallback(void* refcon)
{
CVPixelBufferRetain(static_cast<CVPixelBufferRef>(refcon));
diff --git a/WebCore/platform/graphics/win/QTPixelBuffer.h b/WebCore/platform/graphics/win/QTPixelBuffer.h
index 3af2197..22f8ba4 100644
--- a/WebCore/platform/graphics/win/QTPixelBuffer.h
+++ b/WebCore/platform/graphics/win/QTPixelBuffer.h
@@ -38,6 +38,7 @@ typedef struct __CVBuffer *CVBufferRef;
typedef CVBufferRef CVPixelBufferRef;
typedef struct CGImage* CGImageRef;
typedef int32_t CVReturn;
+typedef const struct __CFDictionary * CFDictionaryRef;
// QTPixelBuffer wraps QuickTime's implementation of CVPixelBuffer, so its functions are
// safe to call within WebKit.
@@ -74,6 +75,7 @@ public:
size_t bytesPerRowOfPlane(size_t) const;
void getExtendedPixels(size_t* left, size_t* right, size_t* top, size_t* bottom) const;
+ CFDictionaryRef attachments() const;
// Generic CFRetain/CFRelease callbacks
static void releaseCallback(void* refcon);
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp
index 3f332d8..d3928f1 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp
@@ -154,6 +154,7 @@ PassRefPtr<WKCACFLayer> WKCACFLayer::create(LayerType type)
WKCACFLayer::WKCACFLayer(LayerType type)
: m_layer(AdoptCF, CACFLayerCreate(toCACFLayerType(type)))
+ , m_layoutClient(0)
, m_needsDisplayOnBoundsChange(false)
{
CACFLayerSetUserData(layer(), this);
@@ -286,11 +287,10 @@ void WKCACFLayer::adoptSublayers(WKCACFLayer* source)
void WKCACFLayer::removeFromSuperlayer()
{
WKCACFLayer* superlayer = this->superlayer();
- if (!superlayer)
- return;
-
CACFLayerRemoveFromSuperlayer(layer());
- superlayer->setNeedsCommit();
+
+ if (superlayer)
+ superlayer->setNeedsCommit();
}
WKCACFLayer* WKCACFLayer::internalSublayerAtIndex(int index) const
@@ -343,6 +343,19 @@ void WKCACFLayer::setBounds(const CGRect& rect)
setNeedsDisplay();
}
+void WKCACFLayer::setFrame(const CGRect& rect)
+{
+ CGRect oldFrame = frame();
+ if (CGRectEqualToRect(rect, oldFrame))
+ return;
+
+ CACFLayerSetFrame(layer(), rect);
+ setNeedsCommit();
+
+ if (m_needsDisplayOnBoundsChange && !CGSizeEqualToSize(rect.size, oldFrame.size))
+ setNeedsDisplay();
+}
+
void WKCACFLayer::setContentsGravity(ContentsGravityType type)
{
CACFLayerSetContentsGravity(layer(), toCACFContentsGravityType(type));
@@ -418,6 +431,22 @@ void WKCACFLayer::internalSetNeedsDisplay(const CGRect* dirtyRect)
CACFLayerSetNeedsDisplay(layer(), dirtyRect);
}
+void WKCACFLayer::setLayoutClient(WKCACFLayerLayoutClient* layoutClient)
+{
+ if (layoutClient == m_layoutClient)
+ return;
+
+ m_layoutClient = layoutClient;
+ CACFLayerSetLayoutCallback(layer(), m_layoutClient ? layoutSublayersProc : 0);
+}
+
+void WKCACFLayer::layoutSublayersProc(CACFLayerRef caLayer)
+{
+ WKCACFLayer* layer = WKCACFLayer::layer(caLayer);
+ if (layer && layer->m_layoutClient)
+ layer->m_layoutClient->layoutSublayersOfLayer(layer);
+}
+
#ifndef NDEBUG
static void printIndent(int indent)
{
@@ -497,11 +526,14 @@ void WKCACFLayer::printLayer(int indent) const
}
// Print contents if needed
- CGImageRef layerContents = contents();
+ CFTypeRef layerContents = contents();
if (layerContents) {
- printIndent(indent + 1);
- fprintf(stderr, "(contents (image [%d %d]))\n",
- CGImageGetWidth(layerContents), CGImageGetHeight(layerContents));
+ if (CFGetTypeID(layerContents) == CGImageGetTypeID()) {
+ CGImageRef imageContents = static_cast<CGImageRef>(const_cast<void*>(layerContents));
+ printIndent(indent + 1);
+ fprintf(stderr, "(contents (image [%d %d]))\n",
+ CGImageGetWidth(imageContents), CGImageGetHeight(imageContents));
+ }
}
// Print sublayers if needed
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.h b/WebCore/platform/graphics/win/WKCACFLayer.h
index bdc427e..5e8eb05 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayer.h
@@ -44,8 +44,14 @@
namespace WebCore {
-class WKCACFAnimation;
-class WKCACFTimingFunction;
+class WKCACFLayer;
+
+class WKCACFLayerLayoutClient {
+public:
+ virtual void layoutSublayersOfLayer(WKCACFLayer*) = 0;
+protected:
+ virtual ~WKCACFLayerLayoutClient() {}
+};
class WKCACFLayer : public RefCounted<WKCACFLayer> {
public:
@@ -63,6 +69,10 @@ public:
virtual void drawInContext(PlatformGraphicsContext*) { }
+ void setLayoutClient(WKCACFLayerLayoutClient*);
+ WKCACFLayerLayoutClient* layoutClient() const { return m_layoutClient; }
+ void setNeedsLayout() { CACFLayerSetNeedsLayout(layer()); }
+
void setNeedsDisplay(const CGRect* dirtyRect = 0)
{
internalSetNeedsDisplay(dirtyRect);
@@ -155,8 +165,8 @@ public:
void setClearsContext(bool clears) { CACFLayerSetClearsContext(layer(), clears); setNeedsCommit(); }
bool clearsContext() const { return CACFLayerGetClearsContext(layer()); }
- void setContents(CGImageRef contents) { CACFLayerSetContents(layer(), contents); setNeedsCommit(); }
- CGImageRef contents() const { return static_cast<CGImageRef>(const_cast<void*>(CACFLayerGetContents(layer()))); }
+ void setContents(CFTypeRef contents) { CACFLayerSetContents(layer(), contents); setNeedsCommit(); }
+ CFTypeRef contents() const { return CACFLayerGetContents(layer()); }
void setContentsRect(const CGRect& contentsRect) { CACFLayerSetContentsRect(layer(), contentsRect); setNeedsCommit(); }
CGRect contentsRect() const { return CACFLayerGetContentsRect(layer()); }
@@ -173,6 +183,9 @@ public:
void setFilters(CFArrayRef filters) { CACFLayerSetFilters(layer(), filters); setNeedsCommit(); }
CFArrayRef filters() const { return CACFLayerGetFilters(layer()); }
+ virtual void setFrame(const CGRect&);
+ CGRect frame() const { return CACFLayerGetFrame(layer()); }
+
void setHidden(bool hidden) { CACFLayerSetHidden(layer(), hidden); setNeedsCommit(); }
bool isHidden() const { return CACFLayerIsHidden(layer()); }
@@ -206,10 +219,10 @@ public:
CGFloat zPosition() const { return CACFLayerGetZPosition(layer()); }
void setSpeed(float speed) { CACFLayerSetSpeed(layer(), speed); }
- CFTimeInterval speed() const { CACFLayerGetSpeed(layer()); }
+ CFTimeInterval speed() const { return CACFLayerGetSpeed(layer()); }
void setTimeOffset(CFTimeInterval t) { CACFLayerSetTimeOffset(layer(), t); }
- CFTimeInterval timeOffset() const { CACFLayerGetTimeOffset(layer()); }
+ CFTimeInterval timeOffset() const { return CACFLayerGetTimeOffset(layer()); }
WKCACFLayer* rootLayer() const;
@@ -261,7 +274,10 @@ protected:
#endif
private:
+ static void layoutSublayersProc(CACFLayerRef);
+
RetainPtr<CACFLayerRef> m_layer;
+ WKCACFLayerLayoutClient* m_layoutClient;
bool m_needsDisplayOnBoundsChange;
};
diff --git a/WebCore/platform/graphics/win/WKCAImageQueue.cpp b/WebCore/platform/graphics/win/WKCAImageQueue.cpp
new file mode 100644
index 0000000..b52b9a4
--- /dev/null
+++ b/WebCore/platform/graphics/win/WKCAImageQueue.cpp
@@ -0,0 +1,104 @@
+/*
+ * 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 INC. 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 INC. 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 "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "WKCAImageQueue.h"
+
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class WKCAImageQueuePrivate {
+public:
+ RetainPtr<CAImageQueueRef> m_imageQueue;
+};
+
+static CAImageQueueRef WKCAImageQueueRetain(CAImageQueueRef iq)
+{
+ if (iq)
+ return (CAImageQueueRef)CFRetain(iq);
+ return 0;
+}
+
+static void WKCAImageQueueRelease(CAImageQueueRef iq)
+{
+ if (iq)
+ CFRelease(iq);
+}
+
+WKCAImageQueue::WKCAImageQueue(uint32_t width, uint32_t height, uint32_t capacity)
+ : m_private(new WKCAImageQueuePrivate())
+{
+ m_private->m_imageQueue.adoptCF(wkCAImageQueueCreate(width, height, capacity));
+}
+
+WKCAImageQueue::WKCAImageQueue(const WKCAImageQueue& o)
+ : m_private(new WKCAImageQueuePrivate())
+{
+ m_private->m_imageQueue = o.m_private->m_imageQueue;
+}
+
+WKCAImageQueue::~WKCAImageQueue(void)
+{
+}
+
+WKCAImageQueue& WKCAImageQueue::operator=(const WKCAImageQueue& o)
+{
+ m_private->m_imageQueue = o.m_private->m_imageQueue;
+ return *this;
+}
+
+size_t WKCAImageQueue::collect()
+{
+ return wkCAImageQueueCollect(m_private->m_imageQueue.get());
+}
+
+bool WKCAImageQueue::insertImage(double t, unsigned int type, uint64_t id, uint32_t flags, ReleaseCallback release, void* info)
+{
+ return wkCAImageQueueInsertImage(m_private->m_imageQueue.get(), t, type, id, flags, release, info);
+}
+
+uint64_t WKCAImageQueue::registerPixelBuffer(void *data, size_t data_size, size_t rowbytes, size_t width, size_t height, uint32_t pixel_format, CFDictionaryRef attachments, uint32_t flags)
+{
+ return wkCAImageQueueRegisterPixelBuffer(m_private->m_imageQueue.get(), data, data_size, rowbytes, width, height, pixel_format, attachments, flags);
+}
+
+void WKCAImageQueue::setFlags(uint32_t mask, uint32_t flags)
+{
+ wkCAImageQueueSetFlags(m_private->m_imageQueue.get(), mask, flags);
+}
+
+CFTypeRef WKCAImageQueue::get()
+{
+ return m_private->m_imageQueue.get();
+}
+
+}
+
+#endif
diff --git a/WebCore/platform/graphics/win/WKCAImageQueue.h b/WebCore/platform/graphics/win/WKCAImageQueue.h
new file mode 100644
index 0000000..5c17575
--- /dev/null
+++ b/WebCore/platform/graphics/win/WKCAImageQueue.h
@@ -0,0 +1,92 @@
+/*
+ * 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 INC. 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 INC. 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.
+ */
+
+#ifndef WKCAImageQueue_h
+#define WKCAImageQueue_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+typedef const void * CFTypeRef;
+typedef const struct __CFDictionary * CFDictionaryRef;
+
+#include <stdint.h>
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+class WKCAImageQueuePrivate;
+
+class WKCAImageQueue {
+public:
+ enum Flags {
+ Async = 1U << 0,
+ Fill = 1U << 1,
+ Protected = 1U << 2,
+ UseCleanAperture = 1U << 3,
+ UseAspectRatio = 1U << 4,
+ LowQualityColor = 1U << 5,
+ };
+
+ enum ImageType {
+ Nil = 1,
+ Surface,
+ Buffer,
+ IOSurface,
+ };
+
+ enum ImageFlags {
+ Opaque = 1U << 0,
+ Flush = 1U << 1,
+ WillFlush = 1U << 2,
+ Flipped = 1U << 3,
+ WaitGPU = 1U << 4,
+ };
+
+ typedef void (*ReleaseCallback)(unsigned int type, uint64_t id, void* info);
+
+ WKCAImageQueue(uint32_t width, uint32_t height, uint32_t capacity);
+ ~WKCAImageQueue(void);
+
+ size_t collect();
+
+ bool insertImage(double t, unsigned int type, uint64_t id, uint32_t flags, ReleaseCallback release, void* info);
+ uint64_t registerPixelBuffer(void *data, size_t data_size, size_t rowbytes, size_t width, size_t height, uint32_t pixel_format, CFDictionaryRef attachments, uint32_t flags);
+
+ uint32_t flags() const;
+ void setFlags(uint32_t mask, uint32_t flags);
+
+ CFTypeRef get();
+
+private:
+ WKCAImageQueue(const WKCAImageQueue&);
+ WKCAImageQueue& operator=(const WKCAImageQueue&);
+ OwnPtr<WKCAImageQueuePrivate> m_private;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/WebCore/platform/graphics/win/WebTiledLayer.cpp b/WebCore/platform/graphics/win/WebTiledLayer.cpp
index 0cf3f9d..d8c02d2 100755
--- a/WebCore/platform/graphics/win/WebTiledLayer.cpp
+++ b/WebCore/platform/graphics/win/WebTiledLayer.cpp
@@ -73,6 +73,15 @@ void WebTiledLayer::setBounds(const CGRect& rect)
updateTiles();
}
+void WebTiledLayer::setFrame(const CGRect& rect)
+{
+ if (CGRectEqualToRect(rect, frame()))
+ return;
+
+ WebLayer::setFrame(rect);
+ updateTiles();
+}
+
void WebTiledLayer::internalSetNeedsDisplay(const CGRect* dirtyRect)
{
// FIXME: Only setNeedsDisplay for tiles that are currently visible
diff --git a/WebCore/platform/graphics/win/WebTiledLayer.h b/WebCore/platform/graphics/win/WebTiledLayer.h
index ed61656..fdf0205 100755
--- a/WebCore/platform/graphics/win/WebTiledLayer.h
+++ b/WebCore/platform/graphics/win/WebTiledLayer.h
@@ -39,6 +39,7 @@ public:
virtual ~WebTiledLayer();
virtual void setBounds(const CGRect&);
+ virtual void setFrame(const CGRect&);
protected:
WebTiledLayer(const CGSize& tileSize, GraphicsLayer* owner);