Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 6823081: Add Skia to CG adapter for plugins. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
===================================================================
--- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 81254)
+++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy)
@@ -76,6 +76,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;
@@ -1212,18 +1216,24 @@
// 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 bitLocker(canvas);
stuartmorgan 2011/04/12 17:35:51 Indentation is wrong on this whole block
_cary 2011/04/12 21:03:55 Done.
+ CGContextRef cgContext = bitLocker.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)
// On Windows, we now need to render the PDF to the DC that backs the
@@ -1380,10 +1390,16 @@
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
data_provider, NULL, false, kCGRenderingIntentDefault));
+#if defined(USE_SKIA)
+ gfx::SkiaBitLocker bitLocker(canvas);
+ CGContextRef cgContext = bitLocker.cgContext();
stuartmorgan 2011/04/12 17:35:51 Is round-tripping through CG actually the best way
_cary 2011/04/12 21:03:55 Fixed, by using non-CG code paths where appropriat
+#else
+ CGContextRef cgContext = canvas;
+#endif
// Flip the transform
- CGContextSaveGState(canvas);
- CGContextTranslateCTM(canvas, 0, canvas_height);
- CGContextScaleCTM(canvas, 1.0, -1.0);
+ CGContextSaveGState(cgContext);
+ CGContextTranslateCTM(cgContext, 0, canvas_height);
+ CGContextScaleCTM(cgContext, 1.0, -1.0);
CGRect bounds;
bounds.origin.x = dest_rect.x();
@@ -1391,8 +1407,8 @@
bounds.size.width = dest_rect.width();
bounds.size.height = dest_rect.height();
- CGContextDrawImage(canvas, bounds, image);
- CGContextRestoreGState(canvas);
+ CGContextDrawImage(cgContext, bounds, image);
+ CGContextRestoreGState(cgContext);
}
#endif // defined(OS_MACOSX)

Powered by Google App Engine
This is Rietveld 408576698