Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkImageInfo_DEFINED | 8 #ifndef SkImageInfo_DEFINED |
| 9 #define SkImageInfo_DEFINED | 9 #define SkImageInfo_DEFINED |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * Describe an image's dimensions and pixel type. | 104 * Describe an image's dimensions and pixel type. |
| 105 */ | 105 */ |
| 106 struct SkImageInfo { | 106 struct SkImageInfo { |
| 107 int fWidth; | 107 int fWidth; |
| 108 int fHeight; | 108 int fHeight; |
| 109 SkColorType fColorType; | 109 SkColorType fColorType; |
| 110 SkAlphaType fAlphaType; | 110 SkAlphaType fAlphaType; |
| 111 | 111 |
| 112 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t) { | |
| 113 SkASSERT(width >= 0); | |
| 114 SkASSERT(height >= 0); | |
| 115 SkImageInfo info = { | |
| 116 width, height, ct, at | |
| 117 }; | |
| 118 return info; | |
| 119 } | |
| 120 | |
| 121 static SkImageInfo MakePM(int width, int height, SkAlphaType at) { | |
| 122 SkASSERT(width >= 0); | |
| 123 SkASSERT(height >= 0); | |
| 124 SkImageInfo info = { | |
| 125 width, height, kPMColor_SkColorType, at | |
| 126 }; | |
| 127 return info; | |
| 128 } | |
| 129 | |
| 130 static SkImageInfo MakePMPremul(int width, int height) { | |
|
scroggo
2014/01/09 00:02:11
Not a big fan of this name... Any chance we can ch
reed1
2014/01/13 16:27:26
Suggestions?
kNativeARGB32_ColorType?
scroggo
2014/01/13 17:48:48
sgtm
| |
| 131 SkASSERT(width >= 0); | |
| 132 SkASSERT(height >= 0); | |
| 133 SkImageInfo info = { | |
| 134 width, height, kPMColor_SkColorType, kPremul_SkAlphaType | |
| 135 }; | |
| 136 return info; | |
| 137 } | |
| 138 | |
| 139 static SkImageInfo MakePMOpaque(int width, int height) { | |
| 140 SkASSERT(width >= 0); | |
| 141 SkASSERT(height >= 0); | |
| 142 SkImageInfo info = { | |
| 143 width, height, kPMColor_SkColorType, kOpaque_SkAlphaType | |
| 144 }; | |
| 145 return info; | |
| 146 } | |
| 147 | |
| 148 static SkImageInfo MakeA8(int width, int height) { | |
| 149 SkASSERT(width >= 0); | |
| 150 SkASSERT(height >= 0); | |
| 151 SkImageInfo info = { | |
| 152 width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType | |
| 153 }; | |
| 154 return info; | |
| 155 } | |
| 156 | |
| 112 bool isOpaque() const { | 157 bool isOpaque() const { |
| 113 return SkAlphaTypeIsOpaque(fAlphaType); | 158 return SkAlphaTypeIsOpaque(fAlphaType); |
| 114 } | 159 } |
| 115 | 160 |
| 116 int bytesPerPixel() const { | 161 int bytesPerPixel() const { |
| 117 return SkColorTypeBytesPerPixel(fColorType); | 162 return SkColorTypeBytesPerPixel(fColorType); |
| 118 } | 163 } |
| 119 | 164 |
| 120 size_t minRowBytes() const { | 165 size_t minRowBytes() const { |
| 121 return fWidth * this->bytesPerPixel(); | 166 return fWidth * this->bytesPerPixel(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 133 | 178 |
| 134 size_t getSafeSize(size_t rowBytes) const { | 179 size_t getSafeSize(size_t rowBytes) const { |
| 135 if (0 == fHeight) { | 180 if (0 == fHeight) { |
| 136 return 0; | 181 return 0; |
| 137 } | 182 } |
| 138 return (fHeight - 1) * rowBytes + fWidth * this->bytesPerPixel(); | 183 return (fHeight - 1) * rowBytes + fWidth * this->bytesPerPixel(); |
| 139 } | 184 } |
| 140 }; | 185 }; |
| 141 | 186 |
| 142 #endif | 187 #endif |
| OLD | NEW |