summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/plugin/webplugin_proxy.cc5
-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
6 files changed, 49 insertions, 14 deletions
diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc
index e046f01..e15e78ca 100644
--- a/content/plugin/webplugin_proxy.cc
+++ b/content/plugin/webplugin_proxy.cc
@@ -351,7 +351,10 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
CGContextClearRect(windowless_context_, rect.ToCGRect());
}
CGContextClipToRect(windowless_context_, rect.ToCGRect());
- delegate_->Paint(windowless_context_, rect);
+ // TODO(caryclark): This is a temporary workaround to allow the Darwin / Skia
+ // port to share code with the Darwin / CG port. All ports will eventually use
+ // the common code below.
+ delegate_->CGPaint(windowless_context_, rect);
if (windowless_context_.get() == saved_context_weak)
CGContextRestoreGState(windowless_context_);
#else
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(