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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1719073002: Use new jpeg_crop_scanlines() API to optimize jpeg subset decodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add to assert Created 4 years, 10 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 | « dm/DMSrcSink.h ('k') | gyp/codec.gyp » ('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 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
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
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 = &subset;
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
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
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/codec.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698