aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkWritePixelsRec.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkWritePixelsRec.h')
-rw-r--r--src/core/SkWritePixelsRec.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/core/SkWritePixelsRec.h b/src/core/SkWritePixelsRec.h
new file mode 100644
index 0000000000..652a13a822
--- /dev/null
+++ b/src/core/SkWritePixelsRec.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkWritePixelsRec_DEFINED
+#define SkWritePixelsRec_DEFINED
+
+#include "SkImageInfo.h"
+
+/**
+ * Helper class to package and trim the parameters passed to writePixels()
+ */
+struct SkWritePixelsRec {
+ SkWritePixelsRec(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y)
+ : fPixels(pixels)
+ , fRowBytes(rowBytes)
+ , fInfo(info)
+ , fX(x)
+ , fY(y)
+ {}
+
+ const 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 dst width/height.
+ *
+ * On false, leaves self unchanged, but indicates that it does not overlap dst, or
+ * is not valid (e.g. bad fInfo) for writePixels().
+ */
+ bool trim(int dstWidth, int dstHeight);
+};
+
+#endif