[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
eric.carlson at apple.com
eric.carlson at apple.com
Thu Feb 4 21:25:05 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit db4bf17f4ffe54d8f2cdae24e620ff7d58811316
Author: eric.carlson at apple.com <eric.carlson at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jan 22 20:40:13 2010 +0000
2010-01-22 Eric Carlson <eric.carlson at apple.com>
Reviewed by Adam Roben.
<rdar://problem/7373568>
https://bugs.webkit.org/show_bug.cgi?id=34007
Implement hardware acceleration of video compositing on Windows
Internally we still have QuickTime render to a bitmap, but frames are then composited
with the page using an accelerated renderer.
* platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp:
(WebCore::MediaPlayerPrivate::MediaPlayerPrivate): Initialize m_newFrameAvailable.
(WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): Call tearDownVideoRendering.
(WebCore::MediaPlayerPrivate::cancelLoad): Call tearDownVideoRendering.
(WebCore::MediaPlayerPrivate::updateStates): Call setUpVideoRendering once the movie
is ready to draw.
(WebCore::MediaPlayerPrivate::isReadyForRendering): New, utility function returns true
only when movie is ready to render.
(WebCore::MediaPlayerPrivate::setSize): Remember the size as we need it when rendering
in accelerated mode.
(WebCore::MediaPlayerPrivate::setVisible): Call setUpVideoRendering when made visible.
(WebCore::MediaPlayerPrivate::paint): Do nothing when rendering to a layer. Move frame
rate drawing code to paintCompleted.
(WebCore::MediaPlayerPrivate::paintCompleted): New, clear m_newFrameAvailable and, when
built with DRAW_FRAME_RATE, draw framerate.
(WebCore::MediaPlayerPrivate::movieNewImageAvailable): Set m_newFrameAvailable, trigger
repaint differently when drawing to a layer.
(WebCore::MediaPlayerPrivate::currentRenderingMode): New, return the current rendering mode.
(WebCore::MediaPlayerPrivate::preferredRenderingMode): New, return preferred rendering mode
(render to a layer whenever possible).
(WebCore::MediaPlayerPrivate::setUpVideoRendering): New, tear down current rendering mode
and set up new mode when necessary.
(WebCore::MediaPlayerPrivate::tearDownVideoRendering): New, noop unless rendering to a layer.
(WebCore::MediaPlayerPrivate::hasSetUpVideoRendering): New.
(WebCore::MediaPlayerPrivate::paintContents): New, callback from compositing layer when it
is time to draw the current frame.
(WebCore::MediaPlayerPrivate::createLayerForMovie): New, allocate a layer for the movie.
(WebCore::MediaPlayerPrivate::destroyLayerForMovie): New, delete movie layer.
(WebCore::MediaPlayerPrivate::supportsAcceleratedRendering): New, return true unless the
movie is not ready to render.
(WebCore::MediaPlayerPrivate::acceleratedRenderingStateChanged): New, deal with change in
accelerated rendering state.
(WebCore::MediaPlayerPrivate::notifySyncRequired): New, callback from compositing layer
when it wants to schedule a redraw.
* platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h:
(WebCore::MediaPlayerPrivate::notifyAnimationStarted):
(WebCore::MediaPlayerPrivate::showDebugBorders):
(WebCore::MediaPlayerPrivate::showRepaintCounter):
* platform/graphics/win/QTMovieWin.cpp:
(QTMovieWin::getCurrentFrameInfo):
New, return information about the offscreen render buffer.
(QTMovieWin::initializeQuickTime):
* platform/graphics/win/QTMovieWin.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2f3d91b..d67c4e6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2010-01-22 Eric Carlson <eric.carlson at apple.com>
+
+ Reviewed by Adam Roben.
+
+ <rdar://problem/7373568>
+ https://bugs.webkit.org/show_bug.cgi?id=34007
+ Implement hardware acceleration of video compositing on Windows
+
+ Internally we still have QuickTime render to a bitmap, but frames are then composited
+ with the page using an accelerated renderer.
+
+ * platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp:
+ (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): Initialize m_newFrameAvailable.
+ (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): Call tearDownVideoRendering.
+ (WebCore::MediaPlayerPrivate::cancelLoad): Call tearDownVideoRendering.
+ (WebCore::MediaPlayerPrivate::updateStates): Call setUpVideoRendering once the movie
+ is ready to draw.
+ (WebCore::MediaPlayerPrivate::isReadyForRendering): New, utility function returns true
+ only when movie is ready to render.
+ (WebCore::MediaPlayerPrivate::setSize): Remember the size as we need it when rendering
+ in accelerated mode.
+ (WebCore::MediaPlayerPrivate::setVisible): Call setUpVideoRendering when made visible.
+ (WebCore::MediaPlayerPrivate::paint): Do nothing when rendering to a layer. Move frame
+ rate drawing code to paintCompleted.
+ (WebCore::MediaPlayerPrivate::paintCompleted): New, clear m_newFrameAvailable and, when
+ built with DRAW_FRAME_RATE, draw framerate.
+ (WebCore::MediaPlayerPrivate::movieNewImageAvailable): Set m_newFrameAvailable, trigger
+ repaint differently when drawing to a layer.
+ (WebCore::MediaPlayerPrivate::currentRenderingMode): New, return the current rendering mode.
+ (WebCore::MediaPlayerPrivate::preferredRenderingMode): New, return preferred rendering mode
+ (render to a layer whenever possible).
+ (WebCore::MediaPlayerPrivate::setUpVideoRendering): New, tear down current rendering mode
+ and set up new mode when necessary.
+ (WebCore::MediaPlayerPrivate::tearDownVideoRendering): New, noop unless rendering to a layer.
+ (WebCore::MediaPlayerPrivate::hasSetUpVideoRendering): New.
+ (WebCore::MediaPlayerPrivate::paintContents): New, callback from compositing layer when it
+ is time to draw the current frame.
+ (WebCore::MediaPlayerPrivate::createLayerForMovie): New, allocate a layer for the movie.
+ (WebCore::MediaPlayerPrivate::destroyLayerForMovie): New, delete movie layer.
+ (WebCore::MediaPlayerPrivate::supportsAcceleratedRendering): New, return true unless the
+ movie is not ready to render.
+ (WebCore::MediaPlayerPrivate::acceleratedRenderingStateChanged): New, deal with change in
+ accelerated rendering state.
+ (WebCore::MediaPlayerPrivate::notifySyncRequired): New, callback from compositing layer
+ when it wants to schedule a redraw.
+ * platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h:
+ (WebCore::MediaPlayerPrivate::notifyAnimationStarted):
+ (WebCore::MediaPlayerPrivate::showDebugBorders):
+ (WebCore::MediaPlayerPrivate::showRepaintCounter):
+
+ * platform/graphics/win/QTMovieWin.cpp:
+ (QTMovieWin::getCurrentFrameInfo):
+ New, return information about the offscreen render buffer.
+ (QTMovieWin::initializeQuickTime):
+ * platform/graphics/win/QTMovieWin.h:
+
2010-01-21 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
index 84cd2a3..e749652 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple, Inc. All rights reserved.
+ * Copyright (C) 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
@@ -35,10 +35,16 @@
#include "StringHash.h"
#include "TimeRanges.h"
#include "Timer.h"
+#include <wtf/CurrentTime.h>
#include <wtf/HashSet.h>
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
+#if USE(ACCELERATED_COMPOSITING)
+#include "GraphicsLayerCACF.h"
+#include "WKCACFLayer.h"
+#endif
+
#if DRAW_FRAME_RATE
#include "Font.h"
#include "FrameView.h"
@@ -75,6 +81,8 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
, m_hasUnsupportedTracks(false)
, m_startedPlaying(false)
, m_isStreaming(false)
+ , m_visible(false)
+ , m_newFrameAvailable(false)
#if DRAW_FRAME_RATE
, m_frameCountWhilePlaying(0)
, m_timeStartedPlaying(0)
@@ -85,6 +93,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
MediaPlayerPrivate::~MediaPlayerPrivate()
{
+ tearDownVideoRendering();
}
bool MediaPlayerPrivate::supportsFullscreen() const
@@ -189,7 +198,7 @@ void MediaPlayerPrivate::pause()
return;
m_startedPlaying = false;
#if DRAW_FRAME_RATE
- m_timeStoppedPlaying = GetTickCount();
+ m_timeStoppedPlaying = WTF::currentTime();
#endif
m_qtMovie->pause();
}
@@ -384,9 +393,11 @@ void MediaPlayerPrivate::cancelLoad()
if (m_networkState < MediaPlayer::Loading || m_networkState == MediaPlayer::Loaded)
return;
+ tearDownVideoRendering();
+
// Cancel the load by destroying the movie.
m_qtMovie.clear();
-
+
updateStates();
}
@@ -449,6 +460,9 @@ void MediaPlayerPrivate::updateStates()
}
}
+ if (isReadyForRendering() && !hasSetUpVideoRendering())
+ setUpVideoRendering();
+
if (seeking())
m_readyState = MediaPlayer::HaveNothing;
@@ -458,6 +472,11 @@ void MediaPlayerPrivate::updateStates()
m_player->readyStateChanged();
}
+bool MediaPlayerPrivate::isReadyForRendering() const
+{
+ return m_readyState >= MediaPlayer::HaveMetadata && m_player->visible();
+}
+
void MediaPlayerPrivate::sawUnsupportedTracks()
{
m_qtMovie->setDisabled(true);
@@ -472,7 +491,7 @@ void MediaPlayerPrivate::didEnd()
m_startedPlaying = false;
#if DRAW_FRAME_RATE
- m_timeStoppedPlaying = GetTickCount();
+ m_timeStoppedPlaying = WTF::currentTime();
#endif
updateStates();
m_player->timeChanged();
@@ -480,20 +499,32 @@ void MediaPlayerPrivate::didEnd()
void MediaPlayerPrivate::setSize(const IntSize& size)
{
- if (m_hasUnsupportedTracks || !m_qtMovie)
+ if (m_hasUnsupportedTracks || !m_qtMovie || m_size == size)
return;
+ m_size = size;
m_qtMovie->setSize(size.width(), size.height());
}
-void MediaPlayerPrivate::setVisible(bool b)
+void MediaPlayerPrivate::setVisible(bool visible)
{
- if (m_hasUnsupportedTracks || !m_qtMovie)
+ if (m_hasUnsupportedTracks || !m_qtMovie || m_visible == visible)
return;
- m_qtMovie->setVisible(b);
+
+ m_qtMovie->setVisible(visible);
+ m_visible = visible;
+ if (m_visible) {
+ if (isReadyForRendering())
+ setUpVideoRendering();
+ } else
+ tearDownVideoRendering();
}
void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r)
{
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_qtVideoLayer)
+ return;
+#endif
if (p->paintingDisabled() || !m_qtMovie || m_hasUnsupportedTracks)
return;
@@ -524,28 +555,50 @@ void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r)
else
p->releaseWindowsContext(hdc, r);
+ paintCompleted(*p, r);
+}
+
+void MediaPlayerPrivate::paintCompleted(GraphicsContext& context, const IntRect& rect)
+{
+ m_newFrameAvailable = false;
+
#if DRAW_FRAME_RATE
if (m_frameCountWhilePlaying > 10) {
- Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : NULL;
- Document* document = frame ? frame->document() : NULL;
- RenderObject* renderer = document ? document->renderer() : NULL;
- RenderStyle* styleToUse = renderer ? renderer->style() : NULL;
- if (styleToUse) {
- double frameRate = (m_frameCountWhilePlaying - 1) / (0.001 * ( m_startedPlaying ? (GetTickCount() - m_timeStartedPlaying) :
- (m_timeStoppedPlaying - m_timeStartedPlaying) ));
- String text = String::format("%1.2f", frameRate);
- TextRun textRun(text.characters(), text.length());
- const Color color(255, 0, 0);
- p->save();
- p->translate(r.x(), r.y() + r.height());
- p->setFont(styleToUse->font());
- p->setStrokeColor(color);
- p->setStrokeStyle(SolidStroke);
- p->setStrokeThickness(1.0f);
- p->setFillColor(color);
- p->drawText(textRun, IntPoint(2, -3));
- p->restore();
- }
+ double interval = m_startedPlaying ? WTF::currentTime() - m_timeStartedPlaying : m_timeStoppedPlaying - m_timeStartedPlaying;
+ double frameRate = (m_frameCountWhilePlaying - 1) / interval;
+ CGContextRef cgContext = context.platformContext();
+ CGRect drawRect = rect;
+
+ char text[8];
+ _snprintf(text, sizeof(text), "%1.2f", frameRate);
+
+ static const int fontSize = 25;
+ static const int fontCharWidth = 12;
+ static const int boxHeight = 25;
+ static const int boxBorderWidth = 4;
+ drawRect.size.width = boxBorderWidth * 2 + fontCharWidth * strlen(text);
+ drawRect.size.height = boxHeight;
+
+ CGContextSaveGState(cgContext);
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_qtVideoLayer)
+ CGContextScaleCTM(cgContext, 1, -1);
+ CGContextTranslateCTM(cgContext, rect.width() - drawRect.size.width, m_qtVideoLayer ? -rect.height() : 0);
+#else
+ CGContextTranslateCTM(cgContext, rect.width() - drawRect.size.width, 0);
+#endif
+ static const CGFloat backgroundColor[4] = { 0.98, 0.98, 0.82, 0.8 };
+ CGContextSetFillColor(cgContext, backgroundColor);
+ CGContextFillRect(cgContext, drawRect);
+
+ static const CGFloat textColor[4] = { 0, 0, 0, 1 };
+ CGContextSetFillColor(cgContext, textColor);
+ CGContextSetTextMatrix(cgContext, CGAffineTransformMakeScale(1, -1));
+ CGContextSelectFont(cgContext, "Helvetica", fontSize, kCGEncodingMacRoman);
+
+ CGContextShowTextAtPoint(cgContext, drawRect.origin.x + boxBorderWidth, drawRect.origin.y + boxHeight - boxBorderWidth, text, strlen(text));
+
+ CGContextRestoreGState(cgContext);
}
#endif
}
@@ -625,13 +678,21 @@ void MediaPlayerPrivate::movieNewImageAvailable(QTMovieWin* movie)
#if DRAW_FRAME_RATE
if (m_startedPlaying) {
m_frameCountWhilePlaying++;
- // to eliminate preroll costs from our calculation,
- // our frame rate calculation excludes the first frame drawn after playback starts
- if (1==m_frameCountWhilePlaying)
- m_timeStartedPlaying = GetTickCount();
+ // To eliminate preroll costs from our calculation, our frame rate calculation excludes
+ // the first frame drawn after playback starts.
+ if (m_frameCountWhilePlaying == 1)
+ m_timeStartedPlaying = WTF::currentTime();
}
#endif
- m_player->repaint();
+
+ m_newFrameAvailable = true;
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_qtVideoLayer)
+ m_qtVideoLayer->platformLayer()->setNeedsDisplay();
+ else
+#endif
+ m_player->repaint();
}
bool MediaPlayerPrivate::hasSingleSecurityOrigin() const
@@ -641,6 +702,171 @@ bool MediaPlayerPrivate::hasSingleSecurityOrigin() const
return true;
}
+MediaPlayerPrivate::MediaRenderingMode MediaPlayerPrivate::currentRenderingMode() const
+{
+ if (!m_qtMovie)
+ return MediaRenderingNone;
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_qtVideoLayer)
+ return MediaRenderingMovieLayer;
+#endif
+
+ return MediaRenderingSoftwareRenderer;
+}
+
+MediaPlayerPrivate::MediaRenderingMode MediaPlayerPrivate::preferredRenderingMode() const
+{
+ if (!m_player->frameView() || !m_qtMovie)
+ return MediaRenderingNone;
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
+ return MediaRenderingMovieLayer;
+#endif
+
+ return MediaRenderingSoftwareRenderer;
+}
+
+void MediaPlayerPrivate::setUpVideoRendering()
+{
+ MediaRenderingMode currentMode = currentRenderingMode();
+ MediaRenderingMode preferredMode = preferredRenderingMode();
+
+#if !USE(ACCELERATED_COMPOSITING)
+ ASSERT(preferredMode != MediaRenderingMovieLayer);
+#endif
+
+ if (currentMode == preferredMode && currentMode != MediaRenderingNone)
+ return;
+
+ if (currentMode != MediaRenderingNone)
+ tearDownVideoRendering();
+
+ if (preferredMode == MediaRenderingMovieLayer)
+ createLayerForMovie();
+}
+
+void MediaPlayerPrivate::tearDownVideoRendering()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_qtVideoLayer)
+ destroyLayerForMovie();
+#endif
+}
+
+bool MediaPlayerPrivate::hasSetUpVideoRendering() const
+{
+#if USE(ACCELERATED_COMPOSITING)
+ return m_qtVideoLayer || currentRenderingMode() != MediaRenderingMovieLayer;
+#else
+ return true;
+#endif
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+
+// Up-call from compositing layer drawing callback.
+void MediaPlayerPrivate::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const IntRect&)
+{
+ if (m_hasUnsupportedTracks)
+ return;
+
+ ASSERT(supportsAcceleratedRendering());
+
+ // No reason to replace the current layer image unless we have something new to show.
+ if (!m_newFrameAvailable)
+ return;
+
+ static CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ void* buffer;
+ unsigned bitsPerPixel;
+ unsigned rowBytes;
+ unsigned width;
+ unsigned height;
+
+ m_qtMovie->getCurrentFrameInfo(buffer, bitsPerPixel, rowBytes, width, height);
+ if (!buffer)
+ return ;
+
+ RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(0, static_cast<UInt8*>(buffer), rowBytes * height, kCFAllocatorNull));
+ RetainPtr<CGDataProviderRef> provider(AdoptCF, CGDataProviderCreateWithCFData(data.get()));
+ RetainPtr<CGImageRef> frameImage(AdoptCF, CGImageCreate(width, height, 8, bitsPerPixel, rowBytes, colorSpace,
+ kCGBitmapByteOrder32Little | kCGImageAlphaFirst, provider.get(), 0, false, kCGRenderingIntentDefault));
+ if (!frameImage)
+ return;
+
+ IntRect rect(0, 0, m_size.width(), m_size.height());
+ CGContextDrawImage(context.platformContext(), rect, frameImage.get());
+ paintCompleted(context, rect);
+}
+#endif
+
+void MediaPlayerPrivate::createLayerForMovie()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ ASSERT(supportsAcceleratedRendering());
+
+ if (!m_qtMovie || m_qtVideoLayer)
+ return;
+
+ // Do nothing if the parent layer hasn't been set up yet.
+ GraphicsLayer* videoGraphicsLayer = m_player->mediaPlayerClient()->mediaPlayerGraphicsLayer(m_player);
+ if (!videoGraphicsLayer)
+ return;
+
+ // Create a GraphicsLayer that won't be inserted directly into the render tree, but will used
+ // as a wrapper for a WKCACFLayer which gets inserted as the content layer of the video
+ // renderer's GraphicsLayer.
+ m_qtVideoLayer.set(new GraphicsLayerCACF(this));
+ if (!m_qtVideoLayer)
+ return;
+
+ // Mark the layer as drawing itself, anchored in the top left, and bottom-up.
+ m_qtVideoLayer->setDrawsContent(true);
+ m_qtVideoLayer->setAnchorPoint(FloatPoint3D());
+ m_qtVideoLayer->setContentsOrientation(GraphicsLayer::CompositingCoordinatesBottomUp);
+#ifndef NDEBUG
+ m_qtVideoLayer->setName("Video layer");
+#endif
+
+ // Hang the video layer from the render layer.
+ videoGraphicsLayer->setContentsToVideo(m_qtVideoLayer->platformLayer());
+#endif
+}
+
+void MediaPlayerPrivate::destroyLayerForMovie()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ if (!m_qtVideoLayer)
+ return;
+ m_qtVideoLayer = 0;
+#endif
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+bool MediaPlayerPrivate::supportsAcceleratedRendering() const
+{
+ return isReadyForRendering();
+}
+
+void MediaPlayerPrivate::acceleratedRenderingStateChanged()
+{
+ // Set up or change the rendering path if necessary.
+ setUpVideoRendering();
+}
+
+void MediaPlayerPrivate::notifySyncRequired(const GraphicsLayer*)
+{
+ GraphicsLayerCACF* videoGraphicsLayer = static_cast<GraphicsLayerCACF*>(m_player->mediaPlayerClient()->mediaPlayerGraphicsLayer(m_player));
+ if (videoGraphicsLayer)
+ videoGraphicsLayer->notifySyncRequired();
+ }
+
+
+#endif
+
+
}
#endif
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
index 14c3ef5..d58f44f 100644
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
+++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -32,11 +32,18 @@
#include "Timer.h"
#include <QTMovieWin.h>
#include <wtf/OwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "GraphicsLayerClient.h"
+#endif
#ifndef DRAW_FRAME_RATE
#define DRAW_FRAME_RATE 0
#endif
+typedef struct CGImage *CGImageRef;
+
namespace WebCore {
class GraphicsContext;
@@ -44,13 +51,27 @@ class IntSize;
class IntRect;
class String;
-class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public QTMovieWinClient {
+class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public QTMovieWinClient
+#if USE(ACCELERATED_COMPOSITING)
+ , public GraphicsLayerClient
+#endif
+{
public:
static void registerMediaEngine(MediaEngineRegistrar);
~MediaPlayerPrivate();
private:
+
+#if USE(ACCELERATED_COMPOSITING)
+ // GraphicsLayerClient methods
+ virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
+ virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
+ virtual void notifySyncRequired(const GraphicsLayer*);
+ virtual bool showDebugBorders() const { return false; }
+ virtual bool showRepaintCounter() const { return false; }
+#endif
+
MediaPlayerPrivate(MediaPlayer*);
virtual bool supportsFullscreen() const;
@@ -92,7 +113,8 @@ private:
void didEnd();
void paint(GraphicsContext*, const IntRect&);
-
+ void paintCompleted(GraphicsContext&, const IntRect&);
+
bool hasSingleSecurityOrigin() const;
bool hasClosedCaptions() const;
@@ -116,10 +138,31 @@ private:
static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
static bool isAvailable();
+#if USE(ACCELERATED_COMPOSITING)
+ virtual bool supportsAcceleratedRendering() const;
+ virtual void acceleratedRenderingStateChanged();
+#endif
+
+ enum MediaRenderingMode { MediaRenderingNone, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
+ MediaRenderingMode currentRenderingMode() const;
+ MediaRenderingMode preferredRenderingMode() const;
+ bool isReadyForRendering() const;
+
+ void setUpVideoRendering();
+ void tearDownVideoRendering();
+ bool hasSetUpVideoRendering() const;
+
+ void createLayerForMovie();
+ void destroyLayerForMovie();
+
MediaPlayer* m_player;
OwnPtr<QTMovieWin> m_qtMovie;
+#if USE(ACCELERATED_COMPOSITING)
+ OwnPtr<GraphicsLayer> m_qtVideoLayer;
+#endif
float m_seekTo;
Timer<MediaPlayerPrivate> m_seekTimer;
+ IntSize m_size;
MediaPlayer::NetworkState m_networkState;
MediaPlayer::ReadyState m_readyState;
unsigned m_enabledTrackCount;
@@ -127,10 +170,12 @@ private:
bool m_hasUnsupportedTracks;
bool m_startedPlaying;
bool m_isStreaming;
+ bool m_visible;
+ bool m_newFrameAvailable;
#if DRAW_FRAME_RATE
- int m_frameCountWhilePlaying;
- int m_timeStartedPlaying;
- int m_timeStoppedPlaying;
+ double m_frameCountWhilePlaying;
+ double m_timeStartedPlaying;
+ double m_timeStoppedPlaying;
#endif
};
diff --git a/WebCore/platform/graphics/win/QTMovieWin.cpp b/WebCore/platform/graphics/win/QTMovieWin.cpp
index c7aad39..8fd6c71 100644
--- a/WebCore/platform/graphics/win/QTMovieWin.cpp
+++ b/WebCore/platform/graphics/win/QTMovieWin.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple, Inc. All rights reserved.
+ * Copyright (C) 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
@@ -608,6 +608,24 @@ void QTMovieWin::setVisible(bool b)
m_private->updateGWorld();
}
+void QTMovieWin::getCurrentFrameInfo(void*& buffer, unsigned& bitsPerPixel, unsigned& rowBytes, unsigned& width, unsigned& height)
+{
+ if (!m_private->m_gWorld) {
+ buffer = 0;
+ bitsPerPixel = 0;
+ rowBytes = 0;
+ width = 0;
+ height = 0;
+ return;
+ }
+ PixMapHandle offscreenPixMap = GetGWorldPixMap(m_private->m_gWorld);
+ buffer = (*offscreenPixMap)->baseAddr;
+ bitsPerPixel = (*offscreenPixMap)->pixelSize;
+ rowBytes = (*offscreenPixMap)->rowBytes & 0x3FFF;
+ width = m_private->m_width;
+ height = m_private->m_height;
+}
+
void QTMovieWin::paint(HDC hdc, int x, int y)
{
if (!m_private->m_gWorld)
diff --git a/WebCore/platform/graphics/win/QTMovieWin.h b/WebCore/platform/graphics/win/QTMovieWin.h
index 796b756..d2a7ed0 100644
--- a/WebCore/platform/graphics/win/QTMovieWin.h
+++ b/WebCore/platform/graphics/win/QTMovieWin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple, Inc. All rights reserved.
+ * Copyright (C) 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
@@ -97,6 +97,7 @@ public:
void setVisible(bool);
void paint(HDC, int x, int y);
+ void getCurrentFrameInfo(void*& buffer, unsigned& bitsPerPixel, unsigned& rowBytes, unsigned& width, unsigned& height);
void disableUnsupportedTracks(unsigned& enabledTrackCount, unsigned& totalTrackCount);
void setDisabled(bool);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list