diff options
author | reed <reed@google.com> | 2014-09-03 11:54:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-03 11:54:58 -0700 |
commit | e5ea500d4714a7d84de2bf913e81be3b65d2de68 (patch) | |
tree | 0c94feeb709b17b954f5e97fad463ec9cfc4dc18 /include/core/SkImageInfo.h | |
parent | 42b0dfeb29e993b7fd247dcecff705d3dd4cf191 (diff) |
Hide fields in SkImageInfo
R=rmistry@google.com
TBR=bsalomon
Author: reed@google.com
Review URL: https://codereview.chromium.org/536003002
Diffstat (limited to 'include/core/SkImageInfo.h')
-rw-r--r-- | include/core/SkImageInfo.h | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index 3d82dc805c..6204cb3b81 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -136,36 +136,30 @@ bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, * Describe an image's dimensions and pixel type. */ struct SkImageInfo { - int fWidth; - int fHeight; - SkColorType fColorType; - SkAlphaType fAlphaType; +public: + SkImageInfo() + : fWidth(0) + , fHeight(0) + , fColorType(kUnknown_SkColorType) + , fAlphaType(kIgnore_SkAlphaType) + {} static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at) { - SkImageInfo info = { - width, height, ct, at - }; - return info; + return SkImageInfo(width, height, ct, at); } /** * Sets colortype to the native ARGB32 type. */ static SkImageInfo MakeN32(int width, int height, SkAlphaType at) { - SkImageInfo info = { - width, height, kN32_SkColorType, at - }; - return info; + return SkImageInfo(width, height, kN32_SkColorType, at); } /** * Sets colortype to the native ARGB32 type, and the alphatype to premul. */ static SkImageInfo MakeN32Premul(int width, int height) { - SkImageInfo info = { - width, height, kN32_SkColorType, kPremul_SkAlphaType - }; - return info; + return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType); } /** @@ -176,24 +170,15 @@ struct SkImageInfo { } static SkImageInfo MakeA8(int width, int height) { - SkImageInfo info = { - width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType - }; - return info; + return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType); } static SkImageInfo MakeUnknown(int width, int height) { - SkImageInfo info = { - width, height, kUnknown_SkColorType, kIgnore_SkAlphaType - }; - return info; + return SkImageInfo(width, height, kUnknown_SkColorType, kIgnore_SkAlphaType); } static SkImageInfo MakeUnknown() { - SkImageInfo info = { - 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType - }; - return info; + return SkImageInfo(); } int width() const { return fWidth; } @@ -217,6 +202,14 @@ struct SkImageInfo { return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType); } + SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const { + return SkImageInfo::Make(fWidth, fHeight, fColorType, newAlphaType); + } + + SkImageInfo makeColorType(SkColorType newColorType) const { + return SkImageInfo::Make(fWidth, fHeight, newColorType, fAlphaType); + } + int bytesPerPixel() const { return SkColorTypeBytesPerPixel(fColorType); } @@ -256,6 +249,24 @@ struct SkImageInfo { } SkDEBUGCODE(void validate() const;) + +#ifdef SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS +public: +#else +private: +#endif + int fWidth; + int fHeight; + SkColorType fColorType; + SkAlphaType fAlphaType; + +private: + SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at) + : fWidth(width) + , fHeight(height) + , fColorType(ct) + , fAlphaType(at) + {} }; #endif |