summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/core/SkReadPixelsRec.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/core/SkReadPixelsRec.h')
-rw-r--r--gfx/skia/skia/src/core/SkReadPixelsRec.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/core/SkReadPixelsRec.h b/gfx/skia/skia/src/core/SkReadPixelsRec.h
new file mode 100644
index 0000000000..959b51b3b5
--- /dev/null
+++ b/gfx/skia/skia/src/core/SkReadPixelsRec.h
@@ -0,0 +1,52 @@
+/*
+ * 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 "include/core/SkImageInfo.h"
+#include "include/core/SkPixmap.h"
+
+#include <cstddef>
+
+/**
+ * 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)
+ {}
+
+ SkReadPixelsRec(const SkPixmap& pm, int x, int y)
+ : fPixels(pm.writable_addr())
+ , fRowBytes(pm.rowBytes())
+ , fInfo(pm.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