Chromium Code Reviews| Index: skia/ext/bitmap_platform_device_mac.cc |
| =================================================================== |
| --- skia/ext/bitmap_platform_device_mac.cc (revision 160846) |
| +++ skia/ext/bitmap_platform_device_mac.cc (working copy) |
| @@ -16,6 +16,8 @@ |
| #include "third_party/skia/include/core/SkTypes.h" |
| #include "third_party/skia/include/core/SkUtils.h" |
| +#include "skia/ext/platform_canvas.h" |
|
brettw
2012/10/09 20:40:12
This should go in the above block in order.
reed1
2012/10/09 21:06:43
Done.
|
| + |
| namespace skia { |
| namespace { |
| @@ -254,4 +256,36 @@ |
| return bitmap_device; |
| } |
| +// Port of PlatformBitmap to mac |
| + |
| +PlatformBitmap::~PlatformBitmap() { |
| + if (surface_) |
| + CGContextRelease(surface_); |
| +} |
| + |
| +bool PlatformBitmap::Allocate(int width, int height, bool isOpaque) { |
| + if (RasterDeviceTooBigToAllocate(width, height)) |
| + return false; |
| + |
| + bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4); |
| + if (!bitmap_.allocPixels()) |
| + return false; |
| + |
| + if (!isOpaque) |
| + bitmap_.eraseColor(0); |
| + bitmap_.setIsOpaque(isOpaque); |
| + return true; |
| +} |
| + |
| +PlatformSurface PlatformBitmap::LockSurface() { |
| + if (!surface_ && bitmap_.getPixels()) |
| + surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(), |
| + bitmap_.height()); |
| + return surface_; |
| +} |
| + |
| +void PlatformBitmap::UnlockSurface() { |
| + // nothing to do for our CGContext. It will be released in our destructor |
| +} |
| + |
| } // namespace skia |