Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: include/core/SkImageInfo.h

Issue 536003002: Hide fields in SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix qt Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkBitmap.h ('k') | samplecode/SampleFatBits.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « include/core/SkBitmap.h ('k') | samplecode/SampleFatBits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698