aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-01-13 09:31:39 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-13 09:31:39 -0800
commitbb25b5324965d53253fc3ad9f43b7d6faa2f9100 (patch)
treef336b3fce37f0e8cc17ba0e4242c7926072b4b2c /dm
parentf33e7a39598f3098a9676724367aef764b02de50 (diff)
Add CodecZeroInit test to DMSrcSink
Diffstat (limited to 'dm')
-rw-r--r--dm/DM.cpp7
-rw-r--r--dm/DMSrcSink.cpp12
-rw-r--r--dm/DMSrcSink.h4
3 files changed, 19 insertions, 4 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 0e36c07367..7302ebc270 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -232,6 +232,9 @@ static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp
case CodecSrc::kCodec_Mode:
folder.append("codec");
break;
+ case CodecSrc::kCodecZeroInit_Mode:
+ folder.append("codec_zero_init");
+ break;
case CodecSrc::kScanline_Mode:
folder.append("scanline");
break;
@@ -311,8 +314,8 @@ static void push_codec_srcs(Path path) {
// SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875
const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
- const CodecSrc::Mode nativeModes[] = { CodecSrc::kCodec_Mode, CodecSrc::kScanline_Mode,
- CodecSrc::kStripe_Mode, CodecSrc::kSubset_Mode };
+ const CodecSrc::Mode nativeModes[] = { CodecSrc::kCodec_Mode, CodecSrc::kCodecZeroInit_Mode,
+ CodecSrc::kScanline_Mode, CodecSrc::kStripe_Mode, CodecSrc::kSubset_Mode };
CodecSrc::DstColorType colorTypes[3];
uint32_t numColorTypes;
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index c9bdcf6706..bbfa5199e6 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -316,14 +316,22 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
}
SkBitmap bitmap;
- if (!bitmap.tryAllocPixels(decodeInfo, nullptr, colorTable.get())) {
+ SkPixelRefFactory* factory = nullptr;
+ SkMallocPixelRef::ZeroedPRFactory zeroFactory;
+ SkCodec::Options options;
+ if (kCodecZeroInit_Mode == fMode) {
+ factory = &zeroFactory;
+ options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
+ }
+ if (!bitmap.tryAllocPixels(decodeInfo, factory, colorTable.get())) {
return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(),
decodeInfo.width(), decodeInfo.height());
}
switch (fMode) {
+ case kCodecZeroInit_Mode:
case kCodec_Mode: {
- switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), nullptr,
+ switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), &options,
colorPtr, colorCountPtr)) {
case SkCodec::kSuccess:
// We consider incomplete to be valid, since we should still decode what is
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 6645807286..def7cc9f5c 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -104,6 +104,10 @@ class CodecSrc : public Src {
public:
enum Mode {
kCodec_Mode,
+ // We choose to test only one mode with zero initialized memory.
+ // This will exercise all of the interesting cases in SkSwizzler
+ // without doubling the size of our test suite.
+ kCodecZeroInit_Mode,
kScanline_Mode,
kStripe_Mode, // Tests the skipping of scanlines
kSubset_Mode, // For codecs that support subsets directly.