diff options
author | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-13 15:11:11 +0000 |
---|---|---|
committer | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-13 15:11:11 +0000 |
commit | b2d93a91222dac2edb3c19128fd58fa2e74272aa (patch) | |
tree | 542e5234ce9408bb85fe36ae131746376eb3ae53 /gm/gammatext.cpp | |
parent | deee496cd30070e52556dcb538c2e5eb39b66b81 (diff) |
add peekPixels to SkCanvas and SkSurface
clone of https://codereview.chromium.org/159723006/
Review URL: https://codereview.chromium.org/161733002
git-svn-id: http://skia.googlecode.com/svn/trunk@13427 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/gammatext.cpp')
-rw-r--r-- | gm/gammatext.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp index 99642f6e3e..7ee55db2fb 100644 --- a/gm/gammatext.cpp +++ b/gm/gammatext.cpp @@ -38,14 +38,14 @@ static bool setFont(SkPaint* paint, const char name[]) { #import <ApplicationServices/ApplicationServices.h> #define BITMAP_INFO_RGB (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host) -static CGContextRef makeCG(const SkBitmap& bm) { - if (SkBitmap::kARGB_8888_Config != bm.config() || - NULL == bm.getPixels()) { +static CGContextRef makeCG(const SkImageInfo& info, const void* addr, + size_t rowBytes) { + if (kPMColor_SkColorType != info.colorType() || NULL == addr) { return NULL; } CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); - CGContextRef cg = CGBitmapContextCreate(bm.getPixels(), bm.width(), bm.height(), - 8, bm.rowBytes(), space, BITMAP_INFO_RGB); + CGContextRef cg = CGBitmapContextCreate((void*)addr, info.width(), info.height(), + 8, rowBytes, space, BITMAP_INFO_RGB); CFRelease(space); CGContextSetAllowsFontSubpixelQuantization(cg, false); @@ -143,7 +143,15 @@ protected: virtual void onDraw(SkCanvas* canvas) { #ifdef SK_BUILD_FOR_MAC - CGContextRef cg = makeCG(canvas->getDevice()->accessBitmap(false)); + CGContextRef cg = 0; + { + SkImageInfo info; + size_t rowBytes; + const void* addr = canvas->peekPixels(&info, &rowBytes); + if (addr) { + cg = makeCG(info, addr, rowBytes); + } + } #endif drawGrad(canvas); |