summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorcaryclark@chromium.org <caryclark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 19:02:11 +0000
committercaryclark@chromium.org <caryclark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 19:02:11 +0000
commit44f854c6501e4c9a410c98b502fe958feca78092 (patch)
treed3fe1b21767862421cd669fac4f105f701ccdd2d /webkit
parentefa272030ddac381061c5ee4272ea201de38f42a (diff)
downloadchromium_src-44f854c6501e4c9a410c98b502fe958feca78092.zip
chromium_src-44f854c6501e4c9a410c98b502fe958feca78092.tar.gz
chromium_src-44f854c6501e4c9a410c98b502fe958feca78092.tar.bz2
Add Skia to CG adapter for plugins.
Skia on Mac uses Skia to render WebKit, and CG to render UI elements. The CG elements need a transcribed graphics context that preserves the canvas matrix, and the canvas clip. The SkiaBitLocker utility class sets up a CGContext from the SkCanvas, locks the bitmap's bits, and releases the lock when the class goes out of scope. The SkiaBitLocker implementation is described by this patch: http://codereview.chromium.org/7031006/ For ppapi, use the CG bitmap copy only if Skia is not used. Otherwise, adjust the Mac-specific code to convert the canvas to a CGContext as needed. Also, add a CG-specific entry point for painting so that the delegate can paint using a WebCanvas, while the proxy paints with a CGContext. This change adds a code path that will be enabled in the future, but does not modify any existing code, so there is no functional change. BUG=79463 TEST=none Review URL: http://codereview.chromium.org/6823081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl.h6
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_mac.mm18
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc30
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h2
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc2
5 files changed, 45 insertions, 13 deletions
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.h b/webkit/plugins/npapi/webplugin_delegate_impl.h
index b5156e3..b68d34c 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl.h
+++ b/webkit/plugins/npapi/webplugin_delegate_impl.h
@@ -177,6 +177,12 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
// Indicates that it's time to send the plugin a null event.
void FireIdleEvent();
#endif
+
+ // TODO(caryclark): This is a temporary workaround to allow the Darwin / Skia
+ // port to share code with the Darwin / CG port. Later, this will be removed
+ // and all callers will use the Paint defined above.
+ void CGPaint(CGContextRef context, const gfx::Rect& rect);
+
#endif // OS_MACOSX
gfx::PluginWindowHandle windowed_handle() const {
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
index 8d9351e..20db93a 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
@@ -37,6 +37,10 @@
#include "webkit/plugins/npapi/quickdraw_drawing_manager_mac.h"
#endif
+#if defined(USE_SKIA)
+#include "skia/ext/skia_utils_mac.h"
+#endif
+
using WebKit::WebCursorInfo;
using WebKit::WebKeyboardEvent;
using WebKit::WebInputEvent;
@@ -457,7 +461,19 @@ void WebPluginDelegateImpl::UpdateGeometryAndContext(
UpdateGeometry(window_rect, clip_rect);
}
-void WebPluginDelegateImpl::Paint(CGContextRef context, const gfx::Rect& rect) {
+void WebPluginDelegateImpl::Paint(WebKit::WebCanvas* canvas,
+ const gfx::Rect& rect) {
+#if defined(USE_SKIA)
+ gfx::SkiaBitLocker bit_locker(canvas);
+ CGContextRef context = bit_locker.cgContext();
+#else
+ CGContextRef context = canvas;
+#endif
+ CGPaint(context, rect);
+}
+
+void WebPluginDelegateImpl::CGPaint(CGContextRef context,
+ const gfx::Rect& rect) {
WindowlessPaint(context, rect);
#ifndef NP_NO_QUICKDRAW
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 0da964a..cfe6386 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -78,6 +78,10 @@
#include "ui/gfx/gdi_util.h"
#endif
+#if defined(OS_MACOSX) && defined(USE_SKIA)
+#include "skia/ext/skia_utils_mac.h"
+#endif
+
using WebKit::WebBindings;
using WebKit::WebCanvas;
using WebKit::WebCursorInfo;
@@ -1333,18 +1337,24 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
// Create a PDF metafile and render from there into the passed in context.
if (metafile.InitFromData(buffer->mapped_buffer(), buffer->size())) {
// Flip the transform.
- CGContextSaveGState(canvas);
- CGContextTranslateCTM(canvas, 0,
+#if defined(USE_SKIA)
+ gfx::SkiaBitLocker bit_locker(canvas);
+ CGContextRef cgContext = bit_locker.cgContext();
+#else
+ CGContextRef cgContext = canvas;
+#endif
+ CGContextSaveGState(cgContext);
+ CGContextTranslateCTM(cgContext, 0,
current_print_settings_.printable_area.size.height);
- CGContextScaleCTM(canvas, 1.0, -1.0);
+ CGContextScaleCTM(cgContext, 1.0, -1.0);
CGRect page_rect;
page_rect.origin.x = current_print_settings_.printable_area.point.x;
page_rect.origin.y = current_print_settings_.printable_area.point.y;
page_rect.size.width = current_print_settings_.printable_area.size.width;
page_rect.size.height = current_print_settings_.printable_area.size.height;
- ret = metafile.RenderPage(1, canvas, page_rect, true, false, true, true);
- CGContextRestoreGState(canvas);
+ ret = metafile.RenderPage(1, cgContext, page_rect, true, false, true, true);
+ CGContextRestoreGState(cgContext);
}
#elif defined(OS_WIN)
printing::Metafile* metafile =
@@ -1428,16 +1438,16 @@ bool PluginInstance::PrintRasterOutput(PP_Resource print_output,
draw_to_canvas = false;
}
#endif // defined(OS_WIN)
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) && !defined(USE_SKIA)
draw_to_canvas = false;
DrawSkBitmapToCanvas(*bitmap, canvas, dest_rect_gfx,
current_print_settings_.printable_area.size.height);
// See comments in the header file.
last_printed_page_ = image;
-#else // defined(OS_MACOSX)
+#else // defined(OS_MACOSX) && !defined(USE_SKIA)
if (draw_to_canvas)
canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect);
-#endif // defined(OS_MACOSX)
+#endif // defined(OS_MACOSX) && !defined(USE_SKIA)
return true;
}
@@ -1490,7 +1500,7 @@ bool PluginInstance::DrawJPEGToPlatformDC(
}
#endif // OS_WIN
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) && !defined(USE_SKIA)
void PluginInstance::DrawSkBitmapToCanvas(
const SkBitmap& bitmap, WebKit::WebCanvas* canvas,
const gfx::Rect& dest_rect,
@@ -1523,7 +1533,7 @@ void PluginInstance::DrawSkBitmapToCanvas(
CGContextDrawImage(canvas, bounds, image);
CGContextRestoreGState(canvas);
}
-#endif // defined(OS_MACOSX)
+#endif // defined(OS_MACOSX) && !defined(USE_SKIA)
PPB_Graphics2D_Impl* PluginInstance::bound_graphics_2d() const {
if (bound_graphics_.get() == NULL)
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 5f0d47f..e165643 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -312,7 +312,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
bool DrawJPEGToPlatformDC(const SkBitmap& bitmap,
const gfx::Rect& printable_area,
WebKit::WebCanvas* canvas);
-#elif defined(OS_MACOSX)
+#elif defined(OS_MACOSX) && !defined(USE_SKIA)
// Draws the given kARGB_8888_Config bitmap to the specified canvas starting
// at the specified destination rect.
void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas,
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index a3f1c0d..813ea0f 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -426,7 +426,7 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
ImageDataAutoMapper auto_mapper(image_data_);
const SkBitmap& backing_bitmap = *image_data_->GetMappedBitmap();
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) && !defined(USE_SKIA)
SkAutoLockPixels lock(backing_bitmap);
base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider(