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

Unified Diff: tests/CodexTest.cpp

Issue 1287863004: Test scaling for small images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed comment Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/codec/SkCodec.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodexTest.cpp
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
index 80164b294bbc03faf31dcbc2877b78582e5a4d60..ec6d6451962e7db1d002045f536a945b4f73ad33 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -10,6 +10,7 @@
#include "SkCodec.h"
#include "SkMD5.h"
#include "SkRandom.h"
+#include "SkScaledCodec.h"
#include "SkScanlineDecoder.h"
#include "Test.h"
@@ -281,17 +282,19 @@ static void test_dimensions(skiatest::Reporter* r, const char path[]) {
SkDebugf("Missing resource '%s'\n", path);
return;
}
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromStream(stream.detach()));
if (!codec) {
ERRORF(r, "Unable to create codec '%s'", path);
return;
}
// Check that the decode is successful for a variety of scales
- for (float scale = -0.05f; scale < 2.0f; scale += 0.05f) {
+ for (float scale = 0.05f; scale < 2.0f; scale += 0.05f) {
// Scale the output dimensions
SkISize scaledDims = codec->getScaledDimensions(scale);
- SkImageInfo scaledInfo = codec->getInfo().makeWH(scaledDims.width(), scaledDims.height());
+ SkImageInfo scaledInfo = codec->getInfo()
+ .makeWH(scaledDims.width(), scaledDims.height())
+ .makeColorType(kN32_SkColorType);
// Set up for the decode
size_t rowBytes = scaledDims.width() * sizeof(SkPMColor);
@@ -312,6 +315,21 @@ DEF_TEST(Codec_Dimensions, r) {
test_dimensions(r, "grayscale.jpg");
test_dimensions(r, "mandrill_512_q075.jpg");
test_dimensions(r, "randPixels.jpg");
+
+ // Decoding small images with very large scaling factors is a potential
+ // source of bugs and crashes. We disable these tests in Gold because
+ // tiny images are not very useful to look at.
+ // Here we make sure that we do not crash or access illegal memory when
+ // performing scaled decodes on small images.
+ test_dimensions(r, "1x1.png");
+ test_dimensions(r, "2x2.png");
+ test_dimensions(r, "3x3.png");
+ test_dimensions(r, "3x1.png");
+ test_dimensions(r, "1x1.png");
+ test_dimensions(r, "16x1.png");
+ test_dimensions(r, "1x16.png");
+ test_dimensions(r, "mandrill_16.png");
+
}
static void test_invalid(skiatest::Reporter* r, const char path[]) {
« no previous file with comments | « include/codec/SkCodec.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698