OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "gm_expectations.h" | 8 #include "gm_expectations.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 filename = SkOSPath::SkPathJoin(imageDir.c_str(), checksumBasedName.c_st
r()); | 157 filename = SkOSPath::SkPathJoin(imageDir.c_str(), checksumBasedName.c_st
r()); |
158 } else { | 158 } else { |
159 make_outname(&filename, outDir, src, ".png"); | 159 make_outname(&filename, outDir, src, ".png"); |
160 } | 160 } |
161 | 161 |
162 const SkBitmap& bm = bitmapAndDigest.fBitmap; | 162 const SkBitmap& bm = bitmapAndDigest.fBitmap; |
163 if (SkImageEncoder::EncodeFile(filename.c_str(), bm, SkImageEncoder::kPNG_Ty
pe, 100)) { | 163 if (SkImageEncoder::EncodeFile(filename.c_str(), bm, SkImageEncoder::kPNG_Ty
pe, 100)) { |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 if (bm.colorType() == kPMColor_SkColorType) { | 167 if (bm.colorType() == kN32_SkColorType) { |
168 // First attempt at encoding failed, and the bitmap was already 8888. Ma
king | 168 // First attempt at encoding failed, and the bitmap was already 8888. Ma
king |
169 // a copy is not going to help. | 169 // a copy is not going to help. |
170 return false; | 170 return false; |
171 } | 171 } |
172 | 172 |
173 // Encoding failed. Copy to 8888 and try again. | 173 // Encoding failed. Copy to 8888 and try again. |
174 SkBitmap bm8888; | 174 SkBitmap bm8888; |
175 if (!bm.copyTo(&bm8888, kPMColor_SkColorType)) { | 175 if (!bm.copyTo(&bm8888, kN32_SkColorType)) { |
176 return false; | 176 return false; |
177 } | 177 } |
178 return SkImageEncoder::EncodeFile(filename.c_str(), bm8888, SkImageEncoder::
kPNG_Type, 100); | 178 return SkImageEncoder::EncodeFile(filename.c_str(), bm8888, SkImageEncoder::
kPNG_Type, 100); |
179 } | 179 } |
180 | 180 |
181 /** | 181 /** |
182 * Return a random SkIRect inside the range specified. | 182 * Return a random SkIRect inside the range specified. |
183 * @param rand Random number generator. | 183 * @param rand Random number generator. |
184 * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will
be | 184 * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will
be |
185 * in the range [0, maxX) | 185 * in the range [0, maxX) |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 print_strings("Known failures", gKnownFailures); | 831 print_strings("Known failures", gKnownFailures); |
832 | 832 |
833 return failed ? -1 : 0; | 833 return failed ? -1 : 0; |
834 } | 834 } |
835 | 835 |
836 #if !defined SK_BUILD_FOR_IOS | 836 #if !defined SK_BUILD_FOR_IOS |
837 int main(int argc, char * const argv[]) { | 837 int main(int argc, char * const argv[]) { |
838 return tool_main(argc, (char**) argv); | 838 return tool_main(argc, (char**) argv); |
839 } | 839 } |
840 #endif | 840 #endif |
OLD | NEW |