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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 } | 56 } |
57 | 57 |
58 /////////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////////// |
59 | 59 |
60 /** | 60 /** |
61 * Describes how to interpret the components of a pixel. | 61 * Describes how to interpret the components of a pixel. |
62 */ | 62 */ |
63 enum SkColorType { | 63 enum SkColorType { |
64 kAlpha_8_SkColorType, | 64 kAlpha_8_SkColorType, |
65 kRGB_565_SkColorType, | 65 kRGB_565_SkColorType, |
66 kARGB_4444_SkColorType, | |
scroggo
2013/11/19 18:17:09
Nooo!
| |
66 kRGBA_8888_SkColorType, | 67 kRGBA_8888_SkColorType, |
67 kBGRA_8888_SkColorType, | 68 kBGRA_8888_SkColorType, |
68 kIndex8_SkColorType, | 69 kIndex8_SkColorType, |
69 | 70 |
70 kLastEnum_SkColorType = kIndex8_SkColorType, | 71 kLastEnum_SkColorType = kIndex8_SkColorType, |
71 | 72 |
72 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) | 73 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
73 kPMColor_SkColorType = kBGRA_8888_SkColorType | 74 kPMColor_SkColorType = kBGRA_8888_SkColorType |
74 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) | 75 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
75 kPMColor_SkColorType = kRGBA_8888_SkColorType | 76 kPMColor_SkColorType = kRGBA_8888_SkColorType |
76 #else | 77 #else |
77 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order" | 78 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order" |
78 #endif | 79 #endif |
79 }; | 80 }; |
80 | 81 |
81 static int SkColorTypeBytesPerPixel(SkColorType ct) { | 82 static int SkColorTypeBytesPerPixel(SkColorType ct) { |
82 static const uint8_t gSize[] = { | 83 static const uint8_t gSize[] = { |
83 1, // Alpha_8 | 84 1, // Alpha_8 |
84 2, // RGB_565 | 85 2, // RGB_565 |
86 2, // ARGB_4444 | |
85 4, // RGBA_8888 | 87 4, // RGBA_8888 |
86 4, // BGRA_8888 | 88 4, // BGRA_8888 |
87 1, // kIndex_8 | 89 1, // kIndex_8 |
88 }; | 90 }; |
89 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1), | 91 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1), |
90 size_mismatch_with_SkColorType_enum); | 92 size_mismatch_with_SkColorType_enum); |
91 | 93 |
92 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize)); | 94 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize)); |
93 return gSize[ct]; | 95 return gSize[ct]; |
94 } | 96 } |
(...skipping 16 matching lines...) Expand all Loading... | |
111 int bytesPerPixel() const { | 113 int bytesPerPixel() const { |
112 return SkColorTypeBytesPerPixel(fColorType); | 114 return SkColorTypeBytesPerPixel(fColorType); |
113 } | 115 } |
114 | 116 |
115 bool operator==(const SkImageInfo& other) const { | 117 bool operator==(const SkImageInfo& other) const { |
116 return 0 == memcmp(this, &other, sizeof(other)); | 118 return 0 == memcmp(this, &other, sizeof(other)); |
117 } | 119 } |
118 bool operator!=(const SkImageInfo& other) const { | 120 bool operator!=(const SkImageInfo& other) const { |
119 return 0 != memcmp(this, &other, sizeof(other)); | 121 return 0 != memcmp(this, &other, sizeof(other)); |
120 } | 122 } |
123 | |
124 // return the number of bytes written, whether or not buffer is null | |
125 size_t writeToMemory(void* buffer) const; | |
126 /** | |
127 * Reads data from the buffer parameter | |
128 * | |
129 * @param buffer Memory to read from | |
130 * @param length Amount of memory available in the buffer | |
scroggo
2013/11/19 18:17:09
What happens if you pass a number that is not a mu
reed1
2013/11/20 20:21:36
I have removed these methods.
| |
131 * @return number of bytes read (must be a multiple of 4) or | |
132 * 0 if there was not enough memory available | |
133 */ | |
134 size_t readFromMemory(const void* buffer, size_t length); | |
121 }; | 135 }; |
122 | 136 |
123 #endif | 137 #endif |
OLD | NEW |