diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebCanvas.h | 20 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.cpp | 32 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.h | 2 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 14 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.cc | 15 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 10 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 5 | ||||
-rw-r--r-- | webkit/glue/webpopupmenu_impl.cc | 12 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/webwidget_host.mm | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 6 |
11 files changed, 68 insertions, 55 deletions
diff --git a/webkit/api/public/WebCanvas.h b/webkit/api/public/WebCanvas.h index 0b47676..d7bf334 100644 --- a/webkit/api/public/WebCanvas.h +++ b/webkit/api/public/WebCanvas.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google 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: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -33,12 +33,20 @@ #include "WebCommon.h" -namespace skia { - class PlatformCanvas; -} +#if WEBKIT_USING_SKIA +namespace skia { class PlatformCanvas; } +#elif WEBKIT_USING_CG +struct CGContext; +#endif namespace WebKit { +#if WEBKIT_USING_SKIA typedef skia::PlatformCanvas WebCanvas; +#elif WEBKIT_USING_CG + typedef struct CGContext WebCanvas; +#else + #error "Need to define WebCanvas" +#endif } #endif diff --git a/webkit/api/src/WebMediaPlayerClientImpl.cpp b/webkit/api/src/WebMediaPlayerClientImpl.cpp index e9d5220..400fa7e 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.cpp +++ b/webkit/api/src/WebMediaPlayerClientImpl.cpp @@ -27,9 +27,12 @@ #include "KURL.h" #include "MediaPlayer.h" #include "NotImplemented.h" -#include "PlatformContextSkia.h" #include <wtf/Assertions.h> +#if WEBKIT_USING_SKIA +#include "PlatformContextSkia.h" +#endif + using namespace WebCore; namespace WebKit { @@ -331,32 +334,7 @@ void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& re #if WEBKIT_USING_SKIA 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); + m_webMediaPlayer->paint(context->platformContext(), rect); #else notImplemented(); #endif diff --git a/webkit/api/src/WebMediaPlayerClientImpl.h b/webkit/api/src/WebMediaPlayerClientImpl.h index c4d8063..8c5add0 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.h +++ b/webkit/api/src/WebMediaPlayerClientImpl.h @@ -36,7 +36,6 @@ #include "WebMediaPlayerClient.h" #include "MediaPlayerPrivate.h" -#include "WebCanvas.h" #include <wtf/OwnPtr.h> namespace WebKit { @@ -104,7 +103,6 @@ namespace WebKit { WebCore::MediaPlayer* m_mediaPlayer; OwnPtr<WebMediaPlayer> m_webMediaPlayer; - OwnPtr<WebKit::WebCanvas> m_webCanvas; }; } // namespace WebKit diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 799e0e5..40038b6 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -1054,8 +1054,7 @@ float WebFrameImpl::printPage(int page, WebCanvas* canvas) { PlatformContextSkia context(canvas); GraphicsContext spool(&context); #elif defined(OS_MACOSX) - CGContextRef context = canvas->beginPlatformPaint(); - GraphicsContext spool(context); + GraphicsContext spool(canvas); WebCore::LocalCurrentGraphicsContext localContext(&spool); #endif @@ -1526,21 +1525,22 @@ void WebFrameImpl::Layout() { FromFrame(child)->Layout(); } -void WebFrameImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) { +void WebFrameImpl::Paint(WebCanvas* canvas, const WebRect& rect) { static StatsRate rendering("WebFramePaintTime"); StatsScope<StatsRate> rendering_scope(rendering); if (!rect.isEmpty()) { IntRect dirty_rect(webkit_glue::WebRectToIntRect(rect)); -#if defined(OS_MACOSX) - CGContextRef context = canvas->getTopPlatformDevice().GetBitmapContext(); - GraphicsContext gc(context); +#if WEBKIT_USING_CG + GraphicsContext gc(canvas); WebCore::LocalCurrentGraphicsContext localContext(&gc); -#else +#elif WEBKIT_USING_SKIA PlatformContextSkia context(canvas); // PlatformGraphicsContext is actually a pointer to PlatformContextSkia GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); +#else + NOTIMPLEMENTED(); #endif if (frame_->document() && frameview()) { frameview()->paint(&gc, dirty_rect); diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 87b2244..ef37d48 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -179,7 +179,7 @@ class WebFrameImpl : public WebKit::WebFrame, WebCore::HTMLFrameOwnerElement* owner_element); void Layout(); - void Paint(skia::PlatformCanvas* canvas, const WebKit::WebRect& rect); + void Paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect); void CreateFrameView(); diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index 1952c27..4fd1626 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -34,6 +34,7 @@ #include "base/string_util.h" #include "base/sys_info.h" #include "base/sys_string_conversions.h" +#include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/api/public/WebHistoryItem.h" #include "webkit/api/public/WebString.h" @@ -48,6 +49,7 @@ #include "webkit_version.h" // Generated +using WebKit::WebCanvas; using WebKit::WebFrame; using WebKit::WebHistoryItem; using WebKit::WebString; @@ -437,4 +439,15 @@ bool ShouldForcefullyTerminatePluginProcess() { return g_forcefully_terminate_plugin_process; } +WebCanvas* ToWebCanvas(skia::PlatformCanvas* canvas) { +#if WEBKIT_USING_SKIA + return canvas; +#elif WEBKIT_USING_CG + return canvas->getTopPlatformDevice().GetBitmapContext(); +#else + NOTIMPLEMENTED(); + return NULL; +#endif +} + } // namespace webkit_glue diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index 686e676..c52f0b1 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,6 +17,7 @@ #include "base/clipboard.h" #include "base/file_path.h" #include "base/string16.h" +#include "webkit/api/public/WebCanvas.h" class GURL; class SkBitmap; @@ -24,6 +25,10 @@ class StringPiece; class WebView; struct WebPluginInfo; +namespace skia { +class PlatformCanvas; +} + namespace WebKit { class WebFrame; class WebString; @@ -104,6 +109,9 @@ bool ShouldForcefullyTerminatePluginProcess(); FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str); WebKit::WebString FilePathStringToWebString(const FilePath::StringType& str); +// Returns a WebCanvas pointer associated with the given Skia canvas. +WebKit::WebCanvas* ToWebCanvas(skia::PlatformCanvas*); + //---- END FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE ------------------------------- diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index 9eae37b..d3d3679 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -425,7 +425,12 @@ void WebMediaPlayerImpl::paint(WebCanvas* canvas, DCHECK(MessageLoop::current() == main_loop_); DCHECK(proxy_); +#if WEBKIT_USING_SKIA proxy_->Paint(canvas, rect); +#else + // TODO(darin): Implement this for Mac, where WebCanvas is a CGContext. + NOTIMPLEMENTED(); +#endif } bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { diff --git a/webkit/glue/webpopupmenu_impl.cc b/webkit/glue/webpopupmenu_impl.cc index 326a326..9a9d7b7 100644 --- a/webkit/glue/webpopupmenu_impl.cc +++ b/webkit/glue/webpopupmenu_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -144,15 +144,15 @@ void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) { return; if (!rect.isEmpty()) { -#if defined(OS_MACOSX) - CGContextRef context = canvas->getTopPlatformDevice().GetBitmapContext(); - GraphicsContext gc(context); -#else +#if WEBKIT_USING_CG + GraphicsContext gc(canvas); +#elif WEBKIT_USING_SKIA PlatformContextSkia context(canvas); // PlatformGraphicsContext is actually a pointer to PlatformContextSkia. GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); +#else + NOTIMPLEMENTED(); #endif - widget_->paint(&gc, webkit_glue::WebRectToIntRect(rect)); } } diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm index c6257f7..9447544 100644 --- a/webkit/tools/test_shell/mac/webwidget_host.mm +++ b/webkit/tools/test_shell/mac/webwidget_host.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,7 @@ #include "webkit/api/public/WebPopupMenu.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebSize.h" +#include "webkit/glue/webkit_glue.h" #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebInputEvent; @@ -280,6 +281,6 @@ void WebWidgetHost::PaintRect(const gfx::Rect& rect) { DCHECK(canvas_.get()); set_painting(true); - webwidget_->paint(canvas_.get(), rect); + webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); set_painting(false); } diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 41fc582..fa6c46e 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -47,6 +47,7 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell_switches.h" +using WebKit::WebCanvas; using WebKit::WebFrame; using WebKit::WebNavigationPolicy; using WebKit::WebRect; @@ -259,7 +260,8 @@ std::string TestShell::DumpImage(WebView* view, skia::PlatformCanvas canvas; if (!canvas.initialize(size.width, size.height, true)) return std::string(); - view->paint(&canvas, WebRect(0, 0, size.width, size.height)); + view->paint(webkit_glue::ToWebCanvas(&canvas), + WebRect(0, 0, size.width, size.height)); skia::BitmapPlatformDevice& device = static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); |