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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1530933003: Use possible read_partial_scanlines() API in SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
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 "SamplePipeControllers.h" 9 #include "SamplePipeControllers.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 codec->getScanlines(dstPtr, 1, bitmap.rowBytes()); 366 codec->getScanlines(dstPtr, 1, bitmap.rowBytes());
367 } 367 }
368 break; 368 break;
369 } 369 }
370 } 370 }
371 371
372 canvas->drawBitmap(bitmap, 0, 0); 372 canvas->drawBitmap(bitmap, 0, 0);
373 break; 373 break;
374 } 374 }
375 case kStripe_Mode: { 375 case kStripe_Mode: {
376 const int width = decodeInfo.width();
376 const int height = decodeInfo.height(); 377 const int height = decodeInfo.height();
377 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that 378 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that
378 // does not align with image blocks. 379 // does not align with image blocks.
379 const int stripeHeight = 37; 380 const int stripeHeight = 37;
380 const int numStripes = (height + stripeHeight - 1) / stripeHeight; 381 const int numStripes = (height + stripeHeight - 1) / stripeHeight;
381 382
382 // Decode odd stripes 383 // Decode odd stripes
383 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr, 384 SkCodec::Options opts;
385 SkIRect subset = SkIRect::MakeXYWH(0, 0, width / 2, height);
386 opts.fSubset = ⊂
387 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &opt s, colorPtr,
384 colorCountPtr) 388 colorCountPtr)
385 || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOr der()) { 389 || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOr der()) {
386 // This mode was designed to test the new skip scanlines API in libjpeg-turbo. 390 // This mode was designed to test the new skip scanlines API in libjpeg-turbo.
387 // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting 391 // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting
388 // to run this test for image types that do not have this scanli ne ordering. 392 // to run this test for image types that do not have this scanli ne ordering.
389 return Error::Nonfatal("Could not start top-down scanline decode r"); 393 return Error::Nonfatal("Could not start top-down scanline decode r");
390 } 394 }
391 395
392 for (int i = 0; i < numStripes; i += 2) { 396 for (int i = 0; i < numStripes; i += 2) {
393 // Skip a stripe 397 // Skip a stripe
394 const int linesToSkip = SkTMin(stripeHeight, height - i * stripe Height); 398 const int linesToSkip = SkTMin(stripeHeight, height - i * stripe Height);
395 codec->skipScanlines(linesToSkip); 399 codec->skipScanlines(linesToSkip);
396 400
397 // Read a stripe 401 // Read a stripe
398 const int startY = (i + 1) * stripeHeight; 402 const int startY = (i + 1) * stripeHeight;
399 const int linesToRead = SkTMin(stripeHeight, height - startY); 403 const int linesToRead = SkTMin(stripeHeight, height - startY);
400 if (linesToRead > 0) { 404 if (linesToRead > 0) {
401 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes()); 405 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
402 } 406 }
403 } 407 }
404 408
405 // Decode even stripes 409 // Decode even stripes
406 const SkCodec::Result startResult = codec->startScanlineDecode(decod eInfo, nullptr, 410 SkCodec::Result startResult = codec->startScanlineDecode(decodeInfo, &opts,
407 colorPtr, colorCountPtr); 411 colorPtr, colorCountPtr);
408 if (SkCodec::kSuccess != startResult) { 412 if (SkCodec::kSuccess != startResult) {
409 return "Failed to restart scanline decoder with same parameters. "; 413 return "Failed to restart scanline decoder with same parameters. ";
410 } 414 }
411 for (int i = 0; i < numStripes; i += 2) { 415 for (int i = 0; i < numStripes; i += 2) {
412 // Read a stripe 416 // Read a stripe
413 const int startY = i * stripeHeight; 417 const int startY = i * stripeHeight;
414 const int linesToRead = SkTMin(stripeHeight, height - startY); 418 const int linesToRead = SkTMin(stripeHeight, height - startY);
415 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitm ap.rowBytes()); 419 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitm ap.rowBytes());
416 420
417 // Skip a stripe 421 // Skip a stripe
418 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight); 422 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
419 if (linesToSkip > 0) { 423 if (linesToSkip > 0) {
420 codec->skipScanlines(linesToSkip); 424 codec->skipScanlines(linesToSkip);
421 } 425 }
422 } 426 }
427
428 // Begin duplicated code
429 SkIRect nextSubset = SkIRect::MakeXYWH(width / 2, 0, width / 2 + wid th % 2, height);
430 opts.fSubset = &nextSubset;
431 startResult = codec->startScanlineDecode(decodeInfo, &opts, colorPtr , colorCountPtr);
432 if (SkCodec::kSuccess != startResult) {
433 return "Failed to restart scanline decoder with same parameters. ";
434 }
435
436 for (int i = 0; i < numStripes; i += 2) {
437 // Skip a stripe
438 const int linesToSkip = SkTMin(stripeHeight, height - i * stripe Height);
439 codec->skipScanlines(linesToSkip);
440
441 // Read a stripe
442 const int startY = (i + 1) * stripeHeight;
443 const int linesToRead = SkTMin(stripeHeight, height - startY);
444 if (linesToRead > 0) {
445 codec->getScanlines(bitmap.getAddr(width / 2, startY), lines ToRead,
446 bitmap.rowBytes());
447 }
448 }
449
450 // Decode even stripes
451 startResult = codec->startScanlineDecode(decodeInfo, &opts, colorPtr , colorCountPtr);
452 if (SkCodec::kSuccess != startResult) {
453 return "Failed to restart scanline decoder with same parameters. ";
454 }
455 for (int i = 0; i < numStripes; i += 2) {
456 // Read a stripe
457 const int startY = i * stripeHeight;
458 const int linesToRead = SkTMin(stripeHeight, height - startY);
459 codec->getScanlines(bitmap.getAddr(width / 2, startY), linesToRe ad, bitmap.rowBytes());
460
461 // Skip a stripe
462 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
463 if (linesToSkip > 0) {
464 codec->skipScanlines(linesToSkip);
465 }
466 }
467
468
423 canvas->drawBitmap(bitmap, 0, 0); 469 canvas->drawBitmap(bitmap, 0, 0);
424 break; 470 break;
425 } 471 }
426 case kSubset_Mode: { 472 case kSubset_Mode: {
427 // Arbitrarily choose a divisor. 473 // Arbitrarily choose a divisor.
428 int divisor = 2; 474 int divisor = 2;
429 // Total width/height of the image. 475 // Total width/height of the image.
430 const int W = codec->getInfo().width(); 476 const int W = codec->getInfo().width();
431 const int H = codec->getInfo().height(); 477 const int H = codec->getInfo().height();
432 if (divisor > W || divisor > H) { 478 if (divisor > W || divisor > H) {
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 skr.visit<void>(i, drawsAsSingletonPictures); 1310 skr.visit<void>(i, drawsAsSingletonPictures);
1265 } 1311 }
1266 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1312 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1267 1313
1268 canvas->drawPicture(macroPic); 1314 canvas->drawPicture(macroPic);
1269 return ""; 1315 return "";
1270 }); 1316 });
1271 } 1317 }
1272 1318
1273 } // namespace DM 1319 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gyp/libjpeg-turbo.gyp » ('j') | src/codec/SkJpegCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698