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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 codec->getScanlines(dstPtr, 1, bitmap.rowBytes()); | 463 codec->getScanlines(dstPtr, 1, bitmap.rowBytes()); |
464 } | 464 } |
465 break; | 465 break; |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 premultiply_if_necessary(bitmap); | 469 premultiply_if_necessary(bitmap); |
470 canvas->drawBitmap(bitmap, 0, 0); | 470 canvas->drawBitmap(bitmap, 0, 0); |
471 break; | 471 break; |
472 } | 472 } |
473 case kStripe_Mode: { | 473 case kTile_Mode: { |
474 const int width = decodeInfo.width(); | |
474 const int height = decodeInfo.height(); | 475 const int height = decodeInfo.height(); |
475 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that | 476 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that |
476 // does not align with image blocks. | 477 // does not align with image blocks. |
scroggo
2016/02/22 15:55:03
Given that our implementation changes a bit depend
msarett
2016/02/22 17:38:15
Agreed. Changing this value to one that will test
| |
477 const int stripeHeight = 37; | 478 const int tileSize = 51; |
scroggo
2016/02/22 15:55:03
Why the change from 37 to 51?
msarett
2016/02/22 17:38:15
The larger the value, the test runs. however, I'v
scroggo
2016/02/22 18:46:47
I'm guessing you left out the word "faster"?
msarett
2016/02/22 19:07:43
Haha yes.
| |
478 const int numStripes = (height + stripeHeight - 1) / stripeHeight; | 479 const int tileWidth = (width + tileSize - 1) / tileSize; |
480 const int tileHeight = (height + tileSize - 1) / tileSize; | |
scroggo
2016/02/22 15:55:03
Why are we concerned with tiles in Y here? The old
msarett
2016/02/22 17:38:16
I guess we just use this to know how many times to
| |
479 | 481 |
480 // Decode odd stripes | 482 SkCodec::Options opts; |
481 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr, | 483 SkIRect subset; |
482 colorCountPtr) | 484 for (int tileX = 0; tileX < tileWidth; tileX++) { |
483 || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOr der()) { | 485 const int startX = tileX * tileSize; |
484 // This mode was designed to test the new skip scanlines API in libjpeg-turbo. | 486 subset = SkIRect::MakeXYWH(startX, 0, SkTMin(tileSize, width - s tartX), height); |
485 // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting | 487 opts.fSubset = ⊂ |
486 // to run this test for image types that do not have this scanli ne ordering. | 488 for (int tileY = 0; tileY < tileHeight; tileY++) { |
487 return Error::Nonfatal("Could not start top-down scanline decode r"); | 489 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeIn fo, &opts, |
488 } | 490 colorPtr, colorCountPtr) || |
491 SkCodec::kTopDown_SkScanlineOrder != codec->getScanl ineOrder()) { | |
scroggo
2016/02/22 15:55:03
This is now only used for JPEG, so it seems like w
msarett
2016/02/22 17:38:16
Yes, I've fixed this.
| |
492 if (0 == tileY && 0 == tileX) { | |
493 return Error::Nonfatal("Could not start top-down sca nline decoder"); | |
scroggo
2016/02/22 15:55:03
Is this not a bug? Why would startScanlineDecode f
msarett
2016/02/22 17:38:15
I believe that we used to need this when kInvalidC
scroggo
2016/02/22 18:46:47
sgtm
| |
494 } | |
495 return "Could not restart scanline decoder."; | |
496 } | |
489 | 497 |
490 for (int i = 0; i < numStripes; i += 2) { | 498 const int startY = tileY * tileSize; |
491 // Skip a stripe | 499 codec->skipScanlines(startY); |
492 const int linesToSkip = SkTMin(stripeHeight, height - i * stripe Height); | 500 const int linesToGet = SkTMin(tileSize, height - startY); |
493 codec->skipScanlines(linesToSkip); | 501 codec->getScanlines(bitmap.getAddr(startX, startY), linesToG et, |
494 | 502 bitmap.rowBytes()); |
495 // Read a stripe | |
496 const int startY = (i + 1) * stripeHeight; | |
497 const int linesToRead = SkTMin(stripeHeight, height - startY); | |
498 if (linesToRead > 0) { | |
499 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes()); | |
500 } | 503 } |
501 } | 504 } |
502 | 505 |
503 // Decode even stripes | |
504 const SkCodec::Result startResult = codec->startScanlineDecode(decod eInfo, nullptr, | |
505 colorPtr, colorCountPtr); | |
506 if (SkCodec::kSuccess != startResult) { | |
507 return "Failed to restart scanline decoder with same parameters. "; | |
508 } | |
509 for (int i = 0; i < numStripes; i += 2) { | |
510 // Read a stripe | |
511 const int startY = i * stripeHeight; | |
512 const int linesToRead = SkTMin(stripeHeight, height - startY); | |
513 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitm ap.rowBytes()); | |
514 | |
515 // Skip a stripe | |
516 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight); | |
517 if (linesToSkip > 0) { | |
518 codec->skipScanlines(linesToSkip); | |
519 } | |
520 } | |
521 premultiply_if_necessary(bitmap); | 506 premultiply_if_necessary(bitmap); |
522 canvas->drawBitmap(bitmap, 0, 0); | 507 canvas->drawBitmap(bitmap, 0, 0); |
523 break; | 508 break; |
524 } | 509 } |
525 case kSubset_Mode: { | 510 case kSubset_Mode: { |
526 // Arbitrarily choose a divisor. | 511 // Arbitrarily choose a divisor. |
527 int divisor = 2; | 512 int divisor = 2; |
528 // Total width/height of the image. | 513 // Total width/height of the image. |
529 const int W = codec->getInfo().width(); | 514 const int W = codec->getInfo().width(); |
530 const int H = codec->getInfo().height(); | 515 const int H = codec->getInfo().height(); |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1407 skr.visit<void>(i, drawsAsSingletonPictures); | 1392 skr.visit<void>(i, drawsAsSingletonPictures); |
1408 } | 1393 } |
1409 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1394 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1410 | 1395 |
1411 canvas->drawPicture(macroPic); | 1396 canvas->drawPicture(macroPic); |
1412 return check_against_reference(bitmap, src, fSink); | 1397 return check_against_reference(bitmap, src, fSink); |
1413 }); | 1398 }); |
1414 } | 1399 } |
1415 | 1400 |
1416 } // namespace DM | 1401 } // namespace DM |
OLD | NEW |