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

Side by Side Diff: include/core/SkImageInfo.h

Issue 132643007: Revert "Revert of https://codereview.chromium.org/129423002/" (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 /**
122 * Sets colortype to the native ARGB32 type.
123 */
124 static SkImageInfo MakeN32(int width, int height, SkAlphaType at) {
125 SkASSERT(width >= 0);
126 SkASSERT(height >= 0);
127 SkImageInfo info = {
128 width, height, kPMColor_SkColorType, at
129 };
130 return info;
131 }
132
133 /**
134 * Sets colortype to the native ARGB32 type, and the alphatype to premul.
135 */
136 static SkImageInfo MakeN32Premul(int width, int height) {
137 SkASSERT(width >= 0);
138 SkASSERT(height >= 0);
139 SkImageInfo info = {
140 width, height, kPMColor_SkColorType, kPremul_SkAlphaType
141 };
142 return info;
143 }
144
145 /**
146 * Sets colortype to the native ARGB32 type, and the alphatype to opaque.
147 */
148 static SkImageInfo MakeN32Opaque(int width, int height) {
149 SkASSERT(width >= 0);
150 SkASSERT(height >= 0);
151 SkImageInfo info = {
152 width, height, kPMColor_SkColorType, kOpaque_SkAlphaType
153 };
154 return info;
155 }
156
157 static SkImageInfo MakeA8(int width, int height) {
158 SkASSERT(width >= 0);
159 SkASSERT(height >= 0);
160 SkImageInfo info = {
161 width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType
162 };
163 return info;
164 }
165
112 bool isOpaque() const { 166 bool isOpaque() const {
113 return SkAlphaTypeIsOpaque(fAlphaType); 167 return SkAlphaTypeIsOpaque(fAlphaType);
114 } 168 }
115 169
116 int bytesPerPixel() const { 170 int bytesPerPixel() const {
117 return SkColorTypeBytesPerPixel(fColorType); 171 return SkColorTypeBytesPerPixel(fColorType);
118 } 172 }
119 173
120 size_t minRowBytes() const { 174 size_t minRowBytes() const {
121 return fWidth * this->bytesPerPixel(); 175 return fWidth * this->bytesPerPixel();
(...skipping 11 matching lines...) Expand all
133 187
134 size_t getSafeSize(size_t rowBytes) const { 188 size_t getSafeSize(size_t rowBytes) const {
135 if (0 == fHeight) { 189 if (0 == fHeight) {
136 return 0; 190 return 0;
137 } 191 }
138 return (fHeight - 1) * rowBytes + fWidth * this->bytesPerPixel(); 192 return (fHeight - 1) * rowBytes + fWidth * this->bytesPerPixel();
139 } 193 }
140 }; 194 };
141 195
142 #endif 196 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698