OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 // Create an arbitrary gray bitmap. | 1113 // Create an arbitrary gray bitmap. |
1114 path = "grayscale.jpg"; | 1114 path = "grayscale.jpg"; |
1115 stream.reset(resource(path)); | 1115 stream.reset(resource(path)); |
1116 codec.reset(SkCodec::NewFromStream(stream.release())); | 1116 codec.reset(SkCodec::NewFromStream(stream.release())); |
1117 SkBitmap bm2; | 1117 SkBitmap bm2; |
1118 bm2.allocPixels(codec->getInfo()); | 1118 bm2.allocPixels(codec->getInfo()); |
1119 result = codec->getPixels(codec->getInfo(), bm2.getPixels(), bm2.rowBytes())
; | 1119 result = codec->getPixels(codec->getInfo(), bm2.getPixels(), bm2.rowBytes())
; |
1120 REPORTER_ASSERT(r, SkCodec::kSuccess == result); | 1120 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
1121 check_round_trip(r, bm2); | 1121 check_round_trip(r, bm2); |
1122 } | 1122 } |
| 1123 |
| 1124 static void test_conversion_possible(skiatest::Reporter* r, const char* path, |
| 1125 bool testScanlineDecoder) { |
| 1126 SkAutoTDelete<SkStream> stream(resource(path)); |
| 1127 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
| 1128 SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType); |
| 1129 |
| 1130 SkBitmap bm; |
| 1131 bm.allocPixels(infoF16); |
| 1132 SkCodec::Result result = codec->getPixels(infoF16, bm.getPixels(), bm.rowByt
es()); |
| 1133 REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); |
| 1134 if (testScanlineDecoder) { |
| 1135 result = codec->startScanlineDecode(infoF16); |
| 1136 REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); |
| 1137 } |
| 1138 |
| 1139 infoF16 = infoF16.makeColorSpace(infoF16.colorSpace()->makeLinearGamma()); |
| 1140 result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes()); |
| 1141 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 1142 if (testScanlineDecoder) { |
| 1143 result = codec->startScanlineDecode(infoF16); |
| 1144 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
| 1145 } |
| 1146 } |
| 1147 |
| 1148 DEF_TEST(Codec_F16ConversionPossible, r) { |
| 1149 test_conversion_possible(r, "color_wheel.webp", false); |
| 1150 test_conversion_possible(r, "mandrill_512_q075.jpg", true); |
| 1151 test_conversion_possible(r, "yellow_rose.png", true); |
| 1152 } |
OLD | NEW |