From: commit-bot@chromium.org Date: Mon, 21 Apr 2014 21:09:38 +0000 (+0000) Subject: add optional origin parameter to accessTopLayerPixels X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~8171 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b4aaa77dcc4f17d0e22986f5f4cca70011d1ee5;p=platform%2Fupstream%2FlibSkiaSharp.git add optional origin parameter to accessTopLayerPixels BUG=skia: R=bsalomon@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/244763004 git-svn-id: http://skia.googlecode.com/svn/trunk@14290 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 6a15c04..0a81969 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -206,15 +206,14 @@ public: * If the canvas has writable pixels in its top layer (and is not recording to a picture * or other non-raster target) and has direct access to its pixels (i.e. they are in * local RAM) return the address of those pixels, and if not null, - * return the ImageInfo and rowBytes. The returned address is only valid + * return the ImageInfo, rowBytes and origin. The returned address is only valid * while the canvas object is in scope and unchanged. Any API calls made on * canvas (or its parent surface if any) will invalidate the * returned address (and associated information). * - * On failure, returns NULL and the info and rowBytes parameters are - * ignored. + * On failure, returns NULL and the info, rowBytes, and origin parameters are ignored. */ - void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes); + void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin = NULL); /** * If the canvas has readable pixels in its base layer (and is not recording to a picture diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index c57ae9a..e8da129 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1106,8 +1106,12 @@ const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) { return dev ? dev->peekPixels(info, rowBytes) : NULL; } -void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) { - return this->onAccessTopLayerPixels(info, rowBytes); +void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin) { + void* pixels = this->onAccessTopLayerPixels(info, rowBytes); + if (pixels && origin) { + *origin = this->getTopDevice(false)->getOrigin(); + } + return pixels; } void* SkCanvas::onAccessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) {