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

Unified Diff: skia/ext/platform_canvas_mac.cc

Issue 21485: Bitmap transport (Closed)
Patch Set: Fix some mac crashes Created 11 years, 10 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: skia/ext/platform_canvas_mac.cc
diff --git a/skia/ext/platform_canvas_mac.cc b/skia/ext/platform_canvas_mac.cc
index 380a78b409e650922138270dc60c00807483604f..9ada02d9630272d70b8a952be9cd648dc2445e9e 100755
--- a/skia/ext/platform_canvas_mac.cc
+++ b/skia/ext/platform_canvas_mac.cc
@@ -25,6 +25,14 @@ PlatformCanvasMac::PlatformCanvasMac(int width,
initialize(width, height, is_opaque);
}
+PlatformCanvasMac::PlatformCanvasMac(int width,
+ int height,
+ bool is_opaque,
+ uint8_t* data)
+ : SkCanvas() {
+ initialize(width, height, is_opaque, data);
+}
+
PlatformCanvasMac::~PlatformCanvasMac() {
}
@@ -40,6 +48,33 @@ bool PlatformCanvasMac::initialize(int width,
return true;
}
+bool PlatformCanvasMac::initialize(int width,
+ int height,
+ bool is_opaque,
+ uint8_t* data) {
+ CGContextRef context = NULL;
+ CGColorSpaceRef colorSpace;
+
+ colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+ context = CGBitmapContextCreate(
+ data, width, height, 8 /* bits per plane */, 4 * width /* stride */,
+ colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+ CGColorSpaceRelease(colorSpace);
+ if (!context)
+ return false;
+ // Change the coordinate system to match WebCore's
+ CGContextTranslateCTM(context, 0, height);
+ CGContextScaleCTM(context, 1.0, -1.0);
+
+ SkDevice* device = createPlatformDevice(width, height, is_opaque, context);
+ if (!device)
+ return false;
+
+ setDevice(device);
+ device->unref(); // was created with refcount 1, and setDevice also refs
+ return true;
+}
+
CGContextRef PlatformCanvasMac::beginPlatformPaint() {
return getTopPlatformDevice().GetBitmapContext();
}
« chrome/browser/renderer_host/backing_store_win.cc ('K') | « skia/ext/platform_canvas_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698