From eb9a46cbbb475e862a084aa2224ec18d4ac5e95b Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Sat, 25 Jan 2014 16:46:20 +0000 Subject: add legacy/helper allocN32Pixels, and convert gm to use it This is an intermediate api, but might help us quickly get to a point where no one is creating bitmaps in a 2-step process (setConfig + alloc). BUG=skia: R=halcanary@google.com Review URL: https://codereview.chromium.org/140593005 git-svn-id: http://skia.googlecode.com/svn/trunk@13182 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkBitmap.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/core/SkBitmap.h') diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 5d6e3ba55b..4dcf327226 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -268,6 +268,20 @@ public: return this->allocPixels(info, NULL, NULL); } + /** + * Legacy helper function, which creates an SkImageInfo from the specified + * config and then calls allocPixels(info). + */ + bool allocConfigPixels(Config, int width, int height, bool isOpaque = false); + + bool allocN32Pixels(int width, int height, bool isOpaque = false) { + SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); + if (isOpaque) { + info.fAlphaType = kOpaque_SkAlphaType; + } + return this->allocPixels(info); + } + /** * Install a pixelref that wraps the specified pixels and rowBytes, and * optional ReleaseProc and context. When the pixels are no longer -- cgit v1.2.3