Chromium Code Reviews| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkData.h" | 12 #include "SkData.h" |
| 13 #include "SkDecodingImageGenerator.h" | 13 #include "SkDecodingImageGenerator.h" |
| 14 #include "SkDiscardableMemoryPool.h" | 14 #include "SkDiscardableMemoryPool.h" |
| 15 #include "SkForceLinking.h" | 15 #include "SkForceLinking.h" |
| 16 #include "SkGradientShader.h" | 16 #include "SkGradientShader.h" |
| 17 #include "SkImageDecoder.h" | 17 #include "SkImageDecoder.h" |
| 18 #include "SkImageEncoder.h" | 18 #include "SkImageEncoder.h" |
| 19 #include "SkImageGenerator.h" | 19 #include "SkImageGeneratorPriv.h" |
|
hal.canary
2014/05/27 13:33:53
do we still need this?
| |
| 20 #include "SkImagePriv.h" | 20 #include "SkImagePriv.h" |
| 21 #include "SkOSFile.h" | 21 #include "SkOSFile.h" |
| 22 #include "SkPoint.h" | 22 #include "SkPoint.h" |
| 23 #include "SkShader.h" | 23 #include "SkShader.h" |
| 24 #include "SkStream.h" | 24 #include "SkStream.h" |
| 25 #include "SkString.h" | 25 #include "SkString.h" |
| 26 #include "Test.h" | 26 #include "Test.h" |
| 27 | 27 |
| 28 __SK_FORCE_IMAGE_DECODER_LINKING; | 28 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 29 | 29 |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 0xa7, 0xf3, 0xa3, 0xbd, 0x83, 0x8b, 0x2a, 0xc8, 0x58, 0xf5, 0xac, 0x80, | 448 0xa7, 0xf3, 0xa3, 0xbd, 0x83, 0x8b, 0x2a, 0xc8, 0x58, 0xf5, 0xac, 0x80, |
| 449 0xe3, 0xfe, 0x66, 0xa4, 0x7c, 0x1b, 0x6c, 0xd1, 0xa9, 0xd8, 0x14, 0xd0, | 449 0xe3, 0xfe, 0x66, 0xa4, 0x7c, 0x1b, 0x6c, 0xd1, 0xa9, 0xd8, 0x14, 0xd0, |
| 450 0xc5, 0xb5, 0x39, 0x71, 0x97, 0x19, 0x19, 0x1b | 450 0xc5, 0xb5, 0x39, 0x71, 0x97, 0x19, 0x19, 0x1b |
| 451 }; | 451 }; |
| 452 SkAutoDataUnref encoded(SkData::NewWithCopy(encodedWebP, | 452 SkAutoDataUnref encoded(SkData::NewWithCopy(encodedWebP, |
| 453 sizeof(encodedWebP))); | 453 sizeof(encodedWebP))); |
| 454 SkBitmap bm; | 454 SkBitmap bm; |
| 455 | 455 |
| 456 bool success = SkInstallDiscardablePixelRef( | 456 bool success = SkInstallDiscardablePixelRef( |
| 457 SkDecodingImageGenerator::Create(encoded, | 457 SkDecodingImageGenerator::Create(encoded, |
| 458 SkDecodingImageGenerator::Options()), &bm, NULL); | 458 SkDecodingImageGenerator::Options()), &bm); |
| 459 | 459 |
| 460 REPORTER_ASSERT(reporter, success); | 460 REPORTER_ASSERT(reporter, success); |
| 461 if (!success) { | 461 if (!success) { |
| 462 return; | 462 return; |
| 463 } | 463 } |
| 464 SkAutoLockPixels alp(bm); | 464 SkAutoLockPixels alp(bm); |
| 465 | 465 |
| 466 bool rightSize = ((kExpectedWidth == bm.width()) | 466 bool rightSize = ((kExpectedWidth == bm.width()) |
| 467 && (kExpectedHeight == bm.height())); | 467 && (kExpectedHeight == bm.height())); |
| 468 REPORTER_ASSERT(reporter, rightSize); | 468 REPORTER_ASSERT(reporter, rightSize); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 SkData* encodedData, | 577 SkData* encodedData, |
| 578 bool useData, | 578 bool useData, |
| 579 const SkString& path) { | 579 const SkString& path) { |
| 580 SkBitmap bm; | 580 SkBitmap bm; |
| 581 bool success = false; | 581 bool success = false; |
| 582 if (useData) { | 582 if (useData) { |
| 583 if (NULL == encodedData) { | 583 if (NULL == encodedData) { |
| 584 return; | 584 return; |
| 585 } | 585 } |
| 586 success = SkInstallDiscardablePixelRef( | 586 success = SkInstallDiscardablePixelRef( |
| 587 SkDecodingImageGenerator::Create(encodedData, opts), &bm, NULL); | 587 SkDecodingImageGenerator::Create(encodedData, opts), &bm); |
| 588 } else { | 588 } else { |
| 589 if (NULL == encodedStream) { | 589 if (NULL == encodedStream) { |
| 590 return; | 590 return; |
| 591 } | 591 } |
| 592 success = SkInstallDiscardablePixelRef( | 592 success = SkInstallDiscardablePixelRef( |
| 593 SkDecodingImageGenerator::Create(encodedStream->duplicate(), opts), | 593 SkDecodingImageGenerator::Create(encodedStream->duplicate(), opts), &bm); |
| 594 &bm, NULL); | |
| 595 } | 594 } |
| 596 if (!success) { | 595 if (!success) { |
| 597 if (opts.fUseRequestedColorType | 596 if (opts.fUseRequestedColorType |
| 598 && (kARGB_4444_SkColorType == opts.fRequestedColorType)) { | 597 && (kARGB_4444_SkColorType == opts.fRequestedColorType)) { |
| 599 return; // Ignore known conversion inabilities. | 598 return; // Ignore known conversion inabilities. |
| 600 } | 599 } |
| 601 // If we get here, it's a failure and we will need more | 600 // If we get here, it's a failure and we will need more |
| 602 // information about why it failed. | 601 // information about why it failed. |
| 603 ERRORF(reporter, "Bounds decode failed [sampleSize=%d dither=%s " | 602 ERRORF(reporter, "Bounds decode failed [sampleSize=%d dither=%s " |
| 604 "colorType=%s %s]", opts.fSampleSize, yn(opts.fDitherImage), | 603 "colorType=%s %s]", opts.fSampleSize, yn(opts.fDitherImage), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 } | 719 } |
| 721 SkDecodingImageGenerator::Options options(scaleList[i], | 720 SkDecodingImageGenerator::Options options(scaleList[i], |
| 722 ditherList[j]); | 721 ditherList[j]); |
| 723 test_options(reporter, options, encodedStream, encodedData, | 722 test_options(reporter, options, encodedStream, encodedData, |
| 724 useDataList[m], path); | 723 useDataList[m], path); |
| 725 } | 724 } |
| 726 } | 725 } |
| 727 } | 726 } |
| 728 } | 727 } |
| 729 } | 728 } |
| OLD | NEW |