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

Unified Diff: skia/ext/bitmap_platform_device_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/bitmap_platform_device_mac.cc
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc
index 9b4beb0dfd14dc81883dfc65303b7530c54c2bc3..a0f0bf1ea6aa664a155f720f0602a794c77c3b10 100755
--- a/skia/ext/bitmap_platform_device_mac.cc
+++ b/skia/ext/bitmap_platform_device_mac.cc
@@ -168,24 +168,26 @@ BitmapPlatformDeviceMac* BitmapPlatformDeviceMac::Create(CGContextRef context,
#endif
}
- CGColorSpaceRef color_space =
- CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
- // allocate a bitmap context with 4 components per pixel (BGRA). Apple
- // recommends these flags for improved CG performance.
- CGContextRef bitmap_context =
- CGBitmapContextCreate(data, width, height, 8, width*4,
- color_space,
- kCGImageAlphaPremultipliedFirst |
- kCGBitmapByteOrder32Host);
-
- // Change the coordinate system to match WebCore's
- CGContextTranslateCTM(bitmap_context, 0, height);
- CGContextScaleCTM(bitmap_context, 1.0, -1.0);
- CGColorSpaceRelease(color_space);
+ if (!context) {
+ CGColorSpaceRef color_space =
+ CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+ // allocate a bitmap context with 4 components per pixel (BGRA). Apple
+ // recommends these flags for improved CG performance.
+ context =
+ CGBitmapContextCreate(data, width, height, 8, width*4,
+ color_space,
+ kCGImageAlphaPremultipliedFirst |
+ kCGBitmapByteOrder32Host);
+
+ // Change the coordinate system to match WebCore's
+ CGContextTranslateCTM(context, 0, height);
+ CGContextScaleCTM(context, 1.0, -1.0);
+ CGColorSpaceRelease(color_space);
+ }
// The device object will take ownership of the graphics context.
return new BitmapPlatformDeviceMac(
- new BitmapPlatformDeviceMacData(bitmap_context), bitmap);
+ new BitmapPlatformDeviceMacData(context), bitmap);
}
// The device will own the bitmap, which corresponds to also owning the pixel

Powered by Google App Engine
This is Rietveld 408576698