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

Side by Side Diff: dm/DM.cpp

Issue 1415243007: Rename SkBitmapRegionDecoder and Create function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 | « bench/nanobench.cpp ('k') | dm/DMSrcSink.h » ('j') | 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 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 for (int sampleSize : sampleSizes) { 375 for (int sampleSize : sampleSizes) {
376 for (AndroidCodecSrc::Mode mode : androidModes) { 376 for (AndroidCodecSrc::Mode mode : androidModes) {
377 for (uint32_t i = 0; i < numColorTypes; i++) { 377 for (uint32_t i = 0; i < numColorTypes; i++) {
378 push_android_codec_src(path, mode, colorTypes[i], sampleSize); 378 push_android_codec_src(path, mode, colorTypes[i], sampleSize);
379 } 379 }
380 } 380 }
381 } 381 }
382 } 382 }
383 383
384 static bool brd_color_type_supported(SkBitmapRegionDecoderInterface::Strategy st rategy, 384 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy,
385 CodecSrc::DstColorType dstColorType) { 385 CodecSrc::DstColorType dstColorType) {
386 switch (strategy) { 386 switch (strategy) {
387 case SkBitmapRegionDecoderInterface::kCanvas_Strategy: 387 case SkBitmapRegionDecoder::kCanvas_Strategy:
388 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { 388 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) {
389 return true; 389 return true;
390 } 390 }
391 return false; 391 return false;
392 case SkBitmapRegionDecoderInterface::kOriginal_Strategy: 392 case SkBitmapRegionDecoder::kOriginal_Strategy:
393 switch (dstColorType) { 393 switch (dstColorType) {
394 case CodecSrc::kGetFromCanvas_DstColorType: 394 case CodecSrc::kGetFromCanvas_DstColorType:
395 case CodecSrc::kIndex8_Always_DstColorType: 395 case CodecSrc::kIndex8_Always_DstColorType:
396 case CodecSrc::kGrayscale_Always_DstColorType: 396 case CodecSrc::kGrayscale_Always_DstColorType:
397 return true; 397 return true;
398 default: 398 default:
399 return false; 399 return false;
400 } 400 }
401 case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy: 401 case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
402 switch (dstColorType) { 402 switch (dstColorType) {
403 case CodecSrc::kGetFromCanvas_DstColorType: 403 case CodecSrc::kGetFromCanvas_DstColorType:
404 case CodecSrc::kIndex8_Always_DstColorType: 404 case CodecSrc::kIndex8_Always_DstColorType:
405 case CodecSrc::kGrayscale_Always_DstColorType: 405 case CodecSrc::kGrayscale_Always_DstColorType:
406 return true; 406 return true;
407 default: 407 default:
408 return false; 408 return false;
409 } 409 }
410 default: 410 default:
411 SkASSERT(false); 411 SkASSERT(false);
412 return false; 412 return false;
413 } 413 }
414 } 414 }
415 415
416 static void push_brd_src(Path path, SkBitmapRegionDecoderInterface::Strategy str ategy, 416 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy,
417 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS ize) { 417 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS ize) {
418 SkString folder; 418 SkString folder;
419 switch (strategy) { 419 switch (strategy) {
420 case SkBitmapRegionDecoderInterface::kCanvas_Strategy: 420 case SkBitmapRegionDecoder::kCanvas_Strategy:
421 folder.append("brd_canvas"); 421 folder.append("brd_canvas");
422 break; 422 break;
423 case SkBitmapRegionDecoderInterface::kOriginal_Strategy: 423 case SkBitmapRegionDecoder::kOriginal_Strategy:
424 folder.append("brd_sample"); 424 folder.append("brd_sample");
425 break; 425 break;
426 case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy: 426 case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
427 folder.append("brd_android_codec"); 427 folder.append("brd_android_codec");
428 break; 428 break;
429 default: 429 default:
430 SkASSERT(false); 430 SkASSERT(false);
431 return; 431 return;
432 } 432 }
433 433
434 switch (mode) { 434 switch (mode) {
435 case BRDSrc::kFullImage_Mode: 435 case BRDSrc::kFullImage_Mode:
436 break; 436 break;
(...skipping 22 matching lines...) Expand all
459 if (1 != sampleSize) { 459 if (1 != sampleSize) {
460 folder.appendf("_%.3f", get_scale_from_sample_size(sampleSize)); 460 folder.appendf("_%.3f", get_scale_from_sample_size(sampleSize));
461 } 461 }
462 462
463 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); 463 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize);
464 push_src("image", folder, src); 464 push_src("image", folder, src);
465 } 465 }
466 466
467 static void push_brd_srcs(Path path) { 467 static void push_brd_srcs(Path path) {
468 468
469 const SkBitmapRegionDecoderInterface::Strategy strategies[] = { 469 const SkBitmapRegionDecoder::Strategy strategies[] = {
470 SkBitmapRegionDecoderInterface::kCanvas_Strategy, 470 SkBitmapRegionDecoder::kCanvas_Strategy,
471 SkBitmapRegionDecoderInterface::kOriginal_Strategy, 471 SkBitmapRegionDecoder::kOriginal_Strategy,
472 SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy, 472 SkBitmapRegionDecoder::kAndroidCodec_Strategy,
473 }; 473 };
474 474
475 // Test on a variety of sampleSizes, making sure to include: 475 // Test on a variety of sampleSizes, making sure to include:
476 // - 2, 4, and 8, which are natively supported by jpeg 476 // - 2, 4, and 8, which are natively supported by jpeg
477 // - multiples of 2 which are not divisible by 4 (analogous for 4) 477 // - multiples of 2 which are not divisible by 4 (analogous for 4)
478 // - larger powers of two, since BRD clients generally use powers of 2 478 // - larger powers of two, since BRD clients generally use powers of 2
479 // We will only produce output for the larger sizes on large images. 479 // We will only produce output for the larger sizes on large images.
480 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 }; 480 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 };
481 481
482 // We will only test to one backend (8888), but we will test all of the 482 // We will only test to one backend (8888), but we will test all of the
483 // color types that we need to decode to on this backend. 483 // color types that we need to decode to on this backend.
484 const CodecSrc::DstColorType dstColorTypes[] = { 484 const CodecSrc::DstColorType dstColorTypes[] = {
485 CodecSrc::kGetFromCanvas_DstColorType, 485 CodecSrc::kGetFromCanvas_DstColorType,
486 CodecSrc::kIndex8_Always_DstColorType, 486 CodecSrc::kIndex8_Always_DstColorType,
487 CodecSrc::kGrayscale_Always_DstColorType, 487 CodecSrc::kGrayscale_Always_DstColorType,
488 }; 488 };
489 489
490 const BRDSrc::Mode modes[] = { 490 const BRDSrc::Mode modes[] = {
491 BRDSrc::kFullImage_Mode, 491 BRDSrc::kFullImage_Mode,
492 BRDSrc::kDivisor_Mode, 492 BRDSrc::kDivisor_Mode,
493 }; 493 };
494 494
495 for (SkBitmapRegionDecoderInterface::Strategy strategy : strategies) { 495 for (SkBitmapRegionDecoder::Strategy strategy : strategies) {
496 496
497 // We disable png testing for kOriginal_Strategy because the implementat ion leaks 497 // We disable png testing for kOriginal_Strategy because the implementat ion leaks
498 // memory in our forked libpng. 498 // memory in our forked libpng.
499 // TODO (msarett): Decide if we want to test pngs in this mode and how w e might do this. 499 // TODO (msarett): Decide if we want to test pngs in this mode and how w e might do this.
500 if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy && 500 if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy &&
501 (path.endsWith(".png") || path.endsWith(".PNG"))) { 501 (path.endsWith(".png") || path.endsWith(".PNG"))) {
502 continue; 502 continue;
503 } 503 }
504 for (uint32_t sampleSize : sampleSizes) { 504 for (uint32_t sampleSize : sampleSizes) {
505 505
506 // kOriginal_Strategy does not work for jpegs that are scaled to non -powers of two. 506 // kOriginal_Strategy does not work for jpegs that are scaled to non -powers of two.
507 // We don't need to test this. We know it doesn't work, and it caus es images with 507 // We don't need to test this. We know it doesn't work, and it caus es images with
508 // uninitialized memory to show up on Gold. 508 // uninitialized memory to show up on Gold.
509 if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy & & 509 if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy &&
510 (path.endsWith(".jpg") || path.endsWith(".JPG") || 510 (path.endsWith(".jpg") || path.endsWith(".JPG") ||
511 path.endsWith(".jpeg") || path.endsWith(".JPEG")) && !SkIsPo w2(sampleSize)) { 511 path.endsWith(".jpeg") || path.endsWith(".JPEG")) && !SkIsPo w2(sampleSize)) {
512 continue; 512 continue;
513 } 513 }
514 for (CodecSrc::DstColorType dstColorType : dstColorTypes) { 514 for (CodecSrc::DstColorType dstColorType : dstColorTypes) {
515 if (brd_color_type_supported(strategy, dstColorType)) { 515 if (brd_color_type_supported(strategy, dstColorType)) {
516 for (BRDSrc::Mode mode : modes) { 516 for (BRDSrc::Mode mode : modes) {
517 push_brd_src(path, strategy, dstColorType, mode, sampleS ize); 517 push_brd_src(path, strategy, dstColorType, mode, sampleS ize);
518 } 518 }
519 } 519 }
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 #endif // SK_PDF_IMAGE_STATS 1168 #endif // SK_PDF_IMAGE_STATS
1169 return 0; 1169 return 0;
1170 } 1170 }
1171 1171
1172 #if !defined(SK_BUILD_FOR_IOS) 1172 #if !defined(SK_BUILD_FOR_IOS)
1173 int main(int argc, char** argv) { 1173 int main(int argc, char** argv) {
1174 SkCommandLineFlags::Parse(argc, argv); 1174 SkCommandLineFlags::Parse(argc, argv);
1175 return dm_main(); 1175 return dm_main();
1176 } 1176 }
1177 #endif 1177 #endif
OLDNEW
« no previous file with comments | « bench/nanobench.cpp ('k') | dm/DMSrcSink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698