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

Unified Diff: skia/ext/bitmap_platform_device_mac.cc

Issue 11031055: Introduce PlatformBitmap, which is a minimal helper class that wraps an SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
===================================================================
--- skia/ext/bitmap_platform_device_mac.cc (revision 160846)
+++ skia/ext/bitmap_platform_device_mac.cc (working copy)
@@ -10,6 +10,7 @@
#include "base/mac/mac_util.h"
#include "base/memory/ref_counted.h"
#include "skia/ext/bitmap_platform_device_data.h"
+#include "skia/ext/platform_canvas.h"
#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkRegion.h"
@@ -254,4 +255,28 @@
return bitmap_device;
}
+// Port of PlatformBitmap to mac
+
+PlatformBitmap::~PlatformBitmap() {
+ if (surface_)
+ CGContextRelease(surface_);
+}
+
+bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
+ if (RasterDeviceTooBigToAllocate(width, height))
+ return false;
+
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4);
+ if (!bitmap_.allocPixels())
+ return false;
+
+ if (!is_opaque)
+ bitmap_.eraseColor(0);
+ bitmap_.setIsOpaque(is_opaque);
+
+ surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(),
+ bitmap_.height());
+ return true;
+}
+
} // namespace skia

Powered by Google App Engine
This is Rietveld 408576698