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

Unified Diff: include/core/SkImageInfo.h

Issue 137993012: use some helper Make functions to initialize SkImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | « gm/srcmode.cpp ('k') | platform_tools/android/examples/hello_skia_app/jni/helloskia.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 1165479f7484267e47dc5dfa2bba90e5a79dce56..e37f2ef6d97ee320f3bd3ba6e290dcf60deaaaec 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -9,6 +9,7 @@
#define SkImageInfo_DEFINED
#include "SkTypes.h"
+#include "SkSize.h"
class SkFlattenableWriteBuffer;
class SkFlattenableReadBuffer;
@@ -109,6 +110,55 @@ struct SkImageInfo {
SkColorType fColorType;
SkAlphaType fAlphaType;
+ static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at) {
+ SkASSERT(width >= 0);
+ SkASSERT(height >= 0);
+ SkImageInfo info = {
+ width, height, ct, at
+ };
+ return info;
+ }
+
+ /**
+ * Sets colortype to the native ARGB32 type.
+ */
+ static SkImageInfo MakeN32(int width, int height, SkAlphaType at) {
+ SkASSERT(width >= 0);
+ SkASSERT(height >= 0);
+ SkImageInfo info = {
+ width, height, kPMColor_SkColorType, at
+ };
+ return info;
+ }
+
+ /**
+ * Sets colortype to the native ARGB32 type, and the alphatype to premul.
+ */
+ static SkImageInfo MakeN32Premul(int width, int height) {
+ SkASSERT(width >= 0);
+ SkASSERT(height >= 0);
+ SkImageInfo info = {
+ width, height, kPMColor_SkColorType, kPremul_SkAlphaType
+ };
+ return info;
+ }
+
+ /**
+ * Sets colortype to the native ARGB32 type, and the alphatype to premul.
+ */
+ static SkImageInfo MakeN32Premul(const SkISize& size) {
+ return MakeN32Premul(size.width(), size.height());
+ }
+
+ static SkImageInfo MakeA8(int width, int height) {
+ SkASSERT(width >= 0);
+ SkASSERT(height >= 0);
+ SkImageInfo info = {
+ width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType
+ };
+ return info;
+ }
+
bool isOpaque() const {
return SkAlphaTypeIsOpaque(fAlphaType);
}
« no previous file with comments | « gm/srcmode.cpp ('k') | platform_tools/android/examples/hello_skia_app/jni/helloskia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698