aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkReadPixelsRec.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-12-10 09:53:42 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-10 09:53:42 -0800
commit96472deea70169396b8e1f576e470138f55fdb1f (patch)
treef245c0de946d6068ba465b9b46b02263cda9ea44 /src/image/SkReadPixelsRec.h
parent18abd1acef7b2aa1967196e1b541c8e640c56091 (diff)
dd readPixels to SkImage
patch from issue 789673007 at patchset 1 (http://crrev.com/789673007#ps1) BUG=skia: Review URL: https://codereview.chromium.org/793723002
Diffstat (limited to 'src/image/SkReadPixelsRec.h')
-rw-r--r--src/image/SkReadPixelsRec.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/image/SkReadPixelsRec.h b/src/image/SkReadPixelsRec.h
new file mode 100644
index 0000000000..ed93b74b0f
--- /dev/null
+++ b/src/image/SkReadPixelsRec.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkReadPixelsRec_DEFINED
+#define SkReadPixelsRec_DEFINED
+
+#include "SkImageInfo.h"
+
+/**
+ * Helper class to package and trim the parameters passed to readPixels()
+ */
+struct SkReadPixelsRec {
+ SkReadPixelsRec(const SkImageInfo& info, void* pixels, size_t rowBytes, int x, int y)
+ : fPixels(pixels)
+ , fRowBytes(rowBytes)
+ , fInfo(info)
+ , fX(x)
+ , fY(y)
+ {}
+
+ void* fPixels;
+ size_t fRowBytes;
+ SkImageInfo fInfo;
+ int fX;
+ int fY;
+
+ /*
+ * On true, may have modified its fields (except fRowBytes) to make it a legal subset
+ * of the specified src width/height.
+ *
+ * On false, leaves self unchanged, but indicates that it does not overlap src, or
+ * is not valid (e.g. bad fInfo) for readPixels().
+ */
+ bool trim(int srcWidth, int srcHeight);
+};
+
+#endif