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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1918813002: Fix kSubset_Mode tests on non-native swizzles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // where the last one ended. So we'll add decodeInfo.width() and hei ght(). 576 // where the last one ended. So we'll add decodeInfo.width() and hei ght().
577 int left = 0; 577 int left = 0;
578 for (int x = 0; x < W; x += w) { 578 for (int x = 0; x < W; x += w) {
579 int top = 0; 579 int top = 0;
580 for (int y = 0; y < H; y+= h) { 580 for (int y = 0; y < H; y+= h) {
581 // Do not make the subset go off the edge of the image. 581 // Do not make the subset go off the edge of the image.
582 const int preScaleW = SkTMin(w, W - x); 582 const int preScaleW = SkTMin(w, W - x);
583 const int preScaleH = SkTMin(h, H - y); 583 const int preScaleH = SkTMin(h, H - y);
584 subset.setXYWH(x, y, preScaleW, preScaleH); 584 subset.setXYWH(x, y, preScaleW, preScaleH);
585 // And scale 585 // And scale
586 // FIXME: Should we have a version of getScaledDimensions th at takes a subset 586 // FIXME: Should we have a version of getScaledDimensions th at takes a subset
msarett 2016/04/25 13:25:50 This may be worth fixing in a follow-up. We do ha
587 // into account? 587 // into account?
588 decodeInfo = decodeInfo.makeWH( 588 const int scaledW = SkTMax(1, SkScalarRoundToInt(preScaleW * fScale));
589 SkTMax(1, SkScalarRoundToInt(preScaleW * fScale)), 589 const int scaledH = SkTMax(1, SkScalarRoundToInt(preScaleH * fScale));
590 SkTMax(1, SkScalarRoundToInt(preScaleH * fScale))); 590 decodeInfo = decodeInfo.makeWH(scaledW, scaledH);
591 size_t rowBytes = decodeInfo.minRowBytes(); 591 SkImageInfo subsetBitmapInfo = bitmapInfo.makeWH(scaledW, sc aledH);
592 if (!subsetBm.installPixels(decodeInfo, pixels, rowBytes, co lorTable.get(), 592 size_t rowBytes = subsetBitmapInfo.minRowBytes();
593 if (!subsetBm.installPixels(subsetBitmapInfo, pixels, rowByt es, colorTable.get(),
593 nullptr, nullptr)) { 594 nullptr, nullptr)) {
594 return SkStringPrintf("could not install pixels for %s." , fPath.c_str()); 595 return SkStringPrintf("could not install pixels for %s." , fPath.c_str());
595 } 596 }
596 const SkCodec::Result result = codec->getPixels(decodeInfo, pixels, rowBytes, 597 const SkCodec::Result result = codec->getPixels(decodeInfo, pixels, rowBytes,
597 &opts, colorPtr, colorCountPtr); 598 &opts, colorPtr, colorCountPtr);
598 switch (result) { 599 switch (result) {
599 case SkCodec::kSuccess: 600 case SkCodec::kSuccess:
600 case SkCodec::kIncompleteInput: 601 case SkCodec::kIncompleteInput:
601 break; 602 break;
602 default: 603 default:
603 return SkStringPrintf("subset codec failed to decode (%d, %d, %d, %d) " 604 return SkStringPrintf("subset codec failed to decode (%d, %d, %d, %d) "
604 "from %s with dimensions (%d x %d)\t error %d", 605 "from %s with dimensions (%d x %d)\t error %d",
605 x, y, decodeInfo.width(), deco deInfo.height(), 606 x, y, decodeInfo.width(), deco deInfo.height(),
606 fPath.c_str(), W, H, result); 607 fPath.c_str(), W, H, result);
607 } 608 }
608 premultiply_if_necessary(subsetBm); 609 premultiply_if_necessary(subsetBm);
609 swap_rb_if_necessary(bitmap, fDstColorType); 610 swap_rb_if_necessary(subsetBm, fDstColorType);
610 canvas->drawBitmap(subsetBm, SkIntToScalar(left), SkIntToSca lar(top)); 611 canvas->drawBitmap(subsetBm, SkIntToScalar(left), SkIntToSca lar(top));
611 // translate by the scaled height. 612 // translate by the scaled height.
612 top += decodeInfo.height(); 613 top += decodeInfo.height();
613 } 614 }
614 // translate by the scaled width. 615 // translate by the scaled width.
615 left += decodeInfo.width(); 616 left += decodeInfo.width();
616 } 617 }
617 return ""; 618 return "";
618 } 619 }
619 default: 620 default:
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 skr.visit(i, drawsAsSingletonPictures); 1499 skr.visit(i, drawsAsSingletonPictures);
1499 } 1500 }
1500 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1501 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1501 1502
1502 canvas->drawPicture(macroPic); 1503 canvas->drawPicture(macroPic);
1503 return check_against_reference(bitmap, src, fSink); 1504 return check_against_reference(bitmap, src, fSink);
1504 }); 1505 });
1505 } 1506 }
1506 1507
1507 } // namespace DM 1508 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698