summaryrefslogtreecommitdiffstats
path: root/webkit/api/src
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 17:34:19 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 17:34:19 +0000
commitdf143bdc1314b6db3d1488a6b8346a4e0bd18a14 (patch)
tree561bd4b35b998216a9d9b3e2c171d6828306c5f6 /webkit/api/src
parentb347bcb71081e02ccb19c6e319bb6c9908b7ce7d (diff)
downloadchromium_src-df143bdc1314b6db3d1488a6b8346a4e0bd18a14.zip
chromium_src-df143bdc1314b6db3d1488a6b8346a4e0bd18a14.tar.gz
chromium_src-df143bdc1314b6db3d1488a6b8346a4e0bd18a14.tar.bz2
Hack to enable video on mac by creating a blank PlatformContextMac to draw on.
This isn't a great solution, but it kinda works. Video renders, and the speed is acceptable even though we're doing an extra copy for each frame. The image shows up upside-down though. :( Review URL: http://codereview.chromium.org/126087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api/src')
-rw-r--r--webkit/api/src/WebMediaPlayerClientImpl.cpp33
-rw-r--r--webkit/api/src/WebMediaPlayerClientImpl.h2
2 files changed, 33 insertions, 2 deletions
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