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

Side by Side Diff: dm/DM.cpp

Issue 1288963002: Provides multiple implementations of Android's SkBitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Disable png subsets for SkImageDecoder Created 5 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 | « no previous file | 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // compute their colors based on uninitialized values. 320 // compute their colors based on uninitialized values.
321 continue; 321 continue;
322 } 322 }
323 323
324 for (uint32_t i = 0; i < numColorTypes; i++) { 324 for (uint32_t i = 0; i < numColorTypes; i++) {
325 push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], sca le); 325 push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], sca le);
326 } 326 }
327 } 327 }
328 } 328 }
329 329
330 static bool codec_supported(const char* ext) { 330 static bool brd_color_type_supported(SkBitmapRegionDecoderInterface::Strategy st rategy,
331 // FIXME: Once other versions of SkCodec are available, we can add them to t his 331 CodecSrc::DstColorType dstColorType) {
332 // list (and eventually we can remove this check once they are all supported ). 332 switch (strategy) {
333 case SkBitmapRegionDecoderInterface::kCanvas_Strategy:
334 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) {
335 return true;
336 }
337 return false;
338 case SkBitmapRegionDecoderInterface::kOriginal_Strategy:
339 switch (dstColorType) {
340 case CodecSrc::kGetFromCanvas_DstColorType:
341 case CodecSrc::kIndex8_Always_DstColorType:
342 case CodecSrc::kGrayscale_Always_DstColorType:
343 return true;
344 default:
345 return false;
346 }
347 default:
348 SkASSERT(false);
349 return false;
350 }
351 }
352
353 static void push_brd_src(Path path, SkBitmapRegionDecoderInterface::Strategy str ategy,
354 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS ize) {
355 SkString folder;
356 switch (strategy) {
357 case SkBitmapRegionDecoderInterface::kCanvas_Strategy:
358 folder.append("brd_canvas");
359 break;
360 case SkBitmapRegionDecoderInterface::kOriginal_Strategy:
361 folder.append("brd_sample");
362 break;
363 default:
364 SkASSERT(false);
365 return;
366 }
367
368 switch (mode) {
369 case BRDSrc::kFullImage_Mode:
370 break;
371 case BRDSrc::kDivisor_Mode:
372 folder.append("_divisor");
373 break;
374 default:
375 SkASSERT(false);
376 return;
377 }
378
379 switch (dstColorType) {
380 case CodecSrc::kGetFromCanvas_DstColorType:
381 break;
382 case CodecSrc::kIndex8_Always_DstColorType:
383 folder.append("_kIndex");
384 break;
385 case CodecSrc::kGrayscale_Always_DstColorType:
386 folder.append("_kGray");
387 break;
388 default:
389 SkASSERT(false);
390 return;
391 }
392
393 if (1 != sampleSize) {
394 folder.appendf("_%.3f", BRDSrc::GetScale(sampleSize));
395 }
396
397 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize);
398 push_src("image", folder, src);
399 }
400
401 static void push_brd_srcs(Path path) {
402
403 const SkBitmapRegionDecoderInterface::Strategy strategies[] = {
404 SkBitmapRegionDecoderInterface::kCanvas_Strategy,
405 SkBitmapRegionDecoderInterface::kOriginal_Strategy
406 };
407
408 // We will only test to one backend (8888), but we will test all of the
409 // color types that we need to decode to on this backend.
410 const CodecSrc::DstColorType dstColorTypes[] = {
411 CodecSrc::kGetFromCanvas_DstColorType,
412 CodecSrc::kIndex8_Always_DstColorType,
413 CodecSrc::kGrayscale_Always_DstColorType,
414 };
415
416 const BRDSrc::Mode modes[] = {
417 BRDSrc::kFullImage_Mode,
418 BRDSrc::kDivisor_Mode
419 };
420
421 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
422
423 for (SkBitmapRegionDecoderInterface::Strategy strategy : strategies) {
424 // We disable png testing for kOriginal_Strategy because the implementat ion leaks
425 // memory in our forked libpng.
426 // TODO (msarett): Decide if we want to test pngs in this mode and how w e might do this.
427 if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strategy &&
428 (path.endsWith(".png") || path.endsWith(".PNG"))) {
429 continue;
430 }
431 for (CodecSrc::DstColorType dstColorType : dstColorTypes) {
432 if (brd_color_type_supported(strategy, dstColorType)) {
433 for (BRDSrc::Mode mode : modes) {
434 for (uint32_t sampleSize : sampleSizes) {
435 push_brd_src(path, strategy, dstColorType, mode, sampleS ize);
436 }
437 }
438 }
439 }
440 }
441 }
442
443 static bool brd_supported(const char* ext) {
333 static const char* const exts[] = { 444 static const char* const exts[] = {
334 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", 445 "jpg", "jpeg", "png", "webp",
335 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", 446 "JPG", "JPEG", "PNG", "WEBP",
336 }; 447 };
337 448
338 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { 449 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
339 if (0 == strcmp(exts[i], ext)) { 450 if (0 == strcmp(exts[i], ext)) {
340 return true; 451 return true;
341 } 452 }
342 } 453 }
343 return false; 454 return false;
344 } 455 }
345 456
(...skipping 18 matching lines...) Expand all
364 }; 475 };
365 for (int i = 0; i < FLAGS_images.count(); i++) { 476 for (int i = 0; i < FLAGS_images.count(); i++) {
366 const char* flag = FLAGS_images[i]; 477 const char* flag = FLAGS_images[i];
367 if (sk_isdir(flag)) { 478 if (sk_isdir(flag)) {
368 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { 479 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) {
369 SkOSFile::Iter it(flag, exts[j]); 480 SkOSFile::Iter it(flag, exts[j]);
370 for (SkString file; it.next(&file); ) { 481 for (SkString file; it.next(&file); ) {
371 SkString path = SkOSPath::Join(flag, file.c_str()); 482 SkString path = SkOSPath::Join(flag, file.c_str());
372 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image 483 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image
373 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets 484 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets
374 if (codec_supported(exts[j])) { 485 push_codec_srcs(path);
375 push_codec_srcs(path); 486 if (brd_supported(exts[j])) {
487 push_brd_srcs(path);
376 } 488 }
377 } 489 }
378 } 490 }
379 } else if (sk_exists(flag)) { 491 } else if (sk_exists(flag)) {
380 // assume that FLAGS_images[i] is a valid image if it is a file. 492 // assume that FLAGS_images[i] is a valid image if it is a file.
381 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. 493 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age.
382 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets 494 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets
383 push_codec_srcs(flag); 495 push_codec_srcs(flag);
496 push_brd_srcs(flag);
384 } 497 }
385 } 498 }
386 } 499 }
387 500
388 static GrGLStandard get_gpu_api() { 501 static GrGLStandard get_gpu_api() {
389 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } 502 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
390 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } 503 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
391 return kNone_GrGLStandard; 504 return kNone_GrGLStandard;
392 } 505 }
393 506
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 } 1072 }
960 return 0; 1073 return 0;
961 } 1074 }
962 1075
963 #if !defined(SK_BUILD_FOR_IOS) 1076 #if !defined(SK_BUILD_FOR_IOS)
964 int main(int argc, char** argv) { 1077 int main(int argc, char** argv) {
965 SkCommandLineFlags::Parse(argc, argv); 1078 SkCommandLineFlags::Parse(argc, argv);
966 return dm_main(); 1079 return dm_main();
967 } 1080 }
968 #endif 1081 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMSrcSink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698