| Index: skia/ext/bitmap_platform_device_mac.cc
|
| ===================================================================
|
| --- skia/ext/bitmap_platform_device_mac.cc (revision 167659)
|
| +++ skia/ext/bitmap_platform_device_mac.cc (working copy)
|
| @@ -28,6 +28,12 @@
|
| #if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0)
|
| // Allocate a bitmap context with 4 components per pixel (BGRA). Apple
|
| // recommends these flags for improved CG performance.
|
| +
|
| + // CGBitmapContextCreate returns NULL if width/height are 0. However, our
|
| + // callers expect to get a canvas back (which they later resize/reallocate)
|
| + // so we pin the dimensions here.
|
| + width = SkMax32(1, width);
|
| + height = SkMax32(1, height);
|
| CGContextRef context =
|
| CGBitmapContextCreate(data, width, height, 8, width * 4,
|
| base::mac::GetSystemColorSpace(),
|
| @@ -255,6 +261,21 @@
|
| return bitmap_device;
|
| }
|
|
|
| +// PlatformCanvas impl
|
| +
|
| +SkCanvas* CreatePlatformCanvas(CGContextRef ctx, int width, int height,
|
| + bool is_opaque, OnFailureType failureType) {
|
| + SkDevice* dev = BitmapPlatformDevice::Create(ctx, width, height, is_opaque);
|
| + return CreateCanvas(dev, failureType);
|
| +}
|
| +
|
| +SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque,
|
| + uint8_t* data, OnFailureType failureType) {
|
| + SkDevice* dev = BitmapPlatformDevice::CreateWithData(data, width, height,
|
| + is_opaque);
|
| + return CreateCanvas(dev, failureType);
|
| +}
|
| +
|
| // Port of PlatformBitmap to mac
|
|
|
| PlatformBitmap::~PlatformBitmap() {
|
|
|