| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   378 } |   378 } | 
|   379  |   379  | 
|   380 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |   380 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, | 
|   381         CodecSrc::DstColorType dstColorType) { |   381         CodecSrc::DstColorType dstColorType) { | 
|   382     switch (strategy) { |   382     switch (strategy) { | 
|   383         case SkBitmapRegionDecoder::kCanvas_Strategy: |   383         case SkBitmapRegionDecoder::kCanvas_Strategy: | 
|   384             if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { |   384             if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { | 
|   385                 return true; |   385                 return true; | 
|   386             } |   386             } | 
|   387             return false; |   387             return false; | 
|   388         case SkBitmapRegionDecoder::kOriginal_Strategy: |  | 
|   389             switch (dstColorType) { |  | 
|   390                 case CodecSrc::kGetFromCanvas_DstColorType: |  | 
|   391                 case CodecSrc::kIndex8_Always_DstColorType: |  | 
|   392                 case CodecSrc::kGrayscale_Always_DstColorType: |  | 
|   393                     return true; |  | 
|   394                 default: |  | 
|   395                     return false; |  | 
|   396             } |  | 
|   397         case SkBitmapRegionDecoder::kAndroidCodec_Strategy: |   388         case SkBitmapRegionDecoder::kAndroidCodec_Strategy: | 
|   398             switch (dstColorType) { |   389             switch (dstColorType) { | 
|   399                 case CodecSrc::kGetFromCanvas_DstColorType: |   390                 case CodecSrc::kGetFromCanvas_DstColorType: | 
|   400                 case CodecSrc::kIndex8_Always_DstColorType: |   391                 case CodecSrc::kIndex8_Always_DstColorType: | 
|   401                 case CodecSrc::kGrayscale_Always_DstColorType: |   392                 case CodecSrc::kGrayscale_Always_DstColorType: | 
|   402                     return true; |   393                     return true; | 
|   403                 default: |   394                 default: | 
|   404                     return false; |   395                     return false; | 
|   405             } |   396             } | 
|   406         default: |   397         default: | 
|   407             SkASSERT(false); |   398             SkASSERT(false); | 
|   408             return false; |   399             return false; | 
|   409     } |   400     } | 
|   410 } |   401 } | 
|   411  |   402  | 
|   412 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, |   403 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, | 
|   413         CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS
      ize) { |   404         CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS
      ize) { | 
|   414     SkString folder; |   405     SkString folder; | 
|   415     switch (strategy) { |   406     switch (strategy) { | 
|   416         case SkBitmapRegionDecoder::kCanvas_Strategy: |   407         case SkBitmapRegionDecoder::kCanvas_Strategy: | 
|   417             folder.append("brd_canvas"); |   408             folder.append("brd_canvas"); | 
|   418             break; |   409             break; | 
|   419         case SkBitmapRegionDecoder::kOriginal_Strategy: |  | 
|   420             folder.append("brd_sample"); |  | 
|   421             break; |  | 
|   422         case SkBitmapRegionDecoder::kAndroidCodec_Strategy: |   410         case SkBitmapRegionDecoder::kAndroidCodec_Strategy: | 
|   423             folder.append("brd_android_codec"); |   411             folder.append("brd_android_codec"); | 
|   424             break; |   412             break; | 
|   425         default: |   413         default: | 
|   426             SkASSERT(false); |   414             SkASSERT(false); | 
|   427             return; |   415             return; | 
|   428     } |   416     } | 
|   429  |   417  | 
|   430     switch (mode) { |   418     switch (mode) { | 
|   431         case BRDSrc::kFullImage_Mode: |   419         case BRDSrc::kFullImage_Mode: | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|   457     } |   445     } | 
|   458  |   446  | 
|   459     BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); |   447     BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); | 
|   460     push_src("image", folder, src); |   448     push_src("image", folder, src); | 
|   461 } |   449 } | 
|   462  |   450  | 
|   463 static void push_brd_srcs(Path path) { |   451 static void push_brd_srcs(Path path) { | 
|   464  |   452  | 
|   465     const SkBitmapRegionDecoder::Strategy strategies[] = { |   453     const SkBitmapRegionDecoder::Strategy strategies[] = { | 
|   466             SkBitmapRegionDecoder::kCanvas_Strategy, |   454             SkBitmapRegionDecoder::kCanvas_Strategy, | 
|   467             SkBitmapRegionDecoder::kOriginal_Strategy, |  | 
|   468             SkBitmapRegionDecoder::kAndroidCodec_Strategy, |   455             SkBitmapRegionDecoder::kAndroidCodec_Strategy, | 
|   469     }; |   456     }; | 
|   470  |   457  | 
|   471     // Test on a variety of sampleSizes, making sure to include: |   458     // Test on a variety of sampleSizes, making sure to include: | 
|   472     // - 2, 4, and 8, which are natively supported by jpeg |   459     // - 2, 4, and 8, which are natively supported by jpeg | 
|   473     // - multiples of 2 which are not divisible by 4 (analogous for 4) |   460     // - multiples of 2 which are not divisible by 4 (analogous for 4) | 
|   474     // - larger powers of two, since BRD clients generally use powers of 2 |   461     // - larger powers of two, since BRD clients generally use powers of 2 | 
|   475     // We will only produce output for the larger sizes on large images. |   462     // We will only produce output for the larger sizes on large images. | 
|   476     const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 
      }; |   463     const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 
      }; | 
|   477  |   464  | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   552         "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO"
      , |   539         "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO"
      , | 
|   553     }; |   540     }; | 
|   554     for (int i = 0; i < FLAGS_images.count(); i++) { |   541     for (int i = 0; i < FLAGS_images.count(); i++) { | 
|   555         const char* flag = FLAGS_images[i]; |   542         const char* flag = FLAGS_images[i]; | 
|   556         if (sk_isdir(flag)) { |   543         if (sk_isdir(flag)) { | 
|   557             for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |   544             for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 
|   558                 SkOSFile::Iter it(flag, exts[j]); |   545                 SkOSFile::Iter it(flag, exts[j]); | 
|   559                 for (SkString file; it.next(&file); ) { |   546                 for (SkString file; it.next(&file); ) { | 
|   560                     SkString path = SkOSPath::Join(flag, file.c_str()); |   547                     SkString path = SkOSPath::Join(flag, file.c_str()); | 
|   561                     push_src("image", "decode", new ImageSrc(path)); // Decode e
      ntire image |   548                     push_src("image", "decode", new ImageSrc(path)); // Decode e
      ntire image | 
|   562                     push_src("image", "subset", new ImageSrc(path, 2)); // Decod
      e into 2x2 subsets |  | 
|   563                     push_codec_srcs(path); |   549                     push_codec_srcs(path); | 
|   564                     if (brd_supported(exts[j])) { |   550                     if (brd_supported(exts[j])) { | 
|   565                         push_brd_srcs(path); |   551                         push_brd_srcs(path); | 
|   566                     } |   552                     } | 
|   567                 } |   553                 } | 
|   568             } |   554             } | 
|   569         } else if (sk_exists(flag)) { |   555         } else if (sk_exists(flag)) { | 
|   570             // assume that FLAGS_images[i] is a valid image if it is a file. |   556             // assume that FLAGS_images[i] is a valid image if it is a file. | 
|   571             push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
      age. |   557             push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
      age. | 
|   572             push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
       x 2 subsets |  | 
|   573             push_codec_srcs(flag); |   558             push_codec_srcs(flag); | 
|   574             push_brd_srcs(flag); |   559             push_brd_srcs(flag); | 
|   575         } |   560         } | 
|   576     } |   561     } | 
|   577 } |   562 } | 
|   578  |   563  | 
|   579 static GrGLStandard get_gpu_api() { |   564 static GrGLStandard get_gpu_api() { | 
|   580     if (FLAGS_gpuAPI.contains("gl"))   { return kGL_GrGLStandard; } |   565     if (FLAGS_gpuAPI.contains("gl"))   { return kGL_GrGLStandard; } | 
|   581     if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |   566     if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 
|   582     return kNone_GrGLStandard; |   567     return kNone_GrGLStandard; | 
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1164     #endif  // SK_PDF_IMAGE_STATS |  1149     #endif  // SK_PDF_IMAGE_STATS | 
|  1165     return 0; |  1150     return 0; | 
|  1166 } |  1151 } | 
|  1167  |  1152  | 
|  1168 #if !defined(SK_BUILD_FOR_IOS) |  1153 #if !defined(SK_BUILD_FOR_IOS) | 
|  1169 int main(int argc, char** argv) { |  1154 int main(int argc, char** argv) { | 
|  1170     SkCommandLineFlags::Parse(argc, argv); |  1155     SkCommandLineFlags::Parse(argc, argv); | 
|  1171     return dm_main(); |  1156     return dm_main(); | 
|  1172 } |  1157 } | 
|  1173 #endif |  1158 #endif | 
| OLD | NEW |