aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkCanvas.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-17 21:31:26 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-17 21:31:26 +0000
commita713f9c6f6a06d216d53e268b9c691941053dabf (patch)
treeb30ac83502f95e32d621d06b2421da8799b5150d /include/core/SkCanvas.h
parentf338d7c860bf0bca82cac793069522311a3dbb1a (diff)
add new readPixels with direct memory parameters
BUG=skia: R=scroggo@google.com, bsalomon@google.com, robertphillips@google.com, fmalita@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/199413013 git-svn-id: http://skia.googlecode.com/svn/trunk@13840 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkCanvas.h')
-rw-r--r--include/core/SkCanvas.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index ca4010798b..8e5f3ac963 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -18,6 +18,8 @@
#include "SkRegion.h"
#include "SkXfermode.h"
+//#define SK_SUPPORT_LEGACY_READPIXELSCONFIG
+
// if not defined, we always assume ClipToLayer for saveLayer()
//#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
@@ -264,6 +266,7 @@ public:
kRGBA_Unpremul_Config8888
};
+#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
/**
* On success (returns true), copy the canvas pixels into the bitmap.
* On failure, the bitmap parameter is left unchanged and false is
@@ -300,15 +303,42 @@ public:
* // use the pixels
* }
*/
- bool readPixels(SkBitmap* bitmap,
- int x, int y,
- Config8888 config8888 = kNative_Premul_Config8888);
+ bool readPixels(SkBitmap* bitmap, int x, int y, Config8888 config8888);
+#endif
+
+ /**
+ * Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes),
+ * converting them into the requested format (SkImageInfo). The base-layer pixels are read
+ * starting at the specified (x,y) location in the coordinate system of the base-layer.
+ *
+ * The specified ImageInfo and (x,y) offset specifies a source rectangle
+ *
+ * srcR(x, y, info.width(), info.height());
+ *
+ * SrcR is intersected with the bounds of the base-layer. If this intersection is not empty,
+ * then we have two sets of pixels (of equal size), the "src" specified by base-layer at (x,y)
+ * and the "dst" by info+pixels+rowBytes. Replace the dst pixels with the corresponding src
+ * pixels, performing any colortype/alphatype transformations needed (in the case where the
+ * src and dst have different colortypes or alphatypes).
+ *
+ * This call can fail, returning false, for several reasons:
+ * - If the requested colortype/alphatype cannot be converted from the base-layer's types.
+ * - If this canvas is not backed by pixels (e.g. picture or PDF)
+ */
+ bool readPixels(const SkImageInfo&, void* pixels, size_t rowBytes, int x, int y);
+
+ /**
+ * Helper for calling readPixels(info, ...). This call will check if bitmap has been allocated.
+ * If not, it will attempt to call allocPixels(). If this fails, it will return false. If not,
+ * it calls through to readPixels(info, ...) and returns its result.
+ */
+ bool readPixels(SkBitmap* bitmap, int x, int y);
/**
- * DEPRECATED: This will be removed as soon as webkit is no longer relying
- * on it. The bitmap is resized to the intersection of srcRect and the
- * canvas bounds. New pixels are always allocated on success. Bitmap is
- * unmodified on failure.
+ * Helper for allocating pixels and then calling readPixels(info, ...). The bitmap is resized
+ * to the intersection of srcRect and the base-layer bounds. On success, pixels will be
+ * allocated in bitmap and true returned. On failure, false is returned and bitmap will be
+ * set to empty.
*/
bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);