add peekPixels to SkCanvas and SkSurface
fix reference to SkBaseDevice, which was only a problem in no-gpu build
This reverts commit 4fa44a6bf73891b21917fb90d02beef9143bffa3.
R=reed@google.com
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/163603003
git-svn-id: http://skia.googlecode.com/svn/trunk@13432 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp
index 99642f6..7ee55db 100644
--- a/gm/gammatext.cpp
+++ b/gm/gammatext.cpp
@@ -38,14 +38,14 @@
#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 @@
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);