aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-15 02:38:22 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-15 02:38:22 +0000
commit32678d9a453e2c9fd26e92be429cdd84250b4d85 (patch)
tree030829a85feda7e6488b7d46f8ad87a0e2fdf443 /include/core
parent78f6ddc1a0a1b1833c71f636e89e796505688b01 (diff)
use some helper Make functions to initialize SkImageInfo
BUG= R=halcanary@google.com, scroggo@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/137993012 git-svn-id: http://skia.googlecode.com/svn/trunk@13081 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkImageInfo.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 1165479f74..e37f2ef6d9 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);
}