diff options
author | reed <reed@google.com> | 2014-12-10 09:53:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-10 09:53:42 -0800 |
commit | 96472deea70169396b8e1f576e470138f55fdb1f (patch) | |
tree | f245c0de946d6068ba465b9b46b02263cda9ea44 /src/image/SkReadPixelsRec.h | |
parent | 18abd1acef7b2aa1967196e1b541c8e640c56091 (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.h | 41 |
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 |