Index: include/core/SkImageInfo.h |
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h |
index 3d82dc805c7998084986878283da43ef9f35b7b8..6204cb3b81ac9903dcb558acd5ea3158fb168eb6 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 |