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

Side by Side Diff: tests/CodecTest.cpp

Issue 2319293003: Checking for valid colorType, alphaType, colorSpace in SkCodec (Closed)
Patch Set: Fix nanobench Created 4 years, 3 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
« no previous file with comments | « src/codec/SkWebpCodec.cpp ('k') | no next file » | 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 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
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 }
OLDNEW
« no previous file with comments | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698