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 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 FLAGS_src.contains(tag.c_str()) && | 218 FLAGS_src.contains(tag.c_str()) && |
219 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 219 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
220 TaggedSrc& s = gSrcs.push_back(); | 220 TaggedSrc& s = gSrcs.push_back(); |
221 s.reset(src.detach()); | 221 s.reset(src.detach()); |
222 s.tag = tag; | 222 s.tag = tag; |
223 s.options = options; | 223 s.options = options; |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp
e dstColorType, | 227 static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp
e dstColorType, |
228 float scale) { | 228 SkAlphaType dstAlphaType, float scale) { |
229 SkString folder; | 229 SkString folder; |
230 switch (mode) { | 230 switch (mode) { |
231 case CodecSrc::kCodec_Mode: | 231 case CodecSrc::kCodec_Mode: |
232 folder.append("codec"); | 232 folder.append("codec"); |
233 break; | 233 break; |
234 case CodecSrc::kCodecZeroInit_Mode: | 234 case CodecSrc::kCodecZeroInit_Mode: |
235 folder.append("codec_zero_init"); | 235 folder.append("codec_zero_init"); |
236 break; | 236 break; |
237 case CodecSrc::kScanline_Mode: | 237 case CodecSrc::kScanline_Mode: |
238 folder.append("scanline"); | 238 folder.append("scanline"); |
(...skipping 13 matching lines...) Expand all Loading... |
252 case CodecSrc::kGrayscale_Always_DstColorType: | 252 case CodecSrc::kGrayscale_Always_DstColorType: |
253 folder.append("_kGray8"); | 253 folder.append("_kGray8"); |
254 break; | 254 break; |
255 case CodecSrc::kIndex8_Always_DstColorType: | 255 case CodecSrc::kIndex8_Always_DstColorType: |
256 folder.append("_kIndex8"); | 256 folder.append("_kIndex8"); |
257 break; | 257 break; |
258 default: | 258 default: |
259 break; | 259 break; |
260 } | 260 } |
261 | 261 |
| 262 switch (dstAlphaType) { |
| 263 case kOpaque_SkAlphaType: |
| 264 folder.append("_opaque"); |
| 265 break; |
| 266 case kPremul_SkAlphaType: |
| 267 folder.append("_premul"); |
| 268 break; |
| 269 case kUnpremul_SkAlphaType: |
| 270 folder.append("_unpremul"); |
| 271 break; |
| 272 default: |
| 273 break; |
| 274 } |
| 275 |
262 if (1.0f != scale) { | 276 if (1.0f != scale) { |
263 folder.appendf("_%.3f", scale); | 277 folder.appendf("_%.3f", scale); |
264 } | 278 } |
265 | 279 |
266 CodecSrc* src = new CodecSrc(path, mode, dstColorType, scale); | 280 CodecSrc* src = new CodecSrc(path, mode, dstColorType, dstAlphaType, scale); |
267 push_src("image", folder, src); | 281 push_src("image", folder, src); |
268 } | 282 } |
269 | 283 |
270 static void push_android_codec_src(Path path, AndroidCodecSrc::Mode mode, | 284 static void push_android_codec_src(Path path, AndroidCodecSrc::Mode mode, |
271 CodecSrc::DstColorType dstColorType, int sampleSize) { | 285 CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType, int sampl
eSize) { |
272 SkString folder; | 286 SkString folder; |
273 switch (mode) { | 287 switch (mode) { |
274 case AndroidCodecSrc::kFullImage_Mode: | 288 case AndroidCodecSrc::kFullImage_Mode: |
275 folder.append("scaled_codec"); | 289 folder.append("scaled_codec"); |
276 break; | 290 break; |
277 case AndroidCodecSrc::kDivisor_Mode: | 291 case AndroidCodecSrc::kDivisor_Mode: |
278 folder.append("scaled_codec_divisor"); | 292 folder.append("scaled_codec_divisor"); |
279 break; | 293 break; |
280 } | 294 } |
281 | 295 |
282 switch (dstColorType) { | 296 switch (dstColorType) { |
283 case CodecSrc::kGrayscale_Always_DstColorType: | 297 case CodecSrc::kGrayscale_Always_DstColorType: |
284 folder.append("_kGray8"); | 298 folder.append("_kGray8"); |
285 break; | 299 break; |
286 case CodecSrc::kIndex8_Always_DstColorType: | 300 case CodecSrc::kIndex8_Always_DstColorType: |
287 folder.append("_kIndex8"); | 301 folder.append("_kIndex8"); |
288 break; | 302 break; |
289 default: | 303 default: |
290 break; | 304 break; |
291 } | 305 } |
292 | 306 |
| 307 switch (dstAlphaType) { |
| 308 case kOpaque_SkAlphaType: |
| 309 folder.append("_opaque"); |
| 310 break; |
| 311 case kPremul_SkAlphaType: |
| 312 folder.append("_premul"); |
| 313 break; |
| 314 default: |
| 315 break; |
| 316 } |
| 317 |
293 if (1 != sampleSize) { | 318 if (1 != sampleSize) { |
294 folder.appendf("_%.3f", 1.0f / (float) sampleSize); | 319 folder.appendf("_%.3f", 1.0f / (float) sampleSize); |
295 } | 320 } |
296 | 321 |
297 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, sampleS
ize); | 322 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph
aType, sampleSize); |
298 push_src("image", folder, src); | 323 push_src("image", folder, src); |
299 } | 324 } |
300 | 325 |
301 static void push_codec_srcs(Path path) { | 326 static void push_codec_srcs(Path path) { |
302 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 327 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
303 if (!encoded) { | 328 if (!encoded) { |
304 SkDebugf("Couldn't read %s.", path.c_str()); | 329 SkDebugf("Couldn't read %s.", path.c_str()); |
305 return; | 330 return; |
306 } | 331 } |
307 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 332 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
(...skipping 29 matching lines...) Expand all Loading... |
337 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; | 362 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; |
338 colorTypes[1] = CodecSrc::kIndex8_Always_DstColorType; | 363 colorTypes[1] = CodecSrc::kIndex8_Always_DstColorType; |
339 numColorTypes = 2; | 364 numColorTypes = 2; |
340 break; | 365 break; |
341 default: | 366 default: |
342 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; | 367 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; |
343 numColorTypes = 1; | 368 numColorTypes = 1; |
344 break; | 369 break; |
345 } | 370 } |
346 | 371 |
| 372 SkTArray<SkAlphaType> alphaModes; |
| 373 alphaModes.push_back(kPremul_SkAlphaType); |
| 374 // FIXME: Currently we cannot draw unpremultiplied sources. skbug.com/3338 a
nd skbug.com/3339 |
| 375 // alphaModes.push_back(kUnpremul_SkAlphaType); |
| 376 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { |
| 377 alphaModes.push_back(kOpaque_SkAlphaType); |
| 378 } |
347 | 379 |
348 for (CodecSrc::Mode mode : nativeModes) { | 380 for (CodecSrc::Mode mode : nativeModes) { |
349 // SkCodecImageGenerator only runs for the default colorType | 381 // SkCodecImageGenerator only runs for the default colorType |
350 // recommended by SkCodec. There is no need to generate multiple | 382 // recommended by SkCodec. There is no need to generate multiple |
351 // tests for different colorTypes. | 383 // tests for different colorTypes. |
352 // TODO (msarett): Add scaling support to SkCodecImageGenerator. | 384 // TODO (msarett): Add scaling support to SkCodecImageGenerator. |
353 if (CodecSrc::kGen_Mode == mode) { | 385 if (CodecSrc::kGen_Mode == mode) { |
354 // FIXME: The gpu backend does not draw kGray sources correctly. (sk
bug.com/4822) | 386 // FIXME: The gpu backend does not draw kGray sources correctly. (sk
bug.com/4822) |
355 if (kGray_8_SkColorType != codec->getInfo().colorType()) { | 387 if (kGray_8_SkColorType != codec->getInfo().colorType()) { |
356 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType
, 1.0f); | 388 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType
, |
| 389 codec->getInfo().alphaType(), 1.0f); |
357 } | 390 } |
358 continue; | 391 continue; |
359 } | 392 } |
360 | 393 |
361 for (float scale : nativeScales) { | 394 for (float scale : nativeScales) { |
362 for (uint32_t i = 0; i < numColorTypes; i++) { | 395 for (uint32_t i = 0; i < numColorTypes; i++) { |
363 push_codec_src(path, mode, colorTypes[i], scale); | 396 for (SkAlphaType alphaType : alphaModes) { |
| 397 push_codec_src(path, mode, colorTypes[i], alphaType, scale); |
| 398 } |
364 } | 399 } |
365 } | 400 } |
366 } | 401 } |
367 | 402 |
368 // https://bug.skia.org/4428 | 403 // https://bug.skia.org/4428 |
369 bool subset = false; | 404 bool subset = false; |
370 // The following image types are supported by BitmapRegionDecoder, | 405 // The following image types are supported by BitmapRegionDecoder, |
371 // so we will test full image decodes and subset decodes. | 406 // so we will test full image decodes and subset decodes. |
372 static const char* const exts[] = { | 407 static const char* const exts[] = { |
373 "jpg", "jpeg", "png", "webp", | 408 "jpg", "jpeg", "png", "webp", |
374 "JPG", "JPEG", "PNG", "WEBP", | 409 "JPG", "JPEG", "PNG", "WEBP", |
375 }; | 410 }; |
376 for (const char* ext : exts) { | 411 for (const char* ext : exts) { |
377 if (path.endsWith(ext)) { | 412 if (path.endsWith(ext)) { |
378 subset = true; | 413 subset = true; |
379 break; | 414 break; |
380 } | 415 } |
381 } | 416 } |
382 | 417 |
383 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | 418 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
384 | 419 |
385 for (int sampleSize : sampleSizes) { | 420 for (int sampleSize : sampleSizes) { |
386 for (uint32_t i = 0; i < numColorTypes; i++) { | 421 for (uint32_t i = 0; i < numColorTypes; i++) { |
387 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, color
Types[i], | 422 for (SkAlphaType alphaType : alphaModes) { |
388 sampleSize); | 423 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c
olorTypes[i], |
389 if (subset) { | 424 alphaType, sampleSize); |
390 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode, col
orTypes[i], | 425 if (subset) { |
391 sampleSize); | 426 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode,
colorTypes[i], |
| 427 alphaType, sampleSize); |
| 428 } |
392 } | 429 } |
393 } | 430 } |
394 } | 431 } |
395 } | 432 } |
396 | 433 |
397 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, | 434 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
398 CodecSrc::DstColorType dstColorType) { | 435 CodecSrc::DstColorType dstColorType) { |
399 switch (strategy) { | 436 switch (strategy) { |
400 case SkBitmapRegionDecoder::kCanvas_Strategy: | 437 case SkBitmapRegionDecoder::kCanvas_Strategy: |
401 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { | 438 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 Reporter* reporter, | 1301 Reporter* reporter, |
1265 GrContextFactory* fac
tory); | 1302 GrContextFactory* fac
tory); |
1266 } // namespace skiatest | 1303 } // namespace skiatest |
1267 | 1304 |
1268 #if !defined(SK_BUILD_FOR_IOS) | 1305 #if !defined(SK_BUILD_FOR_IOS) |
1269 int main(int argc, char** argv) { | 1306 int main(int argc, char** argv) { |
1270 SkCommandLineFlags::Parse(argc, argv); | 1307 SkCommandLineFlags::Parse(argc, argv); |
1271 return dm_main(); | 1308 return dm_main(); |
1272 } | 1309 } |
1273 #endif | 1310 #endif |
OLD | NEW |