aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-09 18:08:24 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-09 18:08:24 +0000
commitb7acbfe0ee940863b5e2350b0b0c3795e01751f5 (patch)
tree7e1136fcb3a24d7fe5be0d5b931e9594252e1293
parent59e7d238522145e00357c54d71a4216b279faf1c (diff)
Flatten resources directory
On android trybots, the files in a subdirectory weren't being loaded onto the device. Consequently, the ImageDecoderOptions test was not testing anything. I had to relax that unit test to reflect the existing behavior of our libjpeg decoder on Android. R=djsollen@google.com Review URL: https://codereview.chromium.org/264583007 git-svn-id: http://skia.googlecode.com/svn/trunk@14682 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--resources/randPixels.bmp (renamed from resources/encoding/randPixels.bmp)bin246 -> 246 bytes
-rw-r--r--resources/randPixels.gif (renamed from resources/encoding/randPixels.gif)bin277 -> 277 bytes
-rw-r--r--resources/randPixels.jpg (renamed from resources/encoding/randPixels.jpg)bin329 -> 329 bytes
-rw-r--r--resources/randPixels.png (renamed from resources/encoding/randPixels.png)bin268 -> 268 bytes
-rw-r--r--resources/randPixels.webp (renamed from resources/encoding/randPixels.webp)bin308 -> 308 bytes
-rw-r--r--tests/ImageDecodingTest.cpp19
6 files changed, 12 insertions, 7 deletions
diff --git a/resources/encoding/randPixels.bmp b/resources/randPixels.bmp
index 1e4ab3b652..1e4ab3b652 100644
--- a/resources/encoding/randPixels.bmp
+++ b/resources/randPixels.bmp
Binary files differ
diff --git a/resources/encoding/randPixels.gif b/resources/randPixels.gif
index 04c8bb9c3a..04c8bb9c3a 100644
--- a/resources/encoding/randPixels.gif
+++ b/resources/randPixels.gif
Binary files differ
diff --git a/resources/encoding/randPixels.jpg b/resources/randPixels.jpg
index ca57fbddf3..ca57fbddf3 100644
--- a/resources/encoding/randPixels.jpg
+++ b/resources/randPixels.jpg
Binary files differ
diff --git a/resources/encoding/randPixels.png b/resources/randPixels.png
index 49ef84603f..49ef84603f 100644
--- a/resources/encoding/randPixels.png
+++ b/resources/randPixels.png
Binary files differ
diff --git a/resources/encoding/randPixels.webp b/resources/randPixels.webp
index 135441e541..135441e541 100644
--- a/resources/encoding/randPixels.webp
+++ b/resources/randPixels.webp
Binary files differ
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index e9348fed99..86b96ae0f9 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -512,8 +512,8 @@ static SkPixelRef* install_pixel_ref(SkBitmap* bitmap,
*/
DEF_TEST(ImprovedBitmapFactory, reporter) {
SkString resourcePath = skiatest::Test::GetResourcePath();
- SkString directory = SkOSPath::SkPathJoin(resourcePath.c_str(), "encoding");
- SkString path = SkOSPath::SkPathJoin(directory.c_str(), "randPixels.png");
+ SkString path = SkOSPath::SkPathJoin(
+ resourcePath.c_str(), "randPixels.png");
SkAutoTUnref<SkStreamRewindable> stream(
SkStream::NewFromFile(path.c_str()));
if (sk_exists(path.c_str())) {
@@ -531,9 +531,10 @@ DEF_TEST(ImprovedBitmapFactory, reporter) {
#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
static inline bool check_rounding(int value, int dividend, int divisor) {
- // returns true if (dividend/divisor) rounds up OR down to value
+ // returns true if the value is greater than floor(dividend/divisor)
+ // and less than SkNextPow2(ceil(dividend - divisor))
return (((divisor * value) > (dividend - divisor))
- && ((divisor * value) < (dividend + divisor)));
+ && value <= SkNextPow2(((dividend - 1) / divisor) + 1));
}
#endif // SK_BUILD_FOR_ANDROID || SK_BUILD_FOR_UNIX
@@ -621,6 +622,11 @@ static void test_options(skiatest::Reporter* reporter,
opts.fSampleSize));
REPORTER_ASSERT(reporter, check_rounding(bm.width(), kExpectedWidth,
opts.fSampleSize));
+ // The ImageDecoder API doesn't guarantee that SampleSize does
+ // anything at all, but the decoders that this test excercises all
+ // produce an output size in the following range:
+ // (((sample_size * out_size) > (in_size - sample_size))
+ // && out_size <= SkNextPow2(((in_size - 1) / sample_size) + 1));
#endif // SK_BUILD_FOR_ANDROID || SK_BUILD_FOR_UNIX
SkAutoLockPixels alp(bm);
if (bm.getPixels() == NULL) {
@@ -682,8 +688,7 @@ DEF_TEST(ImageDecoderOptions, reporter) {
};
SkString resourceDir = skiatest::Test::GetResourcePath();
- SkString directory = SkOSPath::SkPathJoin(resourceDir.c_str(), "encoding");
- if (!sk_exists(directory.c_str())) {
+ if (!sk_exists(resourceDir.c_str())) {
return;
}
@@ -700,7 +705,7 @@ DEF_TEST(ImageDecoderOptions, reporter) {
const bool useDataList[] = {true, false};
for (size_t fidx = 0; fidx < SK_ARRAY_COUNT(files); ++fidx) {
- SkString path = SkOSPath::SkPathJoin(directory.c_str(), files[fidx]);
+ SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), files[fidx]);
if (!sk_exists(path.c_str())) {
continue;
}