diff options
-rw-r--r-- | chrome/renderer/webmediaplayer_impl.h | 3 | ||||
-rw-r--r-- | webkit/api/public/WebCanvas.h | 4 | ||||
-rw-r--r-- | webkit/api/public/WebMediaPlayer.h | 3 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.cpp | 33 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.h | 2 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 6 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.h | 3 |
7 files changed, 35 insertions, 19 deletions
diff --git a/chrome/renderer/webmediaplayer_impl.h b/chrome/renderer/webmediaplayer_impl.h index f2202bf..743e440 100644 --- a/chrome/renderer/webmediaplayer_impl.h +++ b/chrome/renderer/webmediaplayer_impl.h @@ -93,10 +93,7 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // Methods for painting. virtual void setSize(const WebKit::WebSize& size); - // TODO(hclam): enable this for mac. -#if WEBKIT_USING_SKIA virtual void paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect); -#endif // True if a video is loaded. virtual bool hasVideo() const; diff --git a/webkit/api/public/WebCanvas.h b/webkit/api/public/WebCanvas.h index 0cd5d08..0b47676 100644 --- a/webkit/api/public/WebCanvas.h +++ b/webkit/api/public/WebCanvas.h @@ -33,8 +33,6 @@ #include "WebCommon.h" -#if WEBKIT_USING_SKIA && (defined(WIN32) || defined(__linux__)) - namespace skia { class PlatformCanvas; } @@ -44,5 +42,3 @@ namespace WebKit { } #endif - -#endif diff --git a/webkit/api/public/WebMediaPlayer.h b/webkit/api/public/WebMediaPlayer.h index 18d3bbf..56d01e5 100644 --- a/webkit/api/public/WebMediaPlayer.h +++ b/webkit/api/public/WebMediaPlayer.h @@ -80,10 +80,7 @@ namespace WebKit { virtual void setSize(const WebSize&) = 0; - // TODO(hclam): enable this for mac. -#if WEBKIT_USING_SKIA virtual void paint(WebCanvas*, const WebRect&) = 0; -#endif // True if a video is loaded. virtual bool hasVideo() const = 0; diff --git a/webkit/api/src/WebMediaPlayerClientImpl.cpp b/webkit/api/src/WebMediaPlayerClientImpl.cpp index d4d565a..ca666e9 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.cpp +++ b/webkit/api/src/WebMediaPlayerClientImpl.cpp @@ -305,11 +305,40 @@ void WebMediaPlayerClientImpl::setSize(const IntSize& size) void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& rect) { - // FIXME: enable this for mac. + if (m_webMediaPlayer.get()) { #if WEBKIT_USING_SKIA - if (m_webMediaPlayer.get()) m_webMediaPlayer->paint(context->platformContext()->canvas(), rect); +#elif WEBKIT_USING_CG + // If there is no preexisting platform canvas, or if the size has + // changed, recreate the canvas. This is to avoid recreating the bitmap + // buffer over and over for each frame of video. + if (!m_webCanvas || + m_webCanvas->getDevice()->width() != rect.width() || + m_webCanvas->getDevice()->height() != rect.height()) { + m_webCanvas.set(new WebCanvas(rect.width(), rect.height(), true)); + } + + IntRect normalized_rect(0, 0, rect.width(), rect.height()); + m_webMediaPlayer->paint(m_webCanvas.get(), normalized_rect); + + // The mac coordinate system is flipped vertical from the normal skia + // coordinates. During painting of the frame, flip the coordinates + // system and, for simplicity, also translate the clip rectangle to + // start at 0,0. + CGContext* cgContext = context->platformContext(); + CGContextSaveGState(cgContext); + CGContextTranslateCTM(cgContext, rect.x(), rect.height() + rect.y()); + CGContextScaleCTM(cgContext, 1.0, -1.0); + CGRect normalized_cgrect = normalized_rect; // For DrawToContext. + + m_webCanvas->getTopPlatformDevice().DrawToContext( + context->platformContext(), 0, 0, &normalized_cgrect); + + CGContextRestoreGState(cgContext); +#else + notImplemented(); #endif + } } void WebMediaPlayerClientImpl::setAutobuffer(bool autoBuffer) diff --git a/webkit/api/src/WebMediaPlayerClientImpl.h b/webkit/api/src/WebMediaPlayerClientImpl.h index e4f2b9f..9f5cd5d 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.h +++ b/webkit/api/src/WebMediaPlayerClientImpl.h @@ -36,6 +36,7 @@ #include "WebMediaPlayerClient.h" #include "MediaPlayerPrivate.h" +#include "WebCanvas.h" #include <wtf/OwnPtr.h> namespace WebKit { @@ -98,6 +99,7 @@ namespace WebKit { WebCore::MediaPlayer* m_mediaPlayer; OwnPtr<WebMediaPlayer> m_webMediaPlayer; + OwnPtr<WebKit::WebCanvas> m_webCanvas; }; } // namespace WebKit diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index ee6f7b5f..ebdda91 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -15,6 +15,7 @@ #include "webkit/glue/media/video_renderer_impl.h" #include "webkit/glue/webmediaplayer_impl.h" +using WebKit::WebCanvas; using WebKit::WebRect; using WebKit::WebSize; @@ -264,9 +265,7 @@ void WebMediaPlayerImpl::setSize(const WebSize& size) { } } -// TODO(hclam): enable this for mac. -#if WEBKIT_USING_SKIA -void WebMediaPlayerImpl::paint(skia::PlatformCanvas* canvas, +void WebMediaPlayerImpl::paint(WebCanvas* canvas, const WebRect& rect) { DCHECK(main_loop_ && MessageLoop::current() == main_loop_); @@ -274,7 +273,6 @@ void WebMediaPlayerImpl::paint(skia::PlatformCanvas* canvas, video_renderer_->Paint(canvas, rect); } } -#endif void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { pipeline_.Stop(); diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h index e670535..0971125 100644 --- a/webkit/glue/webmediaplayer_impl.h +++ b/webkit/glue/webmediaplayer_impl.h @@ -117,10 +117,7 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // Methods for painting. virtual void setSize(const WebKit::WebSize& size); - // TODO(hclam): enable this for mac. -#if WEBKIT_USING_SKIA virtual void paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect); -#endif // True if a video is loaded. virtual bool hasVideo() const; |