OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
9 #include "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 // Skip a stripe | 515 // Skip a stripe |
516 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight); | 516 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight); |
517 if (linesToSkip > 0) { | 517 if (linesToSkip > 0) { |
518 codec->skipScanlines(linesToSkip); | 518 codec->skipScanlines(linesToSkip); |
519 } | 519 } |
520 } | 520 } |
521 premultiply_if_necessary(bitmap); | 521 premultiply_if_necessary(bitmap); |
522 canvas->drawBitmap(bitmap, 0, 0); | 522 canvas->drawBitmap(bitmap, 0, 0); |
523 break; | 523 break; |
524 } | 524 } |
525 case kCroppedScanline_Mode: { | |
526 const int width = decodeInfo.width(); | |
527 const int height = decodeInfo.height(); | |
528 // This value is chosen because, as we move across the image, it wil l sometimes | |
529 // align with the jpeg block sizes and it will sometimes not. This allows us | |
scroggo
2016/02/22 18:46:47
Is this because it is not a multiple of 8? (But fo
msarett
2016/02/22 19:07:43
The block size is generally 8 or 16. And the requ
scroggo
2016/02/22 19:20:20
Ah, so if width changes, it will be to add origina
| |
530 // to test interestingly different code paths in the implementation. | |
531 const int tileSize = 36; | |
532 | |
533 SkCodec::Options opts; | |
534 SkIRect subset; | |
535 for (int x = 0; x < width; x += tileSize) { | |
536 subset = SkIRect::MakeXYWH(x, 0, SkTMin(tileSize, width - x), he ight); | |
537 opts.fSubset = ⊂ | |
538 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &opts, | |
539 colorPtr, colorCountPtr)) { | |
540 return "Could not start scanline decoder."; | |
541 } | |
542 | |
543 codec->getScanlines(bitmap.getAddr(x, 0), height, bitmap.rowByte s()); | |
544 } | |
545 | |
546 premultiply_if_necessary(bitmap); | |
547 canvas->drawBitmap(bitmap, 0, 0); | |
548 break; | |
549 } | |
525 case kSubset_Mode: { | 550 case kSubset_Mode: { |
526 // Arbitrarily choose a divisor. | 551 // Arbitrarily choose a divisor. |
527 int divisor = 2; | 552 int divisor = 2; |
528 // Total width/height of the image. | 553 // Total width/height of the image. |
529 const int W = codec->getInfo().width(); | 554 const int W = codec->getInfo().width(); |
530 const int H = codec->getInfo().height(); | 555 const int H = codec->getInfo().height(); |
531 if (divisor > W || divisor > H) { | 556 if (divisor > W || divisor > H) { |
532 return Error::Nonfatal(SkStringPrintf("Cannot codec subset: divi sor %d is too big " | 557 return Error::Nonfatal(SkStringPrintf("Cannot codec subset: divi sor %d is too big " |
533 "for %s with dimensions (% d x %d)", divisor, | 558 "for %s with dimensions (% d x %d)", divisor, |
534 fPath.c_str(), W, H)); | 559 fPath.c_str(), W, H)); |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1407 skr.visit<void>(i, drawsAsSingletonPictures); | 1432 skr.visit<void>(i, drawsAsSingletonPictures); |
1408 } | 1433 } |
1409 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1434 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1410 | 1435 |
1411 canvas->drawPicture(macroPic); | 1436 canvas->drawPicture(macroPic); |
1412 return check_against_reference(bitmap, src, fSink); | 1437 return check_against_reference(bitmap, src, fSink); |
1413 }); | 1438 }); |
1414 } | 1439 } |
1415 | 1440 |
1416 } // namespace DM | 1441 } // namespace DM |
OLD | NEW |