Chromium Code Reviews| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 static SkTArray<SkString, false> gMissingExpectations; | 104 static SkTArray<SkString, false> gMissingExpectations; |
| 105 static SkTArray<SkString, false> gMissingSubsetExpectations; | 105 static SkTArray<SkString, false> gMissingSubsetExpectations; |
| 106 | 106 |
| 107 static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config); | 107 static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config); |
| 108 | 108 |
| 109 // Expections read from a file specified by readExpectationsPath. The expectatio ns must have been | 109 // Expections read from a file specified by readExpectationsPath. The expectatio ns must have been |
| 110 // previously written using createExpectationsPath. | 110 // previously written using createExpectationsPath. |
| 111 SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations; | 111 SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations; |
| 112 | 112 |
| 113 static bool write_bitmap(const char outName[], const SkBitmap& bm) { | 113 static bool write_bitmap(const char outName[], const SkBitmap& bm) { |
| 114 const SkBitmap* bmPtr; | 114 if (SkImageEncoder::EncodeFile(outName, bm, SkImageEncoder::kPNG_Type, 100)) { |
| 115 return true; | |
| 116 } | |
| 117 // Encoding failed. Copy to 8888 and try again. | |
| 115 SkBitmap bm8888; | 118 SkBitmap bm8888; |
|
reed1
2013/10/07 13:59:40
Should we first check that we're not already 8888?
scroggo
2013/10/07 16:55:57
Done.
| |
| 116 if (bm.config() == SkBitmap::kA8_Config) { | 119 if (!bm.copyTo(&bm8888, SkBitmap::kARGB_8888_Config)) { |
| 117 // Copy A8 into ARGB_8888, since our image encoders do not currently | 120 return false; |
| 118 // support A8. | |
| 119 if (!bm.copyTo(&bm8888, SkBitmap::kARGB_8888_Config)) { | |
| 120 return false; | |
| 121 } | |
| 122 bmPtr = &bm8888; | |
| 123 } else { | |
| 124 bmPtr = &bm; | |
| 125 } | 121 } |
| 126 return SkImageEncoder::EncodeFile(outName, *bmPtr, SkImageEncoder::kPNG_Type , 100); | 122 return SkImageEncoder::EncodeFile(outName, bm8888, SkImageEncoder::kPNG_Type , 100); |
| 127 } | 123 } |
| 128 | 124 |
| 129 /** | 125 /** |
| 130 * Return a random SkIRect inside the range specified. | 126 * Return a random SkIRect inside the range specified. |
| 131 * @param rand Random number generator. | 127 * @param rand Random number generator. |
| 132 * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will be | 128 * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will be |
| 133 * in the range [0, maxX) | 129 * in the range [0, maxX) |
| 134 * @param maxY Exclusive maximum y-coordinate. SkIRect's fTop and fBottom will be | 130 * @param maxY Exclusive maximum y-coordinate. SkIRect's fTop and fBottom will be |
| 135 * in the range [0, maxY) | 131 * in the range [0, maxY) |
| 136 * @return SkIRect Non-empty, non-degenerate rectangle. | 132 * @return SkIRect Non-empty, non-degenerate rectangle. |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 712 } | 708 } |
| 713 | 709 |
| 714 return failed ? -1 : 0; | 710 return failed ? -1 : 0; |
| 715 } | 711 } |
| 716 | 712 |
| 717 #if !defined SK_BUILD_FOR_IOS | 713 #if !defined SK_BUILD_FOR_IOS |
| 718 int main(int argc, char * const argv[]) { | 714 int main(int argc, char * const argv[]) { |
| 719 return tool_main(argc, (char**) argv); | 715 return tool_main(argc, (char**) argv); |
| 720 } | 716 } |
| 721 #endif | 717 #endif |
| OLD | NEW |